#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 /*<<< orphan*/ EXIT_FAILURE;
int RAND_MAX;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int range_rand(int, int);
int scanf(char *, int *, int *, int *);
int /*<<< orphan*/ srand(unsigned int);
int sscanf(char *, char *, unsigned int *);
int /*<<< orphan*/ stderr;
scalar_t__ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  unsigned seed;
  if (argc > 1) {
    if (sscanf(argv[1], "%u", &seed) != 1) {
      fprintf(stderr, "Invalid seed \"%s\". Please use an integer >= 0.\n",
              argv[1]);
      exit(EXIT_FAILURE);
    }
  } else {
    seed = (unsigned)time(NULL);
  }
  srand(seed);
  printf("Enter a range [l, r], where l >= 0 and r <= %d, followed by the "
         "number of iterations\n",
         RAND_MAX);
  printf("> ");
  int l, h, i;
  while (scanf("%d%d%d", &l, &h, &i) == 3) {
    while (i--) {
      printf("%d\n", range_rand(l, h));
    }
    printf("> ");
  }
  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    11f1 <main+0x71>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe51(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1080 <sscanf@plt>
cmp    $0x1,%eax
je     11ec <main+0x6c>
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe2a(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2deb(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
jmp    11fd <main+0x7d>
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1050 <srand@plt>
mov    0x2ddc(%rip),%rax
mov    (%rax),%esi
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe5b(%rip),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
lea    -0x20(%rbp),%rcx
call   1090 <scanf@plt>
cmp    $0x3,%eax
jne    1297 <main+0x117>
jmp    1250 <main+0xd0>
mov    -0x20(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x20(%rbp)
cmp    $0x0,%eax
je     1284 <main+0x104>
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1030 <range_rand@plt>
mov    %eax,%esi
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1250 <main+0xd0>
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    122a <main+0xaa>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x2,%edi
jl     11ba <main+0x3a>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe5f(%rip),%rsi
lea    0x14(%rsp),%rdx
call   1080 <sscanf@plt>
cmp    $0x1,%eax
jne    1291 <main+0x111>
mov    0x14(%rsp),%edi
jmp    11c8 <main+0x48>
xor    %edi,%edi
call   1070 <time@plt>
mov    %rax,%rdi
mov    %edi,0x14(%rsp)
call   1050 <srand@plt>
mov    0x2e14(%rip),%rax
mov    (%rax),%esi
lea    0xe56(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe9e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe93(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
call   1090 <scanf@plt>
cmp    $0x3,%eax
jne    1280 <main+0x100>
lea    0xe70(%rip),%r14
lea    0xe6c(%rip),%r15
lea    0x10(%rsp),%r12
lea    0xc(%rsp),%r13
lea    0x8(%rsp),%rbx
lea    0xe5d(%rip),%rbp
jmp    1259 <main+0xd9>
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%esi
call   1030 <range_rand@plt>
mov    %rbp,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
subl   $0x1,0x8(%rsp)
jae    1240 <main+0xc0>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %rbx,%rcx
call   1090 <scanf@plt>
cmp    $0x3,%eax
je     1259 <main+0xd9>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d40(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xd5e(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2d1f(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%u\00"
@stderr = global i32 0
@.str.1 = [48 x i8] c"Invalid seed \22%s\22. Please use an integer >= 0.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [86 x i8] c"Enter a range [l, r], where l >= 0 and r <= %d, followed by the number of iterations\0A\00"
@RAND_MAX = global i32 0
@.str.3 = [3 x i8] c"> \00"
@.str.4 = [7 x i8] c"%d%d%d\00"
@.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 i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp sgt i32 %10, 1
br i1 %11, label %12, label %27
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @sscanf(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%17 = icmp ne i32 %16, 1
br i1 %17, label %18, label %26
18: ; preds = %12
%19 = load i32, i32* @stderr
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i8* %22)
%24 = load i32, i32* @EXIT_FAILURE
%25 = call i32 @exit(i32 %24)
unreachable
26: ; preds = %12
br label %30
27: ; preds = %2
%28 = call i64 @time(i32* null)
%29 = trunc i64 %28 to i32
store i32 %29, i32* %6
br label %30
30: ; preds = %27, %26
%31 = load i32, i32* %6
%32 = call i32 @srand(i32 %31)
%33 = load i32, i32* @RAND_MAX
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([86 x i8], [86 x i8]* @.str.2, i64 0, i64 0), i32 %33)
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %36
36: ; preds = %49, %30
%37 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32* %7, i32* %8, i32* %9)
%38 = icmp eq i32 %37, 3
br i1 %38, label %39, label %51
39: ; preds = %36
br label %40
40: ; preds = %44, %39
%41 = load i32, i32* %9
%42 = add nsw i32 %41, -1
store i32 %42, i32* %9
%43 = icmp ne i32 %41, 0
br i1 %43, label %44, label %49
44: ; preds = %40
%45 = load i32, i32* %7
%46 = load i32, i32* %8
%47 = call i32 @range_rand(i32 %45, i32 %46)
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %47)
br label %40
49: ; preds = %40
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %36
51: ; preds = %36
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%u\00"
@stderr = global i32 0
@.str.1 = [48 x i8] c"Invalid seed \22%s\22. Please use an integer >= 0.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [86 x i8] c"Enter a range [l, r], where l >= 0 and r <= %d, followed by the number of iterations\0A\00"
@RAND_MAX = global i32 0
@.str.3 = [3 x i8] c"> \00"
@.str.4 = [7 x i8] c"%d%d%d\00"
@.str.5 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = bitcast i32* %3 to i8*
%8 = icmp sgt i32 %0, 1
br i1 %8, label %9, label %22
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = call i32 @sscanf(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = load i32, i32* %3
br label %25
16: ; preds = %9
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %10
%19 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = load i32, i32* @EXIT_FAILURE
%21 = call i32 @exit(i32 %20)
unreachable
22: ; preds = %2
%23 = tail call i64 @time(i32* null)
%24 = trunc i64 %23 to i32
store i32 %24, i32* %3
br label %25
25: ; preds = %14, %22
%26 = phi i32 [ %15, %14 ], [ %24, %22 ]
%27 = call i32 @srand(i32 %26)
%28 = load i32, i32* @RAND_MAX
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([86 x i8], [86 x i8]* @.str.2, i64 0, i64 0), i32 %28)
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%31 = bitcast i32* %4 to i8*
%32 = bitcast i32* %5 to i8*
%33 = bitcast i32* %6 to i8*
%34 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32* %4, i32* %5, i32* %6)
%35 = icmp eq i32 %34, 3
br i1 %35, label %36, label %52
36: ; preds = %25, %48
%37 = load i32, i32* %6
%38 = add nsw i32 %37, -1
store i32 %38, i32* %6
%39 = icmp eq i32 %37, 0
br i1 %39, label %48, label %40
40: ; preds = %36, %40
%41 = load i32, i32* %4
%42 = load i32, i32* %5
%43 = call i32 @range_rand(i32 %41, i32 %42)
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %43)
%45 = load i32, i32* %6
%46 = add nsw i32 %45, -1
store i32 %46, i32* %6
%47 = icmp eq i32 %45, 0
br i1 %47, label %48, label %40
48: ; preds = %40, %36
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%50 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32* %4, i32* %5, i32* %6)
%51 = icmp eq i32 %50, 3
br i1 %51, label %36, label %52
52: ; preds = %48, %25
ret i32 0
}