#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 EXIT_FAILURE;
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ freopen(int /*<<< orphan*/ *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ fwrite(long *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, long);
long random();
int /*<<< orphan*/ srandom(unsigned int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strncmp(char const *, char *, int);
unsigned int strtol(char const *, int /*<<< orphan*/ *, int /*<<< orphan*/);
int main(int argc, const char *argv[]) {
  unsigned int i = 0, n = 0;
  unsigned int seed = 0x16372789;
  long int r = 0;
  int is_binary = 0;
  if (argc < 2) {
    fprintf(stderr, "Usage: %s [-b]  <number of ints> [random seed]\n",
            argv[0]);
    fprintf(stderr, "with -b option output will be binary\n");
    return EXIT_FAILURE;
  }
  if (argc > 2) {
    if (!strncmp(argv[1], "-b", 3)) {
      is_binary = 1;
      argv++;
      argc--;
    }
  }
  errno = 0;
  n = strtol(argv[1], NULL, 0);
  if (errno) {
    perror("strtol");
    return EXIT_FAILURE;
  }
  if (argc == 3) {
    errno = 0;
    seed = strtol(argv[2], NULL, 0);
    if (errno) {
      perror("strtol");
      return EXIT_FAILURE;
    }
  }
  if (is_binary)
    freopen(NULL, "wb", stdout);
  srandom(seed);
  while (n--) {
    r = random();
    if (is_binary)
      fwrite(&r, sizeof(int), 1, stdout);
    else
      printf("%d\n", r);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x16372789,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    121a <main+0x8a>
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe15(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2de7(%rip),%rax
mov    (%rax),%edi
lea    0xe2e(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2dc0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    13ab <main+0x21b>
cmpl   $0x2,-0x8(%rbp)
jle    1267 <main+0xd7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe23(%rip),%rsi
mov    $0x3,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    1262 <main+0xd2>
movl   $0x1,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1267 <main+0xd7>
mov    0x2d6a(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1080 <strtol@plt>
mov    %eax,-0x18(%rbp)
mov    0x2d46(%rip),%rax
cmpq   $0x0,(%rax)
je     12b9 <main+0x129>
lea    0xdb6(%rip),%rdi
call   10a0 <perror@plt>
mov    0x2d21(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    13ab <main+0x21b>
cmpl   $0x3,-0x8(%rbp)
jne    131a <main+0x18a>
mov    0x2d0e(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1080 <strtol@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2cea(%rip),%rax
cmpq   $0x0,(%rax)
je     1315 <main+0x185>
lea    0xd5a(%rip),%rdi
call   10a0 <perror@plt>
mov    0x2cc5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    13ab <main+0x21b>
jmp    131a <main+0x18a>
cmpl   $0x0,-0x2c(%rbp)
je     133d <main+0x1ad>
mov    0x2c9d(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%edi
lea    0xd28(%rip),%rsi
call   1060 <freopen@plt>
mov    -0x1c(%rbp),%edi
call   1030 <srandom@plt>
mov    -0x18(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x18(%rbp)
cmp    $0x0,%eax
je     13a4 <main+0x214>
mov    $0x0,%al
call   1090 <random@plt>
mov    %rax,-0x28(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     138f <main+0x1ff>
mov    0x2c53(%rip),%rax
mov    (%rax),%ecx
lea    -0x28(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   10b0 <fwrite@plt>
jmp    139f <main+0x20f>
mov    -0x28(%rbp),%rsi
lea    0xcc9(%rip),%rdi
call   1050 <printf@plt>
jmp    1345 <main+0x1b5>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
movq   $0x0,(%rsp)
cmp    $0x1,%edi
jg     11e3 <main+0x53>
mov    0x2e2e(%rip),%rbx
mov    (%rbx),%edi
mov    (%r14),%rdx
lea    0xe42(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe62(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x2df4(%rip),%rax
mov    (%rax),%eax
jmp    12ee <main+0x15e>
mov    %edi,%r12d
mov    $0x1,%bpl
cmp    $0x2,%edi
jne    11f6 <main+0x66>
mov    $0x2,%r12d
jmp    1219 <main+0x89>
mov    0x8(%r14),%rdi
lea    0xe55(%rip),%rsi
mov    $0x3,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
jne    1219 <main+0x89>
add    $0x8,%r14
add    $0xffffffff,%r12d
xor    %ebp,%ebp
mov    0x2db8(%rip),%r13
movq   $0x0,0x0(%r13)
mov    0x8(%r14),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1080 <strtol@plt>
cmpq   $0x0,0x0(%r13)
jne    12fd <main+0x16d>
mov    %eax,%ebx
mov    $0x16372789,%r15d
cmp    $0x3,%r12d
jne    1271 <main+0xe1>
movq   $0x0,0x0(%r13)
mov    0x10(%r14),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1080 <strtol@plt>
cmpq   $0x0,0x0(%r13)
jne    12fd <main+0x16d>
mov    %eax,%r15d
test   %bpl,%bpl
jne    128d <main+0xfd>
mov    0x2d4b(%rip),%rax
mov    (%rax),%edx
lea    0xdda(%rip),%rsi
xor    %edi,%edi
call   1060 <freopen@plt>
mov    %r15d,%edi
call   1030 <srandom@plt>
test   %ebx,%ebx
je     12ec <main+0x15c>
lea    0xdc3(%rip),%r14
mov    0x2d21(%rip),%r12
mov    %rsp,%r15
jmp    12bf <main+0x12f>
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
test   %ebx,%ebx
je     12ec <main+0x15c>
add    $0xffffffff,%ebx
xor    %eax,%eax
call   1090 <random@plt>
mov    %rax,(%rsp)
test   %bpl,%bpl
jne    12b0 <main+0x120>
mov    (%r12),%ecx
mov    %r15,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   10b0 <fwrite@plt>
test   %ebx,%ebx
jne    12bf <main+0x12f>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd55(%rip),%rdi
call   10a0 <perror@plt>
jmp    11d5 <main+0x45>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [48 x i8] c"Usage: %s [-b] <number of ints> [random seed]\0A\00"
@.str.1 = [38 x i8] c"with -b option output will be binary\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [3 x i8] c"-b\00"
@errno = global i64 0
@.str.3 = [7 x i8] c"strtol\00"
@.str.4 = [3 x i8] c"wb\00"
@stdout = global i32 0
@.str.5 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i64
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 372713353, i32* %8
store i64 0, i64* %9
store i32 0, i32* %10
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 2
br i1 %12, label %13, label %22
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = load i32, i32* @stderr
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
%21 = load i32, i32* @EXIT_FAILURE
store i32 %21, i32* %3
br label %86
22: ; preds = %2
%23 = load i32, i32* %4
%24 = icmp sgt i32 %23, 2
br i1 %24, label %25, label %37
25: ; preds = %22
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32 @strncmp(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 3)
%30 = icmp ne i32 %29, 0
br i1 %30, label %36, label %31
31: ; preds = %25
store i32 1, i32* %10
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i32 1
store i8** %33, i8*** %5
%34 = load i32, i32* %4
%35 = add nsw i32 %34, -1
store i32 %35, i32* %4
br label %36
36: ; preds = %31, %25
br label %37
37: ; preds = %36, %22
store i64 0, i64* @errno
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 1
%40 = load i8*, i8** %39
%41 = call i32 @strtol(i8* %40, i32* null, i32 0)
store i32 %41, i32* %7
%42 = load i64, i64* @errno
%43 = icmp ne i64 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %37
%45 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%46 = load i32, i32* @EXIT_FAILURE
store i32 %46, i32* %3
br label %86
47: ; preds = %37
%48 = load i32, i32* %4
%49 = icmp eq i32 %48, 3
br i1 %49, label %50, label %61
50: ; preds = %47
store i64 0, i64* @errno
%51 = load i8**, i8*** %5
%52 = getelementptr inbounds i8*, i8** %51, i64 2
%53 = load i8*, i8** %52
%54 = call i32 @strtol(i8* %53, i32* null, i32 0)
store i32 %54, i32* %8
%55 = load i64, i64* @errno
%56 = icmp ne i64 %55, 0
br i1 %56, label %57, label %60
57: ; preds = %50
%58 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%59 = load i32, i32* @EXIT_FAILURE
store i32 %59, i32* %3
br label %86
60: ; preds = %50
br label %61
61: ; preds = %60, %47
%62 = load i32, i32* %10
%63 = icmp ne i32 %62, 0
br i1 %63, label %64, label %67
64: ; preds = %61
%65 = load i32, i32* @stdout
%66 = call i32 @freopen(i32* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %65)
br label %67
67: ; preds = %64, %61
%68 = load i32, i32* %8
%69 = call i32 @srandom(i32 %68)
br label %70
70: ; preds = %84, %67
%71 = load i32, i32* %7
%72 = add i32 %71, -1
store i32 %72, i32* %7
%73 = icmp ne i32 %71, 0
br i1 %73, label %74, label %85
74: ; preds = %70
%75 = call i64 (...) @random()
store i64 %75, i64* %9
%76 = load i32, i32* %10
%77 = icmp ne i32 %76, 0
br i1 %77, label %78, label %81
78: ; preds = %74
%79 = load i32, i32* @stdout
%80 = call i32 @fwrite(i64* %9, i32 4, i32 1, i32 %79)
br label %84
81: ; preds = %74
%82 = load i64, i64* %9
%83 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i64 %82)
br label %84
84: ; preds = %81, %78
br label %70
85: ; preds = %70
store i32 0, i32* %3
br label %86
86: ; preds = %85, %57, %44, %13
%87 = load i32, i32* %3
ret i32 %87
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [48 x i8] c"Usage: %s [-b] <number of ints> [random seed]\0A\00"
@.str.1 = [38 x i8] c"with -b option output will be binary\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [3 x i8] c"-b\00"
@errno = global i64 0
@.str.3 = [7 x i8] c"strtol\00"
@.str.4 = [3 x i8] c"wb\00"
@stdout = global i32 0
@.str.5 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %13
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i32, i32* @stderr
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
br label %64
13: ; preds = %2
%14 = icmp eq i32 %0, 2
br i1 %14, label %22, label %15
15: ; preds = %13
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = tail call i32 @strncmp(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 3)
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %15
%21 = add nsw i32 %0, -1
br label %22
22: ; preds = %15, %20, %13
%23 = phi i32 [ %0, %15 ], [ %21, %20 ], [ 2, %13 ]
%24 = phi i8** [ %1, %15 ], [ %16, %20 ], [ %1, %13 ]
%25 = phi i1 [ true, %15 ], [ false, %20 ], [ true, %13 ]
store i64 0, i64* @errno
%26 = getelementptr inbounds i8*, i8** %24, i64 1
%27 = load i8*, i8** %26
%28 = tail call i32 @strtol(i8* nocapture %27, i32* null, i32 0)
%29 = load i64, i64* @errno
%30 = icmp eq i64 %29, 0
br i1 %30, label %34, label %31
31: ; preds = %22
%32 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%33 = load i32, i32* @EXIT_FAILURE
br label %64
34: ; preds = %22
%35 = icmp eq i32 %23, 3
br i1 %35, label %36, label %45
36: ; preds = %34
store i64 0, i64* @errno
%37 = getelementptr inbounds i8*, i8** %24, i64 2
%38 = load i8*, i8** %37
%39 = tail call i32 @strtol(i8* nocapture %38, i32* null, i32 0)
%40 = load i64, i64* @errno
%41 = icmp eq i64 %40, 0
br i1 %41, label %45, label %42
42: ; preds = %36
%43 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%44 = load i32, i32* @EXIT_FAILURE
br label %64
45: ; preds = %36, %34
%46 = phi i32 [ %39, %36 ], [ 372713353, %34 ]
br i1 %25, label %50, label %47
47: ; preds = %45
%48 = load i32, i32* @stdout
%49 = tail call i32 @freopen(i32* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %48)
br label %50
50: ; preds = %47, %45
%51 = tail call i32 @srandom(i32 %46)
%52 = icmp eq i32 %28, 0
br i1 %52, label %64, label %53
53: ; preds = %50, %62
%54 = phi i32 [ %55, %62 ], [ %28, %50 ]
%55 = add i32 %54, -1
%56 = call i64 (...) @random()
store i64 %56, i64* %3
br i1 %25, label %60, label %57
57: ; preds = %53
%58 = load i32, i32* @stdout
%59 = call i32 @fwrite(i64* %3, i32 4, i32 1, i32 %58)
br label %62
60: ; preds = %53
%61 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i64 %56)
br label %62
62: ; preds = %60, %57
%63 = icmp eq i32 %55, 0
br i1 %63, label %64, label %53
64: ; preds = %62, %50, %42, %31, %6
%65 = phi i32 [ %12, %6 ], [ %33, %31 ], [ %44, %42 ], [ 0, %50 ], [ 0, %62 ]
ret i32 %65
}