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>
#include <math.h>
#include <string.h>
#include <stdbool.h>

#define ln "\n"
#define reps(i,a,b) for(int (i)=(a); (i)<(b); ++(i))
#define rep(i,n) for(int (i)=0; (i)<(n); ++(i))
#define repst(i,a,b) for(int (i)=(a); (i)<=(b); ++(i))
#define rept(i,n) for(int (i)=0; (i)<=(n); ++(i))
#define reprt(i,a,b) for(int (i)=(a); (i)>=(b); --(i))
#define repr(i,n) for(int (i)=(n); (i)>=0; --(i))
#define repn(i,a,b,n) for(int (i)=(a); (i)<(b); (i)+=(n))
#define repnt(i,a,b,n) for(int (i)=(a); (i)<=(b); (i)+=(n))
#define PI M_PI

typedef long double ld;
typedef long long ll;

const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;
const double EPS = 1e-9;

/*********TEMPLATE**********/

int main() {

  int i,j,N,A,B,C,X,Y[110];
  while(1) {
    scanf("%d %d %d %d %d",&N, &A, &B, &C, &X);
    //printf("%d %d %d %d %d\n",N,A,B,C,X);
    if (N==0 && A==0 && B==0 && C==0 && X==0) break;
    rep(i,N) scanf("%d", &Y[i]);
    //rep(i,N) printf("%d ", Y[i]);
    //printf(ln);

    // jは現在のリールの位置
    j=0;

    for (i=0; i<10001; i++) {
      // 合致したら、リールを右に
      if (X==Y[j]) {
        j++;
      }

      // 次のXを求める
      X = (A * X + B) % C;

      // すべてのりーるがおわったら
      if (j>=N) break;
    }
    if (i<=10000) printf("%d\n",i);
    else printf("-1\n");
  }

  /*
  0
  3
  255
  -1
  198
  199
  10000
  -1
  */

  return 0;

}

