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

```c
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int f(long h[2], const int a[2], const int b[2]){
	if(a[0]*b[1]>a[1]*b[0]){
		long r = (h[1]+a[1]-1)/a[1];
		h[0] = r*a[0];
		h[1] = r*a[1];
	}else{
		long r = (h[0]+a[0]-1)/a[0];
		h[0] = r*a[0];
		h[1] = r*a[1];
	}
}

int main(void){
	int n, i;
	long h[2]={1,1};
	int a[2], b[2]={1,1};
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%d%d", a, a+1);
		f(h, a, b);
		b[0]=a[0], b[1]=a[1];
	}
	printf("%ld\n", h[0]+h[1]);
}
```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.p2align 4
	.globl	f
	.type	f, @function
f:
.LFB51:
	.cfi_startproc
	endbr64
	movl	(%rsi), %r8d
	movq	%rdi, %rcx
	movslq	4(%rsi), %rdi
	movslq	%r8d, %rsi
	imull	4(%rdx), %r8d
	movq	%rdi, %rax
	imull	(%rdx), %eax
	cmpl	%eax, %r8d
	jle	.L2
	movq	8(%rcx), %rax
	addq	%rdi, %rax
	subq	$1, %rax
	cqto
	idivq	%rdi
	imulq	%rax, %rsi
	imulq	%rax, %rdi
	movq	%rsi, (%rcx)
	movq	%rdi, 8(%rcx)
	ret
	.p2align 4,,10
	.p2align 3
.L2:
	movq	(%rcx), %rax
	addq	%rsi, %rax
	subq	$1, %rax
	cqto
	idivq	%rsi
	imulq	%rax, %rsi
	imulq	%rax, %rdi
	movq	%rsi, (%rcx)
	movq	%rdi, 8(%rcx)
	ret
	.cfi_endproc
.LFE51:
	.size	f, .-f
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%ld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB52:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC0(%rip), %rdi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	testl	%eax, %eax
	jle	.L11
	leaq	36(%rsp), %rax
	movl	$1, %r14d
	movl	$1, %ebp
	movl	$1, %ebx
	movq	%rax, 8(%rsp)
	movl	$1, %r12d
	xorl	%r13d, %r13d
	leaq	32(%rsp), %r15
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L14:
	movslq	%r14d, %rsi
	movslq	%ebp, %r12
	addl	$1, %r13d
	leaq	-1(%rbx,%rsi), %rax
	movq	%rsi, %rbx
	cqto
	idivq	%rsi
	imulq	%rax, %r12
	imulq	%rax, %rbx
	cmpl	%r13d, 28(%rsp)
	jle	.L6
.L9:
	movq	8(%rsp), %rdx
	movq	%r15, %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	%ebp, %eax
	movl	%r14d, %edx
	movl	32(%rsp), %ebp
	movl	36(%rsp), %r14d
	imull	%ebp, %edx
	imull	%r14d, %eax
	cmpl	%eax, %edx
	jg	.L14
	movslq	%ebp, %rsi
	movslq	%r14d, %rbx
	addl	$1, %r13d
	leaq	-1(%r12,%rsi), %rax
	cqto
	idivq	%rsi
	imulq	%rax, %rsi
	imulq	%rax, %rbx
	movq	%rsi, %r12
	cmpl	%r13d, 28(%rsp)
	jg	.L9
.L6:
	xorl	%eax, %eax
	leaq	(%r12,%rbx), %rdx
	movl	$1, %edi
	leaq	.LC2(%rip), %rsi
	call	__printf_chk@PLT
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L15
	addq	$56, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
.L11:
	.cfi_restore_state
	movl	$1, %ebx
	movl	$1, %r12d
	jmp	.L6
.L15:
	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	f
	.type	f, @function
f:
.LFB51:
	.cfi_startproc
	endbr64
	movl	(%rsi), %r8d
	movq	%rdi, %rcx
	movslq	4(%rsi), %rdi
	movslq	%r8d, %rsi
	imull	4(%rdx), %r8d
	movq	%rdi, %rax
	imull	(%rdx), %eax
	cmpl	%eax, %r8d
	jle	.L2
	movq	8(%rcx), %rax
	addq	%rdi, %rax
	subq	$1, %rax
	cqto
	idivq	%rdi
	imulq	%rax, %rsi
	imulq	%rax, %rdi
	movq	%rsi, (%rcx)
	movq	%rdi, 8(%rcx)
	ret
	.p2align 4,,10
	.p2align 3
