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>

int main() {
  long int A, B, N;
  scanf("%ld", &N);

  int sum = 0; 
  switch (N){
    case 100000:
    case 10000:
    case 1000:
    case 100:
    case 10:
      sum = 10;
    break;
    default:
      while (N != 0) { 
        sum += N % 10; 
        N = N/10; 
      } 
  }

  printf("%d\n", sum);
}
```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%ld"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movq	(%rsp), %rcx
	movl	$10, %r8d
	cmpq	$1000, %rcx
	je	.L2
	jg	.L3
	cmpq	$10, %rcx
	je	.L2
	cmpq	$100, %rcx
	je	.L2
	xorl	%r8d, %r8d
	testq	%rcx, %rcx
	jne	.L5
	.p2align 4,,10
	.p2align 3
.L2:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L23
	xorl	%eax, %eax
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L3:
	.cfi_restore_state
	cmpq	$10000, %rcx
	je	.L2
	cmpq	$100000, %rcx
	je	.L2
	xorl	%r8d, %r8d
.L5:
	movabsq	$7378697629483820647, %rsi
	.p2align 4,,10
	.p2align 3
.L13:
	movq	%rcx, %rax
	imulq	%rsi
	movq	%rcx, %rax
	sarq	$63, %rax
	sarq	$2, %rdx
	subq	%rax, %rdx
	leaq	(%rdx,%rdx,4), %rax
	addq	%rax, %rax
	subq	%rax, %rcx
	addl	%ecx, %r8d
	movq	%rdx, %rcx
	testq	%rdx, %rdx
	jne	.L13
	movq	$0, (%rsp)
	jmp	.L2
.L23:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.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
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%ld"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movq	(%rsp), %rcx
	movl	$10, %r8d
	cmpq	$1000, %rcx
	je	.L2
	jg	.L3
	cmpq	$10, %rcx
	je	.L2
	cmpq	$100, %rcx
	je	.L2
	xorl	%r8d, %r8d
	testq	%rcx, %rcx
	jne	.L5
	.p2align 4,,10
	.p2align 3
.L2:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L23
	xorl	%eax, %eax
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L3:
	.cfi_restore_state
	cmpq	$10000, %rcx
	je	.L2
	cmpq	$100000, %rcx
	je	.L2
	xorl	%r8d, %r8d
.L5:
	movabsq	$7378697629483820647, %rsi
	.p2align 4,,10
	.p2align 3
.L13:
	movq	%rcx, %rax
	imulq	%rsi
	movq	%rcx, %rax
	sarq	$63, %rax
	sarq	$2, %rdx
	subq	%rax, %rdx
	leaq	(%rdx,%rdx,4), %rax
	addq	%rax, %rax
	subq	%rax, %rcx
	addl	%ecx, %r8d
	movq	%rdx, %rcx
	testq	%rdx, %rdx
	jne	.L13
	movq	$0, (%rsp)
	jmp	.L2
.L23:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.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
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%ld"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movq	(%rsp), %rcx
	movl	$10, %r8d
	cmpq	$1000, %rcx
	je	.L2
	jg	.L3
	cmpq	$10, %rcx
	je	.L2
	cmpq	$100, %rcx
	je	.L2
	xorl	%r8d, %r8d
	testq	%rcx, %rcx
	jne	.L5
	.p2align 4,,10
	.p2align 3
.L2:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L23
	xorl	%eax, %eax
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L3:
	.cfi_restore_state
	cmpq	$10000, %rcx
	je	.L2
	cmpq	$100000, %rcx
	je	.L2
	xorl	%r8d, %r8d
.L5:
	movabsq	$7378697629483820647, %rsi
	.p2align 4,,10
	.p2align 3
.L13:
	movq	%rcx, %rax
	imulq	%rsi
	movq	%rcx, %rax
	sarq	$63, %rax
	sarq	$2, %rdx
	subq	%rax, %rdx
	leaq	(%rdx,%rdx,4), %rax
	addq	%rax, %rax
	subq	%rax, %rcx
	addl	%ecx, %r8d
	movq	%rdx, %rcx
	testq	%rdx, %rdx
	jne	.L13
	movq	$0, (%rsp)
	jmp	.L2
.L23:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.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>

int main() {
  long int A, B, N;
  scanf("%ld", &N);

  int sum = 0; 
  switch (N){
    case 100000:
    case 10000:
    case 1000:
    case 100:
    case 10:
      sum = 10;
    break;
    default:
      while (N != 0) { 
        sum += N % 10; 
        N = N/10; 
      } 
  }

  printf("%d\n", sum);
}
```
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>