```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d %d %d %d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
.LC3:
	.string	"-1"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB51:
	.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
	leaq	.LC1(%rip), %rbx
	subq	$504, %rsp
	.cfi_def_cfa_offset 560
	movq	%fs:40, %rax
	movq	%rax, 488(%rsp)
	xorl	%eax, %eax
	leaq	32(%rsp), %rax
	leaq	44(%rsp), %r15
	movq	%rax, 8(%rsp)
	leaq	28(%rsp), %rax
	leaq	40(%rsp), %r14
	movq	%rax, (%rsp)
	leaq	36(%rsp), %r13
	.p2align 4,,10
	.p2align 3
.L2:
	movq	(%rsp), %rsi
	movq	8(%rsp), %rdx
	movq	%r15, %r9
	movq	%r14, %r8
	movq	%r13, %rcx
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %esi
	testl	%esi, %esi
	jne	.L22
	movl	32(%rsp), %r9d
	movl	36(%rsp), %r10d
	movl	40(%rsp), %edi
	movl	44(%rsp), %edx
	movl	%r9d, %eax
	orl	%r10d, %eax
	orl	%edi, %eax
	orl	%edx, %eax
	je	.L23
.L7:
	xorl	%ecx, %ecx
	xorl	%r8d, %r8d
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L25:
	addl	$1, %r8d
	cmpl	$10001, %r8d
	je	.L24
.L11:
	movslq	%ecx, %rax
	cmpl	%edx, 48(%rsp,%rax,4)
	jne	.L9
	addl	$1, %ecx
.L9:
	imull	%r9d, %edx
	leal	(%rdx,%r10), %eax
	cltd
	idivl	%edi
	cmpl	%esi, %ecx
	jl	.L25
	movl	%edx, 44(%rsp)
	leaq	.LC2(%rip), %rsi
	movl	%r8d, %edx
	xorl	%eax, %eax
	movl	$1, %edi
	call	__printf_chk@PLT
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L22:
	jle	.L17
	leaq	48(%rsp), %r12
	xorl	%ebp, %ebp
	.p2align 4,,10
	.p2align 3
.L8:
	movq	%r12, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	addl	$1, %ebp
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %esi
	addq	$4, %r12
	cmpl	%ebp, %esi
	jg	.L8
.L17:
	movl	32(%rsp), %r9d
	movl	36(%rsp), %r10d
	movl	40(%rsp), %edi
	movl	44(%rsp), %edx
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L24:
	leaq	.LC3(%rip), %rdi
	movl	%edx, 44(%rsp)
	call	puts@PLT
	jmp	.L2
.L23:
	movq	488(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L26
	addq	$504, %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
.L26:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE51:
	.size	main, .-main
	.globl	EPS
	.section	.rodata
	.align 8
	.type	EPS, @object
	.size	EPS, 8
EPS:
	.long	-400107883
	.long	1041313291
	.globl	INFF
	.align 8
	.type	INFF, @object
	.size	INFF, 8
INFF:
	.quad	1000000000000000000
	.globl	INF
	.align 4
	.type	INF, @object
	.size	INF, 4
INF:
	.long	1000000000
	.globl	MOD
	.align 4
	.type	MOD, @object
	.size	MOD, 4
MOD:
	.long	1000000007
	.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 %d %d %d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
.LC3:
	.string	"-1"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB51:
	.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
	leaq	.LC1(%rip), %rbx
	subq	$504, %rsp
	.cfi_def_cfa_offset 560
	movq	%fs:40, %rax
	movq	%rax, 488(%rsp)
	xorl	%eax, %eax
	leaq	32(%rsp), %rax
	leaq	44(%rsp), %r15
	movq	%rax, 8(%rsp)
	leaq	28(%rsp), %rax
	leaq	40(%rsp), %r14
	movq	%rax, (%rsp)
	leaq	36(%rsp), %r13
	.p2align 4,,10
	.p2align 3
.L2:
	movq	(%rsp), %rsi
	movq	8(%rsp), %rdx
	movq	%r15, %r9
	movq	%r14, %r8
	movq	%r13, %rcx
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %esi
	testl	%esi, %esi
	jne	.L22
	movl	32(%rsp), %r9d
	movl	36(%rsp), %r10d
	movl	40(%rsp), %edi
	movl	44(%rsp), %edx
	movl	%r9d, %eax
	orl	%r10d, %eax
	orl	%edi, %eax
	orl	%edx, %eax
	je	.L23
.L7:
	xorl	%ecx, %ecx
	xorl	%r8d, %r8d
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L25:
	addl	$1, %r8d
	cmpl	$10001, %r8d
	je	.L24
.L11:
	movslq	%ecx, %rax
	cmpl	%edx, 48(%rsp,%rax,4)
	jne	.L9
	addl	$1, %ecx
.L9:
	imull	%r9d, %edx
	leal	(%rdx,%r10), %eax
	cltd
	idivl	%edi
	cmpl	%esi, %ecx
	jl	.L25
	movl	%edx, 44(%rsp)
	leaq	.LC2(%rip), %rsi
	movl	%r8d, %edx
	xorl	%eax, %eax
	movl	$1, %edi
	call	__printf_chk@PLT
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L22:
	jle	.L17
	leaq	48(%rsp), %r12
	xorl	%ebp, %ebp
	.p2align 4,,10
	.p2align 3
.L8:
	movq	%r12, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	addl	$1, %ebp
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %esi
	addq	$4, %r12
	cmpl	%ebp, %esi
	jg	.L8
.L17:
	movl	32(%rsp), %r9d
	movl	36(%rsp), %r10d
	movl	40(%rsp), %edi
	movl	44(%rsp), %edx
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L24:
	leaq	.LC3(%rip), %rdi
	movl	%edx, 44(%rsp)
	call	puts@PLT
	jmp	.L2
.L23:
	movq	488(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L26
	addq	$504, %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
.L26:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE51:
	.size	main, .-main
	.globl	EPS
	.section	.rodata
	.align 8
	.type	EPS, @object
	.size	EPS, 8
EPS:
	.long	-400107883
	.long	1041313291
	.globl	INFF
	.align 8
	.type	INFF, @object
	.size	INFF, 8
INFF:
	.quad	1000000000000000000
	.globl	INF
	.align 4
	.type	INF, @object
	.size	INF, 4
INF:
	.long	1000000000
	.globl	MOD
	.align 4
	.type	MOD, @object
	.size	MOD, 4
MOD:
	.long	1000000007
	.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 %d %d %d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
.LC3:
	.string	"-1"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB51:
	.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
	leaq	.LC1(%rip), %rbx
	subq	$504, %rsp
	.cfi_def_cfa_offset 560
	movq	%fs:40, %rax
	movq	%rax, 488(%rsp)
	xorl	%eax, %eax
	leaq	32(%rsp), %rax
	leaq	44(%rsp), %r15
	movq	%rax, 8(%rsp)
	leaq	28(%rsp), %rax
	leaq	40(%rsp), %r14
	movq	%rax, (%rsp)
	leaq	36(%rsp), %r13
	.p2align 4,,10
	.p2align 3
.L2:
	movq	(%rsp), %rsi
	movq	8(%rsp), %rdx
	movq	%r15, %r9
	movq	%r14, %r8
	movq	%r13, %rcx
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %esi
	testl	%esi, %esi
	jne	.L22
	movl	32(%rsp), %r9d
	movl	36(%rsp), %r10d
	movl	40(%rsp), %edi
	movl	44(%rsp), %edx
	movl	%r9d, %eax
	orl	%r10d, %eax
	orl	%edi, %eax
	orl	%edx, %eax
	je	.L23
.L7:
	xorl	%ecx, %ecx
	xorl	%r8d, %r8d
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L25:
	addl	$1, %r8d
	cmpl	$10001, %r8d
	je	.L24
.L11:
	movslq	%ecx, %rax
	cmpl	%edx, 48(%rsp,%rax,4)
	jne	.L9
	addl	$1, %ecx
.L9:
	imull	%r9d, %edx
	leal	(%rdx,%r10), %eax
	cltd
	idivl	%edi
	cmpl	%esi, %ecx
	jl	.L25
	movl	%edx, 44(%rsp)
	leaq	.LC2(%rip), %rsi
	movl	%r8d, %edx
	xorl	%eax, %eax
	movl	$1, %edi
	call	__printf_chk@PLT
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L22:
	jle	.L17
	leaq	48(%rsp), %r12
	xorl	%ebp, %ebp
	.p2align 4,,10
	.p2align 3
.L8:
	movq	%r12, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	addl	$1, %ebp
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %esi
	addq	$4, %r12
	cmpl	%ebp, %esi
	jg	.L8
.L17:
	movl	32(%rsp), %r9d
	movl	36(%rsp), %r10d
	movl	40(%rsp), %edi
	movl	44(%rsp), %edx
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L24:
	leaq	.LC3(%rip), %rdi
	movl	%edx, 44(%rsp)
	call	puts@PLT
	jmp	.L2
.L23:
	movq	488(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L26
	addq	$504, %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
.L26:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE51:
	.size	main, .-main
	.globl	EPS
	.section	.rodata
	.align 8
	.type	EPS, @object
	.size	EPS, 8
EPS:
	.long	-400107883
	.long	1041313291
	.globl	INFF
	.align 8
	.type	INFF, @object
	.size	INFF, 8
INFF:
	.quad	1000000000000000000
	.globl	INF
	.align 4
	.type	INF, @object
	.size	INF, 4
INF:
	.long	1000000000
	.globl	MOD
	.align 4
	.type	MOD, @object
	.size	MOD, 4
MOD:
	.long	1000000007
	.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>
#include <math.h>
#include <string.h>
#include <stdbool.h>

#define ln "\n"
#define reps(i,a,b) for(int (i)=(a); (i)<(b); ++(i))
#define rep(i,n) for(int (i)=0; (i)<(n); ++(i))
#define repst(i,a,b) for(int (i)=(a); (i)<=(b); ++(i))
#define rept(i,n) for(int (i)=0; (i)<=(n); ++(i))
#define reprt(i,a,b) for(int (i)=(a); (i)>=(b); --(i))
#define repr(i,n) for(int (i)=(n); (i)>=0; --(i))
#define repn(i,a,b,n) for(int (i)=(a); (i)<(b); (i)+=(n))
#define repnt(i,a,b,n) for(int (i)=(a); (i)<=(b); (i)+=(n))
#define PI M_PI

typedef long double ld;
typedef long long ll;

const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;
const double EPS = 1e-9;

/*********TEMPLATE**********/

int main() {

  int i,j,N,A,B,C,X,Y[110];
  while(1) {
    scanf("%d %d %d %d %d",&N, &A, &B, &C, &X);
    //printf("%d %d %d %d %d\n",N,A,B,C,X);
    if (N==0 && A==0 && B==0 && C==0 && X==0) break;
    rep(i,N) scanf("%d", &Y[i]);
    //rep(i,N) printf("%d ", Y[i]);
    //printf(ln);

    // jは現在のリールの位置
    j=0;

    for (i=0; i<10001; i++) {
      // 合致したら、リールを右に
      if (X==Y[j]) {
        j++;
      }

      // 次のXを求める
      X = (A * X + B) % C;

      // すべてのりーるがおわったら
      if (j>=N) break;
    }
    if (i<=10000) printf("%d\n",i);
    else printf("-1\n");
  }

  /*
  0
  3
  255
  -1
  198
  199
  10000
  -1
  */

  return 0;

}

```
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>
#include <math.h>
#include <string.h>
#include <stdbool.h>

