#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 nextInt();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ random(long);
int main(int argc, char **argv) {
  long seed = 1234567890L;
  random(seed);
  int expected[] = {782593066, 746941499,  577072204, 541420637,  639986798,
                    604335231, 1004891264, 969239697, 1067805858, 1032154291};
  int i;
  printf("Validating nextInt() against known results from DTFRandom.\n");
  for (i = 0; i < 10; i++) {
    int result = nextInt();
    if (result != expected[i]) {
      printf("nextInt() with seed %ld, did not return %d, got %d instead", seed,
             expected[i], result);
      return -1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x499602d2,-0x18(%rbp)
49
mov    -0x18(%rbp),%rdi
call   1050 <random@plt>
lea    -0x40(%rbp),%rdi
lea    0xe8e(%rip),%rsi
mov    $0x28,%edx
call   1040 <memcpy@plt>
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x44(%rbp)
cmpl   $0xa,-0x44(%rbp)
jge    11f2 <main+0xb2>
mov    $0x0,%al
call   1060 <nextInt@plt>
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%eax
movslq -0x44(%rbp),%rcx
cmp    -0x40(%rbp,%rcx,4),%eax
je     11df <main+0x9f>
mov    -0x18(%rbp),%rsi
movslq -0x44(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%edx
mov    -0x48(%rbp),%ecx
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f9 <main+0xb9>
jmp    11e4 <main+0xa4>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1191 <main+0x51>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x499602d2,%edi
call   1050 <random@plt>
lea    0xee9(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1060 <nextInt@plt>
cmp    $0x2ea56c2a,%eax
jne    11f4 <main+0xb4>
xor    %eax,%eax
call   1060 <nextInt@plt>
cmp    $0x2c856c3b,%eax
jne    11fb <main+0xbb>
xor    %eax,%eax
call   1060 <nextInt@plt>
cmp    $0x22656c4c,%eax
jne    1202 <main+0xc2>
xor    %eax,%eax
call   1060 <nextInt@plt>
cmp    $0x20456c5d,%eax
jne    1209 <main+0xc9>
xor    %eax,%eax
call   1060 <nextInt@plt>
cmp    $0x26256c6e,%eax
jne    1210 <main+0xd0>
xor    %eax,%eax
call   1060 <nextInt@plt>
cmp    $0x24056c7f,%eax
jne    1217 <main+0xd7>
xor    %eax,%eax
call   1060 <nextInt@plt>
cmp    $0x3be56c80,%eax
jne    121e <main+0xde>
xor    %eax,%eax
call   1060 <nextInt@plt>
cmp    $0x39c56c91,%eax
jne    1225 <main+0xe5>
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <nextInt@plt>
cmp    $0x3fa56ca2,%eax
jne    122c <main+0xec>
xor    %eax,%eax
call   1060 <nextInt@plt>
cmp    $0x3d856cb3,%eax
je     124b <main+0x10b>
mov    $0x3d856cb3,%edx
jmp    1231 <main+0xf1>
mov    $0x2ea56c2a,%edx
jmp    1231 <main+0xf1>
mov    $0x2c856c3b,%edx
jmp    1231 <main+0xf1>
mov    $0x22656c4c,%edx
jmp    1231 <main+0xf1>
mov    $0x20456c5d,%edx
jmp    1231 <main+0xf1>
mov    $0x26256c6e,%edx
jmp    1231 <main+0xf1>
mov    $0x24056c7f,%edx
jmp    1231 <main+0xf1>
mov    $0x3be56c80,%edx
jmp    1231 <main+0xf1>
mov    $0x39c56c91,%edx
jmp    1231 <main+0xf1>
mov    $0x3fa56ca2,%edx
lea    0xdc8(%rip),%rdi
mov    $0x499602d2,%esi
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.expected = [10 x i32] [i32 782593066, i32 746941499, i32 577072204, i32 541420637, i32 639986798, i32 604335231, i32 1004891264, i32 969239697, i32 1067805858, i32 1032154291]
@.str = [60 x i8] c"Validating nextInt() against known results from DTFRandom.\0A\00"
@.str.1 = [59 x i8] c"nextInt() with seed %ld, did not return %d, got %d instead\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca [10 x i32]
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 1234567890, i64* %6
%10 = load i64, i64* %6
%11 = call i32 @random(i64 %10)
%12 = bitcast [10 x i32]* %7 to i8*
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %8
br label %14
14: ; preds = %34, %2
%15 = load i32, i32* %8
%16 = icmp slt i32 %15, 10
br i1 %16, label %17, label %37
17: ; preds = %14
%18 = call i32 (...) @nextInt()
store i32 %18, i32* %9
%19 = load i32, i32* %9
%20 = load i32, i32* %8
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [10 x i32], [10 x i32]* %7, i64 0, i64 %21
%23 = load i32, i32* %22
%24 = icmp ne i32 %19, %23
br i1 %24, label %25, label %33
25: ; preds = %17
%26 = load i64, i64* %6
%27 = load i32, i32* %8
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [10 x i32], [10 x i32]* %7, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = load i32, i32* %9
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.1, i64 0, i64 0), i64 %26, i32 %30, i32 %31)
store i32 -1, i32* %3
br label %38
33: ; preds = %17
br label %34
34: ; preds = %33
%35 = load i32, i32* %8
%36 = add nsw i32 %35, 1
store i32 %36, i32* %8
br label %14
37: ; preds = %14
store i32 0, i32* %3
br label %38
38: ; preds = %37, %25
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@.str.1 = [59 x i8] c"nextInt() with seed %ld, did not return %d, got %d instead\00"
@str = [59 x i8] c"Validating nextInt() against known results from DTFRandom.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @random(i64 1234567890)
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 (...) @nextInt()
%6 = icmp eq i32 %5, 782593066
br i1 %6, label %7, label %34
7: ; preds = %2
%8 = tail call i32 (...) @nextInt()
%9 = icmp eq i32 %8, 746941499
br i1 %9, label %10, label %34
10: ; preds = %7
%11 = tail call i32 (...) @nextInt()
%12 = icmp eq i32 %11, 577072204
br i1 %12, label %13, label %34
13: ; preds = %10
%14 = tail call i32 (...) @nextInt()
%15 = icmp eq i32 %14, 541420637
br i1 %15, label %16, label %34
16: ; preds = %13
%17 = tail call i32 (...) @nextInt()
%18 = icmp eq i32 %17, 639986798
br i1 %18, label %19, label %34
19: ; preds = %16
%20 = tail call i32 (...) @nextInt()
%21 = icmp eq i32 %20, 604335231
br i1 %21, label %22, label %34
22: ; preds = %19
%23 = tail call i32 (...) @nextInt()
%24 = icmp eq i32 %23, 1004891264
br i1 %24, label %25, label %34
25: ; preds = %22
%26 = tail call i32 (...) @nextInt()
%27 = icmp eq i32 %26, 969239697
br i1 %27, label %28, label %34
28: ; preds = %25
%29 = tail call i32 (...) @nextInt()
%30 = icmp eq i32 %29, 1067805858
br i1 %30, label %31, label %34
31: ; preds = %28
%32 = tail call i32 (...) @nextInt()
%33 = icmp eq i32 %32, 1032154291
br i1 %33, label %38, label %34
34: ; preds = %31, %28, %25, %22, %19, %16, %13, %10, %7, %2
%35 = phi i32 [ %5, %2 ], [ %8, %7 ], [ %11, %10 ], [ %14, %13 ], [ %17, %16 ], [ %20, %19 ], [ %23, %22 ], [ %26, %25 ], [ %29, %28 ], [ %32, %31 ]
%36 = phi i32 [ 782593066, %2 ], [ 746941499, %7 ], [ 577072204, %10 ], [ 541420637, %13 ], [ 639986798, %16 ], [ 604335231, %19 ], [ 1004891264, %22 ], [ 969239697, %25 ], [ 1067805858, %28 ], [ 1032154291, %31 ]
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str.1, i64 0, i64 0), i64 1234567890, i32 %36, i32 %35)
br label %38
38: ; preds = %31, %34
%39 = phi i32 [ -1, %34 ], [ 0, %31 ]
ret i32 %39
}