int main() {
  long int A, B, N;
  scanf("%ld", &N);

  int sum = 0; 
  switch (N){
    case 100000:
    case 10000:
    case 1000:
    case 100:
    case 10:
      sum = 10;
    break;
    default:
      while (N != 0) { 
        sum += N % 10; 
        N = N/10; 
      } 
  }

  printf("%d\n", sum);
}
```

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:

22
 37
 36
 3
 5
 7
 26
 38
 58
 78

4
 10
 9
 3
 5
 7
 8
 11
 13
 15

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>

int main() {
  long int A, B, N;
  scanf("%ld", &N);

  int sum = 0; 
  switch (N){
    case 100000:
    case 10000:
    case 1000:
    case 100:
    case 10:
      sum = 10;
    break;
    default:
      while (N != 0) { 
        sum += N % 10; 
        N = N/10; 
      } 
  }

  printf("%d\n", sum);
}
```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%ld"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movq	(%rsp), %rcx
	movl	$10, %r8d
	cmpq	$1000, %rcx
	je	.L2
	jg	.L3
	cmpq	$10, %rcx
	je	.L2
	cmpq	$100, %rcx
	je	.L2
	xorl	%r8d, %r8d
	testq	%rcx, %rcx
	jne	.L5
	.p2align 4,,10
	.p2align 3
.L2:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L23
	xorl	%eax, %eax
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L3:
	.cfi_restore_state
	cmpq	$10000, %rcx
	je	.L2
	cmpq	$100000, %rcx
	je	.L2
	xorl	%r8d, %r8d
.L5:
	movabsq	$7378697629483820647, %rsi
	.p2align 4,,10
	.p2align 3
.L13:
	movq	%rcx, %rax
	imulq	%rsi
	movq	%rcx, %rax
	sarq	$63, %rax
	sarq	$2, %rdx
	subq	%rax, %rdx
	leaq	(%rdx,%rdx,4), %rax
	addq	%rax, %rax
	subq	%rax, %rcx
	addl	%ecx, %r8d
	movq	%rdx, %rcx
	testq	%rdx, %rdx
	jne	.L13
	movq	$0, (%rsp)
	jmp	.L2
.L23:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.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
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%ld"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movq	(%rsp), %rcx
	movl	$10, %r8d
	cmpq	$1000, %rcx
	je	.L2
	jg	.L3
	cmpq	$10, %rcx
	je	.L2
	cmpq	$100, %rcx
	je	.L2
	xorl	%r8d, %r8d
	testq	%rcx, %rcx
	jne	.L5
	.p2align 4,,10
	.p2align 3
.L2:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L23
	xorl	%eax, %eax
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L3:
	.cfi_restore_state
	cmpq	$10000, %rcx
	je	.L2
	cmpq	$100000, %rcx
	je	.L2
	xorl	%r8d, %r8d
.L5:
	movabsq	$7378697629483820647, %rsi
	.p2align 4,,10
	.p2align 3
.L13:
	movq	%rcx, %rax
	imulq	%rsi
	movq	%rcx, %rax
	sarq	$63, %rax
	sarq	$2, %rdx
	subq	%rax, %rdx
	leaq	(%rdx,%rdx,4), %rax
	addq	%rax, %rax
	subq	%rax, %rcx
	addl	%ecx, %r8d
	movq	%rdx, %rcx
	testq	%rdx, %rdx
	jne	.L13
	movq	$0, (%rsp)
	jmp	.L2
.L23:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.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:
```