#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 *, unsigned int *);
int main() {
  unsigned int A;
  unsigned int B;
  unsigned int mcd;
  unsigned int buffer;
  printf("Inserire il primo numero: ");
  scanf("%i", &buffer);
  if (buffer > 999999999) {
    printf("Buffer overflow \n");
    return 0;
  }
  printf("Numero inserito (A): %i\n", buffer);
  A = buffer;
  printf("Inserire il secondo numero: ");
  scanf("%i", &buffer);
  if (buffer > 999999999) {
    printf("Buffer overflow \n");
    return 0;
  }
  printf("Numero inserito (B): %i\n", buffer);
  B = buffer;
  while (A != B) {
    if (A > B) {
      A = (A - B);
    } else if (A < B) {
      B = (B - A);
    }
  }
  if (A == B) {
    mcd = A;
    printf("Massimo Comune Divisore (MCD): %d\n", mcd);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed7(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x3b9ac9ff,-0x14(%rbp)
jbe    1174 <main+0x54>
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    124f <main+0x12f>
mov    -0x14(%rbp),%esi
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x8(%rbp)
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7b(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x3b9ac9ff,-0x14(%rbp)
jbe    11d0 <main+0xb0>
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    124f <main+0x12f>
mov    -0x14(%rbp),%esi
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     122c <main+0x10c>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jbe    120d <main+0xed>
mov    -0x8(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    1227 <main+0x107>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    1222 <main+0x102>
mov    -0xc(%rbp),%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1227 <main+0x107>
jmp    11e7 <main+0xc7>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    124f <main+0x12f>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xec6(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed3(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%esi
cmp    $0x3b9aca00,%esi
jae    119b <main+0x6b>
lea    0xeb9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%ebx
lea    0xec0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe96(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%esi
cmp    $0x3b9aca00,%esi
jb     11a9 <main+0x79>
lea    0xeee(%rip),%rdi
call   1030 <puts@plt>
jmp    11fd <main+0xcd>
lea    0xea4(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%eax
cmp    %eax,%ebx
je     11ed <main+0xbd>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    %eax,%ebx
mov    $0x0,%ecx
cmovb  %ebx,%ecx
mov    $0x0,%edx
cmova  %eax,%edx
cmova  %ebp,%ecx
sub    %edx,%ebx
sub    %ecx,%eax
cmp    %eax,%ebx
jne    11d0 <main+0xa0>
lea    0xe79(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Inserire il primo numero: \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [18 x i8] c"Buffer overflow \0A\00"
@.str.3 = [25 x i8] c"Numero inserito (A): %i\0A\00"
@.str.4 = [29 x i8] c"Inserire il secondo numero: \00"
@.str.5 = [25 x i8] c"Numero inserito (B): %i\0A\00"
@.str.6 = [35 x i8] c"Massimo Comune Divisore (MCD): %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%8 = load i32, i32* %5
%9 = icmp ugt i32 %8, 999999999
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %56
12: ; preds = %0
%13 = load i32, i32* %5
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %13)
%15 = load i32, i32* %5
store i32 %15, i32* %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%18 = load i32, i32* %5
%19 = icmp ugt i32 %18, 999999999
br i1 %19, label %20, label %22
20: ; preds = %12
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %56
22: ; preds = %12
%23 = load i32, i32* %5
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %23)
%25 = load i32, i32* %5
store i32 %25, i32* %3
br label %26
26: ; preds = %47, %22
%27 = load i32, i32* %2
%28 = load i32, i32* %3
%29 = icmp ne i32 %27, %28
br i1 %29, label %30, label %48
30: ; preds = %26
%31 = load i32, i32* %2
%32 = load i32, i32* %3
%33 = icmp ugt i32 %31, %32
br i1 %33, label %34, label %38
34: ; preds = %30
%35 = load i32, i32* %2
%36 = load i32, i32* %3
%37 = sub i32 %35, %36
store i32 %37, i32* %2
br label %47
38: ; preds = %30
%39 = load i32, i32* %2
%40 = load i32, i32* %3
%41 = icmp ult i32 %39, %40
br i1 %41, label %42, label %46
42: ; preds = %38
%43 = load i32, i32* %3
%44 = load i32, i32* %2
%45 = sub i32 %43, %44
store i32 %45, i32* %3
br label %46
46: ; preds = %42, %38
br label %47
47: ; preds = %46, %34
br label %26
48: ; preds = %26
%49 = load i32, i32* %2
%50 = load i32, i32* %3
%51 = icmp eq i32 %49, %50
br i1 %51, label %52, label %56
52: ; preds = %48
%53 = load i32, i32* %2
store i32 %53, i32* %4
%54 = load i32, i32* %4
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0), i32 %54)
br label %56
56: ; preds = %10, %20, %52, %48
%57 = load i32, i32* %1
ret i32 %57
}

LLVM IR (-O2):
@.str = [27 x i8] c"Inserire il primo numero: \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.3 = [25 x i8] c"Numero inserito (A): %i\0A\00"
@.str.4 = [29 x i8] c"Inserire il secondo numero: \00"
@.str.5 = [25 x i8] c"Numero inserito (B): %i\0A\00"
@.str.6 = [35 x i8] c"Massimo Comune Divisore (MCD): %d\0A\00"
@str.7 = [17 x i8] c"Buffer overflow \00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp ugt i32 %5, 999999999
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.7, i64 0, i64 0))
br label %36
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %5)
%11 = load i32, i32* %1
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%14 = load i32, i32* %1
%15 = icmp ugt i32 %14, 999999999
br i1 %15, label %16, label %18
16: ; preds = %9
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.7, i64 0, i64 0))
br label %36
18: ; preds = %9
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %14)
%20 = load i32, i32* %1
%21 = icmp eq i32 %11, %20
br i1 %21, label %33, label %22
22: ; preds = %18, %22
%23 = phi i32 [ %31, %22 ], [ %20, %18 ]
%24 = phi i32 [ %29, %22 ], [ %11, %18 ]
%25 = icmp ugt i32 %24, %23
%26 = icmp ult i32 %24, %23
%27 = select i1 %26, i32 %24, i32 0
%28 = select i1 %25, i32 %23, i32 0
%29 = sub i32 %24, %28
%30 = select i1 %25, i32 0, i32 %27
%31 = sub i32 %23, %30
%32 = icmp eq i32 %29, %31
br i1 %32, label %33, label %22
33: ; preds = %22, %18
%34 = phi i32 [ %11, %18 ], [ %29, %22 ]
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %33, %16, %7
ret i32 0
}