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>
#define ll long long
ll max(ll a, ll b){
	if(a>b)return a;
	else return b;
}

int main(void){
	int N;
	int H[100001][3];
	int i;

	scanf("%d",&N);
	for(i=0; i<N; i++)scanf("%d %d %d",&H[i][0],&H[i][1],&H[i][2]);

	long long dp[100001][3];
	dp[0][0]=0;
	dp[0][1]=0;
	dp[0][2]=0;
	for(i=1; i<=N; i++){
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+H[i-1][0];
		dp[i][1]=max(dp[i-1][2],dp[i-1][0])+H[i-1][1];
		dp[i][2]=max(dp[i-1][0],dp[i-1][1])+H[i-1][2];
	}
	printf("%lld\n",max(dp[N][0],max(dp[N][1],dp[N][2])) );
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	max
	.type	max, @function
max:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	cmpq	-16(%rbp), %rax
	jle	.L2
	movq	-8(%rbp), %rax
	jmp	.L3
.L2:
	movq	-16(%rbp), %rax
.L3:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	max, .-max
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d %d"
.LC2:
	.string	"%lld\n"
	.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
	leaq	-3596288(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$3776, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-3600056(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -3600052(%rbp)
	jmp	.L5
.L6:
	leaq	-3600048(%rbp), %rcx
	movl	-3600052(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	$8, %rax
	addq	%rax, %rcx
	leaq	-3600048(%rbp), %rsi
	movl	-3600052(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	$4, %rax
	leaq	(%rsi,%rax), %rdx
	leaq	-3600048(%rbp), %rdi
	movl	-3600052(%rbp), %eax
	movslq	%eax, %rsi
	movq	%rsi, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	salq	$2, %rax
	addq	%rdi, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -3600052(%rbp)
.L5:
	movl	-3600056(%rbp), %eax
	cmpl	%eax, -3600052(%rbp)
	jl	.L6
	movq	$0, -2400032(%rbp)
	movq	$0, -2400024(%rbp)
	movq	$0, -2400016(%rbp)
	movl	$1, -3600052(%rbp)
	jmp	.L7
.L8:
	movl	-3600052(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rbp, %rax
	subq	$2400016, %rax
	movq	(%rax), %rdx
	movl	-3600052(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	salq	$3, %rax
	addq	%rbp, %rax
	subq	$2400024, %rax
	movq	(%rax), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	max
	movq	%rax, %rcx
	movl	-3600052(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rbp, %rax
	subq	$3600048, %rax
	movl	(%rax), %eax
	cltq
	addq	%rax, %rcx
	movl	-3600052(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rbp, %rax
	subq	$2400032, %rax
	movq	%rcx, (%rax)
	movl	-3600052(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rbp, %rax
	subq	$2400032, %rax
	movq	(%rax), %rdx
	movl	-3600052(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	salq	$3, %rax
	addq	%rbp, %rax
	subq	$2400016, %rax
	movq	(%rax), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	max
	movq	%rax, %rcx
	movl	-3600052(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rbp, %rax
	subq	$3600044, %rax
	movl	(%rax), %eax
	cltq
	addq	%rax, %rcx
	movl	-3600052(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rbp, %rax
	subq	$2400024, %rax
	movq	%rcx, (%rax)
	movl	-3600052(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rbp, %rax
	subq	$2400024, %rax
	movq	(%rax), %rdx
	movl	-3600052(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	salq	$3, %rax
	addq	%rbp, %rax
	subq	$2400032, %rax
	movq	(%rax), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	max
	movq	%rax, %rcx
	movl	-3600052(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rbp, %rax
	subq	$3600040, %rax
	movl	(%rax), %eax
	cltq
	addq	%rax, %rcx
	movl	-3600052(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rbp, %rax
	subq	$2400016, %rax
	movq	%rcx, (%rax)
	addl	$1, -3600052(%rbp)
.L7:
	movl	-3600056(%rbp), %eax
	cmpl	%eax, -3600052(%rbp)
	jle	.L8
	movl	-3600056(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rbp, %rax
	subq	$2400016, %rax
	movq	(%rax), %rdx
	movl	-3600056(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	salq	$3, %rax
	addq	%rbp, %rax
	subq	$2400024, %rax
	movq	(%rax), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	max
	movq	%rax, %rcx
	movl	-3600056(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rbp, %rax
	subq	$2400032, %rax
	movq	(%rax), %rax
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	max
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L10
	call	__stack_chk_fail@PLT
.L10:
	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	max
	.type	max, @function
max:
.LFB23:
	.cfi_startproc
	endbr64
	cmpq	%rsi, %rdi
	movq	%rsi, %rax
	cmovge	%rdi, %rax
	ret
	.cfi_endproc
.LFE23:
	.size	max, .-max
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d %d"
.LC2:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	leaq	-3596288(%rsp), %r11
	.cfi_def_cfa 11, 3596336
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$3776, %rsp
	.cfi_def_cfa_offset 3600112
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 3600056(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movslq	12(%rsp), %r8
	testl	%r8d, %r8d
	jle	.L4
	leaq	16(%rsp), %r12
	xorl	%ebp, %ebp
	leaq	.LC1(%rip), %r14
	movq	%r12, %r13
	movq	%r12, %rbx
	.p2align 4,,10
	.p2align 3
.L5:
	leaq	8(%rbx), %rcx
	leaq	4(%rbx), %rdx
	movq	%rbx, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addl	$1, %ebp
	addq	$12, %rbx
	call	__isoc99_scanf@PLT
	movslq	12(%rsp), %r8
	cmpl	%ebp, %r8d
	jg	.L5
	movq	$0, 1200048(%rsp)
	pxor	%xmm0, %xmm0
	movaps	%xmm0, 1200032(%rsp)
	testl	%r8d, %r8d
	jle	.L6
	cmpl	$2, %r8d
	jle	.L11
	leal	-3(%r8), %r10d
	leaq	1200056(%rsp), %rdi
	xorl	%edx, %edx
	xorl	%eax, %eax
	andl	$-2, %r10d
	xorl	%esi, %esi
	movl	$1, %r9d
	addl	$3, %r10d
.L8:
	cmpq	%rax, %rdx
	movq	%rax, %rcx
	movslq	0(%r13), %r11
	cmovge	%rdx, %rcx
	addq	%r11, %rcx
	cmpq	%rsi, %rdx
	movslq	4(%r13), %r11
	cmovl	%rsi, %rdx
	movq	%rcx, (%rdi)
	addq	%rdx, %r11
	cmpq	%rsi, %rax
	movslq	8(%r13), %rdx
	cmovl	%rsi, %rax
	movslq	12(%r13), %rsi
	movq	%r11, 8(%rdi)
	addq	%rdx, %rax
	cmpq	%rax, %r11
	movq	%rax, %rdx
	movq	%rax, 16(%rdi)
	cmovge	%r11, %rdx
	addq	%rdx, %rsi
	cmpq	%rax, %rcx
	movslq	16(%r13), %rdx
	cmovge	%rcx, %rax
	movq	%rsi, 24(%rdi)
	addq	%rdx, %rax
	cmpq	%r11, %rcx
	movslq	20(%r13), %rdx
	cmovl	%r11, %rcx
	addl	$2, %r9d
	movq	%rax, 32(%rdi)
	addq	$24, %r13
	addq	$48, %rdi
	addq	%rcx, %rdx
	movq	%rdx, -8(%rdi)
	cmpl	%r10d, %r9d
	jne	.L8
.L7:
	movslq	%r10d, %rdx
	imulq	$24, %rdx, %rax
	imulq	$12, %rdx, %rdx
	leaq	1200032(%rsp,%rax), %rax
	leaq	(%r12,%rdx), %rsi
	.p2align 4,,10
	.p2align 3
.L9:
	movq	-8(%rax), %rcx
	movq	-16(%rax), %rdi
	movslq	-12(%rsi), %rdx
	cmpq	%rcx, %rdi
	movq	%rcx, %r9
	cmovge	%rdi, %r9
	addq	%r9, %rdx
	movslq	-8(%rsi), %r9
	movq	%rdx, (%rax)
	movq	-24(%rax), %rdx
	cmpq	%rcx, %rdx
	cmovge	%rdx, %rcx
	addq	%r9, %rcx
	cmpq	%rdi, %rdx
	cmovl	%rdi, %rdx
	movq	%rcx, 8(%rax)
	movslq	-4(%rsi), %rcx
	addl	$1, %r10d
	addq	$24, %rax
	addq	$12, %rsi
	addq	%rcx, %rdx
	movq	%rdx, -8(%rax)
	cmpl	%r10d, %r8d
	jge	.L9
.L6:
	leaq	(%r8,%r8,2), %rax
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	salq	$3, %rax
	movq	1200048(%rsp,%rax), %rdx
	movq	1200040(%rsp,%rax), %rcx
	movq	1200032(%rsp,%rax), %rax
	cmpq	%rcx, %rdx
	cmovl	%rcx, %rdx
	cmpq	%rax, %rdx
	cmovl	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	3600056(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L17
	addq	$3600064, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
.L4:
	.cfi_restore_state
	movq	$0, 1200048(%rsp)
	pxor	%xmm0, %xmm0
	movaps	%xmm0, 1200032(%rsp)
	jmp	.L6
.L11:
	movl	$1, %r10d
	jmp	.L7
.L17:
	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	max
	.type	max, @function
max:
.LFB23:
	.cfi_startproc
	endbr64
	cmpq	%rsi, %rdi
	movq	%rsi, %rax
	cmovge	%rdi, %rax
	ret
	.cfi_endproc
.LFE23:
	.size	max, .-max
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d %d"
.LC2:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	leaq	-3596288(%rsp), %r11
	.cfi_def_cfa 11, 3596336
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$3776, %rsp
	.cfi_def_cfa_offset 3600112
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 3600056(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movslq	12(%rsp), %r8
	testl	%r8d, %r8d
	jle	.L4
	leaq	16(%rsp), %r12
	xorl	%ebp, %ebp
	leaq	.LC1(%rip), %r14
	movq	%r12, %r13
	movq	%r12, %rbx
	.p2align 4,,10
	.p2align 3
.L5:
	leaq	8(%rbx), %rcx
	leaq	4(%rbx), %rdx
	movq	%rbx, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addl	$1, %ebp
	addq	$12, %rbx
	call	__isoc99_scanf@PLT
	movslq	12(%rsp), %r8
	cmpl	%ebp, %r8d
	jg	.L5
	movq	$0, 1200048(%rsp)
	pxor	%xmm0, %xmm0
	movaps	%xmm0, 1200032(%rsp)
	testl	%r8d, %r8d
	jle	.L6
	cmpl	$2, %r8d
	jle	.L11
	leal	-3(%r8), %r10d
	leaq	1200056(%rsp), %rdi
	xorl	%edx, %edx
	xorl	%eax, %eax
	andl	$-2, %r10d
	xorl	%esi, %esi
	movl	$1, %r9d
	addl	$3, %r10d
.L8:
	cmpq	%rax, %rdx
	movq	%rax, %rcx
	movslq	0(%r13), %r11
	cmovge	%rdx, %rcx
	addq	%r11, %rcx
	cmpq	%rsi, %rdx
	movslq	4(%r13), %r11
	cmovl	%rsi, %rdx
	movq	%rcx, (%rdi)
	addq	%rdx, %r11
	cmpq	%rsi, %rax
	movslq	8(%r13), %rdx
	cmovl	%rsi, %rax
	movslq	12(%r13), %rsi
	movq	%r11, 8(%rdi)
	addq	%rdx, %rax
	cmpq	%rax, %r11
	movq	%rax, %rdx
	movq	%rax, 16(%rdi)
	cmovge	%r11, %rdx
	addq	%rdx, %rsi
	cmpq	%rax, %rcx
	movslq	16(%r13), %rdx
	cmovge	%rcx, %rax
	movq	%rsi, 24(%rdi)
	addq	%rdx, %rax
	cmpq	%r11, %rcx
	movslq	20(%r13), %rdx
	cmovl	%r11, %rcx
	addl	$2, %r9d
	movq	%rax, 32(%rdi)
	addq	$24, %r13
	addq	$48, %rdi
	addq	%rcx, %rdx
	movq	%rdx, -8(%rdi)
	cmpl	%r10d, %r9d
	jne	.L8
.L7:
	movslq	%r10d, %rdx
	imulq	$24, %rdx, %rax
	imulq	$12, %rdx, %rdx
	leaq	1200032(%rsp,%rax), %rax
	leaq	(%r12,%rdx), %rsi
	.p2align 4,,10
	.p2align 3
.L9:
	movq	-8(%rax), %rcx
	movq	-16(%rax), %rdi
	movslq	-12(%rsi), %rdx
	cmpq	%rcx, %rdi
	movq	%rcx, %r9
	cmovge	%rdi, %r9
	addq	%r9, %rdx
	movslq	-8(%rsi), %r9
	movq	%rdx, (%rax)
	movq	-24(%rax), %rdx
	cmpq	%rcx, %rdx
	cmovge	%rdx, %rcx
	addq	%r9, %rcx
	cmpq	%rdi, %rdx
	cmovl	%rdi, %rdx
	movq	%rcx, 8(%rax)
	movslq	-4(%rsi), %rcx
	addl	$1, %r10d
	addq	$24, %rax
	addq	$12, %rsi
	addq	%rcx, %rdx
	movq	%rdx, -8(%rax)
	cmpl	%r10d, %r8d
	jge	.L9
.L6:
	leaq	(%r8,%r8,2), %rax
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	salq	$3, %rax
	movq	1200048(%rsp,%rax), %rdx
	movq	1200040(%rsp,%rax), %rcx
	movq	1200032(%rsp,%rax), %rax
	cmpq	%rcx, %rdx
	cmovl	%rcx, %rdx
	cmpq	%rax, %rdx
	cmovl	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	3600056(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L17
	addq	$3600064, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
.L4:
	.cfi_restore_state
	movq	$0, 1200048(%rsp)
	pxor	%xmm0, %xmm0
	movaps	%xmm0, 1200032(%rsp)
	jmp	.L6
.L11:
	movl	$1, %r10d
	jmp	.L7
.L17:
	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>
#define ll long long
ll max(ll a, ll b){
	if(a>b)return a;
	else return b;
}

int main(void){
	int N;
	int H[100001][3];
	int i;

	scanf("%d",&N);
	for(i=0; i<N; i++)scanf("%d %d %d",&H[i][0],&H[i][1],&H[i][2]);

	long long dp[100001][3];
	dp[0][0]=0;
	dp[0][1]=0;
	dp[0][2]=0;
	for(i=1; i<=N; i++){
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+H[i-1][0];
		dp[i][1]=max(dp[i-1][2],dp[i-1][0])+H[i-1][1];
		dp[i][2]=max(dp[i-1][0],dp[i-1][1])+H[i-1][2];
	}
	printf("%lld\n",max(dp[N][0],max(dp[N][1],dp[N][2])) );
}

3
1 40 70
20 50 80
30 60 90
 1
100 16 1
 7
6 7 8
8 8 3
2 5 2
7 8 6
4 6 8
2 3 4
7 7 1
 1
000 16 1
 7
6 7 14
8 8 3
2 5 2
7 8 6
4 6 8
2 3 4
7 7 1
 3
1 40 34
20 50 80
30 35 90
 3
1 76 34
20 50 80
30 35 90
 1
000 25 2
 7
5 7 14
7 8 3
2 5 2
7 8 6
4 6 8
2 3 4
7 7 1
 3
0 94 34
20 50 80
30 35 90

210
 100
 46
 16
 52
 174
 191
 25
 51
 209

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>
#define ll long long
ll max(ll a, ll b){
	if(a>b)return a;
	else return b;
}

int main(void){
	int N;
	int H[100001][3];
	int i;

	scanf("%d",&N);
	for(i=0; i<N; i++)scanf("%d %d %d",&H[i][0],&H[i][1],&H[i][2]);

	long long dp[100001][3];
	dp[0][0]=0;
	dp[0][1]=0;
	dp[0][2]=0;
	for(i=1; i<=N; i++){
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+H[i-1][0];
		dp[i][1]=max(dp[i-1][2],dp[i-1][0])+H[i-1][1];
		dp[i][2]=max(dp[i-1][0],dp[i-1][1])+H[i-1][2];
	}
	printf("%lld\n",max(dp[N][0],max(dp[N][1],dp[N][2])) );
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	max
	.type	max, @function
max:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	cmpq	-16(%rbp), %rax
	jle	.L2
	movq	-8(%rbp), %rax
	jmp	.L3
.L2:
	movq	-16(%rbp), %rax
.L3:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	max, .-max
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d %d"
.LC2:
	.string	"%lld\n"
	.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
	leaq	-3596288(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$3776, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-3600056(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -3600052(%rbp)
	jmp	.L5
.L6:
	leaq	-3600048(%rbp), %rcx
	movl	-3600052(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	$8, %rax
	addq	%rax, %rcx
	leaq	-3600048(%rbp), %rsi
	movl	-3600052(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	$4, %rax
	leaq	(%rsi,%rax), %rdx
	leaq	-3600048(%rbp), %rdi
	movl	-3600052(%rbp), %eax
	movslq	%eax, %rsi
	movq	%rsi, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	salq	$2, %rax
	addq	%rdi, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -3600052(%rbp)
.L5:
	movl	-3600056(%rbp), %eax
	cmpl	%eax, -3600052(%rbp)
	jl	.L6
	movq	$0, -2400032(%rbp)
	movq	$0, -2400024(%rbp)
	movq	$0, -2400016(%rbp)
	movl	$1, -3600052(%rbp)
	jmp	.L7
.L8:
	movl	-3600052(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rbp, %rax
	subq	$2400016, %rax
	movq	(%rax), %rdx
	movl	-3600052(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	salq	$3, %rax
	addq	%rbp, %rax
	subq	$2400024, %rax
	movq	(%rax), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	max
	movq	%rax, %rcx
	movl	-3600052(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rbp, %rax
	subq	$3600048, %rax
	movl	(%rax), %eax
	cltq
	addq	%rax, %rcx
	movl	-3600052(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rbp, %rax
	subq	$2400032, %rax
	movq	%rcx, (%rax)
	movl	-3600052(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rbp, %rax
	subq	$2400032, %rax
	movq	(%rax), %rdx
	movl	-3600052(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	salq	$3, %rax
	addq	%rbp, %rax
	subq	$2400016, %rax
	movq	(%rax), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	max
	movq	%rax, %rcx
	movl	-3600052(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rbp, %rax
	subq	$3600044, %rax
	movl	(%rax), %eax
	cltq
	addq	%rax, %rcx
	movl	-3600052(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rbp, %rax
	subq	$2400024, %rax
	movq	%rcx, (%rax)
	movl	-3600052(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rbp, %rax
	subq	$2400024, %rax
	movq	(%rax), %rdx
	movl	-3600052(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	salq	$3, %rax
	addq	%rbp, %rax
	subq	$2400032, %rax
	movq	(%rax), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	max
	movq	%rax, %rcx
	movl	-3600052(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rbp, %rax
	subq	$3600040, %rax
	movl	(%rax), %eax
	cltq
	addq	%rax, %rcx
	movl	-3600052(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rbp, %rax
	subq	$2400016, %rax
	movq	%rcx, (%rax)
	addl	$1, -3600052(%rbp)
.L7:
	movl	-3600056(%rbp), %eax
	cmpl	%eax, -3600052(%rbp)
	jle	.L8
	movl	-3600056(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rbp, %rax
	subq	$2400016, %rax
	movq	(%rax), %rdx
	movl	-3600056(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	salq	$3, %rax
	addq	%rbp, %rax
	subq	$2400024, %rax
	movq	(%rax), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	max
	movq	%rax, %rcx
	movl	-3600056(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rbp, %rax
	subq	$2400032, %rax
	movq	(%rax), %rax
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	max
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L10
	call	__stack_chk_fail@PLT
.L10:
	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	max
	.type	max, @function
max:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	cmpq	-16(%rbp), %rax
	jle	.L2
	movq	-8(%rbp), %rax
	jmp	.L3
.L2:
	movq	-16(%rbp), %rax
.L3:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	max, .-max
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d %d"
.LC2:
	.string	"%lld\n"
	.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
	leaq	-3596288(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$3776, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-3600056(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -3600052(%rbp)
	jmp	.L5
.L6:
	leaq	-3600048(%rbp), %rcx
	movl	-3600052(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	$8, %rax
	addq	%rax, %rcx
	leaq	-3600048(%rbp), %rsi
	movl	-3600052(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	$4, %rax
	leaq	(%rsi,%rax), %rdx
	leaq	-3600048(%rbp), %rdi
	movl	-3600052(%rbp), %eax
	movslq	%eax, %rsi
	movq	%rsi, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	salq	$2, %rax
	addq	%rdi, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -3600052(%rbp)
.L5:
	movl	-3600056(%rbp), %eax
	cmpl	%eax, -3600052(%rbp)
	jl	.L6
	movq	$0, -2400032(%rbp)
	movq	$0, -2400024(%rbp)
	movq	$0, -2400016(%rbp)
	movl	$1, -3600052(%rbp)
	jmp	.L7
.L8:
	movl	-3600052(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rbp, %rax
	subq	$2400016, %rax
	movq	(%rax), %rdx
	movl	-3600052(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	salq	$3, %rax
	addq	%rbp, %rax
	subq	$2400024, %rax
	movq	(%rax), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	max
	movq	%rax, %rcx
	movl	-3600052(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rbp, %rax
	subq	$3600048, %rax
	movl	(%rax), %eax
	cltq
	addq	%rax, %rcx
	movl	-3600052(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rbp, %rax
	subq	$2400032, %rax
	movq	%rcx, (%rax)
	movl	-3600052(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rbp, %rax
	subq	$2400032, %rax
	movq	(%rax), %rdx
	movl	-3600052(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	salq	$3, %rax
	addq	%rbp, %rax
	subq	$2400016, %rax
	movq	(%rax), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	max
	movq	%rax, %rcx
	movl	-3600052(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rbp, %rax
	subq	$3600044, %rax
	movl	(%rax), %eax
	cltq
	addq	%rax, %rcx
	movl	-3600052(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rbp, %rax
	subq	$2400024, %rax
	movq	%rcx, (%rax)
	movl	-3600052(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rbp, %rax
	subq	$2400024, %rax
	movq	(%rax), %rdx
	movl	-3600052(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	salq	$3, %rax
	addq	%rbp, %rax
	subq	$2400032, %rax
	movq	(%rax), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	max
	movq	%rax, %rcx
	movl	-3600052(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rbp, %rax
	subq	$3600040, %rax
	movl	(%rax), %eax
	cltq
	addq	%rax, %rcx
	movl	-3600052(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rbp, %rax
	subq	$2400016, %rax
	movq	%rcx, (%rax)
	addl	$1, -3600052(%rbp)
.L7:
	movl	-3600056(%rbp), %eax
	cmpl	%eax, -3600052(%rbp)
	jle	.L8
	movl	-3600056(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rbp, %rax
	subq	$2400016, %rax
	movq	(%rax), %rdx
	movl	-3600056(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	salq	$3, %rax
	addq	%rbp, %rax
	subq	$2400024, %rax
	movq	(%rax), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	max
	movq	%rax, %rcx
	movl	-3600056(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rbp, %rax
	subq	$2400032, %rax
	movq	(%rax), %rax
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	max
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L10
	call	__stack_chk_fail@PLT
.L10:
	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:
