#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 scanf(char *, int *, char *);
int /*<<< orphan*/ throw(int);
int validate(int, int, char);
int main(void) {
  int num;
  char endInput;
  int result = 0;
  int loop = 0;
  printf("Game of Dice\n");
  printf("=============\n");
  while (loop == 0) {
    printf("Enter total sought: ");
    result = scanf("%d%c", &num, &endInput);
    loop = validate(result, num, endInput);
  }
  throw(num);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xe9c(%rip),%rdi
call   1030 <printf@plt>
lea    0xe9e(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x0,-0x14(%rbp)
jne    11b9 <main+0x79>
lea    0xe97(%rip),%rdi
call   1030 <printf@plt>
lea    0xea0(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0x9(%rbp),%rdx
call   1060 <scanf@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x8(%rbp),%esi
movsbl -0x9(%rbp),%edx
call   1050 <validate@plt>
mov    %eax,-0x14(%rbp)
jmp    1175 <main+0x35>
mov    -0x8(%rbp),%edi
call   1040 <throw@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xebb(%rip),%rdi
call   1030 <puts@plt>
lea    0xebc(%rip),%rdi
call   1030 <puts@plt>
lea    0xe89(%rip),%r14
lea    0xe97(%rip),%r15
lea    0x4(%rsp),%r12
lea    0x3(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1070 <scanf@plt>
mov    0x4(%rsp),%esi
movsbl 0x3(%rsp),%edx
mov    %eax,%edi
call   1060 <validate@plt>
test   %eax,%eax
je     1190 <main+0x40>
mov    0x4(%rsp),%edi
call   1050 <throw@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Game of Dice\0A\00"
@.str.1 = [15 x i8] c"=============\0A\00"
@.str.2 = [21 x i8] c"Enter total sought: \00"
@.str.3 = [5 x i8] c"%d%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
store i32 0, i32* %5
%6 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %8
8: ; preds = %11, %0
%9 = load i32, i32* %5
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %18
11: ; preds = %8
%12 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32* %2, i8* %3)
store i32 %13, i32* %4
%14 = load i32, i32* %4
%15 = load i32, i32* %2
%16 = load i8, i8* %3
%17 = call i32 @validate(i32 %14, i32 %15, i8 signext %16)
store i32 %17, i32* %5
br label %8
18: ; preds = %8
%19 = load i32, i32* %2
%20 = call i32 @throw(i32 %19)
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [21 x i8] c"Enter total sought: \00"
@.str.3 = [5 x i8] c"%d%c\00"
@str = [13 x i8] c"Game of Dice\00"
@str.4 = [14 x i8] c"=============\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = bitcast i32* %1 to i8*
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.4, i64 0, i64 0))
br label %6
6: ; preds = %0, %6
%7 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32* %1, i8* %2)
%9 = load i32, i32* %1
%10 = load i8, i8* %2
%11 = call i32 @validate(i32 %8, i32 %9, i8 signext %10)
%12 = icmp eq i32 %11, 0
br i1 %12, label %6, label %13
13: ; preds = %6
%14 = load i32, i32* %1
%15 = call i32 @throw(i32 %14)
ret i32 0
}