#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 *);
int main() {
  int n, m, r;
  printf("Entre com m e n: ");
  scanf("%d %d", &m, &n);
  r = m % n;
  while (r != 0) {
    m = n;
    n = r;
    r = m % n;
  }
  printf("MDC = %d\n", n);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xece(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x8(%rbp),%rdx
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     1180 <main+0x60>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %edx,-0x10(%rbp)
jmp    115b <main+0x3b>
mov    -0x8(%rbp),%esi
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
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    0xedc(%rip),%rdi
mov    %rsp,%rsi
lea    0x4(%rsp),%rdx
call   1040 <scanf@plt>
mov    (%rsp),%eax
mov    0x4(%rsp),%esi
cltd
idiv   %esi
test   %edx,%edx
je     1174 <main+0x54>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %esi,%ecx
mov    %edx,%esi
mov    %ecx,%eax
cltd
idiv   %esi
test   %edx,%edx
jne    1160 <main+0x40>
mov    %ecx,(%rsp)
mov    %esi,0x4(%rsp)
lea    0xe9d(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Entre com m e n: \00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [10 x i8] c"MDC = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 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* %3, i32* %2)
%7 = load i32, i32* %3
%8 = load i32, i32* %2
%9 = srem i32 %7, %8
store i32 %9, i32* %4
br label %10
10: ; preds = %13, %0
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %19
13: ; preds = %10
%14 = load i32, i32* %2
store i32 %14, i32* %3
%15 = load i32, i32* %4
store i32 %15, i32* %2
%16 = load i32, i32* %3
%17 = load i32, i32* %2
%18 = srem i32 %16, %17
store i32 %18, i32* %4
br label %10
19: ; preds = %10
%20 = load i32, i32* %2
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %20)
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"Entre com m e n: \00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [10 x i8] c"MDC = %d\0A\00"
define i32 @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 ([18 x i8], [18 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* %2, i32* %1)
%7 = load i32, i32* %2
%8 = load i32, i32* %1
%9 = srem i32 %7, %8
%10 = icmp eq i32 %9, 0
br i1 %10, label %17, label %11
11: ; preds = %0, %11
%12 = phi i32 [ %14, %11 ], [ %9, %0 ]
%13 = phi i32 [ %12, %11 ], [ %8, %0 ]
%14 = srem i32 %13, %12
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %11
16: ; preds = %11
store i32 %13, i32* %2
store i32 %12, i32* %1
br label %17
17: ; preds = %16, %0
%18 = phi i32 [ %12, %16 ], [ %8, %0 ]
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %18)
ret i32 0
}