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>

  int gcd(int a,int b){
    while(b!=0){
      int r = a%b;
      a = b;
      b = r;
    }
    return a;
  }
  

int main (){
  int K;
  scanf("%d",&K);
  int ans =0;
  
  for (int i=1;i<=K;i++){
    for (int b=1;b<=K;b++){
      for (int c=1;c<=K;c++){
        ans+=gcd(gcd(i,b),c);
      }
    }
  }
  printf("%d",ans);
  return 0;
}
  
```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.p2align 4
	.globl	gcd
	.type	gcd, @function
gcd:
.LFB23:
	.cfi_startproc
	endbr64
	movl	%edi, %eax
	movl	%esi, %edx
	testl	%esi, %esi
	je	.L4
	.p2align 4,,10
	.p2align 3
.L3:
	movl	%edx, %r8d
	cltd
	idivl	%r8d
	movl	%r8d, %eax
	testl	%edx, %edx
	jne	.L3
	movl	%r8d, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L4:
	movl	%edi, %r8d
	movl	%r8d, %eax
	ret
	.cfi_endproc
.LFE23:
	.size	gcd, .-gcd
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC0(%rip), %rbp
	movq	%rbp, %rdi
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %r10d
	testl	%r10d, %r10d
	jle	.L17
	addl	$1, %r10d
	movl	$1, %r11d
	xorl	%r8d, %r8d
.L9:
	movl	$1, %r9d
	.p2align 4,,10
	.p2align 3
.L15:
	movl	$1, %edi
	.p2align 4,,10
	.p2align 3
.L14:
	movl	%r9d, %edx
	movl	%r11d, %eax
	.p2align 4,,10
	.p2align 3
.L10:
	movl	%edx, %ecx
	cltd
	idivl	%ecx
	movl	%ecx, %eax
	testl	%edx, %edx
	jne	.L10
	movl	%edi, %edx
	.p2align 4,,10
	.p2align 3
.L11:
	movl	%ecx, %eax
	movl	%edx, %ecx
	cltd
	idivl	%ecx
	testl	%edx, %edx
	jne	.L11
	addl	$1, %edi
	addl	%ecx, %r8d
	cmpl	%r10d, %edi
	jne	.L14
	addl	$1, %r9d
	cmpl	%r10d, %r9d
	jne	.L15
	addl	$1, %r11d
	cmpl	%r10d, %r11d
	jne	.L9
.L8:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L21
	addq	$16, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 16
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
.L17:
	.cfi_restore_state
	xorl	%r8d, %r8d
	jmp	.L8
.L21:
	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:
```

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	gcd
	.type	gcd, @function
gcd:
.LFB23:
	.cfi_startproc
	endbr64
	movl	%edi, %eax
	movl	%esi, %edx
	testl	%esi, %esi
	je	.L4
	.p2align 4,,10
	.p2align 3
.L3:
	movl	%edx, %r8d
	cltd
	idivl	%r8d
	movl	%r8d, %eax
	testl	%edx, %edx
	jne	.L3
	movl	%r8d, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L4:
	movl	%edi, %r8d
	movl	%r8d, %eax
	ret
	.cfi_endproc
.LFE23:
	.size	gcd, .-gcd
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC0(%rip), %rbp
	movq	%rbp, %rdi
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %r10d
	testl	%r10d, %r10d
	jle	.L17
	addl	$1, %r10d
	movl	$1, %r11d
	xorl	%r8d, %r8d
.L9:
	movl	$1, %r9d
	.p2align 4,,10
	.p2align 3
.L15:
	movl	$1, %edi
	.p2align 4,,10
	.p2align 3
.L14:
	movl	%r9d, %edx
	movl	%r11d, %eax
	.p2align 4,,10
	.p2align 3
.L10:
	movl	%edx, %ecx
	cltd
	idivl	%ecx
	movl	%ecx, %eax
	testl	%edx, %edx
	jne	.L10
	movl	%edi, %edx
	.p2align 4,,10
	.p2align 3
.L11:
	movl	%ecx, %eax
	movl	%edx, %ecx
	cltd
	idivl	%ecx
	testl	%edx, %edx
	jne	.L11
	addl	$1, %edi
	addl	%ecx, %r8d
	cmpl	%r10d, %edi
	jne	.L14
	addl	$1, %r9d
	cmpl	%r10d, %r9d
	jne	.L15
	addl	$1, %r11d
	cmpl	%r10d, %r11d
	jne	.L9
.L8:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L21
	addq	$16, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 16
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
.L17:
	.cfi_restore_state
	xorl	%r8d, %r8d
	jmp	.L8
.L21:
	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
```assembly
	.file	"temp.c"
	.text
	.p2align 4
	.globl	gcd
	.type	gcd, @function
gcd:
.LFB23:
	.cfi_startproc
	endbr64
	movl	%edi, %eax
	movl	%esi, %edx
	testl	%esi, %esi
	je	.L4
	.p2align 4,,10
	.p2align 3
.L3:
	movl	%edx, %r8d
	cltd
	idivl	%r8d
	movl	%r8d, %eax
	testl	%edx, %edx
	jne	.L3
	movl	%r8d, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L4:
	movl	%edi, %r8d
	movl	%r8d, %eax
	ret
	.cfi_endproc
.LFE23:
	.size	gcd, .-gcd
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC0(%rip), %rbp
	movq	%rbp, %rdi
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %r10d
	testl	%r10d, %r10d
	jle	.L17
	addl	$1, %r10d
	movl	$1, %r11d
	xorl	%r8d, %r8d
.L9:
	movl	$1, %r9d
	.p2align 4,,10
	.p2align 3
.L15:
	movl	$1, %edi
	.p2align 4,,10
	.p2align 3
.L14:
	movl	%r9d, %edx
	movl	%r11d, %eax
	.p2align 4,,10
	.p2align 3
.L10:
	movl	%edx, %ecx
	cltd
	idivl	%ecx
	movl	%ecx, %eax
	testl	%edx, %edx
	jne	.L10
	movl	%edi, %edx
	.p2align 4,,10
	.p2align 3
.L11:
	movl	%ecx, %eax
	movl	%edx, %ecx
	cltd
	idivl	%ecx
	testl	%edx, %edx
	jne	.L11
	addl	$1, %edi
	addl	%ecx, %r8d
	cmpl	%r10d, %edi
	jne	.L14
	addl	$1, %r9d
	cmpl	%r10d, %r9d
	jne	.L15
	addl	$1, %r11d
	cmpl	%r10d, %r11d
	jne	.L9
.L8:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L21
	addq	$16, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 16
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
.L17:
	.cfi_restore_state
	xorl	%r8d, %r8d
	jmp	.L8
.L21:
	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:
```
```c
#include <stdio.h>

  int gcd(int a,int b){
    while(b!=0){
      int r = a%b;
      a = b;
      b = r;
    }
    return a;
  }
  

int main (){
  int K;
  scanf("%d",&K);
  int ans =0;
  
  for (int i=1;i<=K;i++){
    for (int b=1;b<=K;b++){
      for (int c=1;c<=K;c++){
        ans+=gcd(gcd(i,b),c);
      }
    }
  }
  printf("%d",ans);
  return 0;
}
  
```
Given the following C code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include <stdio.h>

  int gcd(int a,int b){
    while(b!=0){
      int r = a%b;
      a = b;
      b = r;
    }
    return a;
  }
  

