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>
#include<stdlib.h>
#include<math.h>
#include<string.h>
long long max(long long a,long long b){
    if(a>b){
        return a;
    }else{
        return b;
    }
}
int main()
{
    long long n,x;
    scanf("%lld %lld",&n,&x);
    long long counter=0;
    long long len1,len2,val;
    counter+=n;
    len1=n-max(x,n-x);
    len2=max(x,n-x);
    while(1)
    {if(len2%len1== 0)
    {counter +=(len2/len1)*2*len1 - len1;
    break;}
    else
    {counter+=(len2/len1)*2*len1;
    val=len1;
    len1=len2-(len2/len1)*len1;
    len2=val;}}
    printf("%lld\n",counter);
    return 0;
}
```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.p2align 4
	.globl	max
	.type	max, @function
max:
.LFB51:
	.cfi_startproc
	endbr64
	cmpq	%rsi, %rdi
	movq	%rsi, %rax
	cmovge	%rdi, %rax
	ret
	.cfi_endproc
.LFE51:
	.size	max, .-max
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%lld %lld"
.LC1:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB52:
	.cfi_startproc
	endbr64
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rdx
	leaq	8(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movq	8(%rsp), %r8
	movq	16(%rsp), %rax
	movq	%r8, %rsi
	movq	%r8, %rcx
	subq	%rax, %rsi
	cmpq	%rax, %rsi
	cmovl	%rax, %rsi
	movq	%rsi, %rax
	subq	%rsi, %rcx
	cqto
	idivq	%rcx
	movq	%rdx, %rdi
	testq	%rdx, %rdx
	jne	.L4
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L15:
	movq	%rdi, %rcx
	movq	%rdx, %rdi
.L4:
	movq	%rsi, %rax
	movq	%rcx, %rsi
	cqto
	idivq	%rcx
	imulq	%rcx, %rax
	leaq	(%r8,%rax,2), %r8
	movq	%rcx, %rax
	cqto
	idivq	%rdi
	testq	%rdx, %rdx
	jne	.L15
.L5:
	movq	%rcx, %rax
	leaq	.LC1(%rip), %rsi
	cqto
	idivq	%rdi
	imulq	%rdi, %rax
	leaq	(%r8,%rax,2), %rdx
	xorl	%eax, %eax
	subq	%rdi, %rdx
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L16
	xorl	%eax, %eax
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
.L14:
	.cfi_restore_state
	movq	%rcx, %rdi
	movq	%rsi, %rcx
	jmp	.L5
.L16:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE52:
	.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
	.p2align 4
	.globl	max
	.type	max, @function
max:
.LFB51:
	.cfi_startproc
	endbr64
	cmpq	%rsi, %rdi
	movq	%rsi, %rax
	cmovge	%rdi, %rax
	ret
	.cfi_endproc
.LFE51:
	.size	max, .-max
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%lld %lld"
.LC1:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB52:
	.cfi_startproc
	endbr64
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rdx
	leaq	8(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movq	8(%rsp), %r8
	movq	16(%rsp), %rax
	movq	%r8, %rsi
	movq	%r8, %rcx
	subq	%rax, %rsi
	cmpq	%rax, %rsi
	cmovl	%rax, %rsi
	movq	%rsi, %rax
	subq	%rsi, %rcx
	cqto
	idivq	%rcx
	movq	%rdx, %rdi
	testq	%rdx, %rdx
	jne	.L4
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L15:
	movq	%rdi, %rcx
	movq	%rdx, %rdi
.L4:
	movq	%rsi, %rax
	movq	%rcx, %rsi
	cqto
	idivq	%rcx
	imulq	%rcx, %rax
	leaq	(%r8,%rax,2), %r8
	movq	%rcx, %rax
	cqto
	idivq	%rdi
	testq	%rdx, %rdx
	jne	.L15
.L5:
	movq	%rcx, %rax
	leaq	.LC1(%rip), %rsi
	cqto
	idivq	%rdi
	imulq	%rdi, %rax
	leaq	(%r8,%rax,2), %rdx
	xorl	%eax, %eax
	subq	%rdi, %rdx
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L16
	xorl	%eax, %eax
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
.L14:
	.cfi_restore_state
	movq	%rcx, %rdi
	movq	%rsi, %rcx
	jmp	.L5
.L16:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE52:
	.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
	.p2align 4
	.globl	max
	.type	max, @function
max:
.LFB51:
	.cfi_startproc
	endbr64
	cmpq	%rsi, %rdi
	movq	%rsi, %rax
	cmovge	%rdi, %rax
	ret
	.cfi_endproc
.LFE51:
	.size	max, .-max
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%lld %lld"
.LC1:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB52:
	.cfi_startproc
	endbr64
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rdx
	leaq	8(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movq	8(%rsp), %r8
	movq	16(%rsp), %rax
	movq	%r8, %rsi
	movq	%r8, %rcx
	subq	%rax, %rsi
	cmpq	%rax, %rsi
	cmovl	%rax, %rsi
	movq	%rsi, %rax
	subq	%rsi, %rcx
	cqto
	idivq	%rcx
	movq	%rdx, %rdi
	testq	%rdx, %rdx
	jne	.L4
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L15:
	movq	%rdi, %rcx
	movq	%rdx, %rdi
.L4:
	movq	%rsi, %rax
	movq	%rcx, %rsi
	cqto
	idivq	%rcx
	imulq	%rcx, %rax
	leaq	(%r8,%rax,2), %r8
	movq	%rcx, %rax
	cqto
	idivq	%rdi
	testq	%rdx, %rdx
	jne	.L15
.L5:
	movq	%rcx, %rax
	leaq	.LC1(%rip), %rsi
	cqto
	idivq	%rdi
	imulq	%rdi, %rax
	leaq	(%r8,%rax,2), %rdx
	xorl	%eax, %eax
	subq	%rdi, %rdx
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L16
	xorl	%eax, %eax
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
.L14:
	.cfi_restore_state
	movq	%rcx, %rdi
	movq	%rsi, %rcx
	jmp	.L5
.L16:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE52:
	.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>
#include<stdlib.h>
#include<math.h>
#include<string.h>
long long max(long long a,long long b){
    if(a>b){
        return a;
    }else{
        return b;
    }
}
int main()
{
    long long n,x;
    scanf("%lld %lld",&n,&x);
    long long counter=0;
    long long len1,len2,val;
    counter+=n;
    len1=n-max(x,n-x);
    len2=max(x,n-x);
    while(1)
    {if(len2%len1== 0)
    {counter +=(len2/len1)*2*len1 - len1;
    break;}
    else
    {counter+=(len2/len1)*2*len1;
    val=len1;
    len1=len2-(len2/len1)*len1;
    len2=val;}}
    printf("%lld\n",counter);
    return 0;
}
```
Given the following C code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
long long max(long long a,long long b){
    if(a>b){
        return a;
    }else{
        return b;
    }
}
int main()
{
    long long n,x;
    scanf("%lld %lld",&n,&x);
    long long counter=0;
    long long len1,len2,val;
    counter+=n;
    len1=n-max(x,n-x);
    len2=max(x,n-x);
    while(1)
    {if(len2%len1== 0)
    {counter +=(len2/len1)*2*len1 - len1;
    break;}
    else
    {counter+=(len2/len1)*2*len1;
    val=len1;
    len1=len2-(len2/len1)*len1;
    len2=val;}}
    printf("%lld\n",counter);
    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:

5 4
 7 4
 6 1
 9 4
 6 3
 14 4
 8 1
 28 4
 15 2
 28 3

12
 18
 15
 24
 9
 36
 21
 72
 42
 81

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>
#include<stdlib.h>
#include<math.h>
#include<string.h>
long long max(long long a,long long b){
    if(a>b){
        return a;
    }else{
        return b;
    }
}
int main()
{
    long long n,x;
    scanf("%lld %lld",&n,&x);
    long long counter=0;
    long long len1,len2,val;
    counter+=n;
    len1=n-max(x,n-x);
    len2=max(x,n-x);
    while(1)
    {if(len2%len1== 0)
    {counter +=(len2/len1)*2*len1 - len1;
    break;}
    else
    {counter+=(len2/len1)*2*len1;
    val=len1;
    len1=len2-(len2/len1)*len1;
    len2=val;}}
    printf("%lld\n",counter);
    return 0;
}
```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.p2align 4
	.globl	max
	.type	max, @function
max:
.LFB51:
	.cfi_startproc
	endbr64
	cmpq	%rsi, %rdi
	movq	%rsi, %rax
	cmovge	%rdi, %rax
	ret
	.cfi_endproc
.LFE51:
	.size	max, .-max
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%lld %lld"
.LC1:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB52:
	.cfi_startproc
	endbr64
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rdx
	leaq	8(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movq	8(%rsp), %r8
	movq	16(%rsp), %rax
	movq	%r8, %rsi
	movq	%r8, %rcx
	subq	%rax, %rsi
	cmpq	%rax, %rsi
	cmovl	%rax, %rsi
	movq	%rsi, %rax
	subq	%rsi, %rcx
	cqto
	idivq	%rcx
	movq	%rdx, %rdi
	testq	%rdx, %rdx
	jne	.L4
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L15:
	movq	%rdi, %rcx
	movq	%rdx, %rdi
.L4:
	movq	%rsi, %rax
	movq	%rcx, %rsi
	cqto
	idivq	%rcx
	imulq	%rcx, %rax
	leaq	(%r8,%rax,2), %r8
	movq	%rcx, %rax
	cqto
	idivq	%rdi
	testq	%rdx, %rdx
	jne	.L15
.L5:
	movq	%rcx, %rax
	leaq	.LC1(%rip), %rsi
	cqto
	idivq	%rdi
	imulq	%rdi, %rax
	leaq	(%r8,%rax,2), %rdx
	xorl	%eax, %eax
	subq	%rdi, %rdx
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L16
	xorl	%eax, %eax
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
.L14:
	.cfi_restore_state
	movq	%rcx, %rdi
	movq	%rsi, %rcx
	jmp	.L5
.L16:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE52:
	.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
	.p2align 4
	.globl	max
	.type	max, @function
max:
.LFB51:
	.cfi_startproc
	endbr64
	cmpq	%rsi, %rdi
	movq	%rsi, %rax
	cmovge	%rdi, %rax
	ret
	.cfi_endproc
.LFE51:
	.size	max, .-max
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%lld %lld"
.LC1:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB52:
	.cfi_startproc
	endbr64
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rdx
	leaq	8(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movq	8(%rsp), %r8
	movq	16(%rsp), %rax
	movq	%r8, %rsi
	movq	%r8, %rcx
	subq	%rax, %rsi
	cmpq	%rax, %rsi
	cmovl	%rax, %rsi
	movq	%rsi, %rax
	subq	%rsi, %rcx
	cqto
	idivq	%rcx
	movq	%rdx, %rdi
	testq	%rdx, %rdx
	jne	.L4
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L15:
	movq	%rdi, %rcx
	movq	%rdx, %rdi
.L4:
	movq	%rsi, %rax
	movq	%rcx, %rsi
	cqto
	idivq	%rcx
	imulq	%rcx, %rax
	leaq	(%r8,%rax,2), %r8
	movq	%rcx, %rax
	cqto
	idivq	%rdi
	testq	%rdx, %rdx
	jne	.L15
.L5:
	movq	%rcx, %rax
	leaq	.LC1(%rip), %rsi
	cqto
	idivq	%rdi
	imulq	%rdi, %rax
	leaq	(%r8,%rax,2), %rdx
	xorl	%eax, %eax
	subq	%rdi, %rdx
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L16
	xorl	%eax, %eax
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
.L14:
	.cfi_restore_state
	movq	%rcx, %rdi
	movq	%rsi, %rcx
	jmp	.L5
.L16:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE52:
	.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:
```