#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 atoi(char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ testPrintError(char *);
int testPrngValue(int);
int do_random_tests(int nArg, char **azArg) {
  int i;
  int nRand;
  if (nArg == 0) {
    nRand = 10;
  } else if (nArg == 1) {
    nRand = atoi(azArg[0]);
  } else {
    testPrintError("Usage: random ?N?\n");
    return -1;
  }
  for (i = 0; i < nRand; i++) {
    printf("0x%x\n", testPrngValue(i));
  }
  return 0;
}


x86 assembly (clang, -O0):
<do_random_tests>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1165 <do_random_tests+0x25>
movl   $0xa,-0x18(%rbp)
jmp    11a0 <do_random_tests+0x60>
cmpl   $0x1,-0x8(%rbp)
jne    1183 <do_random_tests+0x43>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x18(%rbp)
jmp    119b <do_random_tests+0x5b>
lea    0xe76(%rip),%rdi
call   1050 <testPrintError@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11de <do_random_tests+0x9e>
jmp    11a0 <do_random_tests+0x60>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11d7 <do_random_tests+0x97>
mov    -0x14(%rbp),%edi
call   1030 <testPrngValue@plt>
mov    %eax,%esi
lea    0xe4f(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a7 <do_random_tests+0x67>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_random_tests>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %edi,%edi
je     1163 <do_random_tests+0x23>
cmp    $0x1,%edi
jne    119a <do_random_tests+0x5a>
mov    (%rsi),%rdi
call   1060 <atoi@plt>
mov    %eax,%ebx
test   %eax,%eax
jg     1168 <do_random_tests+0x28>
xor    %r14d,%r14d
jmp    11ac <do_random_tests+0x6c>
mov    $0xa,%ebx
xor    %r14d,%r14d
lea    0xea1(%rip),%r15
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebp,%edi
call   1030 <testPrngValue@plt>
mov    %r15,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    %ebp,%ebx
jne    1180 <do_random_tests+0x40>
jmp    11ac <do_random_tests+0x6c>
lea    0xe5f(%rip),%rdi
call   1050 <testPrintError@plt>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Usage: random ?N?\0A\00"
@.str.1 = [6 x i8] c"0x%x\0A\00"
define i32 @do_random_tests(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 10, i32* %7
br label %22
11: ; preds = %2
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %19
14: ; preds = %11
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 @atoi(i8* %17)
store i32 %18, i32* %7
br label %21
19: ; preds = %11
%20 = call i32 @testPrintError(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %35
21: ; preds = %14
br label %22
22: ; preds = %21, %10
store i32 0, i32* %6
br label %23
23: ; preds = %31, %22
%24 = load i32, i32* %6
%25 = load i32, i32* %7
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %34
27: ; preds = %23
%28 = load i32, i32* %6
%29 = call i32 @testPrngValue(i32 %28)
%30 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %29)
br label %31
31: ; preds = %27
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 1
store i32 %33, i32* %6
br label %23
34: ; preds = %23
store i32 0, i32* %3
br label %35
35: ; preds = %34, %19
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
@.str = [19 x i8] c"Usage: random ?N?\0A\00"
@.str.1 = [6 x i8] c"0x%x\0A\00"
define i32 @do_random_tests(i32 %0, i8** nocapture %1) {
switch i32 %0, label %3 [
i32 0, label %9
i32 1, label %5
]
3: ; preds = %2
%4 = tail call i32 @testPrintError(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %17
5: ; preds = %2
%6 = load i8*, i8** %1
%7 = tail call i32 @atoi(i8* %6)
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %17
9: ; preds = %2, %5
%10 = phi i32 [ %7, %5 ], [ 10, %2 ]
br label %11
11: ; preds = %9, %11
%12 = phi i32 [ %15, %11 ], [ 0, %9 ]
%13 = tail call i32 @testPrngValue(i32 %12)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = add nuw nsw i32 %12, 1
%16 = icmp eq i32 %15, %10
br i1 %16, label %17, label %11
17: ; preds = %11, %5, %3
%18 = phi i32 [ -1, %3 ], [ 0, %5 ], [ 0, %11 ]
ret i32 %18
}