.L2:
	movq	(%rcx), %rax
	addq	%rsi, %rax
	subq	$1, %rax
	cqto
	idivq	%rsi
	imulq	%rax, %rsi
	imulq	%rax, %rdi
	movq	%rsi, (%rcx)
	movq	%rdi, 8(%rcx)
	ret
	.cfi_endproc
.LFE51:
	.size	f, .-f
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%ld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB52:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC0(%rip), %rdi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	testl	%eax, %eax
	jle	.L11
	leaq	36(%rsp), %rax
	movl	$1, %r14d
	movl	$1, %ebp
	movl	$1, %ebx
	movq	%rax, 8(%rsp)
	movl	$1, %r12d
	xorl	%r13d, %r13d
	leaq	32(%rsp), %r15
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L14:
	movslq	%r14d, %rsi
	movslq	%ebp, %r12
	addl	$1, %r13d
	leaq	-1(%rbx,%rsi), %rax
	movq	%rsi, %rbx
	cqto
	idivq	%rsi
	imulq	%rax, %r12
	imulq	%rax, %rbx
	cmpl	%r13d, 28(%rsp)
	jle	.L6
.L9:
	movq	8(%rsp), %rdx
	movq	%r15, %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	%ebp, %eax
	movl	%r14d, %edx
	movl	32(%rsp), %ebp
	movl	36(%rsp), %r14d
	imull	%ebp, %edx
	imull	%r14d, %eax
	cmpl	%eax, %edx
	jg	.L14
	movslq	%ebp, %rsi
	movslq	%r14d, %rbx
	addl	$1, %r13d
	leaq	-1(%r12,%rsi), %rax
	cqto
	idivq	%rsi
	imulq	%rax, %rsi
	imulq	%rax, %rbx
	movq	%rsi, %r12
	cmpl	%r13d, 28(%rsp)
	jg	.L9
.L6:
	xorl	%eax, %eax
	leaq	(%r12,%rbx), %rdx
	movl	$1, %edi
	leaq	.LC2(%rip), %rsi
	call	__printf_chk@PLT
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L15
	addq	$56, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
.L11:
	.cfi_restore_state
	movl	$1, %ebx
	movl	$1, %r12d
	jmp	.L6
.L15:
	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	f
	.type	f, @function
f:
.LFB51:
	.cfi_startproc
	endbr64
	movl	(%rsi), %r8d
	movq	%rdi, %rcx
	movslq	4(%rsi), %rdi
	movslq	%r8d, %rsi
	imull	4(%rdx), %r8d
	movq	%rdi, %rax
	imull	(%rdx), %eax
	cmpl	%eax, %r8d
	jle	.L2
	movq	8(%rcx), %rax
	addq	%rdi, %rax
	subq	$1, %rax
	cqto
	idivq	%rdi
	imulq	%rax, %rsi
	imulq	%rax, %rdi
	movq	%rsi, (%rcx)
	movq	%rdi, 8(%rcx)
	ret
	.p2align 4,,10
	.p2align 3
.L2:
	movq	(%rcx), %rax
	addq	%rsi, %rax
	subq	$1, %rax
	cqto
	idivq	%rsi
	imulq	%rax, %rsi
	imulq	%rax, %rdi
	movq	%rsi, (%rcx)
	movq	%rdi, 8(%rcx)
	ret
	.cfi_endproc
.LFE51:
	.size	f, .-f
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%ld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB52:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC0(%rip), %rdi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	testl	%eax, %eax
	jle	.L11
	leaq	36(%rsp), %rax
	movl	$1, %r14d
	movl	$1, %ebp
	movl	$1, %ebx
	movq	%rax, 8(%rsp)
	movl	$1, %r12d
	xorl	%r13d, %r13d
	leaq	32(%rsp), %r15
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L14:
	movslq	%r14d, %rsi
	movslq	%ebp, %r12
	addl	$1, %r13d
	leaq	-1(%rbx,%rsi), %rax
	movq	%rsi, %rbx
	cqto
	idivq	%rsi
	imulq	%rax, %r12
	imulq	%rax, %rbx
	cmpl	%r13d, 28(%rsp)
	jle	.L6
.L9:
	movq	8(%rsp), %rdx
	movq	%r15, %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	%ebp, %eax
	movl	%r14d, %edx
	movl	32(%rsp), %ebp
	movl	36(%rsp), %r14d
	imull	%ebp, %edx
	imull	%r14d, %eax
	cmpl	%eax, %edx
	jg	.L14
	movslq	%ebp, %rsi
	movslq	%r14d, %rbx
	addl	$1, %r13d
	leaq	-1(%r12,%rsi), %rax
	cqto
	idivq	%rsi
	imulq	%rax, %rsi
	imulq	%rax, %rbx
	movq	%rsi, %r12
	cmpl	%r13d, 28(%rsp)
	jg	.L9
