#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 */
struct timespec {
  unsigned int tv_sec;
  unsigned int tv_nsec;
};

/* Variables and functions */
int /*<<< orphan*/ CLOCK_REALTIME;
int /*<<< orphan*/ abort();
scalar_t__ clock_gettime(int /*<<< orphan*/, struct timespec *);
int /*<<< orphan*/ leak_test();
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, unsigned int);
int /*<<< orphan*/ random_create_test();
int /*<<< orphan*/ rigged_create_test();
int /*<<< orphan*/ save_load_test();
int /*<<< orphan*/ srandom(unsigned int);
unsigned int strtoul(char *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ test_mult();
int /*<<< orphan*/ test_prune();
int main(int argc, char *argv[]) {
  struct timespec t;
  unsigned int seed;
  int i;
  if (argc > 1) {
    seed = strtoul(argv[1], NULL, 10);
  } else {
    if (clock_gettime(CLOCK_REALTIME, &t)) {
      perror("clock_gettime");
      abort();
    }
    seed = t.tv_sec + t.tv_nsec;
  }
  printf("Seed: %u\n", seed);
  srandom(seed);
  leak_test();
  rigged_create_test();
  for (i = 0; i < 4; i++)
    random_create_test();
  save_load_test();
  test_mult();
  test_prune();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11fe <main+0x3e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   10d0 <strtoul@plt>
mov    %eax,-0x1c(%rbp)
jmp    1236 <main+0x76>
mov    0x2ddb(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
call   1060 <clock_gettime@plt>
cmp    $0x0,%rax
je     122d <main+0x6d>
lea    0xddf(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x18(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xdce(%rip),%rdi
call   1080 <printf@plt>
mov    -0x1c(%rbp),%edi
call   1040 <srandom@plt>
mov    $0x0,%al
call   10e0 <leak_test@plt>
mov    $0x0,%al
call   10b0 <rigged_create_test@plt>
movl   $0x0,-0x20(%rbp)
cmpl   $0x4,-0x20(%rbp)
jge    1281 <main+0xc1>
mov    $0x0,%al
call   1090 <random_create_test@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1262 <main+0xa2>
mov    $0x0,%al
call   1070 <save_load_test@plt>
mov    $0x0,%al
call   10a0 <test_mult@plt>
mov    $0x0,%al
call   1050 <test_prune@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
cmp    $0x2,%edi
jl     11de <main+0x1e>
mov    0x8(%rsi),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   10d0 <strtoul@plt>
mov    %eax,%ebx
jmp    11fe <main+0x3e>
mov    0x2dfb(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
call   1060 <clock_gettime@plt>
test   %rax,%rax
jne    125a <main+0x9a>
mov    0xc(%rsp),%ebx
add    0x8(%rsp),%ebx
lea    0xe09(%rip),%rdi
mov    %ebx,%esi
call   1080 <printf@plt>
mov    %ebx,%edi
call   1040 <srandom@plt>
xor    %eax,%eax
call   10e0 <leak_test@plt>
xor    %eax,%eax
call   10b0 <rigged_create_test@plt>
xor    %eax,%eax
call   1090 <random_create_test@plt>
xor    %eax,%eax
call   1090 <random_create_test@plt>
xor    %eax,%eax
call   1090 <random_create_test@plt>
xor    %eax,%eax
call   1090 <random_create_test@plt>
xor    %eax,%eax
call   1070 <save_load_test@plt>
xor    %eax,%eax
call   10a0 <test_mult@plt>
xor    %eax,%eax
call   1050 <test_prune@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xd9f(%rip),%rdi
call   10c0 <perror@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
%struct.timespec = type { i32, i32 }
@CLOCK_REALTIME = global i32 0
@.str = [14 x i8] c"clock_gettime\00"
@.str.1 = [10 x i8] c"Seed: %u\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.timespec
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp sgt i32 %9, 1
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @strtoul(i8* %14, i32* null, i32 10)
store i32 %15, i32* %7
br label %29
16: ; preds = %2
%17 = load i32, i32* @CLOCK_REALTIME
%18 = call i64 @clock_gettime(i32 %17, %struct.timespec* %6)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %16
%21 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%22 = call i32 (...) @abort()
unreachable
23: ; preds = %16
%24 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i32 0, i32 0
%25 = load i32, i32* %24
%26 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i32 0, i32 1
%27 = load i32, i32* %26
%28 = add i32 %25, %27
store i32 %28, i32* %7
br label %29
29: ; preds = %23, %11
%30 = load i32, i32* %7
%31 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %7
%33 = call i32 @srandom(i32 %32)
%34 = call i32 (...) @leak_test()
%35 = call i32 (...) @rigged_create_test()
store i32 0, i32* %8
br label %36
36: ; preds = %41, %29
%37 = load i32, i32* %8
%38 = icmp slt i32 %37, 4
br i1 %38, label %39, label %44
39: ; preds = %36
%40 = call i32 (...) @random_create_test()
br label %41
41: ; preds = %39
%42 = load i32, i32* %8
%43 = add nsw i32 %42, 1
store i32 %43, i32* %8
br label %36
44: ; preds = %36
%45 = call i32 (...) @save_load_test()
%46 = call i32 (...) @test_mult()
%47 = call i32 (...) @test_prune()
ret i32 0
}

LLVM IR (-O2):
%struct.timespec = type { i32, i32 }
@CLOCK_REALTIME = global i32 0
@.str = [14 x i8] c"clock_gettime\00"
@.str.1 = [10 x i8] c"Seed: %u\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.timespec
%4 = bitcast %struct.timespec* %3 to i8*
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @strtoul(i8* nocapture %8, i32* null, i32 10)
br label %23
10: ; preds = %2
%11 = load i32, i32* @CLOCK_REALTIME
%12 = call i64 @clock_gettime(i32 %11, %struct.timespec* %3)
%13 = icmp eq i64 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %10
%15 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%16 = call i32 (...) @abort()
unreachable
17: ; preds = %10
%18 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i64 0, i32 0
%19 = load i32, i32* %18
%20 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i64 0, i32 1
%21 = load i32, i32* %20
%22 = add i32 %21, %19
br label %23
23: ; preds = %17, %6
%24 = phi i32 [ %9, %6 ], [ %22, %17 ]
%25 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %24)
%26 = call i32 @srandom(i32 %24)
%27 = call i32 (...) @leak_test()
%28 = call i32 (...) @rigged_create_test()
%29 = call i32 (...) @random_create_test()
%30 = call i32 (...) @random_create_test()
%31 = call i32 (...) @random_create_test()
%32 = call i32 (...) @random_create_test()
%33 = call i32 (...) @save_load_test()
%34 = call i32 (...) @test_mult()
%35 = call i32 (...) @test_prune()
ret i32 0
}