#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);
int /*<<< orphan*/ scanf(char *, int *, int *);
void main() {
  int num0, num1;
  int tmp;
  int i;
  int gcd;
  scanf("%d%d", &num0, &num1);
  if (num0 > num1) {
    tmp = num0;
    num0 = num1;
    num1 = tmp;
  }
  gcd = num0;
  while (1) {
    if (num0 % gcd == 0 && num1 % gcd == 0)
      break;
    gcd--;
  }
  printf("gcd = %d\n", gcd);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xed1(%rip),%rdi
lea    -0x4(%rbp),%rsi
lea    -0x8(%rbp),%rdx
call   1040 <scanf@plt>
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jle    115a <main+0x3a>
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%eax
cltd
idivl  -0x14(%rbp)
cmp    $0x0,%edx
jne    1185 <main+0x65>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x14(%rbp)
cmp    $0x0,%edx
jne    1185 <main+0x65>
jmp    1193 <main+0x73>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1160 <main+0x40>
mov    -0x14(%rbp),%esi
lea    0xe68(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
mov    (%rsp),%ecx
cmp    %ecx,%eax
jle    114b <main+0x2b>
mov    %ecx,0x4(%rsp)
mov    %eax,(%rsp)
mov    %eax,%edi
jmp    114f <main+0x2f>
mov    %ecx,%edi
mov    %eax,%ecx
mov    %ecx,%esi
jmp    1163 <main+0x43>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0xffffffff,%esi
mov    %ecx,%eax
cltd
idiv   %esi
test   %edx,%edx
jne    1160 <main+0x40>
mov    %edi,%eax
cltd
idiv   %esi
test   %edx,%edx
jne    1160 <main+0x40>
lea    0xe89(%rip),%rdi
call   1030 <printf@plt>
pop    %rax
ret

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

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