#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, long *);
int main(void) {
  long int mod, a, c, seed, counter;
  printf("Enter the modulus value: ");
  scanf("%ld", &mod);
  printf("Enter the multiplier value: ");
  scanf("%ld", &a);
  printf("Enter the increment value: ");
  scanf("%ld", &c);
  printf("Enter the seed value: ");
  scanf("%ld", &seed);
  while (counter < 10) {
    seed = (a * seed + c) % mod;
    printf("%ld \n", seed);
    counter++;
  }
  printf("%ld", (a * seed + c) % mod);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed6(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb8(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9a(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7c(%rip),%rdi
lea    -0x28(%rbp),%rsi
call   1040 <scanf@plt>
cmpq   $0xa,-0x30(%rbp)
jge    11ec <main+0xcc>
mov    -0x18(%rbp),%rax
imul   -0x28(%rbp),%rax
add    -0x20(%rbp),%rax
cqto
idivq  -0x10(%rbp)
mov    %rdx,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    11a7 <main+0x87>
mov    -0x18(%rbp),%rax
imul   -0x28(%rbp),%rax
add    -0x20(%rbp),%rax
cqto
idivq  -0x10(%rbp)
mov    %rdx,%rsi
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xed4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee0(%rip),%rbx
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0xed0(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0xed2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0xed3(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
mov    (%rsp),%rax
imul   0x10(%rsp),%rax
add    0x8(%rsp),%rax
mov    0x18(%rsp),%rcx
mov    %rax,%rdx
or     %rcx,%rdx
shr    $0x20,%rdx
je     11bd <main+0x9d>
cqto
idiv   %rcx
jmp    11c1 <main+0xa1>
xor    %edx,%edx
div    %ecx
lea    0xe52(%rip),%rdi
mov    %rdx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Enter the modulus value: \00"
@.str.1 = [4 x i8] c"%ld\00"
@.str.2 = [29 x i8] c"Enter the multiplier value: \00"
@.str.3 = [28 x i8] c"Enter the increment value: \00"
@.str.4 = [23 x i8] c"Enter the seed value: \00"
@.str.5 = [6 x i8] c"%ld \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %2)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %3)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %4)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %5)
br label %15
15: ; preds = %18, %0
%16 = load i64, i64* %6
%17 = icmp slt i64 %16, 10
br i1 %17, label %18, label %30
18: ; preds = %15
%19 = load i64, i64* %3
%20 = load i64, i64* %5
%21 = mul nsw i64 %19, %20
%22 = load i64, i64* %4
%23 = add nsw i64 %21, %22
%24 = load i64, i64* %2
%25 = srem i64 %23, %24
store i64 %25, i64* %5
%26 = load i64, i64* %5
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i64 %26)
%28 = load i64, i64* %6
%29 = add nsw i64 %28, 1
store i64 %29, i64* %6
br label %15
30: ; preds = %15
%31 = load i64, i64* %3
%32 = load i64, i64* %5
%33 = mul nsw i64 %31, %32
%34 = load i64, i64* %4
%35 = add nsw i64 %33, %34
%36 = load i64, i64* %2
%37 = srem i64 %35, %36
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %37)
ret i32 0
}

LLVM IR (-O2):
@.str = [26 x i8] c"Enter the modulus value: \00"
@.str.1 = [4 x i8] c"%ld\00"
@.str.2 = [29 x i8] c"Enter the multiplier value: \00"
@.str.3 = [28 x i8] c"Enter the increment value: \00"
@.str.4 = [23 x i8] c"Enter the seed value: \00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = bitcast i64* %1 to i8*
%6 = bitcast i64* %2 to i8*
%7 = bitcast i64* %3 to i8*
%8 = bitcast i64* %4 to i8*
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %1)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %2)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %3)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %4)
%17 = load i64, i64* %2
%18 = load i64, i64* %4
%19 = mul nsw i64 %18, %17
%20 = load i64, i64* %3
%21 = add nsw i64 %19, %20
%22 = load i64, i64* %1
%23 = srem i64 %21, %22
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %23)
ret i32 0
}