#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 *);
main() {
  int n1, n2, gcd, i;
  printf("Please enter the numbers\n");
  scanf("%d%d", &n1, &n2);
  n1 = (n1 > 0) ? n1 : -n1;
  n2 = (n2 > 0) ? n2 : -n2;
  while (n1 != n2) {
    if (n1 > n2)
      n1 -= n2;
    else
      n2 -= n1;
  }
  printf("GCD is %d\n", n1);
}


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    0xed6(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jle    1166 <main+0x46>
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    116e <main+0x4e>
xor    %eax,%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    1189 <main+0x69>
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1191 <main+0x71>
xor    %eax,%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     11cf <main+0xaf>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    11bf <main+0x9f>
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
jmp    11ca <main+0xaa>
mov    -0x8(%rbp),%ecx
mov    -0xc(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
jmp    1197 <main+0x77>
mov    -0x8(%rbp),%esi
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
call   1030 <puts@plt>
lea    0xebc(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1050 <scanf@plt>
mov    0x4(%rsp),%ecx
mov    %ecx,%eax
neg    %eax
cmovs  %ecx,%eax
mov    %eax,0x4(%rsp)
mov    (%rsp),%ecx
mov    %ecx,%esi
neg    %esi
cmovs  %ecx,%esi
mov    %esi,(%rsp)
cmp    %esi,%eax
jne    118b <main+0x5b>
mov    %eax,%esi
jmp    119b <main+0x6b>
cs nopw 0x0(%rax,%rax,1)
nop
sub    %eax,%esi
mov    %esi,(%rsp)
mov    %eax,%ecx
cmp    %esi,%ecx
je     119b <main+0x6b>
mov    %eax,%ecx
sub    %esi,%ecx
jle    1180 <main+0x50>
mov    %ecx,0x4(%rsp)
mov    %ecx,%eax
cmp    %esi,%ecx
jne    118b <main+0x5b>
lea    0xe63(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Please enter the numbers\0A\00"
@.str.1 = [5 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 ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%8 = load i32, i32* %2
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = load i32, i32* %2
br label %15
12: ; preds = %0
%13 = load i32, i32* %2
%14 = sub nsw i32 0, %13
br label %15
15: ; preds = %12, %10
%16 = phi i32 [ %11, %10 ], [ %14, %12 ]
store i32 %16, i32* %2
%17 = load i32, i32* %3
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = load i32, i32* %3
br label %24
21: ; preds = %15
%22 = load i32, i32* %3
%23 = sub nsw i32 0, %22
br label %24
24: ; preds = %21, %19
%25 = phi i32 [ %20, %19 ], [ %23, %21 ]
store i32 %25, i32* %3
br label %26
26: ; preds = %42, %24
%27 = load i32, i32* %2
%28 = load i32, i32* %3
%29 = icmp ne i32 %27, %28
br i1 %29, label %30, label %43
30: ; preds = %26
%31 = load i32, i32* %2
%32 = load i32, i32* %3
%33 = icmp sgt i32 %31, %32
br i1 %33, label %34, label %38
34: ; preds = %30
%35 = load i32, i32* %3
%36 = load i32, i32* %2
%37 = sub nsw i32 %36, %35
store i32 %37, i32* %2
br label %42
38: ; preds = %30
%39 = load i32, i32* %2
%40 = load i32, i32* %3
%41 = sub nsw i32 %40, %39
store i32 %41, i32* %3
br label %42
42: ; preds = %38, %34
br label %26
43: ; preds = %26
%44 = load i32, i32* %2
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %44)
%46 = load i32, i32* %1
ret i32 %46
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"%d%d\00"
@.str.2 = [11 x i8] c"GCD is %d\0A\00"
@str = [25 x i8] c"Please enter the numbers\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 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 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 = call i32 @llvm.abs.i32(i32 %7, i1 true)
store i32 %8, i32* %1
%9 = load i32, i32* %2
%10 = call i32 @llvm.abs.i32(i32 %9, i1 true)
store i32 %10, i32* %2
%11 = icmp eq i32 %8, %10
br i1 %11, label %24, label %12
12: ; preds = %0, %20
%13 = phi i32 [ %22, %20 ], [ %8, %0 ]
%14 = phi i32 [ %21, %20 ], [ %10, %0 ]
%15 = icmp sgt i32 %13, %14
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = sub nsw i32 %13, %14
store i32 %17, i32* %1
br label %20
18: ; preds = %12
%19 = sub nsw i32 %14, %13
store i32 %19, i32* %2
br label %20
20: ; preds = %18, %16
%21 = phi i32 [ %19, %18 ], [ %14, %16 ]
%22 = phi i32 [ %13, %18 ], [ %17, %16 ]
%23 = icmp eq i32 %22, %21
br i1 %23, label %24, label %12
24: ; preds = %20, %0
%25 = phi i32 [ %8, %0 ], [ %21, %20 ]
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %25)
ret i32 0
}