#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 dicebag_best(int, int, int);
int dicebag_dice(int, int);
int /*<<< orphan*/ dicebag_init();
int dicebag_range(int, int);
int dicebag_roll(int);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char **argv) {
  int n;
  dicebag_init();
  n = dicebag_roll(100);
  printf("roll( 100 ) -> %d\n", n);
  n = dicebag_range(100, 200);
  printf("range( 100, 200 ) -> %d\n", n);
  n = dicebag_range(-200, -100);
  printf("range( -200, -100 ) -> %d\n", n);
  n = dicebag_dice(10, 10);
  printf("dice( 10, 10 ) -> %d\n", n);
  n = dicebag_best(10, 20, 10);
  printf("best( 10, 20, 10 ) -> %d\n", n);
  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)
mov    $0x0,%al
call   1060 <dicebag_init@plt>
mov    $0x64,%edi
call   1050 <dicebag_roll@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe6c(%rip),%rdi
call   1040 <printf@plt>
mov    $0x64,%edi
mov    $0xc8,%esi
call   1080 <dicebag_range@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe5e(%rip),%rdi
call   1040 <printf@plt>
mov    $0xffffff38,%edi
mov    $0xffffff9c,%esi
call   1080 <dicebag_range@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe56(%rip),%rdi
call   1040 <printf@plt>
mov    $0xa,%esi
mov    %esi,%edi
call   1070 <dicebag_dice@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe53(%rip),%rdi
call   1040 <printf@plt>
mov    $0xa,%edx
mov    $0x14,%esi
mov    %edx,%edi
call   1030 <dicebag_best@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe46(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1060 <dicebag_init@plt>
mov    $0x64,%edi
call   1050 <dicebag_roll@plt>
lea    0xe87(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    $0x64,%edi
mov    $0xc8,%esi
call   1080 <dicebag_range@plt>
lea    0xe7d(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    $0xffffff38,%edi
mov    $0xffffff9c,%esi
call   1080 <dicebag_range@plt>
lea    0xe79(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    $0xa,%edi
mov    $0xa,%esi
call   1070 <dicebag_dice@plt>
lea    0xe77(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    $0xa,%edi
mov    $0x14,%esi
mov    $0xa,%edx
call   1030 <dicebag_best@plt>
lea    0xe6b(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [19 x i8] c"roll( 100 ) -> %d\0A\00"
@.str.1 = [25 x i8] c"range( 100, 200 ) -> %d\0A\00"
@.str.2 = [27 x i8] c"range( -200, -100 ) -> %d\0A\00"
@.str.3 = [22 x i8] c"dice( 10, 10 ) -> %d\0A\00"
@.str.4 = [26 x i8] c"best( 10, 20, 10 ) -> %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 (...) @dicebag_init()
%8 = call i32 @dicebag_roll(i32 100)
store i32 %8, i32* %6
%9 = load i32, i32* %6
%10 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = call i32 @dicebag_range(i32 100, i32 200)
store i32 %11, i32* %6
%12 = load i32, i32* %6
%13 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = call i32 @dicebag_range(i32 -200, i32 -100)
store i32 %14, i32* %6
%15 = load i32, i32* %6
%16 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = call i32 @dicebag_dice(i32 10, i32 10)
store i32 %17, i32* %6
%18 = load i32, i32* %6
%19 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %18)
%20 = call i32 @dicebag_best(i32 10, i32 20, i32 10)
store i32 %20, i32* %6
%21 = load i32, i32* %6
%22 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %21)
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"roll( 100 ) -> %d\0A\00"
@.str.1 = [25 x i8] c"range( 100, 200 ) -> %d\0A\00"
@.str.2 = [27 x i8] c"range( -200, -100 ) -> %d\0A\00"
@.str.3 = [22 x i8] c"dice( 10, 10 ) -> %d\0A\00"
@.str.4 = [26 x i8] c"best( 10, 20, 10 ) -> %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @dicebag_init()
%4 = tail call i32 @dicebag_roll(i32 100)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = tail call i32 @dicebag_range(i32 100, i32 200)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = tail call i32 @dicebag_range(i32 -200, i32 -100)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %8)
%10 = tail call i32 @dicebag_dice(i32 10, i32 10)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %10)
%12 = tail call i32 @dicebag_best(i32 10, i32 20, i32 10)
%13 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %12)
ret i32 0
}