#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*/ puts(char *);
int rand1();
int scanf(char *, unsigned int *);
int /*<<< orphan*/ srand1(unsigned int);
int main(void) {
  int count;
  unsigned seed;
  printf("Enter your seed: ");
  while (scanf("%ul", &seed) == 1) {
    srand1(seed);
    for (count = 0; count < 5; count++) {
      printf("%d\n", rand1());
    }
    printf("Enter your seed: ");
  }
  puts("done");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe9e(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1070 <scanf@plt>
cmp    $0x1,%eax
jne    11d7 <main+0x87>
mov    -0xc(%rbp),%edi
call   1060 <srand1@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    11c4 <main+0x74>
mov    $0x0,%al
call   1030 <rand1@plt>
mov    %eax,%esi
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1195 <main+0x45>
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    116d <main+0x1d>
lea    0xe3c(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xea1(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xea5(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
cmp    $0x1,%eax
jne    1226 <main+0xd6>
lea    0xe8f(%rip),%rbx
lea    0xe72(%rip),%r14
lea    0xe7d(%rip),%r15
lea    0x4(%rsp),%r12
nopw   0x0(%rax,%rax,1)
mov    0x4(%rsp),%edi
call   1060 <srand1@plt>
xor    %eax,%eax
call   1030 <rand1@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1030 <rand1@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1030 <rand1@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1030 <rand1@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1030 <rand1@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <scanf@plt>
cmp    $0x1,%eax
je     11a0 <main+0x50>
lea    0xded(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Enter your seed: \00"
@.str.1 = [4 x i8] c"%ul\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [5 x i8] c"done\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %20, %0
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %22
8: ; preds = %5
%9 = load i32, i32* %3
%10 = call i32 @srand1(i32 %9)
store i32 0, i32* %2
br label %11
11: ; preds = %17, %8
%12 = load i32, i32* %2
%13 = icmp slt i32 %12, 5
br i1 %13, label %14, label %20
14: ; preds = %11
%15 = call i32 (...) @rand1()
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %15)
br label %17
17: ; preds = %14
%18 = load i32, i32* %2
%19 = add nsw i32 %18, 1
store i32 %19, i32* %2
br label %11
20: ; preds = %11
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %5
22: ; preds = %5
%23 = call i32 @puts(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"Enter your seed: \00"
@.str.1 = [4 x i8] c"%ul\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [5 x i8] c"done\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %22
6: ; preds = %0, %6
%7 = load i32, i32* %1
%8 = call i32 @srand1(i32 %7)
%9 = call i32 (...) @rand1()
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = call i32 (...) @rand1()
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%13 = call i32 (...) @rand1()
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %13)
%15 = call i32 (...) @rand1()
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = call i32 (...) @rand1()
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %17)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%21 = icmp eq i32 %20, 1
br i1 %21, label %6, label %22
22: ; preds = %6, %0
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}