#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;
int EXIT_SUCCESS;
int INT_MAX;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int my_get_random(int, int);
int /*<<< orphan*/ my_seed_random();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  int iRC;
  int i;
  int min;
  int max;
  int random_value;
  bool max_hit;
  bool min_hit;
  iRC = EXIT_SUCCESS;
  if (argc != 1) {
    fprintf(stderr, "Usage: %s \n", argv[0]);
    iRC = EXIT_FAILURE;
    exit(iRC);
  }
  if (INT_MAX < 500000) {
    printf("INT_MAX is %d\n", INT_MAX);
    iRC = EXIT_FAILURE;
    exit(iRC);
  }
  my_seed_random();
  min = 10;
  max = 500;
  for (i = 0; i < 10000; i++) {
    random_value = my_get_random(min, max);
    if (random_value < min) {
      printf(
          "ERROR: random number too small. Min is %d. Routine generated %d\n",
          min, random_value);
      iRC = EXIT_FAILURE;
      exit(iRC);
    }
    if (random_value > max) {
      printf(
          "ERROR: random number too large. Max is %d. Routine generated %d\n",
          max, random_value);
      iRC = EXIT_FAILURE;
      exit(iRC);
    }
  }
  min = 3;
  max = 5;
  max_hit = false;
  min_hit = false;
  for (i = 0; i < 100; i++) {
    random_value = my_get_random(min, max);
    if (random_value == min) {
      min_hit = true;
    }
    if (random_value == max) {
      max_hit = true;
    }
  }
  if (max_hit && min_hit) {
    printf("PASS: random number generated our endpoints.\n");
  } else {
    printf("ERROR: random number never generated our endpoints.\n");
    iRC = EXIT_FAILURE;
    exit(iRC);
  }
  printf("PASS: random number generator works.\n");
  exit(iRC);
}


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)
mov    0x2e5b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x8(%rbp)
je     11ac <main+0x5c>
mov    0x2e55(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe6d(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e31(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1060 <exit@plt>
mov    0x2e35(%rip),%rax
cmpl   $0x7a120,(%rax)
jge    11ea <main+0x9a>
mov    0x2e22(%rip),%rax
mov    (%rax),%esi
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2df3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1060 <exit@plt>
mov    $0x0,%al
call   1070 <my_seed_random@plt>
movl   $0xa,-0x1c(%rbp)
movl   $0x1f4,-0x20(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x2710,-0x18(%rbp)
jge    129c <main+0x14c>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1050 <my_get_random@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1255 <main+0x105>
mov    -0x1c(%rbp),%esi
mov    -0x24(%rbp),%edx
lea    0xde1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2d88(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1060 <exit@plt>
mov    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
jle    1289 <main+0x139>
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2d54(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1060 <exit@plt>
jmp    128e <main+0x13e>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1206 <main+0xb6>
movl   $0x3,-0x1c(%rbp)
movl   $0x5,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x64,-0x18(%rbp)
jge    1310 <main+0x1c0>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1050 <my_get_random@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jne    12ea <main+0x19a>
movl   $0x1,-0x2c(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
jne    12fd <main+0x1ad>
movl   $0x1,-0x28(%rbp)
jmp    1302 <main+0x1b2>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    12bf <main+0x16f>
cmpl   $0x0,-0x28(%rbp)
je     1337 <main+0x1e7>
cmpl   $0x0,-0x2c(%rbp)
je     1337 <main+0x1e7>
lea    0xd72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1359 <main+0x209>
lea    0xd8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2c84(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1060 <exit@plt>
lea    0xda0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    $0x1,%edi
jne    1191 <main+0x31>
mov    0x2e74(%rip),%rax
mov    (%rax),%esi
cmp    $0x7a11f,%esi
jg     11ae <main+0x4e>
lea    0xe87(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    127c <main+0x11c>
mov    0x2e40(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xe5c(%rip),%rsi
call   1050 <fprintf@plt>
jmp    127c <main+0x11c>
mov    0x2e13(%rip),%rax
mov    (%rax),%r14d
xor    %eax,%eax
call   1080 <my_seed_random@plt>
mov    $0x2710,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0xa,%edi
mov    $0x1f4,%esi
call   1060 <my_get_random@plt>
cmp    $0x9,%eax
jle    124b <main+0xeb>
cmp    $0x1f5,%eax
jae    1259 <main+0xf9>
add    $0xffffffff,%ebx
jne    11d0 <main+0x70>
xor    %r12d,%r12d
mov    $0x64,%ebx
mov    $0x1,%r15d
xor    %ebp,%ebp
mov    $0x3,%edi
mov    $0x5,%esi
call   1060 <my_get_random@plt>
cmp    $0x3,%eax
cmove  %r15d,%r12d
cmp    $0x5,%eax
cmove  %r15d,%ebp
add    $0xffffffff,%ebx
jne    1200 <main+0xa0>
test   %ebp,%ebp
je     1270 <main+0x110>
test   %r12d,%r12d
je     1270 <main+0x110>
lea    0xe9f(%rip),%rdi
call   1030 <puts@plt>
lea    0xec0(%rip),%rdi
call   1030 <puts@plt>
mov    %r14d,%edi
call   1070 <exit@plt>
lea    0xdc9(%rip),%rdi
mov    $0xa,%esi
jmp    1265 <main+0x105>
lea    0xdfc(%rip),%rdi
mov    $0x1f4,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    127c <main+0x11c>
lea    0xe26(%rip),%rdi
call   1030 <puts@plt>
mov    0x2d4d(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@EXIT_SUCCESS = global i32 0
@stderr = global i32 0
@.str = [12 x i8] c"Usage: %s \0A\00"
@EXIT_FAILURE = global i32 0
@INT_MAX = global i32 0
@.str.1 = [15 x i8] c"INT_MAX is %d\0A\00"
@.str.2 = [65 x i8] c"ERROR: random number too small. Min is %d. Routine generated %d\0A\00"
@.str.3 = [65 x i8] c"ERROR: random number too large. Max is %d. Routine generated %d\0A\00"
@.str.4 = [46 x i8] c"PASS: random number generated our endpoints.\0A\00"
@.str.5 = [53 x i8] c"ERROR: random number never generated our endpoints.\0A\00"
@.str.6 = [38 x i8] c"PASS: random number generator works.\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 i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* @EXIT_SUCCESS
store i32 %13, i32* %6
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 1
br i1 %15, label %16, label %25
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = load i32, i32* @EXIT_FAILURE
store i32 %22, i32* %6
%23 = load i32, i32* %6
%24 = call i32 @exit(i32 %23)
unreachable
25: ; preds = %2
%26 = load i32, i32* @INT_MAX
%27 = icmp slt i32 %26, 500000
br i1 %27, label %28, label %34
28: ; preds = %25
%29 = load i32, i32* @INT_MAX
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %29)
%31 = load i32, i32* @EXIT_FAILURE
store i32 %31, i32* %6
%32 = load i32, i32* %6
%33 = call i32 @exit(i32 %32)
unreachable
34: ; preds = %25
%35 = call i32 (...) @my_seed_random()
store i32 10, i32* %8
store i32 500, i32* %9
store i32 0, i32* %7
br label %36
36: ; preds = %65, %34
%37 = load i32, i32* %7
%38 = icmp slt i32 %37, 10000
br i1 %38, label %39, label %68
39: ; preds = %36
%40 = load i32, i32* %8
%41 = load i32, i32* %9
%42 = call i32 @my_get_random(i32 %40, i32 %41)
store i32 %42, i32* %10
%43 = load i32, i32* %10
%44 = load i32, i32* %8
%45 = icmp slt i32 %43, %44
br i1 %45, label %46, label %53
46: ; preds = %39
%47 = load i32, i32* %8
%48 = load i32, i32* %10
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.2, i64 0, i64 0), i32 %47, i32 %48)
%50 = load i32, i32* @EXIT_FAILURE
store i32 %50, i32* %6
%51 = load i32, i32* %6
%52 = call i32 @exit(i32 %51)
unreachable
53: ; preds = %39
%54 = load i32, i32* %10
%55 = load i32, i32* %9
%56 = icmp sgt i32 %54, %55
br i1 %56, label %57, label %64
57: ; preds = %53
%58 = load i32, i32* %9
%59 = load i32, i32* %10
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.3, i64 0, i64 0), i32 %58, i32 %59)
%61 = load i32, i32* @EXIT_FAILURE
store i32 %61, i32* %6
%62 = load i32, i32* %6
%63 = call i32 @exit(i32 %62)
unreachable
64: ; preds = %53
br label %65
65: ; preds = %64
%66 = load i32, i32* %7
%67 = add nsw i32 %66, 1
store i32 %67, i32* %7
br label %36
68: ; preds = %36
store i32 3, i32* %8
store i32 5, i32* %9
store i32 0, i32* %11
store i32 0, i32* %12
store i32 0, i32* %7
br label %69
69: ; preds = %86, %68
%70 = load i32, i32* %7
%71 = icmp slt i32 %70, 100
br i1 %71, label %72, label %89
72: ; preds = %69
%73 = load i32, i32* %8
%74 = load i32, i32* %9
%75 = call i32 @my_get_random(i32 %73, i32 %74)
store i32 %75, i32* %10
%76 = load i32, i32* %10
%77 = load i32, i32* %8
%78 = icmp eq i32 %76, %77
br i1 %78, label %79, label %80
79: ; preds = %72
store i32 1, i32* %12
br label %80
80: ; preds = %79, %72
%81 = load i32, i32* %10
%82 = load i32, i32* %9
%83 = icmp eq i32 %81, %82
br i1 %83, label %84, label %85
84: ; preds = %80
store i32 1, i32* %11
br label %85
85: ; preds = %84, %80
br label %86
86: ; preds = %85
%87 = load i32, i32* %7
%88 = add nsw i32 %87, 1
store i32 %88, i32* %7
br label %69
89: ; preds = %69
%90 = load i32, i32* %11
%91 = icmp ne i32 %90, 0
br i1 %91, label %92, label %97
92: ; preds = %89
%93 = load i32, i32* %12
%94 = icmp ne i32 %93, 0
br i1 %94, label %95, label %97
95: ; preds = %92
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0))
br label %102
97: ; preds = %92, %89
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.5, i64 0, i64 0))
%99 = load i32, i32* @EXIT_FAILURE
store i32 %99, i32* %6
%100 = load i32, i32* %6
%101 = call i32 @exit(i32 %100)
unreachable
102: ; preds = %95
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0))
%104 = load i32, i32* %6
%105 = call i32 @exit(i32 %104)
unreachable
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
@stderr = global i32 0
@.str = [12 x i8] c"Usage: %s \0A\00"
@EXIT_FAILURE = global i32 0
@INT_MAX = global i32 0
@.str.1 = [15 x i8] c"INT_MAX is %d\0A\00"
@.str.2 = [65 x i8] c"ERROR: random number too small. Min is %d. Routine generated %d\0A\00"
@.str.3 = [65 x i8] c"ERROR: random number too large. Max is %d. Routine generated %d\0A\00"
@str = [52 x i8] c"ERROR: random number never generated our endpoints.\00"
@str.7 = [45 x i8] c"PASS: random number generated our endpoints.\00"
@str.8 = [37 x i8] c"PASS: random number generator works.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i32, i32* @EXIT_SUCCESS
%4 = icmp eq i32 %0, 1
br i1 %4, label %11, label %5
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = load i8*, i8** %1
%8 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = load i32, i32* @EXIT_FAILURE
%10 = tail call i32 @exit(i32 %9)
unreachable
11: ; preds = %2
%12 = load i32, i32* @INT_MAX
%13 = icmp slt i32 %12, 500000
br i1 %13, label %14, label %18
14: ; preds = %11
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%16 = load i32, i32* @EXIT_FAILURE
%17 = tail call i32 @exit(i32 %16)
unreachable
18: ; preds = %11
%19 = tail call i32 (...) @my_seed_random()
br label %23
20: ; preds = %31
%21 = add nuw nsw i32 %24, 1
%22 = icmp eq i32 %21, 10000
br i1 %22, label %37, label %23
23: ; preds = %18, %20
%24 = phi i32 [ 0, %18 ], [ %21, %20 ]
%25 = tail call i32 @my_get_random(i32 10, i32 500)
%26 = icmp slt i32 %25, 10
br i1 %26, label %27, label %31
27: ; preds = %23
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @.str.2, i64 0, i64 0), i32 10, i32 %25)
%29 = load i32, i32* @EXIT_FAILURE
%30 = tail call i32 @exit(i32 %29)
unreachable
31: ; preds = %23
%32 = icmp ugt i32 %25, 500
br i1 %32, label %33, label %20
33: ; preds = %31
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @.str.3, i64 0, i64 0), i32 500, i32 %25)
%35 = load i32, i32* @EXIT_FAILURE
%36 = tail call i32 @exit(i32 %35)
unreachable
37: ; preds = %20, %37
%38 = phi i32 [ %43, %37 ], [ 0, %20 ]
%39 = phi i32 [ %45, %37 ], [ 0, %20 ]
%40 = phi i32 [ %46, %37 ], [ 0, %20 ]
%41 = tail call i32 @my_get_random(i32 3, i32 5)
%42 = icmp eq i32 %41, 3
%43 = select i1 %42, i32 1, i32 %38
%44 = icmp eq i32 %41, 5
%45 = select i1 %44, i32 1, i32 %39
%46 = add nuw nsw i32 %40, 1
%47 = icmp eq i32 %46, 100
br i1 %47, label %48, label %37
48: ; preds = %37
%49 = icmp ne i32 %45, 0
%50 = icmp ne i32 %43, 0
%51 = select i1 %49, i1 %50, i1 false
br i1 %51, label %52, label %56
52: ; preds = %48
%53 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.7, i64 0, i64 0))
%54 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.8, i64 0, i64 0))
%55 = tail call i32 @exit(i32 %3)
unreachable
56: ; preds = %48
%57 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str, i64 0, i64 0))
%58 = load i32, i32* @EXIT_FAILURE
%59 = tail call i32 @exit(i32 %58)
unreachable
}