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>
#include <stdbool.h>

int min(int a,int b){return a > b ? b : a;}

int main()
{
    int n,k,x[100];
    scanf("%d %d",&n,&k);

    int i;
    for (i = 0; i < n; i++)
    {
        scanf("%d",&x[i]);
    }

    int ans = 0;
    for (i = 0; i < n; i++)
    {
        ans += 2 * min(x[i],k - x[i]);
    }
    printf("%d",ans);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	min
	.type	min, @function
min:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	-4(%rbp), %edx
	movl	-8(%rbp), %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	min, .-min
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$432, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-428(%rbp), %rdx
	leaq	-432(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -424(%rbp)
	jmp	.L4
.L5:
	leaq	-416(%rbp), %rdx
	movl	-424(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -424(%rbp)
.L4:
	movl	-432(%rbp), %eax
	cmpl	%eax, -424(%rbp)
	jl	.L5
	movl	$0, -420(%rbp)
	movl	$0, -424(%rbp)
	jmp	.L6
.L7:
	movl	-428(%rbp), %edx
	movl	-424(%rbp), %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	subl	%eax, %edx
	movl	-424(%rbp), %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	min
	addl	%eax, %eax
	addl	%eax, -420(%rbp)
	addl	$1, -424(%rbp)
.L6:
	movl	-432(%rbp), %eax
	cmpl	%eax, -424(%rbp)
	jl	.L7
	movl	-420(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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
	.p2align 4
	.globl	min
	.type	min, @function
min:
.LFB23:
	.cfi_startproc
	endbr64
	cmpl	%esi, %edi
	movl	%esi, %eax
	cmovle	%edi, %eax
	ret
	.cfi_endproc
.LFE23:
	.size	min, .-min
	.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:
.LFB24:
	.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	$440, %rsp
	.cfi_def_cfa_offset 480
	movq	%fs:40, %rax
	movq	%rax, 424(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rdx
	leaq	8(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	8(%rsp), %eax
	testl	%eax, %eax
	jle	.L4
	leaq	16(%rsp), %r12
	xorl	%ebx, %ebx
	leaq	.LC1(%rip), %r13
	movq	%r12, %rbp
	.p2align 4,,10
	.p2align 3
.L5:
	movq	%rbp, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	8(%rsp), %ecx
	addq	$4, %rbp
	cmpl	%ebx, %ecx
	jg	.L5
	testl	%ecx, %ecx
	jle	.L4
	leal	-1(%rcx), %eax
	movl	12(%rsp), %esi
	cmpl	$2, %eax
	jbe	.L12
	movl	%ecx, %eax
	movd	%esi, %xmm5
	pxor	%xmm2, %xmm2
	shrl	$2, %eax
	pshufd	$0, %xmm5, %xmm4
	leal	-1(%rax), %edx
	leaq	16(%r12), %rax
	salq	$4, %rdx
	addq	%rax, %rdx
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L19:
	addq	$16, %rax
.L7:
	movdqa	(%r12), %xmm1
	movdqa	%xmm4, %xmm3
	movq	%rax, %r12
	psubd	%xmm1, %xmm3
	movdqa	%xmm3, %xmm0
	pcmpgtd	%xmm1, %xmm0
	pand	%xmm0, %xmm1
	pandn	%xmm3, %xmm0
	por	%xmm1, %xmm0
	pslld	$1, %xmm0
	paddd	%xmm0, %xmm2
	cmpq	%rdx, %rax
	jne	.L19
	movdqa	%xmm2, %xmm0
	movl	%ecx, %eax
	psrldq	$8, %xmm0
	andl	$-4, %eax
	paddd	%xmm0, %xmm2
	movdqa	%xmm2, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm2
	movd	%xmm2, %edx
	testb	$3, %cl
	je	.L9
.L6:
	movslq	%eax, %rdi
	movl	16(%rsp,%rdi,4), %r8d
	movl	%esi, %edi
	subl	%r8d, %edi
	cmpl	%r8d, %edi
	cmovg	%r8d, %edi
	leal	(%rdx,%rdi,2), %edx
	leal	1(%rax), %edi
	cmpl	%edi, %ecx
	jle	.L9
	movslq	%edi, %rdi
	movl	16(%rsp,%rdi,4), %r8d
	movl	%esi, %edi
	subl	%r8d, %edi
	cmpl	%r8d, %edi
	cmovg	%r8d, %edi
	addl	$2, %eax
	leal	(%rdx,%rdi,2), %edx
	cmpl	%eax, %ecx
	jle	.L9
	cltq
	movl	16(%rsp,%rax,4), %eax
	subl	%eax, %esi
	cmpl	%eax, %esi
	cmovg	%eax, %esi
	leal	(%rdx,%rsi,2), %edx
.L9:
	xorl	%eax, %eax
	movq	%r13, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	424(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L20
	addq	$440, %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
.L4:
	.cfi_restore_state
	xorl	%edx, %edx
	jmp	.L9
.L12:
	xorl	%edx, %edx
	xorl	%eax, %eax
	jmp	.L6
.L20:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.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
	.p2align 4
	.globl	min
	.type	min, @function
min:
.LFB23:
	.cfi_startproc
	endbr64
	cmpl	%esi, %edi
	movl	%esi, %eax
	cmovle	%edi, %eax
	ret
	.cfi_endproc
.LFE23:
	.size	min, .-min
	.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:
.LFB24:
	.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	$440, %rsp
	.cfi_def_cfa_offset 480
	movq	%fs:40, %rax
	movq	%rax, 424(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rdx
	leaq	8(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	8(%rsp), %eax
	testl	%eax, %eax
	jle	.L4
	leaq	16(%rsp), %r12
	xorl	%ebx, %ebx
	leaq	.LC1(%rip), %r13
	movq	%r12, %rbp
	.p2align 4,,10
	.p2align 3
.L5:
	movq	%rbp, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	8(%rsp), %ecx
	addq	$4, %rbp
	cmpl	%ebx, %ecx
	jg	.L5
	testl	%ecx, %ecx
	jle	.L4
	leal	-1(%rcx), %eax
	movl	12(%rsp), %esi
	cmpl	$2, %eax
	jbe	.L12
	movl	%ecx, %eax
	movd	%esi, %xmm5
	pxor	%xmm2, %xmm2
	shrl	$2, %eax
	pshufd	$0, %xmm5, %xmm4
	leal	-1(%rax), %edx
	leaq	16(%r12), %rax
	salq	$4, %rdx
	addq	%rax, %rdx
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L19:
	addq	$16, %rax
.L7:
	movdqa	(%r12), %xmm1
	movdqa	%xmm4, %xmm3
	movq	%rax, %r12
	psubd	%xmm1, %xmm3
	movdqa	%xmm3, %xmm0
	pcmpgtd	%xmm1, %xmm0
	pand	%xmm0, %xmm1
	pandn	%xmm3, %xmm0
	por	%xmm1, %xmm0
	pslld	$1, %xmm0
	paddd	%xmm0, %xmm2
	cmpq	%rdx, %rax
	jne	.L19
	movdqa	%xmm2, %xmm0
	movl	%ecx, %eax
	psrldq	$8, %xmm0
	andl	$-4, %eax
	paddd	%xmm0, %xmm2
	movdqa	%xmm2, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm2
	movd	%xmm2, %edx
	testb	$3, %cl
	je	.L9
.L6:
	movslq	%eax, %rdi
	movl	16(%rsp,%rdi,4), %r8d
	movl	%esi, %edi
	subl	%r8d, %edi
	cmpl	%r8d, %edi
	cmovg	%r8d, %edi
	leal	(%rdx,%rdi,2), %edx
	leal	1(%rax), %edi
	cmpl	%edi, %ecx
	jle	.L9
	movslq	%edi, %rdi
	movl	16(%rsp,%rdi,4), %r8d
	movl	%esi, %edi
	subl	%r8d, %edi
	cmpl	%r8d, %edi
	cmovg	%r8d, %edi
	addl	$2, %eax
	leal	(%rdx,%rdi,2), %edx
	cmpl	%eax, %ecx
	jle	.L9
	cltq
	movl	16(%rsp,%rax,4), %eax
	subl	%eax, %esi
	cmpl	%eax, %esi
	cmovg	%eax, %esi
	leal	(%rdx,%rsi,2), %edx
.L9:
	xorl	%eax, %eax
	movq	%r13, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	424(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L20
	addq	$440, %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
.L4:
	.cfi_restore_state
	xorl	%edx, %edx
	jmp	.L9
.L12:
	xorl	%edx, %edx
	xorl	%eax, %eax
	jmp	.L6
.L20:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.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>
#include <stdbool.h>

int min(int a,int b){return a > b ? b : a;}

int main()
{
    int n,k,x[100];
    scanf("%d %d",&n,&k);

    int i;
    for (i = 0; i < n; i++)
    {
        scanf("%d",&x[i]);
    }

    int ans = 0;
    for (i = 0; i < n; i++)
    {
        ans += 2 * min(x[i],k - x[i]);
    }
    printf("%d",ans);
}
1
18
2
 2
9
2 6
 5
20
11 12 9 17 15
 1
23
1
 1
23
0
 1
25
-1
 1
10
3
 5
20
11 12 9 17 1
 2
9
1 6
 5
20
8 12 9 17 15

4 10 68 2 0 -2 6 60 8 66
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>
#include <stdbool.h>

int min(int a,int b){return a > b ? b : a;}

int main()
{
    int n,k,x[100];
    scanf("%d %d",&n,&k);

    int i;
    for (i = 0; i < n; i++)
    {
        scanf("%d",&x[i]);
    }

    int ans = 0;
    for (i = 0; i < n; i++)
    {
        ans += 2 * min(x[i],k - x[i]);
    }
    printf("%d",ans);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	min
	.type	min, @function
min:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	-4(%rbp), %edx
	movl	-8(%rbp), %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	min, .-min
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$432, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-428(%rbp), %rdx
	leaq	-432(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -424(%rbp)
	jmp	.L4
.L5:
	leaq	-416(%rbp), %rdx
	movl	-424(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -424(%rbp)
.L4:
	movl	-432(%rbp), %eax
	cmpl	%eax, -424(%rbp)
	jl	.L5
	movl	$0, -420(%rbp)
	movl	$0, -424(%rbp)
	jmp	.L6
.L7:
	movl	-428(%rbp), %edx
	movl	-424(%rbp), %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	subl	%eax, %edx
	movl	-424(%rbp), %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	min
	addl	%eax, %eax
	addl	%eax, -420(%rbp)
	addl	$1, -424(%rbp)
.L6:
	movl	-432(%rbp), %eax
	cmpl	%eax, -424(%rbp)
	jl	.L7
	movl	-420(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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
	.globl	min
	.type	min, @function
min:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	-4(%rbp), %edx
	movl	-8(%rbp), %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	min, .-min
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$432, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-428(%rbp), %rdx
	leaq	-432(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -424(%rbp)
	jmp	.L4
.L5:
	leaq	-416(%rbp), %rdx
	movl	-424(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -424(%rbp)
.L4:
	movl	-432(%rbp), %eax
	cmpl	%eax, -424(%rbp)
	jl	.L5
	movl	$0, -420(%rbp)
	movl	$0, -424(%rbp)
	jmp	.L6
.L7:
	movl	-428(%rbp), %edx
	movl	-424(%rbp), %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	subl	%eax, %edx
	movl	-424(%rbp), %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	min
	addl	%eax, %eax
	addl	%eax, -420(%rbp)
	addl	$1, -424(%rbp)
.L6:
	movl	-432(%rbp), %eax
	cmpl	%eax, -424(%rbp)
	jl	.L7
	movl	-420(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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:
