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 <stdlib.h>

int A, B, C, D;

int nigeru(int x, int y, int isSrc) {
	int cost = 0;
	if (x < A) cost += A - x;
	if (C < x) cost += x - C;
	if (y < B) cost += B - y;
	if (D < y) cost += y - D;
	if (isSrc && cost > 0) cost--;
	return cost;
}

int main(void) {
	int N;
	while (scanf("%d", &N) == 1 && N > 0) {
		int X[128], Y[128];
		int i;
		int mikakosi = 0;
		if (scanf("%d%d%d%d", &A, &B, &C, &D) != 4) return 1;
		for (i = 0; i <= N; i++) {
			if (scanf("%d%d", &X[i], &Y[i]) != 2) return 1;
		}
		for (i = 1; i <= N; i++) {
			int naka = abs(X[i - 1] - X[i]) + abs(Y[i - 1] - Y[i]);
			int simakaze = nigeru(X[i - 1], Y[i - 1], 1) + nigeru(X[i], Y[i], 0);
			mikakosi += naka < simakaze ? naka : simakaze;
		}
		printf("%d\n", mikakosi);
	}
	return 0;
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	A
	.bss
	.align 4
	.type	A, @object
	.size	A, 4
A:
	.zero	4
	.globl	B
	.align 4
	.type	B, @object
	.size	B, 4
B:
	.zero	4
	.globl	C
	.align 4
	.type	C, @object
	.size	C, 4
C:
	.zero	4
	.globl	D
	.align 4
	.type	D, @object
	.size	D, 4
D:
	.zero	4
	.text
	.globl	nigeru
	.type	nigeru, @function
nigeru:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	%edx, -28(%rbp)
	movl	$0, -4(%rbp)
	movl	A(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jge	.L2
	movl	A(%rip), %eax
	subl	-20(%rbp), %eax
	addl	%eax, -4(%rbp)
.L2:
	movl	C(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jle	.L3
	movl	C(%rip), %edx
	movl	-20(%rbp), %eax
	subl	%edx, %eax
	addl	%eax, -4(%rbp)
.L3:
	movl	B(%rip), %eax
	cmpl	%eax, -24(%rbp)
	jge	.L4
	movl	B(%rip), %eax
	subl	-24(%rbp), %eax
	addl	%eax, -4(%rbp)
.L4:
	movl	D(%rip), %eax
	cmpl	%eax, -24(%rbp)
	jle	.L5
	movl	D(%rip), %edx
	movl	-24(%rbp), %eax
	subl	%edx, %eax
	addl	%eax, -4(%rbp)
.L5:
	cmpl	$0, -28(%rbp)
	je	.L6
	cmpl	$0, -4(%rbp)
	jle	.L6
	subl	$1, -4(%rbp)
.L6:
	movl	-4(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	nigeru, .-nigeru
	.section	.rodata
.LC0:
	.string	"%d%d%d%d"
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d\n"
.LC3:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	subq	$1080, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	jmp	.L9
.L19:
	movl	$0, -1068(%rbp)
	leaq	D(%rip), %r8
	leaq	C(%rip), %rax
	movq	%rax, %rcx
	leaq	B(%rip), %rax
	movq	%rax, %rdx
	leaq	A(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$4, %eax
	je	.L10
	movl	$1, %eax
	jmp	.L20
.L10:
	movl	$0, -1072(%rbp)
	jmp	.L12
.L14:
	leaq	-544(%rbp), %rdx
	movl	-1072(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rax, %rdx
	leaq	-1056(%rbp), %rcx
	movl	-1072(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$2, %eax
	je	.L13
	movl	$1, %eax
	jmp	.L20
.L13:
	addl	$1, -1072(%rbp)
.L12:
	movl	-1076(%rbp), %eax
	cmpl	%eax, -1072(%rbp)
	jle	.L14
	movl	$1, -1072(%rbp)
	jmp	.L15
.L16:
	movl	-1072(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-1056(%rbp,%rax,4), %edx
	movl	-1072(%rbp), %eax
	cltq
	movl	-1056(%rbp,%rax,4), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, %ecx
	movl	-1072(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-544(%rbp,%rax,4), %edx
	movl	-1072(%rbp), %eax
	cltq
	movl	-544(%rbp,%rax,4), %esi
	movl	%edx, %eax
	subl	%esi, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	addl	%ecx, %eax
	movl	%eax, -1064(%rbp)
	movl	-1072(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-544(%rbp,%rax,4), %ecx
	movl	-1072(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-1056(%rbp,%rax,4), %eax
	movl	$1, %edx
	movl	%ecx, %esi
	movl	%eax, %edi
	call	nigeru
	movl	%eax, %ebx
	movl	-1072(%rbp), %eax
	cltq
	movl	-544(%rbp,%rax,4), %ecx
	movl	-1072(%rbp), %eax
	cltq
	movl	-1056(%rbp,%rax,4), %eax
	movl	$0, %edx
	movl	%ecx, %esi
	movl	%eax, %edi
	call	nigeru
	addl	%ebx, %eax
	movl	%eax, -1060(%rbp)
	movl	-1060(%rbp), %edx
	movl	-1064(%rbp), %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	addl	%eax, -1068(%rbp)
	addl	$1, -1072(%rbp)
.L15:
	movl	-1076(%rbp), %eax
	cmpl	%eax, -1072(%rbp)
	jle	.L16
	movl	-1068(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L9:
	leaq	-1076(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	jne	.L18
	movl	-1076(%rbp), %eax
	testl	%eax, %eax
	jg	.L19
.L18:
	movl	$0, %eax
.L20:
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L21
	call	__stack_chk_fail@PLT
.L21:
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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	nigeru
	.type	nigeru, @function
nigeru:
.LFB39:
	.cfi_startproc
	endbr64
	movl	%edx, %r8d
	movl	A(%rip), %edx
	movl	%esi, %ecx
	movl	C(%rip), %esi
	movl	%edx, %eax
	subl	%edi, %eax
	cmpl	%edi, %edx
	movl	$0, %edx
	cmovle	%edx, %eax
	movl	%edi, %edx
	subl	%esi, %edx
	addl	%eax, %edx
	cmpl	%edi, %esi
	movl	B(%rip), %esi
	cmovl	%edx, %eax
	movl	%esi, %edx
	subl	%ecx, %edx
	addl	%eax, %edx
	cmpl	%ecx, %esi
	movl	D(%rip), %esi
	cmovg	%edx, %eax
	movl	%ecx, %edx
	subl	%esi, %edx
	addl	%eax, %edx
	cmpl	%ecx, %esi
	cmovl	%edx, %eax
	testl	%r8d, %r8d
	je	.L1
	testl	%eax, %eax
	setg	%dl
	cmpb	$1, %dl
	adcl	$-1, %eax
.L1:
	ret
	.cfi_endproc
.LFE39:
	.size	nigeru, .-nigeru
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%d%d%d"
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d\n"
.LC3:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB40:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$1080, %rsp
	.cfi_def_cfa_offset 1136
	movq	%fs:40, %rax
	movq	%rax, 1064(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %r13
.L15:
	movq	%r13, %rsi
	leaq	.LC3(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	%eax, %r12d
	cmpl	$1, %eax
	jne	.L64
	movl	28(%rsp), %eax
	testl	%eax, %eax
	jle	.L64
	xorl	%eax, %eax
	leaq	D(%rip), %r8
	leaq	C(%rip), %rcx
	leaq	B(%rip), %rdx
	leaq	A(%rip), %rsi
	leaq	.LC0(%rip), %rdi
	call	__isoc99_scanf@PLT
	cmpl	$4, %eax
	jne	.L14
	movl	28(%rsp), %edx
	testl	%edx, %edx
	js	.L55
	leaq	32(%rsp), %rax
	xorl	%ebx, %ebx
	leaq	544(%rsp), %rbp
	movq	%rax, (%rsp)
	movq	%rax, %r14
	leaq	.LC1(%rip), %r15
	jmp	.L18
	.p2align 4,,10
	.p2align 3
.L78:
	movl	28(%rsp), %eax
	addq	$1, %rbx
	addq	$4, %r14
	cmpl	%ebx, %eax
	jl	.L77
.L18:
	xorl	%eax, %eax
	leaq	0(%rbp,%rbx,4), %rdx
	movq	%r14, %rsi
	movq	%r15, %rdi
	call	__isoc99_scanf@PLT
	cmpl	$2, %eax
	je	.L78
.L14:
	movq	1064(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L79
	addq	$1080, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	movl	%r12d, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L77:
	.cfi_restore_state
	testl	%eax, %eax
	jle	.L55
	leal	-1(%rax), %edx
	movl	A(%rip), %r8d
	movl	C(%rip), %r9d
	movl	B(%rip), %esi
	movl	D(%rip), %edi
	cmpl	$2, %edx
	jbe	.L56
	movl	%eax, %edx
	movd	%r8d, %xmm2
	movd	%r9d, %xmm7
	movq	(%rsp), %r14
	shrl	$2, %edx
	pshufd	$0, %xmm2, %xmm14
	movd	%esi, %xmm2
	subl	$1, %edx
	pshufd	$0, %xmm7, %xmm13
	pshufd	$0, %xmm2, %xmm12
	movd	%edi, %xmm7
	pxor	%xmm2, %xmm2
	salq	$4, %rdx
	pshufd	$0, %xmm7, %xmm11
	leaq	48(%rsp,%rdx), %rdx
	movaps	%xmm2, (%rsp)
	movdqa	%xmm2, %xmm10
	.p2align 4,,10
	.p2align 3
.L20:
	movdqa	(%r14), %xmm0
	movdqu	4(%r14), %xmm1
	movdqa	%xmm12, %xmm8
	addq	$16, %r14
	movdqa	0(%rbp), %xmm3
	movdqu	4(%rbp), %xmm2
	addq	$16, %rbp
	movdqa	%xmm0, %xmm5
	psubd	%xmm1, %xmm5
	movdqa	%xmm3, %xmm7
	psubd	%xmm3, %xmm8
	movdqa	%xmm5, %xmm4
	pcmpgtd	%xmm11, %xmm7
	psrad	$31, %xmm4
	pxor	%xmm4, %xmm5
	psubd	%xmm4, %xmm5
	movdqa	%xmm3, %xmm4
	movdqa	%xmm7, %xmm9
	psubd	%xmm2, %xmm4
	pcmpeqd	%xmm10, %xmm9
	movdqa	%xmm4, %xmm6
	psrad	$31, %xmm6
	pxor	%xmm6, %xmm4
	psubd	%xmm6, %xmm4
	movdqa	%xmm14, %xmm6
	pcmpgtd	%xmm0, %xmm6
	paddd	%xmm4, %xmm5
	movdqa	%xmm14, %xmm4
	psubd	%xmm0, %xmm4
	pand	%xmm4, %xmm6
	movdqa	%xmm0, %xmm4
	pcmpgtd	%xmm13, %xmm0
	psubd	%xmm13, %xmm4
	paddd	%xmm6, %xmm4
	pand	%xmm0, %xmm4
	pandn	%xmm6, %xmm0
	por	%xmm4, %xmm0
	movdqa	%xmm12, %xmm4
	pcmpgtd	%xmm3, %xmm4
	paddd	%xmm0, %xmm8
	movdqa	%xmm0, %xmm15
	psubd	%xmm11, %xmm3
	movdqa	%xmm4, %xmm6
	pcmpeqd	%xmm10, %xmm4
	pand	%xmm9, %xmm6
	pand	%xmm4, %xmm9
	pand	%xmm7, %xmm4
	pand	%xmm4, %xmm15
	pandn	%xmm8, %xmm4
	pand	%xmm6, %xmm8
	por	%xmm15, %xmm4
	paddd	%xmm4, %xmm3
	movdqa	%xmm0, %xmm4
	pcmpeqd	%xmm10, %xmm4
	movdqa	%xmm4, %xmm15
	pcmpeqd	%xmm10, %xmm4
	pand	%xmm9, %xmm15
	pand	%xmm9, %xmm4
	pand	%xmm4, %xmm0
	pandn	%xmm3, %xmm4
	pand	%xmm7, %xmm3
	por	%xmm0, %xmm4
	movdqa	%xmm14, %xmm0
	pandn	%xmm4, %xmm7
	psubd	%xmm1, %xmm0
	por	%xmm3, %xmm7
	movdqa	%xmm14, %xmm3
	pcmpgtd	%xmm1, %xmm3
	pandn	%xmm7, %xmm6
	por	%xmm8, %xmm6
	paddd	.LC4(%rip), %xmm6
	pand	%xmm0, %xmm3
	movdqa	%xmm1, %xmm0
	pandn	%xmm6, %xmm15
	pcmpgtd	%xmm13, %xmm1
	psubd	%xmm13, %xmm0
	paddd	%xmm3, %xmm0
	pand	%xmm1, %xmm0
	pandn	%xmm3, %xmm1
	movdqa	%xmm12, %xmm3
	por	%xmm0, %xmm1
	movdqa	%xmm12, %xmm0
	psubd	%xmm2, %xmm3
	pcmpgtd	%xmm2, %xmm0
	paddd	%xmm1, %xmm3
	pand	%xmm0, %xmm3
	pandn	%xmm1, %xmm0
	movdqa	%xmm2, %xmm1
	pcmpgtd	%xmm11, %xmm2
	por	%xmm3, %xmm0
	psubd	%xmm11, %xmm1
	paddd	%xmm0, %xmm1
	pand	%xmm2, %xmm1
	pandn	%xmm0, %xmm2
	por	%xmm1, %xmm2
	paddd	%xmm2, %xmm15
	movdqa	%xmm15, %xmm0
	pcmpgtd	%xmm5, %xmm0
	pand	%xmm0, %xmm5
	pandn	%xmm15, %xmm0
	por	%xmm5, %xmm0
	paddd	(%rsp), %xmm0
	movaps	%xmm0, (%rsp)
	cmpq	%rdx, %r14
	jne	.L20
	movdqa	%xmm0, %xmm2
	psrldq	$8, %xmm0
	movl	%eax, %ecx
	paddd	%xmm2, %xmm0
	andl	$-4, %ecx
	movdqa	%xmm0, %xmm1
	leal	1(%rcx), %r12d
	psrldq	$4, %xmm1
	paddd	%xmm1, %xmm0
	movd	%xmm0, %edx
	cmpl	%ecx, %eax
	je	.L17
.L19:
	movslq	%r12d, %r10
	leaq	-4(,%r10,4), %r11
	movl	32(%rsp,%r10,4), %ebp
	movl	544(%rsp,%r10,4), %ebx
	movl	32(%rsp,%r11), %r14d
	movl	544(%rsp,%r11), %ecx
	movl	%r14d, %r10d
	movl	%ecx, %r15d
	subl	%ebp, %r10d
	movl	%r10d, %r11d
	negl	%r11d
	cmovs	%r10d, %r11d
	subl	%ebx, %r15d
	movl	%r15d, %r10d
	negl	%r10d
	cmovs	%r15d, %r10d
	addl	%r10d, %r11d
	xorl	%r10d, %r10d
	cmpl	%r14d, %r8d
	jle	.L23
	movl	%r8d, %r10d
	subl	%r14d, %r10d
.L23:
	cmpl	%r14d, %r9d
	jge	.L24
	subl	%r9d, %r14d
	addl	%r14d, %r10d
.L24:
	cmpl	%esi, %ecx
	jl	.L80
	cmpl	%edi, %ecx
	jg	.L27
	testl	%r10d, %r10d
	jne	.L26
.L28:
	xorl	%ecx, %ecx
	cmpl	%ebp, %r8d
	jle	.L29
	movl	%r8d, %ecx
	subl	%ebp, %ecx
.L29:
	cmpl	%ebp, %r9d
	jge	.L30
	movl	%ebp, %r14d
	subl	%r9d, %r14d
	addl	%r14d, %ecx
.L30:
	movl	%ecx, %r14d
	cmpl	%ebx, %esi
	jle	.L31
	movl	%esi, %r14d
	subl	%ebx, %r14d
	addl	%ecx, %r14d
.L31:
	cmpl	%ebx, %edi
	jge	.L32
	movl	%ebx, %r15d
	subl	%edi, %r15d
	addl	%r15d, %r14d
.L32:
	addl	%r14d, %r10d
	cmpl	%r11d, %r10d
	cmovg	%r11d, %r10d
	addl	%r10d, %edx
	leal	1(%r12), %r10d
	cmpl	%r10d, %eax
	jl	.L17
	movslq	%r10d, %r11
	movl	%ebx, %r15d
	movl	32(%rsp,%r11,4), %r10d
	movl	544(%rsp,%r11,4), %r11d
	subl	%r11d, %r15d
	movl	%r15d, %r14d
	negl	%r14d
	cmovs	%r15d, %r14d
	subl	%r10d, %ebp
	movl	%ebp, %r15d
	negl	%r15d
	cmovns	%r15d, %ebp
	addl	%ebp, %r14d
	cmpl	%ebx, %esi
	jle	.L33
	movl	%esi, %ebp
	subl	%ebx, %ebp
	addl	%ebp, %ecx
	cmpl	%ebx, %edi
	jge	.L34
.L35:
	subl	%edi, %ebx
	addl	%ebx, %ecx
.L34:
	subl	$1, %ecx
.L36:
	xorl	%ebx, %ebx
	cmpl	%r8d, %r10d
	jge	.L37
	movl	%r8d, %ebx
	subl	%r10d, %ebx
.L37:
	cmpl	%r9d, %r10d
	jle	.L38
	movl	%r10d, %ebp
	subl	%r9d, %ebp
	addl	%ebp, %ebx
.L38:
	movl	%ebx, %ebp
	cmpl	%esi, %r11d
	jge	.L39
	movl	%esi, %ebp
	subl	%r11d, %ebp
	addl	%ebx, %ebp
.L39:
	movl	%ebp, %r15d
	cmpl	%edi, %r11d
	jle	.L40
	movl	%r11d, %r15d
	subl	%edi, %r15d
	addl	%ebp, %r15d
.L40:
	addl	%r15d, %ecx
	cmpl	%r14d, %ecx
	cmovg	%r14d, %ecx
	addl	$2, %r12d
	addl	%ecx, %edx
	cmpl	%r12d, %eax
	jl	.L17
	movslq	%r12d, %r12
	movl	32(%rsp,%r12,4), %r14d
	movl	544(%rsp,%r12,4), %r12d
	subl	%r14d, %r10d
	movl	%r10d, %ecx
	negl	%ecx
	cmovs	%r10d, %ecx
	movl	%r11d, %r10d
	subl	%r12d, %r10d
	movl	%r10d, %eax
	negl	%eax
	cmovs	%r10d, %eax
	addl	%eax, %ecx
	cmpl	%esi, %r11d
	jge	.L81
	movl	%esi, %eax
	subl	%r11d, %eax
	addl	%eax, %ebx
	cmpl	%edi, %r11d
	jle	.L48
.L50:
	movl	%r11d, %ebx
	subl	%edi, %ebx
	addl	%ebp, %ebx
.L48:
	subl	$1, %ebx
.L47:
	xorl	%eax, %eax
	cmpl	%r14d, %r8d
	jle	.L46
	movl	%r8d, %eax
	subl	%r14d, %eax
.L46:
	cmpl	%r14d, %r9d
	jge	.L45
	subl	%r9d, %r14d
	addl	%r14d, %eax
.L45:
	cmpl	%r12d, %esi
	jle	.L44
	subl	%r12d, %esi
	addl	%esi, %eax
.L44:
	cmpl	%r12d, %edi
	jge	.L43
	subl	%edi, %r12d
	addl	%r12d, %eax
.L43:
	addl	%ebx, %eax
	cmpl	%ecx, %eax
	cmovg	%ecx, %eax
	addl	%eax, %edx
.L17:
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L15
.L80:
	movl	%esi, %r14d
	subl	%ecx, %r14d
	addl	%r14d, %r10d
	cmpl	%edi, %ecx
	jle	.L26
.L27:
	subl	%edi, %ecx
	addl	%ecx, %r10d
.L26:
	subl	$1, %r10d
	jmp	.L28
.L33:
	cmpl	%ebx, %edi
	jl	.L35
	testl	%ecx, %ecx
	je	.L36
	jmp	.L34
.L81:
	cmpl	%edi, %r11d
	jg	.L50
	testl	%ebx, %ebx
	je	.L47
	jmp	.L48
.L64:
	xorl	%r12d, %r12d
	jmp	.L14
.L55:
	xorl	%edx, %edx
	jmp	.L17
.L56:
	xorl	%edx, %edx
	jmp	.L19
.L79:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE40:
	.size	main, .-main
	.globl	D
	.bss
	.align 4
	.type	D, @object
	.size	D, 4
D:
	.zero	4
	.globl	C
	.align 4
	.type	C, @object
	.size	C, 4
C:
	.zero	4
	.globl	B
	.align 4
	.type	B, @object
	.size	B, 4
B:
	.zero	4
	.globl	A
	.align 4
	.type	A, @object
	.size	A, 4
A:
	.zero	4
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC4:
	.long	-1
	.long	-1
	.long	-1
	.long	-1
	.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	nigeru
	.type	nigeru, @function
nigeru:
.LFB39:
	.cfi_startproc
	endbr64
	movl	%edx, %r8d
	movl	A(%rip), %edx
	movl	%esi, %ecx
	movl	C(%rip), %esi
	movl	%edx, %eax
	subl	%edi, %eax
	cmpl	%edi, %edx
	movl	$0, %edx
	cmovle	%edx, %eax
	movl	%edi, %edx
	subl	%esi, %edx
	addl	%eax, %edx
	cmpl	%edi, %esi
	movl	B(%rip), %esi
	cmovl	%edx, %eax
	movl	%esi, %edx
	subl	%ecx, %edx
	addl	%eax, %edx
	cmpl	%ecx, %esi
	movl	D(%rip), %esi
	cmovg	%edx, %eax
	movl	%ecx, %edx
	subl	%esi, %edx
	addl	%eax, %edx
	cmpl	%ecx, %esi
	cmovl	%edx, %eax
	testl	%r8d, %r8d
	je	.L1
	testl	%eax, %eax
	setg	%dl
	cmpb	$1, %dl
	adcl	$-1, %eax
.L1:
	ret
	.cfi_endproc
.LFE39:
	.size	nigeru, .-nigeru
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%d%d%d"
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d\n"
.LC3:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB40:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$1080, %rsp
	.cfi_def_cfa_offset 1136
	movq	%fs:40, %rax
	movq	%rax, 1064(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %r13
.L15:
	movq	%r13, %rsi
	leaq	.LC3(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	%eax, %r12d
	cmpl	$1, %eax
	jne	.L64
	movl	28(%rsp), %eax
	testl	%eax, %eax
	jle	.L64
	xorl	%eax, %eax
	leaq	D(%rip), %r8
	leaq	C(%rip), %rcx
	leaq	B(%rip), %rdx
	leaq	A(%rip), %rsi
	leaq	.LC0(%rip), %rdi
	call	__isoc99_scanf@PLT
	cmpl	$4, %eax
	jne	.L14
	movl	28(%rsp), %edx
	testl	%edx, %edx
	js	.L55
	leaq	32(%rsp), %rax
	xorl	%ebx, %ebx
	leaq	544(%rsp), %rbp
	movq	%rax, (%rsp)
	movq	%rax, %r14
	leaq	.LC1(%rip), %r15
	jmp	.L18
	.p2align 4,,10
	.p2align 3
.L78:
	movl	28(%rsp), %eax
	addq	$1, %rbx
	addq	$4, %r14
	cmpl	%ebx, %eax
	jl	.L77
.L18:
	xorl	%eax, %eax
	leaq	0(%rbp,%rbx,4), %rdx
	movq	%r14, %rsi
	movq	%r15, %rdi
	call	__isoc99_scanf@PLT
	cmpl	$2, %eax
	je	.L78
.L14:
	movq	1064(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L79
	addq	$1080, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	movl	%r12d, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L77:
	.cfi_restore_state
	testl	%eax, %eax
	jle	.L55
	leal	-1(%rax), %edx
	movl	A(%rip), %r8d
	movl	C(%rip), %r9d
	movl	B(%rip), %esi
	movl	D(%rip), %edi
	cmpl	$2, %edx
	jbe	.L56
	movl	%eax, %edx
	movd	%r8d, %xmm2
	movd	%r9d, %xmm7
	movq	(%rsp), %r14
	shrl	$2, %edx
	pshufd	$0, %xmm2, %xmm14
	movd	%esi, %xmm2
	subl	$1, %edx
	pshufd	$0, %xmm7, %xmm13
	pshufd	$0, %xmm2, %xmm12
	movd	%edi, %xmm7
	pxor	%xmm2, %xmm2
	salq	$4, %rdx
	pshufd	$0, %xmm7, %xmm11
	leaq	48(%rsp,%rdx), %rdx
	movaps	%xmm2, (%rsp)
	movdqa	%xmm2, %xmm10
	.p2align 4,,10
	.p2align 3
.L20:
	movdqa	(%r14), %xmm0
	movdqu	4(%r14), %xmm1
	movdqa	%xmm12, %xmm8
	addq	$16, %r14
	movdqa	0(%rbp), %xmm3
	movdqu	4(%rbp), %xmm2
	addq	$16, %rbp
	movdqa	%xmm0, %xmm5
	psubd	%xmm1, %xmm5
	movdqa	%xmm3, %xmm7
	psubd	%xmm3, %xmm8
	movdqa	%xmm5, %xmm4
	pcmpgtd	%xmm11, %xmm7
	psrad	$31, %xmm4
	pxor	%xmm4, %xmm5
	psubd	%xmm4, %xmm5
	movdqa	%xmm3, %xmm4
	movdqa	%xmm7, %xmm9
	psubd	%xmm2, %xmm4
	pcmpeqd	%xmm10, %xmm9
	movdqa	%xmm4, %xmm6
	psrad	$31, %xmm6
	pxor	%xmm6, %xmm4
	psubd	%xmm6, %xmm4
	movdqa	%xmm14, %xmm6
	pcmpgtd	%xmm0, %xmm6
	paddd	%xmm4, %xmm5
	movdqa	%xmm14, %xmm4
	psubd	%xmm0, %xmm4
	pand	%xmm4, %xmm6
	movdqa	%xmm0, %xmm4
	pcmpgtd	%xmm13, %xmm0
	psubd	%xmm13, %xmm4
	paddd	%xmm6, %xmm4
	pand	%xmm0, %xmm4
	pandn	%xmm6, %xmm0
	por	%xmm4, %xmm0
	movdqa	%xmm12, %xmm4
	pcmpgtd	%xmm3, %xmm4
	paddd	%xmm0, %xmm8
	movdqa	%xmm0, %xmm15
	psubd	%xmm11, %xmm3
	movdqa	%xmm4, %xmm6
	pcmpeqd	%xmm10, %xmm4
	pand	%xmm9, %xmm6
	pand	%xmm4, %xmm9
	pand	%xmm7, %xmm4
	pand	%xmm4, %xmm15
	pandn	%xmm8, %xmm4
	pand	%xmm6, %xmm8
	por	%xmm15, %xmm4
	paddd	%xmm4, %xmm3
	movdqa	%xmm0, %xmm4
	pcmpeqd	%xmm10, %xmm4
	movdqa	%xmm4, %xmm15
	pcmpeqd	%xmm10, %xmm4
	pand	%xmm9, %xmm15
	pand	%xmm9, %xmm4
	pand	%xmm4, %xmm0
	pandn	%xmm3, %xmm4
	pand	%xmm7, %xmm3
	por	%xmm0, %xmm4
	movdqa	%xmm14, %xmm0
	pandn	%xmm4, %xmm7
	psubd	%xmm1, %xmm0
	por	%xmm3, %xmm7
	movdqa	%xmm14, %xmm3
	pcmpgtd	%xmm1, %xmm3
	pandn	%xmm7, %xmm6
	por	%xmm8, %xmm6
	paddd	.LC4(%rip), %xmm6
	pand	%xmm0, %xmm3
	movdqa	%xmm1, %xmm0
	pandn	%xmm6, %xmm15
	pcmpgtd	%xmm13, %xmm1
	psubd	%xmm13, %xmm0
	paddd	%xmm3, %xmm0
	pand	%xmm1, %xmm0
	pandn	%xmm3, %xmm1
	movdqa	%xmm12, %xmm3
	por	%xmm0, %xmm1
	movdqa	%xmm12, %xmm0
	psubd	%xmm2, %xmm3
	pcmpgtd	%xmm2, %xmm0
	paddd	%xmm1, %xmm3
	pand	%xmm0, %xmm3
	pandn	%xmm1, %xmm0
	movdqa	%xmm2, %xmm1
	pcmpgtd	%xmm11, %xmm2
	por	%xmm3, %xmm0
	psubd	%xmm11, %xmm1
	paddd	%xmm0, %xmm1
	pand	%xmm2, %xmm1
	pandn	%xmm0, %xmm2
	por	%xmm1, %xmm2
	paddd	%xmm2, %xmm15
	movdqa	%xmm15, %xmm0
	pcmpgtd	%xmm5, %xmm0
	pand	%xmm0, %xmm5
	pandn	%xmm15, %xmm0
	por	%xmm5, %xmm0
	paddd	(%rsp), %xmm0
	movaps	%xmm0, (%rsp)
	cmpq	%rdx, %r14
	jne	.L20
	movdqa	%xmm0, %xmm2
	psrldq	$8, %xmm0
	movl	%eax, %ecx
	paddd	%xmm2, %xmm0
	andl	$-4, %ecx
	movdqa	%xmm0, %xmm1
	leal	1(%rcx), %r12d
	psrldq	$4, %xmm1
	paddd	%xmm1, %xmm0
	movd	%xmm0, %edx
	cmpl	%ecx, %eax
	je	.L17
.L19:
	movslq	%r12d, %r10
	leaq	-4(,%r10,4), %r11
	movl	32(%rsp,%r10,4), %ebp
	movl	544(%rsp,%r10,4), %ebx
	movl	32(%rsp,%r11), %r14d
	movl	544(%rsp,%r11), %ecx
	movl	%r14d, %r10d
	movl	%ecx, %r15d
	subl	%ebp, %r10d
	movl	%r10d, %r11d
	negl	%r11d
	cmovs	%r10d, %r11d
	subl	%ebx, %r15d
	movl	%r15d, %r10d
	negl	%r10d
	cmovs	%r15d, %r10d
	addl	%r10d, %r11d
	xorl	%r10d, %r10d
	cmpl	%r14d, %r8d
	jle	.L23
	movl	%r8d, %r10d
	subl	%r14d, %r10d
.L23:
	cmpl	%r14d, %r9d
	jge	.L24
	subl	%r9d, %r14d
	addl	%r14d, %r10d
.L24:
	cmpl	%esi, %ecx
	jl	.L80
	cmpl	%edi, %ecx
	jg	.L27
	testl	%r10d, %r10d
	jne	.L26
.L28:
	xorl	%ecx, %ecx
	cmpl	%ebp, %r8d
	jle	.L29
	movl	%r8d, %ecx
	subl	%ebp, %ecx
.L29:
	cmpl	%ebp, %r9d
	jge	.L30
	movl	%ebp, %r14d
	subl	%r9d, %r14d
	addl	%r14d, %ecx
.L30:
	movl	%ecx, %r14d
	cmpl	%ebx, %esi
	jle	.L31
	movl	%esi, %r14d
	subl	%ebx, %r14d
	addl	%ecx, %r14d
.L31:
	cmpl	%ebx, %edi
	jge	.L32
	movl	%ebx, %r15d
	subl	%edi, %r15d
	addl	%r15d, %r14d
.L32:
	addl	%r14d, %r10d
	cmpl	%r11d, %r10d
	cmovg	%r11d, %r10d
	addl	%r10d, %edx
	leal	1(%r12), %r10d
	cmpl	%r10d, %eax
	jl	.L17
	movslq	%r10d, %r11
	movl	%ebx, %r15d
	movl	32(%rsp,%r11,4), %r10d
	movl	544(%rsp,%r11,4), %r11d
	subl	%r11d, %r15d
	movl	%r15d, %r14d
	negl	%r14d
	cmovs	%r15d, %r14d
	subl	%r10d, %ebp
	movl	%ebp, %r15d
	negl	%r15d
	cmovns	%r15d, %ebp
	addl	%ebp, %r14d
	cmpl	%ebx, %esi
	jle	.L33
	movl	%esi, %ebp
	subl	%ebx, %ebp
	addl	%ebp, %ecx
	cmpl	%ebx, %edi
	jge	.L34
.L35:
	subl	%edi, %ebx
	addl	%ebx, %ecx
.L34:
	subl	$1, %ecx
.L36:
	xorl	%ebx, %ebx
	cmpl	%r8d, %r10d
	jge	.L37
	movl	%r8d, %ebx
	subl	%r10d, %ebx
.L37:
	cmpl	%r9d, %r10d
	jle	.L38
	movl	%r10d, %ebp
	subl	%r9d, %ebp
	addl	%ebp, %ebx
.L38:
	movl	%ebx, %ebp
	cmpl	%esi, %r11d
	jge	.L39
	movl	%esi, %ebp
	subl	%r11d, %ebp
	addl	%ebx, %ebp
.L39:
	movl	%ebp, %r15d
	cmpl	%edi, %r11d
	jle	.L40
	movl	%r11d, %r15d
	subl	%edi, %r15d
	addl	%ebp, %r15d
.L40:
	addl	%r15d, %ecx
	cmpl	%r14d, %ecx
	cmovg	%r14d, %ecx
	addl	$2, %r12d
	addl	%ecx, %edx
	cmpl	%r12d, %eax
	jl	.L17
	movslq	%r12d, %r12
	movl	32(%rsp,%r12,4), %r14d
	movl	544(%rsp,%r12,4), %r12d
	subl	%r14d, %r10d
	movl	%r10d, %ecx
	negl	%ecx
	cmovs	%r10d, %ecx
	movl	%r11d, %r10d
	subl	%r12d, %r10d
	movl	%r10d, %eax
	negl	%eax
	cmovs	%r10d, %eax
	addl	%eax, %ecx
	cmpl	%esi, %r11d
	jge	.L81
	movl	%esi, %eax
	subl	%r11d, %eax
	addl	%eax, %ebx
	cmpl	%edi, %r11d
	jle	.L48
.L50:
	movl	%r11d, %ebx
	subl	%edi, %ebx
	addl	%ebp, %ebx
.L48:
	subl	$1, %ebx
.L47:
	xorl	%eax, %eax
	cmpl	%r14d, %r8d
	jle	.L46
	movl	%r8d, %eax
	subl	%r14d, %eax
.L46:
	cmpl	%r14d, %r9d
	jge	.L45
	subl	%r9d, %r14d
	addl	%r14d, %eax
.L45:
	cmpl	%r12d, %esi
	jle	.L44
	subl	%r12d, %esi
	addl	%esi, %eax
.L44:
	cmpl	%r12d, %edi
	jge	.L43
	subl	%edi, %r12d
	addl	%r12d, %eax
.L43:
	addl	%ebx, %eax
	cmpl	%ecx, %eax
	cmovg	%ecx, %eax
	addl	%eax, %edx
.L17:
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L15
.L80:
	movl	%esi, %r14d
	subl	%ecx, %r14d
	addl	%r14d, %r10d
	cmpl	%edi, %ecx
	jle	.L26
.L27:
	subl	%edi, %ecx
	addl	%ecx, %r10d
.L26:
	subl	$1, %r10d
	jmp	.L28
.L33:
	cmpl	%ebx, %edi
	jl	.L35
	testl	%ecx, %ecx
	je	.L36
	jmp	.L34
.L81:
	cmpl	%edi, %r11d
	jg	.L50
	testl	%ebx, %ebx
	je	.L47
	jmp	.L48
.L64:
	xorl	%r12d, %r12d
	jmp	.L14
.L55:
	xorl	%edx, %edx
	jmp	.L17
.L56:
	xorl	%edx, %edx
	jmp	.L19
.L79:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE40:
	.size	main, .-main
	.globl	D
	.bss
	.align 4
	.type	D, @object
	.size	D, 4
D:
	.zero	4
	.globl	C
	.align 4
	.type	C, @object
	.size	C, 4
C:
	.zero	4
	.globl	B
	.align 4
	.type	B, @object
	.size	B, 4
B:
	.zero	4
	.globl	A
	.align 4
	.type	A, @object
	.size	A, 4
A:
	.zero	4
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC4:
	.long	-1
	.long	-1
	.long	-1
	.long	-1
	.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 <stdlib.h>

int A, B, C, D;

int nigeru(int x, int y, int isSrc) {
	int cost = 0;
	if (x < A) cost += A - x;
	if (C < x) cost += x - C;
	if (y < B) cost += B - y;
	if (D < y) cost += y - D;
	if (isSrc && cost > 0) cost--;
	return cost;
}

int main(void) {
	int N;
	while (scanf("%d", &N) == 1 && N > 0) {
		int X[128], Y[128];
		int i;
		int mikakosi = 0;
		if (scanf("%d%d%d%d", &A, &B, &C, &D) != 4) return 1;
		for (i = 0; i <= N; i++) {
			if (scanf("%d%d", &X[i], &Y[i]) != 2) return 1;
		}
		for (i = 1; i <= N; i++) {
			int naka = abs(X[i - 1] - X[i]) + abs(Y[i - 1] - Y[i]);
			int simakaze = nigeru(X[i - 1], Y[i - 1], 1) + nigeru(X[i], Y[i], 0);
			mikakosi += naka < simakaze ? naka : simakaze;
		}
		printf("%d\n", mikakosi);
	}
	return 0;
}


2
3 3 5 7
3 3
7 3
7 7
5
1 10 100 10
1 1
100 1
53 20
50 80
51 21
51 1
0
 2
3 3 5 7
3 3
7 3
7 7
5
1 10 100 18
1 1
100 1
53 20
50 80
51 21
51 1
0
 2
3 3 5 7
3 3
7 3
7 7
5
1 10 100 18
1 1
100 1
53 3
50 80
51 21
51 1
0
 2
3 3 7 7
3 3
7 3
7 7
5
1 10 100 10
1 1
100 1
50 20
50 80
51 21
51 1
0
 2
3 3 5 7
3 3
7 3
7 7
5
1 10 100 10
1 1
100 1
53 20
50 80
16 21
51 1
0
 2
3 3 5 7
3 3
7 3
2 7
5
1 10 100 18
1 1
100 1
53 3
50 80
51 21
51 1
0
 2
3 3 7 7
3 1
7 3
7 7
5
1 10 100 10
1 1
100 1
50 20
50 80
51 21
51 1
0
 2
3 3 5 7
3 3
7 3
7 7
5
1 10 100 34
1 1
100 1
53 20
50 80
51 21
91 1
0
 2
3 3 5 7
3 3
7 3
2 7
5
1 10 100 18
1 0
100 1
53 3
50 80
51 21
51 1
0
 2
3 3 7 7
3 1
7 3
7 7
5
1 10 100 10
1 0
100 1
50 20
50 80
51 21
51 1
0

5
177
 5
161
 5
171
 0
174
 5
197
 4
171
 1
174
 5
125
 4
172
 1
175

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 <stdlib.h>

int A, B, C, D;

int nigeru(int x, int y, int isSrc) {
	int cost = 0;
	if (x < A) cost += A - x;
	if (C < x) cost += x - C;
	if (y < B) cost += B - y;
	if (D < y) cost += y - D;
	if (isSrc && cost > 0) cost--;
	return cost;
}

int main(void) {
	int N;
	while (scanf("%d", &N) == 1 && N > 0) {
		int X[128], Y[128];
		int i;
		int mikakosi = 0;
		if (scanf("%d%d%d%d", &A, &B, &C, &D) != 4) return 1;
		for (i = 0; i <= N; i++) {
			if (scanf("%d%d", &X[i], &Y[i]) != 2) return 1;
		}
		for (i = 1; i <= N; i++) {
			int naka = abs(X[i - 1] - X[i]) + abs(Y[i - 1] - Y[i]);
			int simakaze = nigeru(X[i - 1], Y[i - 1], 1) + nigeru(X[i], Y[i], 0);
			mikakosi += naka < simakaze ? naka : simakaze;
		}
		printf("%d\n", mikakosi);
	}
	return 0;
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	A
	.bss
	.align 4
	.type	A, @object
	.size	A, 4
A:
	.zero	4
	.globl	B
	.align 4
	.type	B, @object
	.size	B, 4
B:
	.zero	4
	.globl	C
	.align 4
	.type	C, @object
	.size	C, 4
C:
	.zero	4
	.globl	D
	.align 4
	.type	D, @object
	.size	D, 4
D:
	.zero	4
	.text
	.globl	nigeru
	.type	nigeru, @function
nigeru:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	%edx, -28(%rbp)
	movl	$0, -4(%rbp)
	movl	A(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jge	.L2
	movl	A(%rip), %eax
	subl	-20(%rbp), %eax
	addl	%eax, -4(%rbp)
.L2:
	movl	C(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jle	.L3
	movl	C(%rip), %edx
	movl	-20(%rbp), %eax
	subl	%edx, %eax
	addl	%eax, -4(%rbp)
.L3:
	movl	B(%rip), %eax
	cmpl	%eax, -24(%rbp)
	jge	.L4
	movl	B(%rip), %eax
	subl	-24(%rbp), %eax
	addl	%eax, -4(%rbp)
.L4:
	movl	D(%rip), %eax
	cmpl	%eax, -24(%rbp)
	jle	.L5
	movl	D(%rip), %edx
	movl	-24(%rbp), %eax
	subl	%edx, %eax
	addl	%eax, -4(%rbp)
.L5:
	cmpl	$0, -28(%rbp)
	je	.L6
	cmpl	$0, -4(%rbp)
	jle	.L6
	subl	$1, -4(%rbp)
.L6:
	movl	-4(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	nigeru, .-nigeru
	.section	.rodata
.LC0:
	.string	"%d%d%d%d"
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d\n"
.LC3:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	subq	$1080, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	jmp	.L9
.L19:
	movl	$0, -1068(%rbp)
	leaq	D(%rip), %r8
	leaq	C(%rip), %rax
	movq	%rax, %rcx
	leaq	B(%rip), %rax
	movq	%rax, %rdx
	leaq	A(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$4, %eax
	je	.L10
	movl	$1, %eax
	jmp	.L20
.L10:
	movl	$0, -1072(%rbp)
	jmp	.L12
.L14:
	leaq	-544(%rbp), %rdx
	movl	-1072(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rax, %rdx
	leaq	-1056(%rbp), %rcx
	movl	-1072(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$2, %eax
	je	.L13
	movl	$1, %eax
	jmp	.L20
.L13:
	addl	$1, -1072(%rbp)
.L12:
	movl	-1076(%rbp), %eax
	cmpl	%eax, -1072(%rbp)
	jle	.L14
	movl	$1, -1072(%rbp)
	jmp	.L15
.L16:
	movl	-1072(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-1056(%rbp,%rax,4), %edx
	movl	-1072(%rbp), %eax
	cltq
	movl	-1056(%rbp,%rax,4), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, %ecx
	movl	-1072(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-544(%rbp,%rax,4), %edx
	movl	-1072(%rbp), %eax
	cltq
	movl	-544(%rbp,%rax,4), %esi
	movl	%edx, %eax
	subl	%esi, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	addl	%ecx, %eax
	movl	%eax, -1064(%rbp)
	movl	-1072(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-544(%rbp,%rax,4), %ecx
	movl	-1072(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-1056(%rbp,%rax,4), %eax
	movl	$1, %edx
	movl	%ecx, %esi
	movl	%eax, %edi
	call	nigeru
	movl	%eax, %ebx
	movl	-1072(%rbp), %eax
	cltq
	movl	-544(%rbp,%rax,4), %ecx
	movl	-1072(%rbp), %eax
	cltq
	movl	-1056(%rbp,%rax,4), %eax
	movl	$0, %edx
	movl	%ecx, %esi
	movl	%eax, %edi
	call	nigeru
	addl	%ebx, %eax
	movl	%eax, -1060(%rbp)
	movl	-1060(%rbp), %edx
	movl	-1064(%rbp), %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	addl	%eax, -1068(%rbp)
	addl	$1, -1072(%rbp)
.L15:
	movl	-1076(%rbp), %eax
	cmpl	%eax, -1072(%rbp)
	jle	.L16
	movl	-1068(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L9:
	leaq	-1076(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	jne	.L18
	movl	-1076(%rbp), %eax
	testl	%eax, %eax
	jg	.L19
.L18:
	movl	$0, %eax
.L20:
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L21
	call	__stack_chk_fail@PLT
.L21:
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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	A
	.bss
	.align 4
	.type	A, @object
	.size	A, 4
A:
	.zero	4
	.globl	B
	.align 4
	.type	B, @object
	.size	B, 4
B:
	.zero	4
	.globl	C
	.align 4
	.type	C, @object
	.size	C, 4
C:
	.zero	4
	.globl	D
	.align 4
	.type	D, @object
	.size	D, 4
D:
	.zero	4
	.text
	.globl	nigeru
	.type	nigeru, @function
nigeru:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	%edx, -28(%rbp)
	movl	$0, -4(%rbp)
	movl	A(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jge	.L2
	movl	A(%rip), %eax
	subl	-20(%rbp), %eax
	addl	%eax, -4(%rbp)
.L2:
	movl	C(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jle	.L3
	movl	C(%rip), %edx
	movl	-20(%rbp), %eax
	subl	%edx, %eax
	addl	%eax, -4(%rbp)
.L3:
	movl	B(%rip), %eax
	cmpl	%eax, -24(%rbp)
	jge	.L4
	movl	B(%rip), %eax
	subl	-24(%rbp), %eax
	addl	%eax, -4(%rbp)
.L4:
	movl	D(%rip), %eax
	cmpl	%eax, -24(%rbp)
	jle	.L5
	movl	D(%rip), %edx
	movl	-24(%rbp), %eax
	subl	%edx, %eax
	addl	%eax, -4(%rbp)
.L5:
	cmpl	$0, -28(%rbp)
	je	.L6
	cmpl	$0, -4(%rbp)
	jle	.L6
	subl	$1, -4(%rbp)
.L6:
	movl	-4(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	nigeru, .-nigeru
	.section	.rodata
.LC0:
	.string	"%d%d%d%d"
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d\n"
.LC3:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	subq	$1080, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	jmp	.L9
.L19:
	movl	$0, -1068(%rbp)
	leaq	D(%rip), %r8
	leaq	C(%rip), %rax
	movq	%rax, %rcx
	leaq	B(%rip), %rax
	movq	%rax, %rdx
	leaq	A(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$4, %eax
	je	.L10
	movl	$1, %eax
	jmp	.L20
.L10:
	movl	$0, -1072(%rbp)
	jmp	.L12
.L14:
	leaq	-544(%rbp), %rdx
	movl	-1072(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rax, %rdx
	leaq	-1056(%rbp), %rcx
	movl	-1072(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$2, %eax
	je	.L13
	movl	$1, %eax
	jmp	.L20
.L13:
	addl	$1, -1072(%rbp)
.L12:
	movl	-1076(%rbp), %eax
	cmpl	%eax, -1072(%rbp)
	jle	.L14
	movl	$1, -1072(%rbp)
	jmp	.L15
.L16:
	movl	-1072(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-1056(%rbp,%rax,4), %edx
	movl	-1072(%rbp), %eax
	cltq
	movl	-1056(%rbp,%rax,4), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, %ecx
	movl	-1072(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-544(%rbp,%rax,4), %edx
	movl	-1072(%rbp), %eax
	cltq
	movl	-544(%rbp,%rax,4), %esi
	movl	%edx, %eax
	subl	%esi, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	addl	%ecx, %eax
	movl	%eax, -1064(%rbp)
	movl	-1072(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-544(%rbp,%rax,4), %ecx
	movl	-1072(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-1056(%rbp,%rax,4), %eax
	movl	$1, %edx
	movl	%ecx, %esi
	movl	%eax, %edi
	call	nigeru
	movl	%eax, %ebx
	movl	-1072(%rbp), %eax
	cltq
	movl	-544(%rbp,%rax,4), %ecx
	movl	-1072(%rbp), %eax
	cltq
	movl	-1056(%rbp,%rax,4), %eax
	movl	$0, %edx
	movl	%ecx, %esi
	movl	%eax, %edi
	call	nigeru
	addl	%ebx, %eax
	movl	%eax, -1060(%rbp)
	movl	-1060(%rbp), %edx
	movl	-1064(%rbp), %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	addl	%eax, -1068(%rbp)
	addl	$1, -1072(%rbp)
.L15:
	movl	-1076(%rbp), %eax
	cmpl	%eax, -1072(%rbp)
	jle	.L16
	movl	-1068(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L9:
	leaq	-1076(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	jne	.L18
	movl	-1076(%rbp), %eax
	testl	%eax, %eax
	jg	.L19
.L18:
	movl	$0, %eax
.L20:
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L21
	call	__stack_chk_fail@PLT
.L21:
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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:
