#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*/ printf(char *);
int /*<<< orphan*/ scanf(char *, ...);
void AskForBonus(int *bonus, int *floatbonus, unsigned int *numberofdice,
                 unsigned int *numberofsides, int *fastmode) {
  printf("ToBeFree's Dice Fight Probability Calculator, version 1.42.2\n");
  printf("This program is distributed in the hope that it will be useful, "
         "but WITHOUT ANY WARRANTY; "
         "without even the implied warranty of MERCHANTABILITY "
         "or FITNESS FOR A PARTICULAR PURPOSE.  See the "
         "GNU General Public License for more details.\n");
  printf("GPL 3.0, https://github.com/ToBeFree/DiceCalculator\n\n");
  printf("When the simulation is running, press Ctrl+C to exit.\n");
  printf("Enter integer bonus (e.g. 1 or -2): ");
  scanf("%d", bonus);
  do {
    printf("Add 0.5 to the bonus? (0 for no, 1 for yes): ");
    scanf("%d", floatbonus);
  } while (((*floatbonus) != 0) && ((*floatbonus) != 1));
  printf("How many dice? ");
  scanf("%d", numberofdice);
  printf("How many sides per die? ");
  scanf("%d", numberofsides);
  do {
    printf("Enable fast calculation mode (print each 100,000,000th line only)? "
           "(0 for no, 1 for yes): ");
    scanf("%d", fastmode);
  } while (((*fastmode) != 0) && ((*fastmode) != 1));
}


x86 assembly (clang, -O0):
<AskForBonus>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
lea    0xebd(%rip),%rdi
call   1030 <printf@plt>
lea    0xeef(%rip),%rdi
call   1030 <printf@plt>
lea    0xfce(%rip),%rdi
call   1030 <printf@plt>
lea    0xff8(%rip),%rdi
call   1030 <printf@plt>
lea    0x1023(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rsi
lea    0x1038(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0x102d(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0x101a(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x10(%rbp),%rcx
xor    %eax,%eax
cmpl   $0x0,(%rcx)
mov    %al,-0x29(%rbp)
je     11c7 <AskForBonus+0xa7>
mov    -0x10(%rbp),%rax
cmpl   $0x1,(%rax)
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    118a <AskForBonus+0x6a>
lea    0x1013(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xfd2(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0x1005(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xfb4(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0x1000(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xf96(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x28(%rbp),%rcx
xor    %eax,%eax
cmpl   $0x0,(%rcx)
mov    %al,-0x2a(%rbp)
je     124b <AskForBonus+0x12b>
mov    -0x28(%rbp),%rax
cmpl   $0x1,(%rax)
setne  %al
mov    %al,-0x2a(%rbp)
mov    -0x2a(%rbp),%al
test   $0x1,%al
jne    120e <AskForBonus+0xee>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AskForBonus>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r12
mov    %rcx,(%rsp)
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r13
lea    0xf88(%rip),%rdi
call   1030 <puts@plt>
lea    0xfb9(%rip),%rdi
call   1030 <puts@plt>
lea    0x1097(%rip),%rdi
call   1030 <puts@plt>
lea    0x10c0(%rip),%rdi
call   1030 <puts@plt>
lea    0xe7e(%rip),%rdi
call   1040 <printf@plt>
lea    0xe97(%rip),%r14
mov    %r14,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xe86(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbp,%rdi
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpl   $0x1,(%rbx)
ja     11b0 <AskForBonus+0x80>
lea    0xe85(%rip),%rdi
call   1040 <printf@plt>
lea    0xe48(%rip),%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xe75(%rip),%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    (%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xe74(%rip),%rbp
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpl   $0x1,(%r12)
ja     1210 <AskForBonus+0xe0>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [62 x i8] c"ToBeFree's Dice Fight Probability Calculator, version 1.42.2\0A\00"
@.str.1 = [235 x i8] c"This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\0A\00"
@.str.2 = [54 x i8] c"GPL 3.0, https://github.com/ToBeFree/DiceCalculator\0A\0A\00"
@.str.3 = [55 x i8] c"When the simulation is running, press Ctrl+C to exit.\0A\00"
@.str.4 = [37 x i8] c"Enter integer bonus (e.g. 1 or -2): \00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [46 x i8] c"Add 0.5 to the bonus? (0 for no, 1 for yes): \00"
@.str.7 = [16 x i8] c"How many dice? \00"
@.str.8 = [25 x i8] c"How many sides per die? \00"
@.str.9 = [91 x i8] c"Enable fast calculation mode (print each 100,000,000th line only)? (0 for no, 1 for yes): \00"
define void @AskForBonus(i32* %0, i32* %1, i32* %2, i32* %3, i32* %4) {
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
store i32* %0, i32** %6
store i32* %1, i32** %7
store i32* %2, i32** %8
store i32* %3, i32** %9
store i32* %4, i32** %10
%11 = call i32 @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([235 x i8], [235 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
%16 = load i32*, i32** %6
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %16)
br label %18
18: ; preds = %30, %5
%19 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.6, i64 0, i64 0))
%20 = load i32*, i32** %7
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %20)
br label %22
22: ; preds = %18
%23 = load i32*, i32** %7
%24 = load i32, i32* %23
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %22
%27 = load i32*, i32** %7
%28 = load i32, i32* %27
%29 = icmp ne i32 %28, 1
br label %30
30: ; preds = %26, %22
%31 = phi i1 [ false, %22 ], [ %29, %26 ]
br i1 %31, label %18, label %32
32: ; preds = %30
%33 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
%34 = load i32*, i32** %8
%35 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %34)
%36 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0))
%37 = load i32*, i32** %9
%38 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %37)
br label %39
39: ; preds = %51, %32
%40 = call i32 @printf(i8* getelementptr inbounds ([91 x i8], [91 x i8]* @.str.9, i64 0, i64 0))
%41 = load i32*, i32** %10
%42 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %41)
br label %43
43: ; preds = %39
%44 = load i32*, i32** %10
%45 = load i32, i32* %44
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %51
47: ; preds = %43
%48 = load i32*, i32** %10
%49 = load i32, i32* %48
%50 = icmp ne i32 %49, 1
br label %51
51: ; preds = %47, %43
%52 = phi i1 [ false, %43 ], [ %50, %47 ]
br i1 %52, label %39, label %53
53: ; preds = %51
ret void
}

LLVM IR (-O2):
@.str.4 = [37 x i8] c"Enter integer bonus (e.g. 1 or -2): \00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [46 x i8] c"Add 0.5 to the bonus? (0 for no, 1 for yes): \00"
@.str.7 = [16 x i8] c"How many dice? \00"
@.str.8 = [25 x i8] c"How many sides per die? \00"
@.str.9 = [91 x i8] c"Enable fast calculation mode (print each 100,000,000th line only)? (0 for no, 1 for yes): \00"
@str = [61 x i8] c"ToBeFree's Dice Fight Probability Calculator, version 1.42.2\00"
@str.10 = [234 x i8] c"This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\00"
@str.11 = [53 x i8] c"GPL 3.0, https://github.com/ToBeFree/DiceCalculator\0A\00"
@str.12 = [54 x i8] c"When the simulation is running, press Ctrl+C to exit.\00"
define void @AskForBonus(i32* %0, i32* %1, i32* %2, i32* %3, i32* %4) {
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([234 x i8], [234 x i8]* @str.10, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.11, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.12, i64 0, i64 0))
%10 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
%11 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %0)
br label %12
12: ; preds = %12, %5
%13 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.6, i64 0, i64 0))
%14 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %1)
%15 = load i32, i32* %1
%16 = icmp ult i32 %15, 2
br i1 %16, label %17, label %12
17: ; preds = %12
%18 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
%19 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %2)
%20 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0))
%21 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %3)
br label %22
22: ; preds = %22, %17
%23 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([91 x i8], [91 x i8]* @.str.9, i64 0, i64 0))
%24 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %4)
%25 = load i32, i32* %4
%26 = icmp ult i32 %25, 2
br i1 %26, label %27, label %22
27: ; preds = %22
ret void
}