.L6:
	xorl	%eax, %eax
	leaq	(%r12,%rbx), %rdx
	movl	$1, %edi
	leaq	.LC2(%rip), %rsi
	call	__printf_chk@PLT
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L15
	addq	$56, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
.L11:
	.cfi_restore_state
	movl	$1, %ebx
	movl	$1, %r12d
	jmp	.L6
.L15:
	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 <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int f(long h[2], const int a[2], const int b[2]){
	if(a[0]*b[1]>a[1]*b[0]){
		long r = (h[1]+a[1]-1)/a[1];
		h[0] = r*a[0];
		h[1] = r*a[1];
	}else{
		long r = (h[0]+a[0]-1)/a[0];
		h[0] = r*a[0];
		h[1] = r*a[1];
	}
}

int main(void){
	int n, i;
	long h[2]={1,1};
	int a[2], b[2]={1,1};
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%d%d", a, a+1);
		f(h, a, b);
		b[0]=a[0], b[1]=a[1];
	}
	printf("%ld\n", h[0]+h[1]);
}
```
Given the following C code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int f(long h[2], const int a[2], const int b[2]){
	if(a[0]*b[1]>a[1]*b[0]){
		long r = (h[1]+a[1]-1)/a[1];
		h[0] = r*a[0];
		h[1] = r*a[1];
	}else{
		long r = (h[0]+a[0]-1)/a[0];
		h[0] = r*a[0];
		h[1] = r*a[1];
	}
}

int main(void){
	int n, i;
	long h[2]={1,1};
	int a[2], b[2]={1,1};
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%d%d", a, a+1);
		f(h, a, b);
		b[0]=a[0], b[1]=a[1];
	}
	printf("%ld\n", h[0]+h[1]);
}
```

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
3 1
48 17
31 199
231 23
3 2
 4
1 1
1 1
1 9
1 100
 3
3 3
1 1
3 2
 3
4 3
1 1
3 1
 3
4 3
1 2
3 1
 3
2 3
1 1
1 2
 4
1 2
1 1
1 9
1 100
 5
3 10
48 28
31 199
319 23
3 2
 3
4 3
1 1
1 2
 5
3 10
48 28
31 199
300 23
3 2

6930
 101
 10
 16
 32
 9
 202
 9570
 12
 9000

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

```c
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int f(long h[2], const int a[2], const int b[2]){
	if(a[0]*b[1]>a[1]*b[0]){
		long r = (h[1]+a[1]-1)/a[1];
		h[0] = r*a[0];
		h[1] = r*a[1];
	}else{
		long r = (h[0]+a[0]-1)/a[0];
		h[0] = r*a[0];
		h[1] = r*a[1];
	}
}

int main(void){
	int n, i;
	long h[2]={1,1};
	int a[2], b[2]={1,1};
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%d%d", a, a+1);
		f(h, a, b);
		b[0]=a[0], b[1]=a[1];
	}
	printf("%ld\n", h[0]+h[1]);
}
```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.p2align 4
	.globl	f
	.type	f, @function
f:
.LFB51:
	.cfi_startproc
	endbr64
	movl	(%rsi), %r8d
	movq	%rdi, %rcx
	movslq	4(%rsi), %rdi
	movslq	%r8d, %rsi
	imull	4(%rdx), %r8d
	movq	%rdi, %rax
	imull	(%rdx), %eax
	cmpl	%eax, %r8d
	jle	.L2
	movq	8(%rcx), %rax
	addq	%rdi, %rax
	subq	$1, %rax
	cqto
	idivq	%rdi
	imulq	%rax, %rsi
	imulq	%rax, %rdi
	movq	%rsi, (%rcx)
	movq	%rdi, 8(%rcx)
	ret
	.p2align 4,,10
	.p2align 3
.L2:
	movq	(%rcx), %rax
	addq	%rsi, %rax
	subq	$1, %rax
	cqto
	idivq	%rsi
	imulq	%rax, %rsi
	imulq	%rax, %rdi
	movq	%rsi, (%rcx)
	movq	%rdi, 8(%rcx)
	ret
	.cfi_endproc
