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

```c
#include <stdio.h>
int main(void){
	int N,K,i,j,k,a[51],max=0,sum=0;
	scanf("%d %d",&N,&K);
	for(i=0;i<N;i++){scanf("%d",&a[i]);}
	for(i=0;i<K;i++){
		for(j=0;j<N;j++){if(max<a[j]){max=a[j];k=j;}}
		sum+=max;
		a[k]=0;
		max=0;
	}
	printf("%d",sum);
	return 0;
}```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC0(%rip), %rdi
	leaq	.LC1(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$248, %rsp
	.cfi_def_cfa_offset 288
	movq	%fs:40, %rax
	movq	%rax, 232(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rdx
	leaq	8(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	8(%rsp), %r8d
	testl	%r8d, %r8d
	jle	.L2
	leaq	16(%rsp), %r12
	xorl	%ebp, %ebp
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r12, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	addl	$1, %ebp
	call	__isoc99_scanf@PLT
	movl	8(%rsp), %r8d
	addq	$4, %r12
	cmpl	%ebp, %r8d
	jg	.L3
.L2:
	movl	12(%rsp), %r11d
	xorl	%r10d, %r10d
	xorl	%r9d, %r9d
	movslq	%r8d, %rdi
	testl	%r11d, %r11d
	jle	.L5
	.p2align 4,,10
	.p2align 3
.L4:
	xorl	%eax, %eax
	xorl	%ecx, %ecx
	leaq	16(%rsp), %rsi
	testl	%r8d, %r8d
	jle	.L9
	.p2align 4,,10
	.p2align 3
.L7:
	movl	(%rsi,%rax,4), %edx
	cmpl	%edx, %ecx
	jge	.L6
	movl	%edx, %ecx
	movl	%eax, %ebx
.L6:
	addq	$1, %rax
	cmpq	%rax, %rdi
	jne	.L7
	addl	%ecx, %r10d
.L9:
	movslq	%ebx, %rax
	addl	$1, %r9d
	movl	$0, 16(%rsp,%rax,4)
	cmpl	%r11d, %r9d
	jne	.L4
.L5:
	xorl	%eax, %eax
	movl	%r10d, %edx
	movq	%r13, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	232(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L18
	addq	$248, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L18:
	.cfi_restore_state
	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:
```

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.
Optimized Assembly Code:

user
```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC0(%rip), %rdi
	leaq	.LC1(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$248, %rsp
	.cfi_def_cfa_offset 288
	movq	%fs:40, %rax
	movq	%rax, 232(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rdx
	leaq	8(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	8(%rsp), %r8d
	testl	%r8d, %r8d
	jle	.L2
	leaq	16(%rsp), %r12
	xorl	%ebp, %ebp
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r12, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	addl	$1, %ebp
	call	__isoc99_scanf@PLT
	movl	8(%rsp), %r8d
	addq	$4, %r12
	cmpl	%ebp, %r8d
	jg	.L3
.L2:
	movl	12(%rsp), %r11d
	xorl	%r10d, %r10d
	xorl	%r9d, %r9d
	movslq	%r8d, %rdi
	testl	%r11d, %r11d
	jle	.L5
	.p2align 4,,10
	.p2align 3
.L4:
	xorl	%eax, %eax
	xorl	%ecx, %ecx
	leaq	16(%rsp), %rsi
	testl	%r8d, %r8d
	jle	.L9
	.p2align 4,,10
	.p2align 3
.L7:
	movl	(%rsi,%rax,4), %edx
	cmpl	%edx, %ecx
	jge	.L6
	movl	%edx, %ecx
	movl	%eax, %ebx
.L6:
	addq	$1, %rax
	cmpq	%rax, %rdi
	jne	.L7
	addl	%ecx, %r10d
.L9:
	movslq	%ebx, %rax
	addl	$1, %r9d
	movl	$0, 16(%rsp,%rax,4)
	cmpl	%r11d, %r9d
	jne	.L4
.L5:
	xorl	%eax, %eax
	movl	%r10d, %edx
	movq	%r13, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	232(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L18
	addq	$248, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L18:
	.cfi_restore_state
	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
```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC0(%rip), %rdi
	leaq	.LC1(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$248, %rsp
	.cfi_def_cfa_offset 288
	movq	%fs:40, %rax
	movq	%rax, 232(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rdx
	leaq	8(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	8(%rsp), %r8d
	testl	%r8d, %r8d
	jle	.L2
	leaq	16(%rsp), %r12
	xorl	%ebp, %ebp
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r12, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	addl	$1, %ebp
	call	__isoc99_scanf@PLT
	movl	8(%rsp), %r8d
	addq	$4, %r12
	cmpl	%ebp, %r8d
	jg	.L3
.L2:
	movl	12(%rsp), %r11d
	xorl	%r10d, %r10d
	xorl	%r9d, %r9d
	movslq	%r8d, %rdi
	testl	%r11d, %r11d
	jle	.L5
	.p2align 4,,10
	.p2align 3
.L4:
	xorl	%eax, %eax
	xorl	%ecx, %ecx
	leaq	16(%rsp), %rsi
	testl	%r8d, %r8d
	jle	.L9
	.p2align 4,,10
	.p2align 3
.L7:
	movl	(%rsi,%rax,4), %edx
	cmpl	%edx, %ecx
	jge	.L6
	movl	%edx, %ecx
	movl	%eax, %ebx
.L6:
	addq	$1, %rax
	cmpq	%rax, %rdi
	jne	.L7
	addl	%ecx, %r10d
.L9:
	movslq	%ebx, %rax
	addl	$1, %r9d
	movl	$0, 16(%rsp,%rax,4)
	cmpl	%r11d, %r9d
	jne	.L4
.L5:
	xorl	%eax, %eax
	movl	%r10d, %edx
	movq	%r13, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	232(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L18
	addq	$248, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L18:
	.cfi_restore_state
	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:
```
```c
#include <stdio.h>
int main(void){
	int N,K,i,j,k,a[51],max=0,sum=0;
	scanf("%d %d",&N,&K);
	for(i=0;i<N;i++){scanf("%d",&a[i]);}
	for(i=0;i<K;i++){
		for(j=0;j<N;j++){if(max<a[j]){max=a[j];k=j;}}
		sum+=max;
		a[k]=0;
		max=0;
	}
	printf("%d",sum);
	return 0;
}```
Given the following C code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include <stdio.h>
int main(void){
	int N,K,i,j,k,a[51],max=0,sum=0;
	scanf("%d %d",&N,&K);
	for(i=0;i<N;i++){scanf("%d",&a[i]);}
	for(i=0;i<K;i++){
		for(j=0;j<N;j++){if(max<a[j]){max=a[j];k=j;}}
		sum+=max;
		a[k]=0;
		max=0;
	}
	printf("%d",sum);
	return 0;
}```

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.
Optimized Assembly Code:

15 14
49 26 27 21 41 7 42 35 7 5 5 36 39 1 45
 5 5
1 2 3 4 5
 15 14
49 26 27 21 33 7 42 35 7 5 5 36 39 1 45
 5 5
2 2 3 4 5
 15 14
49 26 27 26 33 7 42 35 7 5 5 36 39 1 45
 5 3
2 2 3 4 5
 15 14
50 26 27 21 41 7 42 35 7 5 5 36 33 1 45
 15 14
49 26 27 21 41 12 42 35 7 5 5 36 39 1 45
 5 5
1 2 2 4 5
 15 14
49 26 27 21 33 7 42 35 7 5 5 31 39 1 45

385 15 377 16 382 12 380 390 14 372
Given the following C code and assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include <stdio.h>
int main(void){
	int N,K,i,j,k,a[51],max=0,sum=0;
	scanf("%d %d",&N,&K);
	for(i=0;i<N;i++){scanf("%d",&a[i]);}
	for(i=0;i<K;i++){
		for(j=0;j<N;j++){if(max<a[j]){max=a[j];k=j;}}
		sum+=max;
		a[k]=0;
		max=0;
	}
	printf("%d",sum);
	return 0;
}```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC0(%rip), %rdi
	leaq	.LC1(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$248, %rsp
	.cfi_def_cfa_offset 288
	movq	%fs:40, %rax
	movq	%rax, 232(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rdx
	leaq	8(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	8(%rsp), %r8d
	testl	%r8d, %r8d
	jle	.L2
	leaq	16(%rsp), %r12
	xorl	%ebp, %ebp
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r12, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	addl	$1, %ebp
	call	__isoc99_scanf@PLT
	movl	8(%rsp), %r8d
	addq	$4, %r12
	cmpl	%ebp, %r8d
	jg	.L3
.L2:
	movl	12(%rsp), %r11d
	xorl	%r10d, %r10d
	xorl	%r9d, %r9d
	movslq	%r8d, %rdi
	testl	%r11d, %r11d
	jle	.L5
	.p2align 4,,10
	.p2align 3
.L4:
	xorl	%eax, %eax
	xorl	%ecx, %ecx
	leaq	16(%rsp), %rsi
	testl	%r8d, %r8d
	jle	.L9
	.p2align 4,,10
	.p2align 3
.L7:
	movl	(%rsi,%rax,4), %edx
	cmpl	%edx, %ecx
	jge	.L6
	movl	%edx, %ecx
	movl	%eax, %ebx
.L6:
	addq	$1, %rax
	cmpq	%rax, %rdi
	jne	.L7
	addl	%ecx, %r10d
.L9:
	movslq	%ebx, %rax
	addl	$1, %r9d
	movl	$0, 16(%rsp,%rax,4)
	cmpl	%r11d, %r9d
	jne	.L4
.L5:
	xorl	%eax, %eax
	movl	%r10d, %edx
	movq	%r13, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	232(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L18
	addq	$248, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L18:
	.cfi_restore_state
	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:
```

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.
Optimized Assembly Code:

train
```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC0(%rip), %rdi
	leaq	.LC1(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$248, %rsp
	.cfi_def_cfa_offset 288
	movq	%fs:40, %rax
	movq	%rax, 232(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rdx
	leaq	8(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	8(%rsp), %r8d
	testl	%r8d, %r8d
	jle	.L2
	leaq	16(%rsp), %r12
	xorl	%ebp, %ebp
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r12, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	addl	$1, %ebp
	call	__isoc99_scanf@PLT
	movl	8(%rsp), %r8d
	addq	$4, %r12
	cmpl	%ebp, %r8d
	jg	.L3
.L2:
	movl	12(%rsp), %r11d
	xorl	%r10d, %r10d
	xorl	%r9d, %r9d
	movslq	%r8d, %rdi
	testl	%r11d, %r11d
	jle	.L5
	.p2align 4,,10
	.p2align 3
.L4:
	xorl	%eax, %eax
	xorl	%ecx, %ecx
	leaq	16(%rsp), %rsi
	testl	%r8d, %r8d
	jle	.L9
	.p2align 4,,10
	.p2align 3
.L7:
	movl	(%rsi,%rax,4), %edx
	cmpl	%edx, %ecx
	jge	.L6
	movl	%edx, %ecx
	movl	%eax, %ebx
.L6:
	addq	$1, %rax
	cmpq	%rax, %rdi
	jne	.L7
	addl	%ecx, %r10d
.L9:
	movslq	%ebx, %rax
	addl	$1, %r9d
	movl	$0, 16(%rsp,%rax,4)
	cmpl	%r11d, %r9d
	jne	.L4
.L5:
	xorl	%eax, %eax
	movl	%r10d, %edx
	movq	%r13, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	232(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L18
	addq	$248, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L18:
	.cfi_restore_state
	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:
```