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>
char c;
int N, A, i;
int main(void){
	c=getchar();
	while(c!=10){N=N*10+(c-'0'); c=getchar();}
	for(i=0; i<N; i++){
		c=getchar();
		while(c!=10){A=c; c=getchar();}
		if(A&1){
			printf("first\n");
			return 0;
		}
	}
	printf("second\n");
	return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	c
	.bss
	.type	c, @object
	.size	c, 1
c:
	.zero	1
	.globl	N
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.globl	A
	.align 4
	.type	A, @object
	.size	A, 4
A:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.section	.rodata
.LC0:
	.string	"first"
.LC1:
	.string	"second"
	.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
	call	getchar@PLT
	movb	%al, c(%rip)
	jmp	.L2
.L3:
	movl	N(%rip), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %edx
	movzbl	c(%rip), %eax
	movsbl	%al, %eax
	subl	$48, %eax
	addl	%edx, %eax
	movl	%eax, N(%rip)
	call	getchar@PLT
	movb	%al, c(%rip)
.L2:
	movzbl	c(%rip), %eax
	cmpb	$10, %al
	jne	.L3
	movl	$0, i(%rip)
	jmp	.L4
.L9:
	call	getchar@PLT
	movb	%al, c(%rip)
	jmp	.L5
.L6:
	movzbl	c(%rip), %eax
	movsbl	%al, %eax
	movl	%eax, A(%rip)
	call	getchar@PLT
	movb	%al, c(%rip)
.L5:
	movzbl	c(%rip), %eax
	cmpb	$10, %al
	jne	.L6
	movl	A(%rip), %eax
	andl	$1, %eax
	testl	%eax, %eax
	je	.L7
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
	jmp	.L8
.L7:
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L4:
	movl	i(%rip), %edx
	movl	N(%rip), %eax
	cmpl	%eax, %edx
	jl	.L9
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
.L8:
	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	"first"
.LC1:
	.string	"second"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	subq	$8, %rsp
	.cfi_def_cfa_offset 16
	movq	stdin(%rip), %rdi
	call	getc@PLT
	movb	%al, c(%rip)
	cmpb	$10, %al
	je	.L2
	movsbl	%al, %edx
	.p2align 4,,10
	.p2align 3
.L3:
	movl	N(%rip), %eax
	movq	stdin(%rip), %rdi
	leal	(%rax,%rax,4), %eax
	leal	-48(%rdx,%rax,2), %eax
	movl	%eax, N(%rip)
	call	getc@PLT
	movb	%al, c(%rip)
	movsbl	%al, %edx
	cmpb	$10, %al
	jne	.L3
.L2:
	movl	$0, i(%rip)
	movl	N(%rip), %eax
	testl	%eax, %eax
	jg	.L9
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L15:
	movl	%edx, A(%rip)
.L9:
	movq	stdin(%rip), %rdi
	call	getc@PLT
	movb	%al, c(%rip)
	movsbl	%al, %edx
	cmpb	$10, %al
	jne	.L15
	testb	$1, A(%rip)
	jne	.L16
	movl	i(%rip), %eax
	addl	$1, %eax
	cmpl	N(%rip), %eax
	movl	%eax, i(%rip)
	jl	.L9
.L4:
	leaq	.LC1(%rip), %rdi
	call	puts@PLT
.L8:
	xorl	%eax, %eax
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
.L16:
	.cfi_restore_state
	leaq	.LC0(%rip), %rdi
	call	puts@PLT
	jmp	.L8
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	i
	.bss
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	A
	.align 4
	.type	A, @object
	.size	A, 4
A:
	.zero	4
	.globl	N
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.globl	c
	.type	c, @object
	.size	c, 1
c:
	.zero	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
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"first"
.LC1:
	.string	"second"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	subq	$8, %rsp
	.cfi_def_cfa_offset 16
	movq	stdin(%rip), %rdi
	call	getc@PLT
	movb	%al, c(%rip)
	cmpb	$10, %al
	je	.L2
	movsbl	%al, %edx
	.p2align 4,,10
	.p2align 3
.L3:
	movl	N(%rip), %eax
	movq	stdin(%rip), %rdi
	leal	(%rax,%rax,4), %eax
	leal	-48(%rdx,%rax,2), %eax
	movl	%eax, N(%rip)
	call	getc@PLT
	movb	%al, c(%rip)
	movsbl	%al, %edx
	cmpb	$10, %al
	jne	.L3
.L2:
	movl	$0, i(%rip)
	movl	N(%rip), %eax
	testl	%eax, %eax
	jg	.L9
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L15:
	movl	%edx, A(%rip)
.L9:
	movq	stdin(%rip), %rdi
	call	getc@PLT
	movb	%al, c(%rip)
	movsbl	%al, %edx
	cmpb	$10, %al
	jne	.L15
	testb	$1, A(%rip)
	jne	.L16
	movl	i(%rip), %eax
	addl	$1, %eax
	cmpl	N(%rip), %eax
	movl	%eax, i(%rip)
	jl	.L9
.L4:
	leaq	.LC1(%rip), %rdi
	call	puts@PLT
.L8:
	xorl	%eax, %eax
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
.L16:
	.cfi_restore_state
	leaq	.LC0(%rip), %rdi
	call	puts@PLT
	jmp	.L8
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	i
	.bss
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	A
	.align 4
	.type	A, @object
	.size	A, 4
A:
	.zero	4
	.globl	N
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.globl	c
	.type	c, @object
	.size	c, 1
c:
	.zero	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>
char c;
int N, A, i;
int main(void){
	c=getchar();
	while(c!=10){N=N*10+(c-'0'); c=getchar();}
	for(i=0; i<N; i++){
		c=getchar();
		while(c!=10){A=c; c=getchar();}
		if(A&1){
			printf("first\n");
			return 0;
		}
	}
	printf("second\n");
	return 0;
}

2
1
2

first

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>
char c;
int N, A, i;
int main(void){
	c=getchar();
	while(c!=10){N=N*10+(c-'0'); c=getchar();}
	for(i=0; i<N; i++){
		c=getchar();
		while(c!=10){A=c; c=getchar();}
		if(A&1){
			printf("first\n");
			return 0;
		}
	}
	printf("second\n");
	return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	c
	.bss
	.type	c, @object
	.size	c, 1
c:
	.zero	1
	.globl	N
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.globl	A
	.align 4
	.type	A, @object
	.size	A, 4
A:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.section	.rodata
.LC0:
	.string	"first"
.LC1:
	.string	"second"
	.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
	call	getchar@PLT
	movb	%al, c(%rip)
	jmp	.L2
.L3:
	movl	N(%rip), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %edx
	movzbl	c(%rip), %eax
	movsbl	%al, %eax
	subl	$48, %eax
	addl	%edx, %eax
	movl	%eax, N(%rip)
	call	getchar@PLT
	movb	%al, c(%rip)
.L2:
	movzbl	c(%rip), %eax
	cmpb	$10, %al
	jne	.L3
	movl	$0, i(%rip)
	jmp	.L4
.L9:
	call	getchar@PLT
	movb	%al, c(%rip)
	jmp	.L5
.L6:
	movzbl	c(%rip), %eax
	movsbl	%al, %eax
	movl	%eax, A(%rip)
	call	getchar@PLT
	movb	%al, c(%rip)
.L5:
	movzbl	c(%rip), %eax
	cmpb	$10, %al
	jne	.L6
	movl	A(%rip), %eax
	andl	$1, %eax
	testl	%eax, %eax
	je	.L7
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
	jmp	.L8
.L7:
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L4:
	movl	i(%rip), %edx
	movl	N(%rip), %eax
	cmpl	%eax, %edx
	jl	.L9
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
.L8:
	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.
val
	.file	"temp.c"
	.text
	.globl	c
	.bss
	.type	c, @object
	.size	c, 1
c:
	.zero	1
	.globl	N
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.globl	A
	.align 4
	.type	A, @object
	.size	A, 4
A:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.section	.rodata
.LC0:
	.string	"first"
.LC1:
	.string	"second"
	.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
	call	getchar@PLT
	movb	%al, c(%rip)
	jmp	.L2
.L3:
	movl	N(%rip), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %edx
	movzbl	c(%rip), %eax
	movsbl	%al, %eax
	subl	$48, %eax
	addl	%edx, %eax
	movl	%eax, N(%rip)
	call	getchar@PLT
	movb	%al, c(%rip)
.L2:
	movzbl	c(%rip), %eax
	cmpb	$10, %al
	jne	.L3
	movl	$0, i(%rip)
	jmp	.L4
.L9:
	call	getchar@PLT
	movb	%al, c(%rip)
	jmp	.L5
.L6:
	movzbl	c(%rip), %eax
	movsbl	%al, %eax
	movl	%eax, A(%rip)
	call	getchar@PLT
	movb	%al, c(%rip)
.L5:
	movzbl	c(%rip), %eax
	cmpb	$10, %al
	jne	.L6
	movl	A(%rip), %eax
	andl	$1, %eax
	testl	%eax, %eax
	je	.L7
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
	jmp	.L8
.L7:
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L4:
	movl	i(%rip), %edx
	movl	N(%rip), %eax
	cmpl	%eax, %edx
	jl	.L9
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
.L8:
	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:
