#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 num1, num2, remain;
  remain = 0;
  printf("Enter two integers: ");
  scanf("%d %d", &num1, &num2);
  while (true) {
    if (num2 == 0) {
      printf("GCD is %d\n", num1);
      break;
    } else {
      remain = num1 % num2;
      num1 = num2;
      num2 = remain;
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
cmpl   $0x0,-0xc(%rbp)
jne    1178 <main+0x58>
mov    -0x8(%rbp),%esi
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1193 <main+0x73>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1158 <main+0x38>
mov    -0x4(%rbp),%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    0xedf(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1040 <scanf@plt>
mov    (%rsp),%edx
mov    0x4(%rsp),%esi
test   %edx,%edx
je     1166 <main+0x46>
xchg   %ax,%ax
mov    %esi,%eax
mov    %edx,%esi
cltd
idiv   %esi
test   %edx,%edx
jne    1150 <main+0x30>
mov    %esi,0x4(%rsp)
movl   $0x0,(%rsp)
lea    0xeae(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Enter two integers: \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
store i32 0, i32* %1
store i32 0, i32* %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 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* %2, i32* %3)
br label %7
7: ; preds = %0, %19
%8 = load i32, i32* %3
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = load i32, i32* %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %11)
br label %20
13: ; preds = %7
%14 = load i32, i32* %2
%15 = load i32, i32* %3
%16 = srem i32 %14, %15
store i32 %16, i32* %4
%17 = load i32, i32* %3
store i32 %17, i32* %2
%18 = load i32, i32* %4
store i32 %18, i32* %3
br label %19
19: ; preds = %13
br label %7
20: ; preds = %10
%21 = load i32, i32* %1
ret i32 %21
}

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