int main (){
  int K;
  scanf("%d",&K);
  int ans =0;
  
  for (int i=1;i<=K;i++){
    for (int b=1;b<=K;b++){
      for (int c=1;c<=K;c++){
        ans+=gcd(gcd(i,b),c);
      }
    }
  }
  printf("%d",ans);
  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:

4
 8
 3
 5
 7
 0
 1
 10
 20
 9

76 624 30 141 400 0 1 1249 10248 885
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>

  int gcd(int a,int b){
    while(b!=0){
      int r = a%b;
      a = b;
      b = r;
    }
    return a;
  }
  

int main (){
  int K;
  scanf("%d",&K);
  int ans =0;
  
  for (int i=1;i<=K;i++){
    for (int b=1;b<=K;b++){
      for (int c=1;c<=K;c++){
        ans+=gcd(gcd(i,b),c);
      }
    }
  }
  printf("%d",ans);
  return 0;
}
  
```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.p2align 4
	.globl	gcd
	.type	gcd, @function
gcd:
.LFB23:
	.cfi_startproc
	endbr64
	movl	%edi, %eax
	movl	%esi, %edx
	testl	%esi, %esi
	je	.L4
	.p2align 4,,10
	.p2align 3
.L3:
	movl	%edx, %r8d
	cltd
	idivl	%r8d
	movl	%r8d, %eax
	testl	%edx, %edx
	jne	.L3
	movl	%r8d, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L4:
	movl	%edi, %r8d
	movl	%r8d, %eax
	ret
	.cfi_endproc
.LFE23:
	.size	gcd, .-gcd
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC0(%rip), %rbp
	movq	%rbp, %rdi
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %r10d
	testl	%r10d, %r10d
	jle	.L17
	addl	$1, %r10d
	movl	$1, %r11d
	xorl	%r8d, %r8d
.L9:
	movl	$1, %r9d
	.p2align 4,,10
	.p2align 3
.L15:
	movl	$1, %edi
	.p2align 4,,10
	.p2align 3
.L14:
	movl	%r9d, %edx
	movl	%r11d, %eax
	.p2align 4,,10
	.p2align 3
.L10:
	movl	%edx, %ecx
	cltd
	idivl	%ecx
	movl	%ecx, %eax
	testl	%edx, %edx
	jne	.L10
	movl	%edi, %edx
	.p2align 4,,10
	.p2align 3
.L11:
	movl	%ecx, %eax
	movl	%edx, %ecx
	cltd
	idivl	%ecx
	testl	%edx, %edx
	jne	.L11
	addl	$1, %edi
	addl	%ecx, %r8d
	cmpl	%r10d, %edi
	jne	.L14
	addl	$1, %r9d
	cmpl	%r10d, %r9d
	jne	.L15
	addl	$1, %r11d
	cmpl	%r10d, %r11d
	jne	.L9
.L8:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L21
	addq	$16, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 16
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
.L17:
	.cfi_restore_state
	xorl	%r8d, %r8d
	jmp	.L8
.L21:
	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:
```

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	gcd
	.type	gcd, @function
gcd:
.LFB23:
	.cfi_startproc
	endbr64
	movl	%edi, %eax
	movl	%esi, %edx
	testl	%esi, %esi
	je	.L4
	.p2align 4,,10
	.p2align 3
.L3:
	movl	%edx, %r8d
	cltd
	idivl	%r8d
	movl	%r8d, %eax
	testl	%edx, %edx
	jne	.L3
	movl	%r8d, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L4:
	movl	%edi, %r8d
	movl	%r8d, %eax
	ret
	.cfi_endproc
.LFE23:
	.size	gcd, .-gcd
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC0(%rip), %rbp
	movq	%rbp, %rdi
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %r10d
	testl	%r10d, %r10d
	jle	.L17
	addl	$1, %r10d
	movl	$1, %r11d
	xorl	%r8d, %r8d
.L9:
	movl	$1, %r9d
	.p2align 4,,10
	.p2align 3
.L15:
	movl	$1, %edi
	.p2align 4,,10
	.p2align 3
.L14:
	movl	%r9d, %edx
	movl	%r11d, %eax
	.p2align 4,,10
	.p2align 3
.L10:
	movl	%edx, %ecx
	cltd
	idivl	%ecx
	movl	%ecx, %eax
	testl	%edx, %edx
	jne	.L10
	movl	%edi, %edx
	.p2align 4,,10
	.p2align 3
.L11:
	movl	%ecx, %eax
	movl	%edx, %ecx
	cltd
	idivl	%ecx
	testl	%edx, %edx
	jne	.L11
	addl	$1, %edi
	addl	%ecx, %r8d
	cmpl	%r10d, %edi
	jne	.L14
	addl	$1, %r9d
	cmpl	%r10d, %r9d
	jne	.L15
	addl	$1, %r11d
	cmpl	%r10d, %r11d
	jne	.L9
.L8:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L21
	addq	$16, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 16
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
.L17:
	.cfi_restore_state
	xorl	%r8d, %r8d
	jmp	.L8
.L21:
	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:
```