Given the following C code and unoptimized assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include <stdio.h>

int main(void){

int r,c,n,ans=0,ansa=0,ansb=0;
int i,j;

scanf("%d %d",&r,&c);

int t[r][c];

for(i=0;i<r;i++){
  for(j=0;j<c;j++){
    scanf("%d",&n);
    printf("%d ",n);
    ans=ans+n;
    t[i][j] = n;
  if(j==c-1){
    printf("%d\n",ans);
    ans=0;
}}}
for(j=0;j<c;j++){
  for(i=0;i<r;i++){
    ansa = ansa + t[i][j];
  if(i==r-1){
    printf("%d ",ansa);
    ansb=ansb+ansa;
    ansa=0;}}}
printf("%d\n",ansb);
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d "
.LC3:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$136, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, -168(%rbp)
	movl	$0, -100(%rbp)
	movl	$0, -96(%rbp)
	movl	$0, -92(%rbp)
	leaq	-108(%rbp), %rdx
	leaq	-112(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-108(%rbp), %ecx
	movl	-112(%rbp), %esi
	movslq	%ecx, %rax
	subq	$1, %rax
	movq	%rax, -80(%rbp)
	movslq	%ecx, %rax
	movq	%rax, -160(%rbp)
	movq	$0, -152(%rbp)
	movslq	%ecx, %rax
	leaq	0(,%rax,4), %rbx
	movslq	%esi, %rax
	subq	$1, %rax
	movq	%rax, -72(%rbp)
	movslq	%ecx, %rax
	movq	%rax, -128(%rbp)
	movq	$0, -120(%rbp)
	movslq	%esi, %rax
	movq	%rax, -144(%rbp)
	movq	$0, -136(%rbp)
	movq	-128(%rbp), %r8
	movq	-120(%rbp), %r9
	movq	%r9, %rdx
	movq	-144(%rbp), %r10
	movq	-136(%rbp), %r11
	imulq	%r10, %rdx
	movq	%r11, %rax
	imulq	%r8, %rax
	leaq	(%rdx,%rax), %rdi
	movq	%r8, %rax
	mulq	%r10
	addq	%rdx, %rdi
	movq	%rdi, %rdx
	movslq	%ecx, %rax
	movq	%rax, %r14
	movl	$0, %r15d
	movslq	%esi, %rax
	movq	%rax, %r12
	movl	$0, %r13d
	movq	%r15, %rdx
	imulq	%r12, %rdx
	movq	%r13, %rax
	imulq	%r14, %rax
	leaq	(%rdx,%rax), %rdi
	movq	%r14, %rax
	mulq	%r12
	addq	%rdx, %rdi
	movq	%rdi, %rdx
	movslq	%ecx, %rdx
	movslq	%esi, %rax
	imulq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %edi
	movl	$0, %edx
	divq	%rdi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L2:
	cmpq	%rdx, %rsp
	je	.L3
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L2
.L3:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L4
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L4:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -64(%rbp)
	movl	$0, -88(%rbp)
	jmp	.L5
.L9:
	movl	$0, -84(%rbp)
	jmp	.L6
.L8:
	leaq	-104(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-104(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	-104(%rbp), %eax
	addl	%eax, -100(%rbp)
	movq	%rbx, %rsi
	shrq	$2, %rsi
	movl	-104(%rbp), %edx
	movq	-64(%rbp), %rax
	movl	-84(%rbp), %ecx
	movslq	%ecx, %rdi
	movl	-88(%rbp), %ecx
	movslq	%ecx, %rcx
	imulq	%rsi, %rcx
	addq	%rdi, %rcx
	movl	%edx, (%rax,%rcx,4)
	movl	-108(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -84(%rbp)
	jne	.L7
	movl	-100(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, -100(%rbp)
.L7:
	addl	$1, -84(%rbp)
.L6:
	movl	-108(%rbp), %eax
	cmpl	%eax, -84(%rbp)
	jl	.L8
	addl	$1, -88(%rbp)
.L5:
	movl	-112(%rbp), %eax
	cmpl	%eax, -88(%rbp)
	jl	.L9
	movl	$0, -84(%rbp)
	jmp	.L10
.L14:
	movl	$0, -88(%rbp)
	jmp	.L11
.L13:
	movq	%rbx, %rcx
	shrq	$2, %rcx
	movq	-64(%rbp), %rax
	movl	-84(%rbp), %edx
	movslq	%edx, %rsi
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	imulq	%rcx, %rdx
	addq	%rsi, %rdx
	movl	(%rax,%rdx,4), %eax
	addl	%eax, -96(%rbp)
	movl	-112(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -88(%rbp)
	jne	.L12
	movl	-96(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	-96(%rbp), %eax
	addl	%eax, -92(%rbp)
	movl	$0, -96(%rbp)
.L12:
	addl	$1, -88(%rbp)
.L11:
	movl	-112(%rbp), %eax
	cmpl	%eax, -88(%rbp)
	jl	.L13
	addl	$1, -84(%rbp)
.L10:
	movl	-108(%rbp), %eax
	cmpl	%eax, -84(%rbp)
	jl	.L14
	movl	-92(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	-168(%rbp), %rsp
	movl	$0, %eax
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L16
	call	__stack_chk_fail@PLT
.L16:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
user
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d "
.LC3:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC0(%rip), %rdi
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	leaq	-64(%rbp), %rdx
	leaq	-68(%rbp), %rsi
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$88, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	-64(%rbp), %rcx
	movslq	-68(%rbp), %rdx
	movq	%rsp, %rsi
	movq	%rdx, %rdi
	imulq	%rcx, %rdx
	leaq	0(,%rcx,4), %rbx
	movq	%rcx, %rax
	movq	%rbx, -120(%rbp)
	leaq	15(,%rdx,4), %rdx
	movq	%rdx, %rcx
	andq	$-4096, %rdx
	subq	%rdx, %rsi
	andq	$-16, %rcx
	cmpq	%rsi, %rsp
	je	.L3
.L35:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rsi, %rsp
	jne	.L35
.L3:
	andl	$4095, %ecx
	subq	%rcx, %rsp
	testq	%rcx, %rcx
	jne	.L36
.L4:
	movq	%rsp, -96(%rbp)
	testl	%edi, %edi
	jle	.L37
	movq	%rsp, %rcx
	leaq	.LC3(%rip), %rdx
	leaq	-60(%rbp), %r15
	xorl	%r12d, %r12d
	movq	%rcx, -88(%rbp)
	leaq	.LC1(%rip), %r14
	leaq	.LC2(%rip), %r13
	movl	$0, -100(%rbp)
	movq	%rdx, -112(%rbp)
	testl	%eax, %eax
	jle	.L22
	.p2align 4,,10
	.p2align 3
.L21:
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L10:
	movq	%r15, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	-60(%rbp), %edx
	movq	%r13, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	-60(%rbp), %eax
	movq	-88(%rbp), %rcx
	addl	%eax, %r12d
	movl	%eax, (%rcx,%rbx,4)
	movl	-64(%rbp), %eax
	leal	-1(%rax), %edx
	cmpl	%ebx, %edx
	je	.L38
	addq	$1, %rbx
	cmpl	%ebx, %eax
	jg	.L10
	addl	$1, -100(%rbp)
	movl	-68(%rbp), %edi
	movl	-100(%rbp), %edx
	cmpl	%edx, %edi
	jle	.L5
.L11:
	movq	-120(%rbp), %rdi
	addq	%rdi, -88(%rbp)
	testl	%eax, %eax
	jg	.L21
.L22:
	movl	$0, -88(%rbp)
.L12:
	movl	-88(%rbp), %edx
	movq	-112(%rbp), %rsi
	xorl	%eax, %eax
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L39
	leaq	-40(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_remember_state
	.cfi_def_cfa 7, 8
	ret
	.p2align 4,,10
	.p2align 3
.L38:
	.cfi_restore_state
	movq	-112(%rbp), %rsi
	movl	%r12d, %edx
	movl	$1, %edi
	xorl	%eax, %eax
	addq	$1, %rbx
	xorl	%r12d, %r12d
	call	__printf_chk@PLT
	movl	-64(%rbp), %eax
	cmpl	%ebx, %eax
	jg	.L10
	addl	$1, -100(%rbp)
	movl	-68(%rbp), %edi
	movl	-100(%rbp), %edx
	cmpl	%edx, %edi
	jg	.L11
	.p2align 4,,10
	.p2align 3
.L5:
	testl	%eax, %eax
	jle	.L22
	movq	-120(%rbp), %r13
	movl	$0, -88(%rbp)
	xorl	%ebx, %ebx
	xorl	%r14d, %r14d
	shrq	$2, %r13
	.p2align 4,,10
	.p2align 3
.L13:
	testl	%edi, %edi
	jle	.L12
	xorl	%esi, %esi
	movslq	%ebx, %r12
.L33:
	leal	-1(%rdi), %r15d
.L17:
	movslq	%esi, %rax
	movq	-96(%rbp), %rcx
	imulq	%r13, %rax
	addq	%r12, %rax
	addl	(%rcx,%rax,4), %r14d
	cmpl	%esi, %r15d
	je	.L40
	addl	$1, %esi
	cmpl	%edi, %esi
	jl	.L17
	addl	$1, %ebx
	cmpl	%ebx, -64(%rbp)
	jg	.L13
	jmp	.L12
	.p2align 4,,10
	.p2align 3
.L40:
	movl	%r14d, %edx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	-68(%rbp), %edi
	leal	1(%r15), %esi
	addl	%r14d, -88(%rbp)
	xorl	%r14d, %r14d
	cmpl	%esi, %edi
	jg	.L33
	addl	$1, %ebx
	cmpl	%ebx, -64(%rbp)
	jg	.L13
	jmp	.L12
.L36:
	orq	$0, -8(%rsp,%rcx)
	jmp	.L4
.L37:
	leaq	.LC3(%rip), %rcx
	movq	%rcx, -112(%rbp)
	jmp	.L5
.L39:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

rule
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d "
.LC3:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC0(%rip), %rdi
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	leaq	-64(%rbp), %rdx
	leaq	-68(%rbp), %rsi
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$88, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	-64(%rbp), %rcx
	movslq	-68(%rbp), %rdx
	movq	%rsp, %rsi
	movq	%rdx, %rdi
	imulq	%rcx, %rdx
	leaq	0(,%rcx,4), %rbx
	movq	%rcx, %rax
	movq	%rbx, -120(%rbp)
	leaq	15(,%rdx,4), %rdx
	movq	%rdx, %rcx
	andq	$-4096, %rdx
	subq	%rdx, %rsi
	andq	$-16, %rcx
	cmpq	%rsi, %rsp
	je	.L3
.L35:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rsi, %rsp
	jne	.L35
.L3:
	andl	$4095, %ecx
	subq	%rcx, %rsp
	testq	%rcx, %rcx
	jne	.L36
.L4:
	movq	%rsp, -96(%rbp)
	testl	%edi, %edi
	jle	.L37
	movq	%rsp, %rcx
	leaq	.LC3(%rip), %rdx
	leaq	-60(%rbp), %r15
	xorl	%r12d, %r12d
	movq	%rcx, -88(%rbp)
	leaq	.LC1(%rip), %r14
	leaq	.LC2(%rip), %r13
	movl	$0, -100(%rbp)
	movq	%rdx, -112(%rbp)
	testl	%eax, %eax
	jle	.L22
	.p2align 4,,10
	.p2align 3
.L21:
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L10:
	movq	%r15, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	-60(%rbp), %edx
	movq	%r13, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	-60(%rbp), %eax
	movq	-88(%rbp), %rcx
	addl	%eax, %r12d
	movl	%eax, (%rcx,%rbx,4)
	movl	-64(%rbp), %eax
	leal	-1(%rax), %edx
	cmpl	%ebx, %edx
	je	.L38
	addq	$1, %rbx
	cmpl	%ebx, %eax
	jg	.L10
	addl	$1, -100(%rbp)
	movl	-68(%rbp), %edi
	movl	-100(%rbp), %edx
	cmpl	%edx, %edi
	jle	.L5
.L11:
	movq	-120(%rbp), %rdi
	addq	%rdi, -88(%rbp)
	testl	%eax, %eax
	jg	.L21
.L22:
	movl	$0, -88(%rbp)
.L12:
	movl	-88(%rbp), %edx
	movq	-112(%rbp), %rsi
	xorl	%eax, %eax
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L39
	leaq	-40(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_remember_state
	.cfi_def_cfa 7, 8
	ret
	.p2align 4,,10
	.p2align 3
.L38:
	.cfi_restore_state
	movq	-112(%rbp), %rsi
	movl	%r12d, %edx
	movl	$1, %edi
	xorl	%eax, %eax
	addq	$1, %rbx
	xorl	%r12d, %r12d
	call	__printf_chk@PLT
	movl	-64(%rbp), %eax
	cmpl	%ebx, %eax
	jg	.L10
	addl	$1, -100(%rbp)
	movl	-68(%rbp), %edi
	movl	-100(%rbp), %edx
	cmpl	%edx, %edi
	jg	.L11
	.p2align 4,,10
	.p2align 3
.L5:
	testl	%eax, %eax
	jle	.L22
	movq	-120(%rbp), %r13
	movl	$0, -88(%rbp)
	xorl	%ebx, %ebx
	xorl	%r14d, %r14d
	shrq	$2, %r13
	.p2align 4,,10
	.p2align 3
.L13:
	testl	%edi, %edi
	jle	.L12
	xorl	%esi, %esi
	movslq	%ebx, %r12
.L33:
	leal	-1(%rdi), %r15d
.L17:
	movslq	%esi, %rax
	movq	-96(%rbp), %rcx
	imulq	%r13, %rax
	addq	%r12, %rax
	addl	(%rcx,%rax,4), %r14d
	cmpl	%esi, %r15d
	je	.L40
	addl	$1, %esi
	cmpl	%edi, %esi
	jl	.L17
	addl	$1, %ebx
	cmpl	%ebx, -64(%rbp)
	jg	.L13
	jmp	.L12
	.p2align 4,,10
	.p2align 3
.L40:
	movl	%r14d, %edx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	-68(%rbp), %edi
	leal	1(%r15), %esi
	addl	%r14d, -88(%rbp)
	xorl	%r14d, %r14d
	cmpl	%esi, %edi
	jg	.L33
	addl	$1, %ebx
	cmpl	%ebx, -64(%rbp)
	jg	.L13
	jmp	.L12
.L36:
	orq	$0, -8(%rsp,%rcx)
	jmp	.L4
.L37:
	leaq	.LC3(%rip), %rcx
	movq	%rcx, -112(%rbp)
	jmp	.L5
.L39:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#include <stdio.h>

int main(void){

int r,c,n,ans=0,ansa=0,ansb=0;
int i,j;

scanf("%d %d",&r,&c);

int t[r][c];

for(i=0;i<r;i++){
  for(j=0;j<c;j++){
    scanf("%d",&n);
    printf("%d ",n);
    ans=ans+n;
    t[i][j] = n;
  if(j==c-1){
    printf("%d\n",ans);
    ans=0;
}}}
for(j=0;j<c;j++){
  for(i=0;i<r;i++){
    ansa = ansa + t[i][j];
  if(i==r-1){
    printf("%d ",ansa);
    ansb=ansb+ansa;
    ansa=0;}}}
printf("%d\n",ansb);
}

4 5
1 1 3 4 8
2 2 2 4 5
3 3 0 1 1
2 3 4 4 6
 4 5
1 1 3 4 8
2 2 2 4 5
3 3 0 1 1
2 3 4 8 6
 4 5
1 1 3 4 8
2 2 2 4 5
3 3 0 1 1
2 6 4 8 6
 4 5
1 1 3 4 8
2 2 2 4 5
3 3 0 1 2
2 6 4 8 6
 4 5
2 1 3 4 8
2 2 2 4 5
3 3 0 1 2
2 6 4 8 6
 4 5
1 1 3 1 5
2 2 2 4 5
3 3 0 1 1
2 3 4 4 6
 4 5
1 1 1 4 8
2 2 2 4 5
3 3 0 1 1
2 3 4 4 6
 4 5
1 1 3 4 8
2 2 2 4 5
3 3 0 1 0
2 3 4 8 6
 4 5
1 1 3 4 8
2 2 2 4 5
3 3 0 1 1
2 6 4 1 6
 4 5
1 1 3 8 8
2 2 2 4 5
3 3 0 1 2
2 6 4 8 6

1 1 3 4 8 17
2 2 2 4 5 15
3 3 0 1 1 8
2 3 4 4 6 19
8 9 9 13 20 59
 1 1 3 4 8 17
2 2 2 4 5 15
3 3 0 1 1 8
2 3 4 8 6 23
8 9 9 17 20 63
 1 1 3 4 8 17
2 2 2 4 5 15
3 3 0 1 1 8
2 6 4 8 6 26
8 12 9 17 20 66
 1 1 3 4 8 17
2 2 2 4 5 15
3 3 0 1 2 9
2 6 4 8 6 26
8 12 9 17 21 67
 2 1 3 4 8 18
2 2 2 4 5 15
3 3 0 1 2 9
2 6 4 8 6 26
9 12 9 17 21 68
 1 1 3 1 5 11
2 2 2 4 5 15
3 3 0 1 1 8
2 3 4 4 6 19
8 9 9 10 17 53
 1 1 1 4 8 15
2 2 2 4 5 15
3 3 0 1 1 8
2 3 4 4 6 19
8 9 7 13 20 57
 1 1 3 4 8 17
2 2 2 4 5 15
3 3 0 1 0 7
2 3 4 8 6 23
8 9 9 17 19 62
 1 1 3 4 8 17
2 2 2 4 5 15
3 3 0 1 1 8
2 6 4 1 6 19
8 12 9 10 20 59
 1 1 3 8 8 21
2 2 2 4 5 15
3 3 0 1 2 9
2 6 4 8 6 26
8 12 9 21 21 71

Given the following C code and unoptimized assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include <stdio.h>

int main(void){

int r,c,n,ans=0,ansa=0,ansb=0;
int i,j;

scanf("%d %d",&r,&c);

int t[r][c];

for(i=0;i<r;i++){
  for(j=0;j<c;j++){
    scanf("%d",&n);
    printf("%d ",n);
    ans=ans+n;
    t[i][j] = n;
  if(j==c-1){
    printf("%d\n",ans);
    ans=0;
}}}
for(j=0;j<c;j++){
  for(i=0;i<r;i++){
    ansa = ansa + t[i][j];
  if(i==r-1){
    printf("%d ",ansa);
    ansb=ansb+ansa;
    ansa=0;}}}
printf("%d\n",ansb);
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d "
.LC3:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$136, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, -168(%rbp)
	movl	$0, -100(%rbp)
	movl	$0, -96(%rbp)
	movl	$0, -92(%rbp)
	leaq	-108(%rbp), %rdx
	leaq	-112(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-108(%rbp), %ecx
	movl	-112(%rbp), %esi
	movslq	%ecx, %rax
	subq	$1, %rax
	movq	%rax, -80(%rbp)
	movslq	%ecx, %rax
	movq	%rax, -160(%rbp)
	movq	$0, -152(%rbp)
	movslq	%ecx, %rax
	leaq	0(,%rax,4), %rbx
	movslq	%esi, %rax
	subq	$1, %rax
	movq	%rax, -72(%rbp)
	movslq	%ecx, %rax
	movq	%rax, -128(%rbp)
	movq	$0, -120(%rbp)
	movslq	%esi, %rax
	movq	%rax, -144(%rbp)
	movq	$0, -136(%rbp)
	movq	-128(%rbp), %r8
	movq	-120(%rbp), %r9
	movq	%r9, %rdx
	movq	-144(%rbp), %r10
	movq	-136(%rbp), %r11
	imulq	%r10, %rdx
	movq	%r11, %rax
	imulq	%r8, %rax
	leaq	(%rdx,%rax), %rdi
	movq	%r8, %rax
	mulq	%r10
	addq	%rdx, %rdi
	movq	%rdi, %rdx
	movslq	%ecx, %rax
	movq	%rax, %r14
	movl	$0, %r15d
	movslq	%esi, %rax
	movq	%rax, %r12
	movl	$0, %r13d
	movq	%r15, %rdx
	imulq	%r12, %rdx
	movq	%r13, %rax
	imulq	%r14, %rax
	leaq	(%rdx,%rax), %rdi
	movq	%r14, %rax
	mulq	%r12
	addq	%rdx, %rdi
	movq	%rdi, %rdx
	movslq	%ecx, %rdx
	movslq	%esi, %rax
	imulq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %edi
	movl	$0, %edx
	divq	%rdi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L2:
	cmpq	%rdx, %rsp
	je	.L3
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L2
.L3:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L4
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L4:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -64(%rbp)
	movl	$0, -88(%rbp)
	jmp	.L5
.L9:
	movl	$0, -84(%rbp)
	jmp	.L6
.L8:
	leaq	-104(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-104(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	-104(%rbp), %eax
	addl	%eax, -100(%rbp)
	movq	%rbx, %rsi
	shrq	$2, %rsi
	movl	-104(%rbp), %edx
	movq	-64(%rbp), %rax
	movl	-84(%rbp), %ecx
	movslq	%ecx, %rdi
	movl	-88(%rbp), %ecx
	movslq	%ecx, %rcx
	imulq	%rsi, %rcx
	addq	%rdi, %rcx
	movl	%edx, (%rax,%rcx,4)
	movl	-108(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -84(%rbp)
	jne	.L7
	movl	-100(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, -100(%rbp)
.L7:
	addl	$1, -84(%rbp)
.L6:
	movl	-108(%rbp), %eax
	cmpl	%eax, -84(%rbp)
	jl	.L8
	addl	$1, -88(%rbp)
.L5:
	movl	-112(%rbp), %eax
	cmpl	%eax, -88(%rbp)
	jl	.L9
	movl	$0, -84(%rbp)
	jmp	.L10
.L14:
	movl	$0, -88(%rbp)
	jmp	.L11
.L13:
	movq	%rbx, %rcx
	shrq	$2, %rcx
	movq	-64(%rbp), %rax
	movl	-84(%rbp), %edx
	movslq	%edx, %rsi
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	imulq	%rcx, %rdx
	addq	%rsi, %rdx
	movl	(%rax,%rdx,4), %eax
	addl	%eax, -96(%rbp)
	movl	-112(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -88(%rbp)
	jne	.L12
	movl	-96(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	-96(%rbp), %eax
	addl	%eax, -92(%rbp)
	movl	$0, -96(%rbp)
.L12:
	addl	$1, -88(%rbp)
.L11:
	movl	-112(%rbp), %eax
	cmpl	%eax, -88(%rbp)
	jl	.L13
	addl	$1, -84(%rbp)
.L10:
	movl	-108(%rbp), %eax
	cmpl	%eax, -84(%rbp)
	jl	.L14
	movl	-92(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	-168(%rbp), %rsp
	movl	$0, %eax
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L16
	call	__stack_chk_fail@PLT
.L16:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
train
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d "
.LC3:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$136, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, -168(%rbp)
	movl	$0, -100(%rbp)
	movl	$0, -96(%rbp)
	movl	$0, -92(%rbp)
	leaq	-108(%rbp), %rdx
	leaq	-112(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-108(%rbp), %ecx
	movl	-112(%rbp), %esi
	movslq	%ecx, %rax
	subq	$1, %rax
	movq	%rax, -80(%rbp)
	movslq	%ecx, %rax
	movq	%rax, -160(%rbp)
	movq	$0, -152(%rbp)
	movslq	%ecx, %rax
	leaq	0(,%rax,4), %rbx
	movslq	%esi, %rax
	subq	$1, %rax
	movq	%rax, -72(%rbp)
	movslq	%ecx, %rax
	movq	%rax, -128(%rbp)
	movq	$0, -120(%rbp)
	movslq	%esi, %rax
	movq	%rax, -144(%rbp)
	movq	$0, -136(%rbp)
	movq	-128(%rbp), %r8
	movq	-120(%rbp), %r9
	movq	%r9, %rdx
	movq	-144(%rbp), %r10
	movq	-136(%rbp), %r11
	imulq	%r10, %rdx
	movq	%r11, %rax
	imulq	%r8, %rax
	leaq	(%rdx,%rax), %rdi
	movq	%r8, %rax
	mulq	%r10
	addq	%rdx, %rdi
	movq	%rdi, %rdx
	movslq	%ecx, %rax
	movq	%rax, %r14
	movl	$0, %r15d
	movslq	%esi, %rax
	movq	%rax, %r12
	movl	$0, %r13d
	movq	%r15, %rdx
	imulq	%r12, %rdx
	movq	%r13, %rax
	imulq	%r14, %rax
	leaq	(%rdx,%rax), %rdi
	movq	%r14, %rax
	mulq	%r12
	addq	%rdx, %rdi
	movq	%rdi, %rdx
	movslq	%ecx, %rdx
	movslq	%esi, %rax
	imulq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %edi
	movl	$0, %edx
	divq	%rdi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L2:
	cmpq	%rdx, %rsp
	je	.L3
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L2
.L3:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L4
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L4:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -64(%rbp)
	movl	$0, -88(%rbp)
	jmp	.L5
.L9:
	movl	$0, -84(%rbp)
	jmp	.L6
.L8:
	leaq	-104(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-104(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	-104(%rbp), %eax
	addl	%eax, -100(%rbp)
	movq	%rbx, %rsi
	shrq	$2, %rsi
	movl	-104(%rbp), %edx
	movq	-64(%rbp), %rax
	movl	-84(%rbp), %ecx
	movslq	%ecx, %rdi
	movl	-88(%rbp), %ecx
	movslq	%ecx, %rcx
	imulq	%rsi, %rcx
	addq	%rdi, %rcx
	movl	%edx, (%rax,%rcx,4)
	movl	-108(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -84(%rbp)
	jne	.L7
	movl	-100(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, -100(%rbp)
.L7:
	addl	$1, -84(%rbp)
.L6:
	movl	-108(%rbp), %eax
	cmpl	%eax, -84(%rbp)
	jl	.L8
	addl	$1, -88(%rbp)
.L5:
	movl	-112(%rbp), %eax
	cmpl	%eax, -88(%rbp)
	jl	.L9
	movl	$0, -84(%rbp)
	jmp	.L10
.L14:
	movl	$0, -88(%rbp)
	jmp	.L11
.L13:
	movq	%rbx, %rcx
	shrq	$2, %rcx
	movq	-64(%rbp), %rax
	movl	-84(%rbp), %edx
	movslq	%edx, %rsi
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	imulq	%rcx, %rdx
	addq	%rsi, %rdx
	movl	(%rax,%rdx,4), %eax
	addl	%eax, -96(%rbp)
	movl	-112(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -88(%rbp)
	jne	.L12
	movl	-96(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	-96(%rbp), %eax
	addl	%eax, -92(%rbp)
	movl	$0, -96(%rbp)
.L12:
	addl	$1, -88(%rbp)
.L11:
	movl	-112(%rbp), %eax
	cmpl	%eax, -88(%rbp)
	jl	.L13
	addl	$1, -84(%rbp)
.L10:
	movl	-108(%rbp), %eax
	cmpl	%eax, -84(%rbp)
	jl	.L14
	movl	-92(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	-168(%rbp), %rsp
	movl	$0, %eax
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L16
	call	__stack_chk_fail@PLT
.L16:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
