#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(void) {
  int a, b, remainder;
  printf("enter two number: ");
  scanf("%d %d", &a, &b);
  if (a > b) {
    int temp = b;
    b = a;
    a = temp;
  }
  do {
    remainder = b % a;
    b = a;
    a = remainder;
  } while (remainder != 0);
  printf("gcd is %d\n", b);
  return 0;
}


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    0xecf(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    116f <main+0x4f>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    1174 <main+0x54>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    1174 <main+0x54>
mov    -0xc(%rbp),%esi
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%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),%eax
mov    (%rsp),%esi
cmp    %esi,%eax
mov    %eax,%edx
cmovg  %esi,%edx
cmovg  %eax,%esi
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %esi,%eax
mov    %edx,%esi
cltd
idiv   %esi
test   %edx,%edx
jne    1160 <main+0x40>
mov    %esi,(%rsp)
movl   $0x0,0x4(%rsp)
lea    0xe9c(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

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