#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;
  printf("First number: ");
  scanf("%d", &n1);
  printf("Second number: ");
  scanf("%d", &n2);
  for (; n1 != n2;) {
    if (n1 > n2)
      n1 -= n2;
    else
      n2 -= n1;
  }
  printf("the GCD is: %d\n", n1);
  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    0xecb(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xead(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     11a3 <main+0x83>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    1193 <main+0x73>
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
jmp    119e <main+0x7e>
mov    -0x8(%rbp),%ecx
mov    -0xc(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
jmp    116b <main+0x4b>
mov    -0x8(%rbp),%esi
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xed4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed5(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0xec4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
mov    0x8(%rsp),%esi
cmp    %esi,%eax
jne    118c <main+0x6c>
mov    %eax,%esi
jmp    119c <main+0x7c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
sub    %eax,%esi
mov    %esi,0x8(%rsp)
mov    %eax,%ecx
cmp    %esi,%ecx
je     119c <main+0x7c>
mov    %eax,%ecx
sub    %esi,%ecx
jle    1180 <main+0x60>
mov    %ecx,0xc(%rsp)
mov    %ecx,%eax
cmp    %esi,%ecx
jne    118c <main+0x6c>
lea    0xe7f(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [15 x i8] c"First number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [16 x i8] c"Second number: \00"
@.str.3 = [16 x i8] c"the 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 ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %1
%10 = load i32, i32* %2
%11 = icmp eq i32 %9, %10
br i1 %11, label %24, label %12
12: ; preds = %0, %20
%13 = phi i32 [ %22, %20 ], [ %9, %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 [ %9, %0 ], [ %21, %20 ]
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %25)
ret i32 0
}