#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 */
scalar_t__ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int randRange(int, int, int, int);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int /*<<< orphan*/ stdin;
int main() {
  char buffer[100];
  int a, b;
  printf("choose first number: ");
  if (fgets(buffer, 100, stdin)) {
    sscanf(buffer, "%d", &a);
  }
  printf("choose second number: ");
  if (fgets(buffer, 100, stdin)) {
    sscanf(buffer, "%d", &b);
  }
  printf("a random number between %d and %d is %d\n", a, b,
         randRange(a, b, true, true));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    0x2e7d(%rip),%rax
mov    (%rax),%edx
mov    $0x64,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     1195 <main+0x55>
lea    -0x70(%rbp),%rdi
lea    0xe8a(%rip),%rsi
lea    -0x74(%rbp),%rdx
call   1060 <sscanf@plt>
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    0x2e3a(%rip),%rax
mov    (%rax),%edx
mov    $0x64,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     11d8 <main+0x98>
lea    -0x70(%rbp),%rdi
lea    0xe47(%rip),%rsi
lea    -0x78(%rbp),%rdx
call   1060 <sscanf@plt>
mov    -0x74(%rbp),%eax
mov    %eax,-0x80(%rbp)
mov    -0x78(%rbp),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x74(%rbp),%edi
mov    -0x78(%rbp),%esi
mov    $0x1,%ecx
mov    %ecx,%edx
call   1050 <randRange@plt>
mov    -0x80(%rbp),%esi
mov    -0x7c(%rbp),%edx
mov    %eax,%ecx
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x78,%rsp
lea    0xeb3(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2e8d(%rip),%rbx
mov    (%rbx),%edx
lea    0x10(%rsp),%rdi
mov    $0x64,%esi
call   1040 <fgets@plt>
test   %rax,%rax
je     1187 <main+0x47>
lea    0xe9e(%rip),%rsi
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rdx
call   1060 <sscanf@plt>
lea    0xe8b(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%rbx),%edx
lea    0x10(%rsp),%rdi
mov    $0x64,%esi
call   1040 <fgets@plt>
test   %rax,%rax
je     11c7 <main+0x87>
lea    0xe64(%rip),%rsi
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rdx
call   1060 <sscanf@plt>
mov    0x8(%rsp),%ebx
jmp    11c7 <main+0x87>
mov    0xc(%rsp),%ebp
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x1,%edx
mov    $0x1,%ecx
call   1050 <randRange@plt>
lea    0xe4b(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"choose first number: \00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [23 x i8] c"choose second number: \00"
@.str.3 = [41 x i8] c"a random number between %d and %d is %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%7 = load i32, i32* @stdin
%8 = call i64 @fgets(i8* %6, i32 100, i32 %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %0
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%12 = call i32 @sscanf(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
br label %13
13: ; preds = %10, %0
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%16 = load i32, i32* @stdin
%17 = call i64 @fgets(i8* %15, i32 100, i32 %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %13
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%21 = call i32 @sscanf(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
br label %22
22: ; preds = %19, %13
%23 = load i32, i32* %3
%24 = load i32, i32* %4
%25 = load i32, i32* %3
%26 = load i32, i32* %4
%27 = call i32 @randRange(i32 %25, i32 %26, i32 1, i32 1)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0), i32 %23, i32 %24, i32 %27)
%29 = load i32, i32* %1
ret i32 %29
}

LLVM IR (-O2):
@.str = [22 x i8] c"choose first number: \00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [23 x i8] c"choose second number: \00"
@.str.3 = [41 x i8] c"a random number between %d and %d is %d\0A\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca i32
%3 = alloca i32
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @stdin
%9 = call i64 @fgets(i8* %4, i32 100, i32 %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %0
%12 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %13
13: ; preds = %11, %0
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%15 = load i32, i32* @stdin
%16 = call i64 @fgets(i8* %4, i32 100, i32 %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %13
%19 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%20 = load i32, i32* %3
br label %21
21: ; preds = %18, %13
%22 = phi i32 [ %20, %18 ], [ undef, %13 ]
%23 = load i32, i32* %2
%24 = call i32 @randRange(i32 %23, i32 %22, i32 1, i32 1)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0), i32 %23, i32 %22, i32 %24)
ret i32 0
}