#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 gcd(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
unsigned int scanf(char *, ...);
int main(void) {
  int primoNumero;
  int secondoNumero;
  int massimoComunDivisore;
  unsigned int esitoScanf;
  do {
    printf("Inserire i due numeri su cui calcolare il minimo comun divisore "
           "separati da uno spazio: ");
    if ((esitoScanf = scanf("%d %d", &primoNumero, &secondoNumero)) == 0) {
      scanf("%*[^\n]");
      puts("Valori inseriti non validi");
    }
  } while (esitoScanf == 0);
  massimoComunDivisore = gcd(primoNumero, secondoNumero);
  printf("Il massimo comun divisore di %d e %d e' pari a: %d", primoNumero,
         secondoNumero, massimoComunDivisore);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xef5(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
mov    $0x0,%al
call   1050 <scanf@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jne    1199 <main+0x59>
lea    0xed9(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xed2(%rip),%rdi
call   1030 <puts@plt>
jmp    119e <main+0x5e>
cmpl   $0x0,-0x14(%rbp)
je     114f <main+0xf>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1060 <gcd@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xeae(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xef9(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
test   %eax,%eax
jne    11d0 <main+0x90>
lea    0xee5(%rip),%r14
lea    0xee5(%rip),%r15
lea    0xe78(%rip),%r12
lea    0xeca(%rip),%r13
lea    0x4(%rsp),%rbx
mov    %rsp,%rbp
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
test   %eax,%eax
je     11a0 <main+0x60>
mov    0x4(%rsp),%edi
mov    (%rsp),%esi
call   1060 <gcd@plt>
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
lea    0xe97(%rip),%rdi
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [89 x i8] c"Inserire i due numeri su cui calcolare il minimo comun divisore separati da uno spazio: \00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [7 x i8] c"%*[^\0A]\00"
@.str.3 = [27 x i8] c"Valori inseriti non validi\00"
@.str.4 = [51 x i8] c"Il massimo comun divisore di %d e %d e' pari a: %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
br label %6
6: ; preds = %14, %0
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
store i32 %8, i32* %5
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %6
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @puts(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
br label %13
13: ; preds = %10, %6
br label %14
14: ; preds = %13
%15 = load i32, i32* %5
%16 = icmp eq i32 %15, 0
br i1 %16, label %6, label %17
17: ; preds = %14
%18 = load i32, i32* %2
%19 = load i32, i32* %3
%20 = call i32 @gcd(i32 %18, i32 %19)
store i32 %20, i32* %4
%21 = load i32, i32* %2
%22 = load i32, i32* %3
%23 = load i32, i32* %4
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0), i32 %21, i32 %22, i32 %23)
ret i32 0
}

LLVM IR (-O2):
@.str = [89 x i8] c"Inserire i due numeri su cui calcolare il minimo comun divisore separati da uno spazio: \00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [7 x i8] c"%*[^\0A]\00"
@.str.3 = [27 x i8] c"Valori inseriti non validi\00"
@.str.4 = [51 x i8] c"Il massimo comun divisore di %d e %d e' pari a: %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([89 x i8], [89 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %14
8: ; preds = %0, %8
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([89 x i8], [89 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%13 = icmp eq i32 %12, 0
br i1 %13, label %8, label %14
14: ; preds = %8, %0
%15 = load i32, i32* %1
%16 = load i32, i32* %2
%17 = call i32 @gcd(i32 %15, i32 %16)
%18 = load i32, i32* %1
%19 = load i32, i32* %2
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0), i32 %18, i32 %19, i32 %17)
ret i32 0
}