#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*/ puts(char *);
int rand();
unsigned int scanf(char *, ...);
void nuovaDomanda(void) {
  unsigned int esitoDomanda = 0;
  unsigned int rispostaDomanda;
  unsigned int moltiplicando;
  unsigned int moltiplicatore;
  unsigned int risultatoDomanda;
  unsigned int esitoScanf;
  char *messaggioEsattoPtr = "Bravo hai fatto bene i conti";
  char *messaggioErratoPtr = "Ho no, hai sbagliato, riprova!";
  moltiplicando = rand() % 100;
  moltiplicatore = rand() % 100;
  risultatoDomanda = moltiplicando * moltiplicatore;
  do {
    printf("\nQuanto fanno %u per %u? = ", moltiplicando, moltiplicatore);
    if ((esitoScanf = scanf("%u", &rispostaDomanda)) == 0) {
      scanf("%*[^\n]");
      puts("Input errato, sono accettati solo interi positivi");
    } else {
      if (rispostaDomanda == risultatoDomanda) {
        printf("%s", messaggioEsattoPtr);
        nuovaDomanda();
      } else {
        printf("%s", messaggioErratoPtr);
      }
    }
  } while (esitoDomanda == 0);
  return;
}


x86 assembly (clang, -O0):
<nuovaDomanda>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xeac(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe9a(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jne    11f4 <nuovaDomanda+0xa4>
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xe78(%rip),%rdi
call   1030 <puts@plt>
jmp    1233 <nuovaDomanda+0xe3>
mov    -0x8(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    121c <nuovaDomanda+0xcc>
mov    -0x20(%rbp),%rsi
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
call   1060 <nuovaDomanda@plt>
jmp    122e <nuovaDomanda+0xde>
mov    -0x28(%rbp),%rsi
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1233 <nuovaDomanda+0xe3>
jmp    1238 <nuovaDomanda+0xe8>
cmpl   $0x0,-0x4(%rbp)
je     11a3 <nuovaDomanda+0x53>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nuovaDomanda>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1070 <rand@plt>
movslq %eax,%r14
imul   $0x51eb851f,%r14,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%r14d
xor    %eax,%eax
call   1070 <rand@plt>
movslq %eax,%rbx
imul   $0x51eb851f,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%ebx
mov    %ebx,%ebp
imul   %r14d,%ebp
lea    0xe8d(%rip),%r15
lea    0xea2(%rip),%r12
lea    0x4(%rsp),%r13
jmp    11da <nuovaDomanda+0x8a>
nopl   (%rax)
lea    0xe94(%rip),%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xe8d(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r14d,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
test   %eax,%eax
je     11c0 <nuovaDomanda+0x70>
cmp    %ebp,0x4(%rsp)
je     1217 <nuovaDomanda+0xc7>
lea    0xe8d(%rip),%rdi
lea    0xe0f(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11da <nuovaDomanda+0x8a>
lea    0xe76(%rip),%rdi
lea    0xddb(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
call   1060 <nuovaDomanda@plt>

LLVM IR (-O0):
@.str = [29 x i8] c"Bravo hai fatto bene i conti\00"
@.str.1 = [31 x i8] c"Ho no, hai sbagliato, riprova!\00"
@.str.2 = [28 x i8] c"\0AQuanto fanno %u per %u? = \00"
@.str.3 = [3 x i8] c"%u\00"
@.str.4 = [7 x i8] c"%*[^\0A]\00"
@.str.5 = [50 x i8] c"Input errato, sono accettati solo interi positivi\00"
@.str.6 = [3 x i8] c"%s\00"
define void @nuovaDomanda() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8** %7
store i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8** %8
%9 = call i32 (...) @rand()
%10 = srem i32 %9, 100
store i32 %10, i32* %3
%11 = call i32 (...) @rand()
%12 = srem i32 %11, 100
store i32 %12, i32* %4
%13 = load i32, i32* %3
%14 = load i32, i32* %4
%15 = mul i32 %13, %14
store i32 %15, i32* %5
br label %16
16: ; preds = %37, %0
%17 = load i32, i32* %3
%18 = load i32, i32* %4
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %17, i32 %18)
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
store i32 %20, i32* %6
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %16
%23 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%24 = call i32 @puts(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.5, i64 0, i64 0))
br label %36
25: ; preds = %16
%26 = load i32, i32* %2
%27 = load i32, i32* %5
%28 = icmp eq i32 %26, %27
br i1 %28, label %29, label %32
29: ; preds = %25
%30 = load i8*, i8** %7
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %30)
br label %35
32: ; preds = %25
%33 = load i8*, i8** %8
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %33)
br label %35
35: ; preds = %32, %29
br label %36
36: ; preds = %35, %22
br label %37
37: ; preds = %36
%38 = load i32, i32* %1
%39 = icmp eq i32 %38, 0
br i1 %39, label %16, label %40
40: ; preds = %37
ret void
}

LLVM IR (-O2):
@.str = [29 x i8] c"Bravo hai fatto bene i conti\00"
@.str.1 = [31 x i8] c"Ho no, hai sbagliato, riprova!\00"
@.str.2 = [28 x i8] c"\0AQuanto fanno %u per %u? = \00"
@.str.3 = [3 x i8] c"%u\00"
@.str.4 = [7 x i8] c"%*[^\0A]\00"
@.str.5 = [50 x i8] c"Input errato, sono accettati solo interi positivi\00"
@.str.6 = [3 x i8] c"%s\00"
define void @nuovaDomanda() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (...) @rand()
%4 = srem i32 %3, 100
%5 = tail call i32 (...) @rand()
%6 = srem i32 %5, 100
%7 = mul nsw i32 %6, %4
br label %8
8: ; preds = %15, %0
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %4, i32 %6)
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %8
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.5, i64 0, i64 0))
br label %15
15: ; preds = %12, %21
br label %8
16: ; preds = %8
%17 = load i32, i32* %1
%18 = icmp eq i32 %17, %7
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
unreachable
21: ; preds = %16
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %15
}