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

```c
#include <stdio.h>
int makerand(int a, int b, int c, int x);
int main(void) {
    int num,a,b,c,rand,i,reel[100],sp;
    while (1) {
        scanf("%d %d %d %d %d",&num,&a,&b,&c,&rand);
        if (num==0&&a==0&&b==0&&c==0&&rand==0) break;
        for (i=0; i<num; i++) scanf("%d",&reel[i]);
        sp=0;
        for (i=0; i<num; i++) {
            if (reel[i]>=c) break;
        }
        if (i!=num) {
            printf("-1\n");
            continue;
        }
        if (rand==reel[0]) {
            sp++;
            if (sp==num) {
            	printf("0\n");
            	continue;
            }
            
        }
        for (i=1; i<=10000; i++) {
            if (sp>=num-1&&reel[sp]==makerand(a,b,c,rand)) break;
        	rand=makerand(a,b,c,rand);
            if (rand==reel[sp]) sp++;
        }
        if (i==10001) {
            printf("-1\n");
        } else {
            printf("%d\n",i);
        }
    }
    return 0;
}

int makerand(int a, int b, int c, int x) {
    return (a*x+b)%c;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d %d %d %d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"-1"
.LC3:
	.string	"0"
.LC4:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	subq	$456, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
.L19:
	leaq	-444(%rbp), %rdi
	leaq	-448(%rbp), %rsi
	leaq	-452(%rbp), %rcx
	leaq	-456(%rbp), %rdx
	leaq	-460(%rbp), %rax
	movq	%rdi, %r9
	movq	%rsi, %r8
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-460(%rbp), %eax
	testl	%eax, %eax
	jne	.L2
	movl	-456(%rbp), %eax
	testl	%eax, %eax
	jne	.L2
	movl	-452(%rbp), %eax
	testl	%eax, %eax
	jne	.L2
	movl	-448(%rbp), %eax
	testl	%eax, %eax
	jne	.L2
	movl	-444(%rbp), %eax
	testl	%eax, %eax
	je	.L23
.L2:
	movl	$0, -440(%rbp)
	jmp	.L4
.L5:
	leaq	-432(%rbp), %rdx
	movl	-440(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -440(%rbp)
.L4:
	movl	-460(%rbp), %eax
	cmpl	%eax, -440(%rbp)
	jl	.L5
	movl	$0, -436(%rbp)
	movl	$0, -440(%rbp)
	jmp	.L6
.L9:
	movl	-440(%rbp), %eax
	cltq
	movl	-432(%rbp,%rax,4), %edx
	movl	-448(%rbp), %eax
	cmpl	%eax, %edx
	jge	.L24
	addl	$1, -440(%rbp)
.L6:
	movl	-460(%rbp), %eax
	cmpl	%eax, -440(%rbp)
	jl	.L9
	jmp	.L8
.L24:
	nop
.L8:
	movl	-460(%rbp), %eax
	cmpl	%eax, -440(%rbp)
	je	.L10
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L11
.L10:
	movl	-432(%rbp), %edx
	movl	-444(%rbp), %eax
	cmpl	%eax, %edx
	jne	.L12
	addl	$1, -436(%rbp)
	movl	-460(%rbp), %eax
	cmpl	%eax, -436(%rbp)
	jne	.L12
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L11
.L12:
	movl	$1, -440(%rbp)
	jmp	.L13
.L17:
	movl	-460(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -436(%rbp)
	jl	.L14
	movl	-436(%rbp), %eax
	cltq
	movl	-432(%rbp,%rax,4), %ebx
	movl	-444(%rbp), %ecx
	movl	-448(%rbp), %edx
	movl	-452(%rbp), %esi
	movl	-456(%rbp), %eax
	movl	%eax, %edi
	call	makerand
	cmpl	%eax, %ebx
	je	.L25
.L14:
	movl	-444(%rbp), %ecx
	movl	-448(%rbp), %edx
	movl	-452(%rbp), %esi
	movl	-456(%rbp), %eax
	movl	%eax, %edi
	call	makerand
	movl	%eax, -444(%rbp)
	movl	-436(%rbp), %eax
	cltq
	movl	-432(%rbp,%rax,4), %edx
	movl	-444(%rbp), %eax
	cmpl	%eax, %edx
	jne	.L16
	addl	$1, -436(%rbp)
.L16:
	addl	$1, -440(%rbp)
.L13:
	cmpl	$10000, -440(%rbp)
	jle	.L17
	jmp	.L15
.L25:
	nop
.L15:
	cmpl	$10001, -440(%rbp)
	jne	.L18
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L19
.L18:
	movl	-440(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L11:
	jmp	.L19
.L23:
	nop
	movl	$0, %eax
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L21
	call	__stack_chk_fail@PLT
.L21:
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	makerand
	.type	makerand, @function
makerand:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	%edx, -12(%rbp)
	movl	%ecx, -16(%rbp)
	movl	-4(%rbp), %eax
	imull	-16(%rbp), %eax
	movl	%eax, %edx
	movl	-8(%rbp), %eax
	addl	%edx, %eax
	cltd
	idivl	-12(%rbp)
	movl	%edx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	makerand, .-makerand
	.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.
user
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d %d %d %d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"-1"
.LC3:
	.string	"0"
.LC4:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	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	$488, %rsp
	.cfi_def_cfa_offset 544
	movq	%fs:40, %rax
	movq	%rax, 472(%rsp)
	xorl	%eax, %eax
	leaq	52(%rsp), %rax
	leaq	60(%rsp), %r12
	movq	%rax, 24(%rsp)
	leaq	48(%rsp), %rax
	leaq	56(%rsp), %rbp
	movq	%rax, 16(%rsp)
	leaq	44(%rsp), %rax
	movq	%rax, 8(%rsp)
	.p2align 4,,10
	.p2align 3
.L2:
	movq	8(%rsp), %rsi
	movq	24(%rsp), %rcx
	movq	%r12, %r9
	movq	%rbp, %r8
	movq	16(%rsp), %rdx
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	44(%rsp), %esi
	testl	%esi, %esi
	jne	.L46
	movl	48(%rsp), %r13d
	movl	52(%rsp), %eax
	orl	%r13d, %eax
	orl	56(%rsp), %eax
	orl	60(%rsp), %eax
	je	.L47
	movl	64(%rsp), %r10d
	movl	60(%rsp), %r9d
	xorl	%r11d, %r11d
	cmpl	%r9d, %r10d
	jne	.L13
.L26:
	movl	68(%rsp), %r10d
	movl	%esi, %r11d
	movl	$1, %esi
.L13:
	movl	56(%rsp), %edi
	movl	52(%rsp), %r14d
	subl	$1, %r11d
	xorl	%r15d, %r15d
	movl	$1, %r8d
	.p2align 4,,10
	.p2align 3
.L21:
	movl	%r13d, %eax
	imull	%r9d, %eax
	addl	%r14d, %eax
	cltd
	idivl	%edi
	movl	%edx, %ecx
	cmpl	%r11d, %esi
	jl	.L15
	cmpl	%edx, %r10d
	je	.L48
	addl	$1, %r8d
	cmpl	$10001, %r8d
	je	.L19
	movslq	%esi, %rsi
	movl	64(%rsp,%rsi,4), %r10d
	jmp	.L20
	.p2align 4,,10
	.p2align 3
.L50:
	addl	$1, %r8d
	cmpl	$10001, %r8d
	je	.L49
.L20:
	movl	%r13d, %eax
	movl	%edx, %r9d
	imull	%edx, %eax
	addl	%r14d, %eax
	cltd
	idivl	%edi
	cmpl	%r10d, %edx
	jne	.L50
.L22:
	movl	%r9d, 60(%rsp)
.L23:
	movl	%r8d, %edx
	leaq	.LC4(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L15:
	xorl	%eax, %eax
	cmpl	%edx, %r10d
	sete	%al
	addl	$1, %r8d
	addl	%eax, %esi
	cmpl	$10001, %r8d
	je	.L19
	movslq	%esi, %rax
	movl	%edx, %r9d
	movl	$1, %r15d
	movl	64(%rsp,%rax,4), %r10d
	jmp	.L21
	.p2align 4,,10
	.p2align 3
.L46:
	jle	.L44
	leaq	64(%rsp), %r13
	xorl	%r15d, %r15d
	leaq	.LC1(%rip), %r14
	movq	%r13, %rbx
	.p2align 4,,10
	.p2align 3
.L8:
	movq	%rbx, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addl	$1, %r15d
	call	__isoc99_scanf@PLT
	movl	44(%rsp), %r11d
	addq	$4, %rbx
	cmpl	%r15d, %r11d
	jg	.L8
	testl	%r11d, %r11d
	jle	.L28
	movl	56(%rsp), %edx
	leal	1(%r11), %ecx
	movl	$1, %eax
	jmp	.L12
	.p2align 4,,10
	.p2align 3
.L10:
	movl	%eax, %esi
	addq	$1, %rax
	cmpq	%rax, %rcx
	je	.L9
.L12:
	cmpl	%edx, -4(%r13,%rax,4)
	jl	.L10
.L44:
	leaq	.LC2(%rip), %rdi
	call	puts@PLT
	jmp	.L2
.L28:
	xorl	%esi, %esi
	.p2align 4,,10
	.p2align 3
.L9:
	cmpl	%esi, %r11d
	jne	.L44
	movl	64(%rsp), %r10d
	movl	60(%rsp), %r9d
	cmpl	%r9d, %r10d
	jne	.L29
	cmpl	$1, %r11d
	jne	.L51
	leaq	.LC3(%rip), %rdi
	call	puts@PLT
	jmp	.L2
.L49:
	movl	%edx, %ecx
.L19:
	leaq	.LC2(%rip), %rdi
	movl	%ecx, 60(%rsp)
	call	puts@PLT
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L48:
	testb	%r15b, %r15b
	je	.L23
	jmp	.L22
	.p2align 4,,10
	.p2align 3
.L29:
	movl	48(%rsp), %r13d
	xorl	%esi, %esi
	jmp	.L13
.L51:
	movl	48(%rsp), %r13d
	movl	%r11d, %esi
	jmp	.L26
.L47:
	movq	472(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L52
	addq	$488, %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
.L52:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.text
	.p2align 4
	.globl	makerand
	.type	makerand, @function
makerand:
.LFB24:
	.cfi_startproc
	endbr64
	imull	%ecx, %edi
	movl	%edx, %r9d
	leal	(%rdi,%rsi), %eax
	cltd
	idivl	%r9d
	movl	%edx, %eax
	ret
	.cfi_endproc
.LFE24:
	.size	makerand, .-makerand
	.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
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d %d %d %d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"-1"
.LC3:
	.string	"0"
.LC4:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	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	$488, %rsp
	.cfi_def_cfa_offset 544
	movq	%fs:40, %rax
	movq	%rax, 472(%rsp)
	xorl	%eax, %eax
	leaq	52(%rsp), %rax
	leaq	60(%rsp), %r12
	movq	%rax, 24(%rsp)
	leaq	48(%rsp), %rax
	leaq	56(%rsp), %rbp
	movq	%rax, 16(%rsp)
	leaq	44(%rsp), %rax
	movq	%rax, 8(%rsp)
	.p2align 4,,10
	.p2align 3
.L2:
	movq	8(%rsp), %rsi
	movq	24(%rsp), %rcx
	movq	%r12, %r9
	movq	%rbp, %r8
	movq	16(%rsp), %rdx
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	44(%rsp), %esi
	testl	%esi, %esi
	jne	.L46
	movl	48(%rsp), %r13d
	movl	52(%rsp), %eax
	orl	%r13d, %eax
	orl	56(%rsp), %eax
	orl	60(%rsp), %eax
	je	.L47
	movl	64(%rsp), %r10d
	movl	60(%rsp), %r9d
	xorl	%r11d, %r11d
	cmpl	%r9d, %r10d
	jne	.L13
.L26:
	movl	68(%rsp), %r10d
	movl	%esi, %r11d
	movl	$1, %esi
.L13:
	movl	56(%rsp), %edi
	movl	52(%rsp), %r14d
	subl	$1, %r11d
	xorl	%r15d, %r15d
	movl	$1, %r8d
	.p2align 4,,10
	.p2align 3
.L21:
	movl	%r13d, %eax
	imull	%r9d, %eax
	addl	%r14d, %eax
	cltd
	idivl	%edi
	movl	%edx, %ecx
	cmpl	%r11d, %esi
	jl	.L15
	cmpl	%edx, %r10d
	je	.L48
	addl	$1, %r8d
	cmpl	$10001, %r8d
	je	.L19
	movslq	%esi, %rsi
	movl	64(%rsp,%rsi,4), %r10d
	jmp	.L20
	.p2align 4,,10
	.p2align 3
.L50:
	addl	$1, %r8d
	cmpl	$10001, %r8d
	je	.L49
.L20:
	movl	%r13d, %eax
	movl	%edx, %r9d
	imull	%edx, %eax
	addl	%r14d, %eax
	cltd
	idivl	%edi
	cmpl	%r10d, %edx
	jne	.L50
.L22:
	movl	%r9d, 60(%rsp)
.L23:
	movl	%r8d, %edx
	leaq	.LC4(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L15:
	xorl	%eax, %eax
	cmpl	%edx, %r10d
	sete	%al
	addl	$1, %r8d
	addl	%eax, %esi
	cmpl	$10001, %r8d
	je	.L19
	movslq	%esi, %rax
	movl	%edx, %r9d
	movl	$1, %r15d
	movl	64(%rsp,%rax,4), %r10d
	jmp	.L21
	.p2align 4,,10
	.p2align 3
.L46:
	jle	.L44
	leaq	64(%rsp), %r13
	xorl	%r15d, %r15d
	leaq	.LC1(%rip), %r14
	movq	%r13, %rbx
	.p2align 4,,10
	.p2align 3
.L8:
	movq	%rbx, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addl	$1, %r15d
	call	__isoc99_scanf@PLT
	movl	44(%rsp), %r11d
	addq	$4, %rbx
	cmpl	%r15d, %r11d
	jg	.L8
	testl	%r11d, %r11d
	jle	.L28
	movl	56(%rsp), %edx
	leal	1(%r11), %ecx
	movl	$1, %eax
	jmp	.L12
	.p2align 4,,10
	.p2align 3
.L10:
	movl	%eax, %esi
	addq	$1, %rax
	cmpq	%rax, %rcx
	je	.L9
.L12:
	cmpl	%edx, -4(%r13,%rax,4)
	jl	.L10
.L44:
	leaq	.LC2(%rip), %rdi
	call	puts@PLT
	jmp	.L2
.L28:
	xorl	%esi, %esi
	.p2align 4,,10
	.p2align 3
.L9:
	cmpl	%esi, %r11d
	jne	.L44
	movl	64(%rsp), %r10d
	movl	60(%rsp), %r9d
	cmpl	%r9d, %r10d
	jne	.L29
	cmpl	$1, %r11d
	jne	.L51
	leaq	.LC3(%rip), %rdi
	call	puts@PLT
	jmp	.L2
.L49:
	movl	%edx, %ecx
.L19:
	leaq	.LC2(%rip), %rdi
	movl	%ecx, 60(%rsp)
	call	puts@PLT
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L48:
	testb	%r15b, %r15b
	je	.L23
	jmp	.L22
	.p2align 4,,10
	.p2align 3
.L29:
	movl	48(%rsp), %r13d
	xorl	%esi, %esi
	jmp	.L13
.L51:
	movl	48(%rsp), %r13d
	movl	%r11d, %esi
	jmp	.L26
.L47:
	movq	472(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L52
	addq	$488, %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
.L52:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.text
	.p2align 4
	.globl	makerand
	.type	makerand, @function
makerand:
.LFB24:
	.cfi_startproc
	endbr64
	imull	%ecx, %edi
	movl	%edx, %r9d
	leal	(%rdi,%rsi), %eax
	cltd
	idivl	%r9d
	movl	%edx, %eax
	ret
	.cfi_endproc
.LFE24:
	.size	makerand, .-makerand
	.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:

#include <stdio.h>
int makerand(int a, int b, int c, int x);
int main(void) {
    int num,a,b,c,rand,i,reel[100],sp;
    while (1) {
        scanf("%d %d %d %d %d",&num,&a,&b,&c,&rand);
        if (num==0&&a==0&&b==0&&c==0&&rand==0) break;
        for (i=0; i<num; i++) scanf("%d",&reel[i]);
        sp=0;
        for (i=0; i<num; i++) {
            if (reel[i]>=c) break;
        }
        if (i!=num) {
            printf("-1\n");
            continue;
        }
        if (rand==reel[0]) {
            sp++;
            if (sp==num) {
            	printf("0\n");
            	continue;
            }
            
        }
        for (i=1; i<=10000; i++) {
            if (sp>=num-1&&reel[sp]==makerand(a,b,c,rand)) break;
        	rand=makerand(a,b,c,rand);
            if (rand==reel[sp]) sp++;
        }
        if (i==10001) {
            printf("-1\n");
        } else {
            printf("%d\n",i);
        }
    }
    return 0;
}

int makerand(int a, int b, int c, int x) {
    return (a*x+b)%c;
}
1 5 7 11 10
10
2 5 7 11 10
2 4
2 1 1 256 0
128 255
2 0 0 1 0
1234 5678
2 1 1 100 0
99 98
2 1 1 100 0
99 99
2 1 1 10000 0
1 0
2 1 2 10000 0
2 1
0 0 0 0 0
 1 5 7 11 10
10
2 5 5 11 10
2 4
2 1 1 256 0
128 255
2 0 0 1 0
1234 5678
2 1 1 100 0
99 98
2 1 1 100 0
99 99
2 1 1 10000 0
1 0
3 1 2 10000 0
2 1
0 0 0 0 0
 1 5 7 11 10
10
2 5 5 11 10
2 4
2 1 0 256 0
128 255
2 0 0 1 0
1234 5678
2 1 1 100 0
99 98
2 1 1 100 0
99 99
2 1 1 10000 0
1 0
3 1 2 10000 0
2 1
0 0 0 0 0
 1 5 7 11 10
10
2 5 5 11 20
2 4
2 1 0 256 0
128 255
2 0 0 1 0
1751 5678
2 1 1 100 0
99 98
2 1 1 100 0
99 99
2 1 1 10000 0
1 0
3 1 1 10000 0
2 1
0 0 0 0 0
 1 5 7 11 10
10
2 5 7 11 10
2 4
2 1 1 256 0
128 255
2 0 0 1 0
1234 5678
2 1 1 100 0
99 98
2 1 1 100 0
99 99
2 1 2 10000 0
1 0
2 1 1 10000 0
2 1
0 0 0 0 0
 1 5 7 11 10
11
2 5 5 11 10
2 4
2 1 1 256 0
128 255
2 0 0 1 0
1234 5678
2 1 1 100 0
99 98
2 1 1 100 0
99 99
2 1 1 10000 0
1 0
3 1 2 10000 0
2 1
0 0 0 0 0
 1 5 7 11 10
20
2 5 5 11 10
2 4
2 1 0 256 0
128 255
2 0 0 1 0
1264 5678
2 1 1 100 0
99 98
2 1 1 100 0
99 99
2 1 1 10000 0
1 0
3 1 2 10000 0
2 1
0 0 0 0 0
 1 5 7 11 10
10
2 5 5 11 10
2 4
2 1 0 256 0
128 255
2 0 0 1 0
1751 5678
2 1 1 100 0
99 98
2 1 1 100 0
99 99
2 1 0 10000 0
1 0
3 1 1 10000 0
2 1
0 0 0 0 0
 1 5 7 11 10
10
2 5 3 11 10
2 4
2 1 1 256 0
128 255
2 0 0 1 0
1234 5678
2 1 1 100 0
99 98
2 1 1 100 0
99 99
2 1 2 10000 0
1 0
2 1 1 10000 0
2 1
0 0 0 0 0
 1 5 7 5 10
10
2 1 5 11 10
2 4
2 1 0 256 0
128 255
2 0 0 1 0
1234 5678
2 1 1 100 0
99 98
2 1 1 100 0
99 99
2 1 1 10000 0
1 0
3 1 2 10000 0
2 1
0 0 0 0 0

0
3
255
-1
198
199
10000
-1
 0
-1
255
-1
198
199
10000
-1
 0
-1
-1
-1
198
199
10000
-1
 0
3
-1
-1
198
199
10000
-1
 0
3
255
-1
198
199
-1
-1
 -1
-1
255
-1
198
199
10000
-1
 -1
-1
-1
-1
198
199
10000
-1
 0
-1
-1
-1
198
199
-1
-1
 0
-1
255
-1
198
199
-1
-1
 -1
12
-1
-1
198
199
10000
-1

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

```c
#include <stdio.h>
int makerand(int a, int b, int c, int x);
int main(void) {
    int num,a,b,c,rand,i,reel[100],sp;
    while (1) {
        scanf("%d %d %d %d %d",&num,&a,&b,&c,&rand);
        if (num==0&&a==0&&b==0&&c==0&&rand==0) break;
        for (i=0; i<num; i++) scanf("%d",&reel[i]);
        sp=0;
        for (i=0; i<num; i++) {
            if (reel[i]>=c) break;
        }
        if (i!=num) {
            printf("-1\n");
            continue;
        }
        if (rand==reel[0]) {
            sp++;
            if (sp==num) {
            	printf("0\n");
            	continue;
            }
            
        }
        for (i=1; i<=10000; i++) {
            if (sp>=num-1&&reel[sp]==makerand(a,b,c,rand)) break;
        	rand=makerand(a,b,c,rand);
            if (rand==reel[sp]) sp++;
        }
        if (i==10001) {
            printf("-1\n");
        } else {
            printf("%d\n",i);
        }
    }
    return 0;
}

int makerand(int a, int b, int c, int x) {
    return (a*x+b)%c;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d %d %d %d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"-1"
.LC3:
	.string	"0"
.LC4:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	subq	$456, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
.L19:
	leaq	-444(%rbp), %rdi
	leaq	-448(%rbp), %rsi
	leaq	-452(%rbp), %rcx
	leaq	-456(%rbp), %rdx
	leaq	-460(%rbp), %rax
	movq	%rdi, %r9
	movq	%rsi, %r8
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-460(%rbp), %eax
	testl	%eax, %eax
	jne	.L2
	movl	-456(%rbp), %eax
	testl	%eax, %eax
	jne	.L2
	movl	-452(%rbp), %eax
	testl	%eax, %eax
	jne	.L2
	movl	-448(%rbp), %eax
	testl	%eax, %eax
	jne	.L2
	movl	-444(%rbp), %eax
	testl	%eax, %eax
	je	.L23
.L2:
	movl	$0, -440(%rbp)
	jmp	.L4
.L5:
	leaq	-432(%rbp), %rdx
	movl	-440(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -440(%rbp)
.L4:
	movl	-460(%rbp), %eax
	cmpl	%eax, -440(%rbp)
	jl	.L5
	movl	$0, -436(%rbp)
	movl	$0, -440(%rbp)
	jmp	.L6
.L9:
	movl	-440(%rbp), %eax
	cltq
	movl	-432(%rbp,%rax,4), %edx
	movl	-448(%rbp), %eax
	cmpl	%eax, %edx
	jge	.L24
	addl	$1, -440(%rbp)
.L6:
	movl	-460(%rbp), %eax
	cmpl	%eax, -440(%rbp)
	jl	.L9
	jmp	.L8
.L24:
	nop
.L8:
	movl	-460(%rbp), %eax
	cmpl	%eax, -440(%rbp)
	je	.L10
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L11
.L10:
	movl	-432(%rbp), %edx
	movl	-444(%rbp), %eax
	cmpl	%eax, %edx
	jne	.L12
	addl	$1, -436(%rbp)
	movl	-460(%rbp), %eax
	cmpl	%eax, -436(%rbp)
	jne	.L12
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L11
.L12:
	movl	$1, -440(%rbp)
	jmp	.L13
.L17:
	movl	-460(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -436(%rbp)
	jl	.L14
	movl	-436(%rbp), %eax
	cltq
	movl	-432(%rbp,%rax,4), %ebx
	movl	-444(%rbp), %ecx
	movl	-448(%rbp), %edx
	movl	-452(%rbp), %esi
	movl	-456(%rbp), %eax
	movl	%eax, %edi
	call	makerand
	cmpl	%eax, %ebx
	je	.L25
.L14:
	movl	-444(%rbp), %ecx
	movl	-448(%rbp), %edx
	movl	-452(%rbp), %esi
	movl	-456(%rbp), %eax
	movl	%eax, %edi
	call	makerand
	movl	%eax, -444(%rbp)
	movl	-436(%rbp), %eax
	cltq
	movl	-432(%rbp,%rax,4), %edx
	movl	-444(%rbp), %eax
	cmpl	%eax, %edx
	jne	.L16
	addl	$1, -436(%rbp)
.L16:
	addl	$1, -440(%rbp)
.L13:
	cmpl	$10000, -440(%rbp)
	jle	.L17
	jmp	.L15
.L25:
	nop
.L15:
	cmpl	$10001, -440(%rbp)
	jne	.L18
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L19
.L18:
	movl	-440(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L11:
	jmp	.L19
.L23:
	nop
	movl	$0, %eax
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L21
	call	__stack_chk_fail@PLT
.L21:
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	makerand
	.type	makerand, @function
makerand:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	%edx, -12(%rbp)
	movl	%ecx, -16(%rbp)
	movl	-4(%rbp), %eax
	imull	-16(%rbp), %eax
	movl	%eax, %edx
	movl	-8(%rbp), %eax
	addl	%edx, %eax
	cltd
	idivl	-12(%rbp)
	movl	%edx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	makerand, .-makerand
	.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.
train
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d %d %d %d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"-1"
.LC3:
	.string	"0"
.LC4:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	subq	$456, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
.L19:
	leaq	-444(%rbp), %rdi
	leaq	-448(%rbp), %rsi
	leaq	-452(%rbp), %rcx
	leaq	-456(%rbp), %rdx
	leaq	-460(%rbp), %rax
	movq	%rdi, %r9
	movq	%rsi, %r8
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-460(%rbp), %eax
	testl	%eax, %eax
	jne	.L2
	movl	-456(%rbp), %eax
	testl	%eax, %eax
	jne	.L2
	movl	-452(%rbp), %eax
	testl	%eax, %eax
	jne	.L2
	movl	-448(%rbp), %eax
	testl	%eax, %eax
	jne	.L2
	movl	-444(%rbp), %eax
	testl	%eax, %eax
	je	.L23
.L2:
	movl	$0, -440(%rbp)
	jmp	.L4
.L5:
	leaq	-432(%rbp), %rdx
	movl	-440(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -440(%rbp)
.L4:
	movl	-460(%rbp), %eax
	cmpl	%eax, -440(%rbp)
	jl	.L5
	movl	$0, -436(%rbp)
	movl	$0, -440(%rbp)
	jmp	.L6
.L9:
	movl	-440(%rbp), %eax
	cltq
	movl	-432(%rbp,%rax,4), %edx
	movl	-448(%rbp), %eax
	cmpl	%eax, %edx
	jge	.L24
	addl	$1, -440(%rbp)
.L6:
	movl	-460(%rbp), %eax
	cmpl	%eax, -440(%rbp)
	jl	.L9
	jmp	.L8
.L24:
	nop
.L8:
	movl	-460(%rbp), %eax
	cmpl	%eax, -440(%rbp)
	je	.L10
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L11
.L10:
	movl	-432(%rbp), %edx
	movl	-444(%rbp), %eax
	cmpl	%eax, %edx
	jne	.L12
	addl	$1, -436(%rbp)
	movl	-460(%rbp), %eax
	cmpl	%eax, -436(%rbp)
	jne	.L12
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L11
.L12:
	movl	$1, -440(%rbp)
	jmp	.L13
.L17:
	movl	-460(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -436(%rbp)
	jl	.L14
	movl	-436(%rbp), %eax
	cltq
	movl	-432(%rbp,%rax,4), %ebx
	movl	-444(%rbp), %ecx
	movl	-448(%rbp), %edx
	movl	-452(%rbp), %esi
	movl	-456(%rbp), %eax
	movl	%eax, %edi
	call	makerand
	cmpl	%eax, %ebx
	je	.L25
.L14:
	movl	-444(%rbp), %ecx
	movl	-448(%rbp), %edx
	movl	-452(%rbp), %esi
	movl	-456(%rbp), %eax
	movl	%eax, %edi
	call	makerand
	movl	%eax, -444(%rbp)
	movl	-436(%rbp), %eax
	cltq
	movl	-432(%rbp,%rax,4), %edx
	movl	-444(%rbp), %eax
	cmpl	%eax, %edx
	jne	.L16
	addl	$1, -436(%rbp)
.L16:
	addl	$1, -440(%rbp)
.L13:
	cmpl	$10000, -440(%rbp)
	jle	.L17
	jmp	.L15
.L25:
	nop
.L15:
	cmpl	$10001, -440(%rbp)
	jne	.L18
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L19
.L18:
	movl	-440(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L11:
	jmp	.L19
.L23:
	nop
	movl	$0, %eax
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L21
	call	__stack_chk_fail@PLT
.L21:
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	makerand
	.type	makerand, @function
makerand:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	%edx, -12(%rbp)
	movl	%ecx, -16(%rbp)
	movl	-4(%rbp), %eax
	imull	-16(%rbp), %eax
	movl	%eax, %edx
	movl	-8(%rbp), %eax
	addl	%edx, %eax
	cltd
	idivl	-12(%rbp)
	movl	%edx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	makerand, .-makerand
	.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:
