Given the following C code and assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
k,s,x;main(i){for(;scanf("%d",&k),k;printf("%d\n",s/--k))for(i=s=0;i<k*(k-1)/2;i++)scanf("%d",&x),s+=x;}```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB0:
	.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
	leaq	.LC1(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	leaq	k(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	leaq	x(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	leaq	.LC0(%rip), %rbx
	.p2align 4,,10
	.p2align 3
.L2:
	movq	%r12, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	scanf@PLT
	movl	k(%rip), %eax
	testl	%eax, %eax
	je	.L10
	movl	$0, s(%rip)
	leal	-1(%rax), %edi
	imull	%edi, %eax
	cmpl	$1, %eax
	jle	.L6
	xorl	%r14d, %r14d
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%rbx, %rdi
	movq	%rbp, %rsi
	xorl	%eax, %eax
	addl	$1, %r14d
	call	scanf@PLT
	movl	k(%rip), %ecx
	movl	x(%rip), %eax
	addl	s(%rip), %eax
	leal	-1(%rcx), %edi
	movl	%eax, s(%rip)
	imull	%edi, %ecx
	movl	%ecx, %edx
	shrl	$31, %edx
	addl	%ecx, %edx
	sarl	%edx
	cmpl	%r14d, %edx
	jg	.L4
	cltd
	idivl	%edi
	movl	%eax, %esi
.L3:
	movl	%edi, k(%rip)
	xorl	%eax, %eax
	movq	%r13, %rdi
	call	printf@PLT
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L10:
	popq	%rbx
	.cfi_remember_state
	.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
	.p2align 4,,10
	.p2align 3
.L6:
	.cfi_restore_state
	xorl	%esi, %esi
	jmp	.L3
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	x
	.bss
	.align 4
	.type	x, @object
	.size	x, 4
x:
	.zero	4
	.globl	s
	.align 4
	.type	s, @object
	.size	s, 4
s:
	.zero	4
	.globl	k
	.align 4
	.type	k, @object
	.size	k, 4
k:
	.zero	4
	.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	"%d"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB0:
	.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
	leaq	.LC1(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	leaq	k(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	leaq	x(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	leaq	.LC0(%rip), %rbx
	.p2align 4,,10
	.p2align 3
.L2:
	movq	%r12, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	scanf@PLT
	movl	k(%rip), %eax
	testl	%eax, %eax
	je	.L10
	movl	$0, s(%rip)
	leal	-1(%rax), %edi
	imull	%edi, %eax
	cmpl	$1, %eax
	jle	.L6
	xorl	%r14d, %r14d
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%rbx, %rdi
	movq	%rbp, %rsi
	xorl	%eax, %eax
	addl	$1, %r14d
	call	scanf@PLT
	movl	k(%rip), %ecx
	movl	x(%rip), %eax
	addl	s(%rip), %eax
	leal	-1(%rcx), %edi
	movl	%eax, s(%rip)
	imull	%edi, %ecx
	movl	%ecx, %edx
	shrl	$31, %edx
	addl	%ecx, %edx
	sarl	%edx
	cmpl	%r14d, %edx
	jg	.L4
	cltd
	idivl	%edi
	movl	%eax, %esi
.L3:
	movl	%edi, k(%rip)
	xorl	%eax, %eax
	movq	%r13, %rdi
	call	printf@PLT
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L10:
	popq	%rbx
	.cfi_remember_state
	.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
	.p2align 4,,10
	.p2align 3
.L6:
	.cfi_restore_state
	xorl	%esi, %esi
	jmp	.L3
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	x
	.bss
	.align 4
	.type	x, @object
	.size	x, 4
x:
	.zero	4
	.globl	s
	.align 4
	.type	s, @object
	.size	s, 4
s:
	.zero	4
	.globl	k
	.align 4
	.type	k, @object
	.size	k, 4
k:
	.zero	4
	.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	"%d"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB0:
	.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
	leaq	.LC1(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	leaq	k(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	leaq	x(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	leaq	.LC0(%rip), %rbx
	.p2align 4,,10
	.p2align 3
.L2:
	movq	%r12, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	scanf@PLT
	movl	k(%rip), %eax
	testl	%eax, %eax
	je	.L10
	movl	$0, s(%rip)
	leal	-1(%rax), %edi
	imull	%edi, %eax
	cmpl	$1, %eax
	jle	.L6
	xorl	%r14d, %r14d
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%rbx, %rdi
	movq	%rbp, %rsi
	xorl	%eax, %eax
	addl	$1, %r14d
	call	scanf@PLT
	movl	k(%rip), %ecx
	movl	x(%rip), %eax
	addl	s(%rip), %eax
	leal	-1(%rcx), %edi
	movl	%eax, s(%rip)
	imull	%edi, %ecx
	movl	%ecx, %edx
	shrl	$31, %edx
	addl	%ecx, %edx
	sarl	%edx
	cmpl	%r14d, %edx
	jg	.L4
	cltd
	idivl	%edi
	movl	%eax, %esi
.L3:
	movl	%edi, k(%rip)
	xorl	%eax, %eax
	movq	%r13, %rdi
	call	printf@PLT
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L10:
	popq	%rbx
	.cfi_remember_state
	.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
	.p2align 4,,10
	.p2align 3
.L6:
	.cfi_restore_state
	xorl	%esi, %esi
	jmp	.L3
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	x
	.bss
	.align 4
	.type	x, @object
	.size	x, 4
x:
	.zero	4
	.globl	s
	.align 4
	.type	s, @object
	.size	s, 4
s:
	.zero	4
	.globl	k
	.align 4
	.type	k, @object
	.size	k, 4
k:
	.zero	4
	.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
k,s,x;main(i){for(;scanf("%d",&k),k;printf("%d\n",s/--k))for(i=s=0;i<k*(k-1)/2;i++)scanf("%d",&x),s+=x;}```
Given the following C code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
k,s,x;main(i){for(;scanf("%d",&k),k;printf("%d\n",s/--k))for(i=s=0;i<k*(k-1)/2;i++)scanf("%d",&x),s+=x;}```

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:

2
2
3
7 4 3
0
 2
2
0
7 4 3
0
 2
2
3
3 4 3
0
 2
0
0
7 8 3
0
 2
1
3
3 4 3
0
 2
1
0
7 14 4
0
 2
2
3
2 1 4
0
 2
2
3
4 1 4
0
 2
1
3
4 5 3
0
 2
-1
0
7 14 4
0

2
7
 2
 2
5
 0
 1
5
 1
 2
3
 2
4
 1
6
 -1

Given the following C code and assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
k,s,x;main(i){for(;scanf("%d",&k),k;printf("%d\n",s/--k))for(i=s=0;i<k*(k-1)/2;i++)scanf("%d",&x),s+=x;}```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB0:
	.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
	leaq	.LC1(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	leaq	k(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	leaq	x(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	leaq	.LC0(%rip), %rbx
	.p2align 4,,10
	.p2align 3
.L2:
	movq	%r12, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	scanf@PLT
	movl	k(%rip), %eax
	testl	%eax, %eax
	je	.L10
	movl	$0, s(%rip)
	leal	-1(%rax), %edi
	imull	%edi, %eax
	cmpl	$1, %eax
	jle	.L6
	xorl	%r14d, %r14d
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%rbx, %rdi
	movq	%rbp, %rsi
	xorl	%eax, %eax
	addl	$1, %r14d
	call	scanf@PLT
	movl	k(%rip), %ecx
	movl	x(%rip), %eax
	addl	s(%rip), %eax
	leal	-1(%rcx), %edi
	movl	%eax, s(%rip)
	imull	%edi, %ecx
	movl	%ecx, %edx
	shrl	$31, %edx
	addl	%ecx, %edx
	sarl	%edx
	cmpl	%r14d, %edx
	jg	.L4
	cltd
	idivl	%edi
	movl	%eax, %esi
.L3:
	movl	%edi, k(%rip)
	xorl	%eax, %eax
	movq	%r13, %rdi
	call	printf@PLT
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L10:
	popq	%rbx
	.cfi_remember_state
	.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
	.p2align 4,,10
	.p2align 3
.L6:
	.cfi_restore_state
	xorl	%esi, %esi
	jmp	.L3
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	x
	.bss
	.align 4
	.type	x, @object
	.size	x, 4
x:
	.zero	4
	.globl	s
	.align 4
	.type	s, @object
	.size	s, 4
s:
	.zero	4
	.globl	k
	.align 4
	.type	k, @object
	.size	k, 4
k:
	.zero	4
	.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	"%d"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB0:
	.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
	leaq	.LC1(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	leaq	k(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	leaq	x(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	leaq	.LC0(%rip), %rbx
	.p2align 4,,10
	.p2align 3
.L2:
	movq	%r12, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	scanf@PLT
	movl	k(%rip), %eax
	testl	%eax, %eax
	je	.L10
	movl	$0, s(%rip)
	leal	-1(%rax), %edi
	imull	%edi, %eax
	cmpl	$1, %eax
	jle	.L6
	xorl	%r14d, %r14d
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%rbx, %rdi
	movq	%rbp, %rsi
	xorl	%eax, %eax
	addl	$1, %r14d
	call	scanf@PLT
	movl	k(%rip), %ecx
	movl	x(%rip), %eax
	addl	s(%rip), %eax
	leal	-1(%rcx), %edi
	movl	%eax, s(%rip)
	imull	%edi, %ecx
	movl	%ecx, %edx
	shrl	$31, %edx
	addl	%ecx, %edx
	sarl	%edx
	cmpl	%r14d, %edx
	jg	.L4
	cltd
	idivl	%edi
	movl	%eax, %esi
.L3:
	movl	%edi, k(%rip)
	xorl	%eax, %eax
	movq	%r13, %rdi
	call	printf@PLT
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L10:
	popq	%rbx
	.cfi_remember_state
	.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
	.p2align 4,,10
	.p2align 3
.L6:
	.cfi_restore_state
	xorl	%esi, %esi
	jmp	.L3
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	x
	.bss
	.align 4
	.type	x, @object
	.size	x, 4
x:
	.zero	4
	.globl	s
	.align 4
	.type	s, @object
	.size	s, 4
s:
	.zero	4
	.globl	k
	.align 4
	.type	k, @object
	.size	k, 4
k:
	.zero	4
	.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:
```