#define ln "\n"
#define reps(i,a,b) for(int (i)=(a); (i)<(b); ++(i))
#define rep(i,n) for(int (i)=0; (i)<(n); ++(i))
#define repst(i,a,b) for(int (i)=(a); (i)<=(b); ++(i))
#define rept(i,n) for(int (i)=0; (i)<=(n); ++(i))
#define reprt(i,a,b) for(int (i)=(a); (i)>=(b); --(i))
#define repr(i,n) for(int (i)=(n); (i)>=0; --(i))
#define repn(i,a,b,n) for(int (i)=(a); (i)<(b); (i)+=(n))
#define repnt(i,a,b,n) for(int (i)=(a); (i)<=(b); (i)+=(n))
#define PI M_PI

typedef long double ld;
typedef long long ll;

const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;
const double EPS = 1e-9;

/*********TEMPLATE**********/

int main() {

  int i,j,N,A,B,C,X,Y[110];
  while(1) {
    scanf("%d %d %d %d %d",&N, &A, &B, &C, &X);
    //printf("%d %d %d %d %d\n",N,A,B,C,X);
    if (N==0 && A==0 && B==0 && C==0 && X==0) break;
    rep(i,N) scanf("%d", &Y[i]);
    //rep(i,N) printf("%d ", Y[i]);
    //printf(ln);

    // jは現在のリールの位置
    j=0;

    for (i=0; i<10001; i++) {
      // 合致したら、リールを右に
      if (X==Y[j]) {
        j++;
      }

      // 次のXを求める
      X = (A * X + B) % C;

      // すべてのりーるがおわったら
      if (j>=N) break;
    }
    if (i<=10000) printf("%d\n",i);
    else printf("-1\n");
  }

  /*
  0
  3
  255
  -1
  198
  199
  10000
  -1
  */

  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:

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

0
3
255
-1
198
199
10000
-1

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>
#include <math.h>
#include <string.h>
#include <stdbool.h>

#define ln "\n"
#define reps(i,a,b) for(int (i)=(a); (i)<(b); ++(i))
#define rep(i,n) for(int (i)=0; (i)<(n); ++(i))
#define repst(i,a,b) for(int (i)=(a); (i)<=(b); ++(i))
#define rept(i,n) for(int (i)=0; (i)<=(n); ++(i))
#define reprt(i,a,b) for(int (i)=(a); (i)>=(b); --(i))
#define repr(i,n) for(int (i)=(n); (i)>=0; --(i))
#define repn(i,a,b,n) for(int (i)=(a); (i)<(b); (i)+=(n))
#define repnt(i,a,b,n) for(int (i)=(a); (i)<=(b); (i)+=(n))
#define PI M_PI

typedef long double ld;
typedef long long ll;

const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;
const double EPS = 1e-9;

/*********TEMPLATE**********/

int main() {

  int i,j,N,A,B,C,X,Y[110];
  while(1) {
    scanf("%d %d %d %d %d",&N, &A, &B, &C, &X);
    //printf("%d %d %d %d %d\n",N,A,B,C,X);
    if (N==0 && A==0 && B==0 && C==0 && X==0) break;
    rep(i,N) scanf("%d", &Y[i]);
    //rep(i,N) printf("%d ", Y[i]);
    //printf(ln);

    // jは現在のリールの位置
    j=0;

    for (i=0; i<10001; i++) {
      // 合致したら、リールを右に
      if (X==Y[j]) {
        j++;
      }

      // 次のXを求める
      X = (A * X + B) % C;

      // すべてのりーるがおわったら
      if (j>=N) break;
    }
    if (i<=10000) printf("%d\n",i);
    else printf("-1\n");
  }

  /*
  0
  3
  255
  -1
  198
  199
  10000
  -1
  */

  return 0;

}

```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d %d %d %d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
.LC3:
	.string	"-1"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB51:
	.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
	leaq	.LC1(%rip), %rbx
	subq	$504, %rsp
	.cfi_def_cfa_offset 560
	movq	%fs:40, %rax
	movq	%rax, 488(%rsp)
	xorl	%eax, %eax
	leaq	32(%rsp), %rax
	leaq	44(%rsp), %r15
	movq	%rax, 8(%rsp)
	leaq	28(%rsp), %rax
	leaq	40(%rsp), %r14
	movq	%rax, (%rsp)
	leaq	36(%rsp), %r13
	.p2align 4,,10
	.p2align 3
.L2:
	movq	(%rsp), %rsi
	movq	8(%rsp), %rdx
	movq	%r15, %r9
	movq	%r14, %r8
	movq	%r13, %rcx
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %esi
	testl	%esi, %esi
	jne	.L22
	movl	32(%rsp), %r9d
	movl	36(%rsp), %r10d
	movl	40(%rsp), %edi
	movl	44(%rsp), %edx
	movl	%r9d, %eax
	orl	%r10d, %eax
	orl	%edi, %eax
	orl	%edx, %eax
	je	.L23
.L7:
	xorl	%ecx, %ecx
	xorl	%r8d, %r8d
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L25:
	addl	$1, %r8d
	cmpl	$10001, %r8d
	je	.L24
.L11:
	movslq	%ecx, %rax
	cmpl	%edx, 48(%rsp,%rax,4)
	jne	.L9
	addl	$1, %ecx
.L9:
	imull	%r9d, %edx
	leal	(%rdx,%r10), %eax
	cltd
	idivl	%edi
	cmpl	%esi, %ecx
	jl	.L25
	movl	%edx, 44(%rsp)
	leaq	.LC2(%rip), %rsi
	movl	%r8d, %edx
	xorl	%eax, %eax
	movl	$1, %edi
	call	__printf_chk@PLT
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L22:
	jle	.L17
	leaq	48(%rsp), %r12
	xorl	%ebp, %ebp
	.p2align 4,,10
	.p2align 3
.L8:
	movq	%r12, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	addl	$1, %ebp
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %esi
	addq	$4, %r12
	cmpl	%ebp, %esi
	jg	.L8
.L17:
	movl	32(%rsp), %r9d
	movl	36(%rsp), %r10d
	movl	40(%rsp), %edi
	movl	44(%rsp), %edx
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L24:
	leaq	.LC3(%rip), %rdi
	movl	%edx, 44(%rsp)
	call	puts@PLT
	jmp	.L2
.L23:
	movq	488(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L26
	addq	$504, %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
.L26:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE51:
	.size	main, .-main
	.globl	EPS
	.section	.rodata
	.align 8
	.type	EPS, @object
	.size	EPS, 8
EPS:
	.long	-400107883
	.long	1041313291
	.globl	INFF
	.align 8
	.type	INFF, @object
	.size	INFF, 8
INFF:
	.quad	1000000000000000000
	.globl	INF
	.align 4
	.type	INF, @object
	.size	INF, 4
INF:
	.long	1000000000
	.globl	MOD
	.align 4
	.type	MOD, @object
	.size	MOD, 4
MOD:
	.long	1000000007
	.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 %d %d %d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
.LC3:
	.string	"-1"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB51:
	.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
	leaq	.LC1(%rip), %rbx
	subq	$504, %rsp
	.cfi_def_cfa_offset 560
	movq	%fs:40, %rax
	movq	%rax, 488(%rsp)
	xorl	%eax, %eax
	leaq	32(%rsp), %rax
	leaq	44(%rsp), %r15
	movq	%rax, 8(%rsp)
	leaq	28(%rsp), %rax
	leaq	40(%rsp), %r14
	movq	%rax, (%rsp)
	leaq	36(%rsp), %r13
	.p2align 4,,10
	.p2align 3
.L2:
	movq	(%rsp), %rsi
	movq	8(%rsp), %rdx
	movq	%r15, %r9
	movq	%r14, %r8
	movq	%r13, %rcx
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %esi
	testl	%esi, %esi
	jne	.L22
	movl	32(%rsp), %r9d
	movl	36(%rsp), %r10d
	movl	40(%rsp), %edi
	movl	44(%rsp), %edx
	movl	%r9d, %eax
	orl	%r10d, %eax
	orl	%edi, %eax
	orl	%edx, %eax
	je	.L23
.L7:
	xorl	%ecx, %ecx
	xorl	%r8d, %r8d
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L25:
	addl	$1, %r8d
	cmpl	$10001, %r8d
	je	.L24
.L11:
	movslq	%ecx, %rax
	cmpl	%edx, 48(%rsp,%rax,4)
	jne	.L9
	addl	$1, %ecx
.L9:
	imull	%r9d, %edx
	leal	(%rdx,%r10), %eax
	cltd
	idivl	%edi
	cmpl	%esi, %ecx
	jl	.L25
	movl	%edx, 44(%rsp)
	leaq	.LC2(%rip), %rsi
	movl	%r8d, %edx
	xorl	%eax, %eax
	movl	$1, %edi
	call	__printf_chk@PLT
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L22:
	jle	.L17
	leaq	48(%rsp), %r12
	xorl	%ebp, %ebp
	.p2align 4,,10
	.p2align 3
.L8:
	movq	%r12, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	addl	$1, %ebp
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %esi
	addq	$4, %r12
	cmpl	%ebp, %esi
	jg	.L8
.L17:
	movl	32(%rsp), %r9d
	movl	36(%rsp), %r10d
	movl	40(%rsp), %edi
	movl	44(%rsp), %edx
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L24:
	leaq	.LC3(%rip), %rdi
	movl	%edx, 44(%rsp)
	call	puts@PLT
	jmp	.L2
.L23:
	movq	488(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L26
	addq	$504, %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
.L26:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE51:
	.size	main, .-main
	.globl	EPS
	.section	.rodata
	.align 8
	.type	EPS, @object
	.size	EPS, 8
EPS:
	.long	-400107883
	.long	1041313291
	.globl	INFF
	.align 8
	.type	INFF, @object
	.size	INFF, 8
INFF:
	.quad	1000000000000000000
	.globl	INF
	.align 4
	.type	INF, @object
	.size	INF, 4
INF:
	.long	1000000000
	.globl	MOD
	.align 4
	.type	MOD, @object
	.size	MOD, 4
MOD:
	.long	1000000007
	.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:
```