#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 *, int *, int *);
void main() {
  int a, b, resto, aux;
  printf("Digite 2 numeros inteiros: ");
  scanf("%d %d", &a, &b);
  if (b > a) {
    aux = b;
    b = a;
    a = aux;
  }
  resto = a % b;
  while (resto != 0) {
    a = b;
    b = resto;
    resto = a % b;
  }
  printf("O MDC dos numeros entrados eh %d\n", b);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedf(%rip),%rdi
lea    -0x4(%rbp),%rsi
lea    -0x8(%rbp),%rdx
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jle    1168 <main+0x48>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %edx,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1197 <main+0x77>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %edx,-0xc(%rbp)
jmp    1172 <main+0x52>
mov    -0x8(%rbp),%esi
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee6(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1040 <scanf@plt>
mov    (%rsp),%eax
mov    0x4(%rsp),%ecx
cmp    %ecx,%eax
jle    1159 <main+0x39>
mov    %ecx,(%rsp)
mov    %eax,0x4(%rsp)
mov    %ecx,%esi
jmp    115d <main+0x3d>
mov    %eax,%esi
mov    %ecx,%eax
cltd
idiv   %esi
test   %edx,%edx
je     1184 <main+0x64>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %esi,%ecx
mov    %edx,%esi
mov    %ecx,%eax
cltd
idiv   %esi
test   %edx,%edx
jne    1170 <main+0x50>
mov    %ecx,0x4(%rsp)
mov    %esi,(%rsp)
lea    0xe97(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Digite 2 numeros inteiros: \00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [34 x i8] c"O MDC dos numeros entrados eh %d\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%7 = load i32, i32* %2
%8 = load i32, i32* %1
%9 = icmp sgt i32 %7, %8
br i1 %9, label %10, label %14
10: ; preds = %0
%11 = load i32, i32* %2
store i32 %11, i32* %4
%12 = load i32, i32* %1
store i32 %12, i32* %2
%13 = load i32, i32* %4
store i32 %13, i32* %1
br label %14
14: ; preds = %10, %0
%15 = load i32, i32* %1
%16 = load i32, i32* %2
%17 = srem i32 %15, %16
store i32 %17, i32* %3
br label %18
18: ; preds = %21, %14
%19 = load i32, i32* %3
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %27
21: ; preds = %18
%22 = load i32, i32* %2
store i32 %22, i32* %1
%23 = load i32, i32* %3
store i32 %23, i32* %2
%24 = load i32, i32* %1
%25 = load i32, i32* %2
%26 = srem i32 %24, %25
store i32 %26, i32* %3
br label %18
27: ; preds = %18
%28 = load i32, i32* %2
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %28)
ret void
}

LLVM IR (-O2):
@.str = [28 x i8] c"Digite 2 numeros inteiros: \00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [34 x i8] c"O MDC dos numeros entrados eh %d\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%7 = load i32, i32* %2
%8 = load i32, i32* %1
%9 = icmp sgt i32 %7, %8
br i1 %9, label %10, label %11
10: ; preds = %0
store i32 %8, i32* %2
store i32 %7, i32* %1
br label %11
11: ; preds = %10, %0
%12 = phi i32 [ %8, %10 ], [ %7, %0 ]
%13 = phi i32 [ %7, %10 ], [ %8, %0 ]
%14 = srem i32 %13, %12
%15 = icmp eq i32 %14, 0
br i1 %15, label %22, label %16
16: ; preds = %11, %16
%17 = phi i32 [ %19, %16 ], [ %14, %11 ]
%18 = phi i32 [ %17, %16 ], [ %12, %11 ]
%19 = srem i32 %18, %17
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %16
21: ; preds = %16
store i32 %18, i32* %1
store i32 %17, i32* %2
br label %22
22: ; preds = %21, %11
%23 = phi i32 [ %17, %21 ], [ %12, %11 ]
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %23)
ret void
}