.LFE51:
	.size	f, .-f
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%ld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB52:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC0(%rip), %rdi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	testl	%eax, %eax
	jle	.L11
	leaq	36(%rsp), %rax
	movl	$1, %r14d
	movl	$1, %ebp
	movl	$1, %ebx
	movq	%rax, 8(%rsp)
	movl	$1, %r12d
	xorl	%r13d, %r13d
	leaq	32(%rsp), %r15
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L14:
	movslq	%r14d, %rsi
	movslq	%ebp, %r12
	addl	$1, %r13d
	leaq	-1(%rbx,%rsi), %rax
	movq	%rsi, %rbx
	cqto
	idivq	%rsi
	imulq	%rax, %r12
	imulq	%rax, %rbx
	cmpl	%r13d, 28(%rsp)
	jle	.L6
.L9:
	movq	8(%rsp), %rdx
	movq	%r15, %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	%ebp, %eax
	movl	%r14d, %edx
	movl	32(%rsp), %ebp
	movl	36(%rsp), %r14d
	imull	%ebp, %edx
	imull	%r14d, %eax
	cmpl	%eax, %edx
	jg	.L14
	movslq	%ebp, %rsi
	movslq	%r14d, %rbx
	addl	$1, %r13d
	leaq	-1(%r12,%rsi), %rax
	cqto
	idivq	%rsi
	imulq	%rax, %rsi
	imulq	%rax, %rbx
	movq	%rsi, %r12
	cmpl	%r13d, 28(%rsp)
	jg	.L9
.L6:
	xorl	%eax, %eax
	leaq	(%r12,%rbx), %rdx
	movl	$1, %edi
	leaq	.LC2(%rip), %rsi
	call	__printf_chk@PLT
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L15
	addq	$56, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
.L11:
	.cfi_restore_state
	movl	$1, %ebx
	movl	$1, %r12d
	jmp	.L6
.L15:
	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	f
	.type	f, @function
f:
.LFB51:
	.cfi_startproc
	endbr64
	movl	(%rsi), %r8d
	movq	%rdi, %rcx
	movslq	4(%rsi), %rdi
	movslq	%r8d, %rsi
	imull	4(%rdx), %r8d
	movq	%rdi, %rax
	imull	(%rdx), %eax
	cmpl	%eax, %r8d
	jle	.L2
	movq	8(%rcx), %rax
	addq	%rdi, %rax
	subq	$1, %rax
	cqto
	idivq	%rdi
	imulq	%rax, %rsi
	imulq	%rax, %rdi
	movq	%rsi, (%rcx)
	movq	%rdi, 8(%rcx)
	ret
	.p2align 4,,10
	.p2align 3
.L2:
	movq	(%rcx), %rax
	addq	%rsi, %rax
	subq	$1, %rax
	cqto
	idivq	%rsi
	imulq	%rax, %rsi
	imulq	%rax, %rdi
	movq	%rsi, (%rcx)
	movq	%rdi, 8(%rcx)
	ret
	.cfi_endproc
.LFE51:
	.size	f, .-f
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%ld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB52:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC0(%rip), %rdi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	testl	%eax, %eax
	jle	.L11
	leaq	36(%rsp), %rax
	movl	$1, %r14d
	movl	$1, %ebp
	movl	$1, %ebx
	movq	%rax, 8(%rsp)
	movl	$1, %r12d
	xorl	%r13d, %r13d
	leaq	32(%rsp), %r15
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L14:
	movslq	%r14d, %rsi
	movslq	%ebp, %r12
	addl	$1, %r13d
	leaq	-1(%rbx,%rsi), %rax
	movq	%rsi, %rbx
	cqto
	idivq	%rsi
	imulq	%rax, %r12
	imulq	%rax, %rbx
	cmpl	%r13d, 28(%rsp)
	jle	.L6
.L9:
	movq	8(%rsp), %rdx
	movq	%r15, %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	%ebp, %eax
	movl	%r14d, %edx
	movl	32(%rsp), %ebp
	movl	36(%rsp), %r14d
	imull	%ebp, %edx
	imull	%r14d, %eax
	cmpl	%eax, %edx
	jg	.L14
	movslq	%ebp, %rsi
	movslq	%r14d, %rbx
	addl	$1, %r13d
	leaq	-1(%r12,%rsi), %rax
	cqto
	idivq	%rsi
	imulq	%rax, %rsi
	imulq	%rax, %rbx
	movq	%rsi, %r12
	cmpl	%r13d, 28(%rsp)
	jg	.L9
.L6:
	xorl	%eax, %eax
	leaq	(%r12,%rbx), %rdx
	movl	$1, %edi
	leaq	.LC2(%rip), %rsi
	call	__printf_chk@PLT
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L15
	addq	$56, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
.L11:
	.cfi_restore_state
	movl	$1, %ebx
	movl	$1, %r12d
	jmp	.L6
.L15:
	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:
```