#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 a, b, c;
  printf("input two numbers:");
  scanf("%d%d", &a, &b);
  if (a < b) {
    c = b;
    b = a;
    a = c;
  }
  while (b != 0) {
    a = a % b;
    if (a < b) {
      c = b;
      b = a;
      a = c;
    }
  }
  printf("the max devidor is %d\n", a);
  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    0xecf(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    116f <main+0x4f>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    1174 <main+0x54>
cmpl   $0x0,-0xc(%rbp)
je     11ab <main+0x8b>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a6 <main+0x86>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    1174 <main+0x54>
mov    -0x8(%rbp),%esi
lea    0xe63(%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    0xedd(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1040 <scanf@plt>
mov    0x4(%rsp),%ecx
mov    (%rsp),%edx
cmp    %edx,%ecx
jge    115d <main+0x3d>
mov    %ecx,(%rsp)
mov    %edx,0x4(%rsp)
mov    %edx,%eax
test   %ecx,%ecx
jne    117b <main+0x5b>
jmp    118e <main+0x6e>
mov    %ecx,%eax
mov    %edx,%ecx
test   %ecx,%ecx
jne    117b <main+0x5b>
jmp    118e <main+0x6e>
nopw   0x0(%rax,%rax,1)
mov    %edx,(%rsp)
mov    %ecx,%eax
mov    %edx,%ecx
test   %edx,%edx
je     118a <main+0x6a>
cltd
idiv   %ecx
test   %ecx,%ecx
jns    1170 <main+0x50>
mov    %edx,%eax
mov    %ecx,%edx
test   %edx,%edx
jne    117b <main+0x5b>
mov    %eax,0x4(%rsp)
lea    0xe83(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [19 x i8] c"input two numbers:\00"
@.str.1 = [5 x i8] c"%d%d\00"
@.str.2 = [23 x i8] c"the max devidor is %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 ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%7 = load i32, i32* %2
%8 = load i32, i32* %3
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %14
10: ; preds = %0
%11 = load i32, i32* %3
store i32 %11, i32* %4
%12 = load i32, i32* %2
store i32 %12, i32* %3
%13 = load i32, i32* %4
store i32 %13, i32* %2
br label %14
14: ; preds = %10, %0
br label %15
15: ; preds = %29, %14
%16 = load i32, i32* %3
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %30
18: ; preds = %15
%19 = load i32, i32* %2
%20 = load i32, i32* %3
%21 = srem i32 %19, %20
store i32 %21, i32* %2
%22 = load i32, i32* %2
%23 = load i32, i32* %3
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %29
25: ; preds = %18
%26 = load i32, i32* %3
store i32 %26, i32* %4
%27 = load i32, i32* %2
store i32 %27, i32* %3
%28 = load i32, i32* %4
store i32 %28, i32* %2
br label %29
29: ; preds = %25, %18
br label %15
30: ; preds = %15
%31 = load i32, i32* %2
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %31)
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"input two numbers:\00"
@.str.1 = [5 x i8] c"%d%d\00"
@.str.2 = [23 x i8] c"the max devidor is %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 ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%7 = load i32, i32* %1
%8 = load i32, i32* %2
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %11
10: ; preds = %0
store i32 %7, i32* %2
store i32 %8, i32* %1
br label %11
11: ; preds = %10, %0
%12 = phi i32 [ %8, %10 ], [ %7, %0 ]
%13 = phi i32 [ %7, %10 ], [ %8, %0 ]
%14 = icmp eq i32 %13, 0
br i1 %14, label %26, label %15
15: ; preds = %11, %21
%16 = phi i32 [ %23, %21 ], [ %13, %11 ]
%17 = phi i32 [ %22, %21 ], [ %12, %11 ]
%18 = srem i32 %17, %16
%19 = icmp sgt i32 %16, -1
br i1 %19, label %20, label %21
20: ; preds = %15
store i32 %18, i32* %2
br label %21
21: ; preds = %20, %15
%22 = phi i32 [ %16, %20 ], [ %18, %15 ]
%23 = phi i32 [ %18, %20 ], [ %16, %15 ]
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %15
25: ; preds = %21
store i32 %22, i32* %1
br label %26
26: ; preds = %25, %11
%27 = phi i32 [ %22, %25 ], [ %12, %11 ]
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %27)
ret i32 0
}