#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 = 0, num2 = 0, gcd = 0;
  printf("enter 2 integers:(xx xx)\n");
  scanf("%d %d", &num1, &num2);
  while (num2 != 0) {
    gcd = num1;
    num1 = num2;
    num2 = gcd % num2;
  }
  gcd = num1;
  printf("greatest common divisor: %d\n", gcd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec1(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
cmpl   $0x0,-0xc(%rbp)
je     118b <main+0x6b>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,-0xc(%rbp)
jmp    1166 <main+0x46>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movl   $0x0,0x4(%rsp)
movl   $0x0,(%rsp)
lea    0xedc(%rip),%rdi
call   1030 <puts@plt>
lea    0xead(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1050 <scanf@plt>
mov    (%rsp),%edx
mov    0x4(%rsp),%esi
test   %edx,%edx
je     1186 <main+0x56>
nopl   0x0(%rax,%rax,1)
mov    %esi,%eax
mov    %edx,%esi
cltd
idiv   %esi
test   %edx,%edx
jne    1170 <main+0x40>
mov    %esi,0x4(%rsp)
movl   $0x0,(%rsp)
lea    0xe79(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [26 x i8] c"enter 2 integers:(xx xx)\0A\00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [29 x i8] c"greatest common divisor: %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* %2
store i32 0, i32* %3
store i32 0, i32* %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 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 = %10, %0
%8 = load i32, i32* %3
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %16
10: ; preds = %7
%11 = load i32, i32* %2
store i32 %11, i32* %4
%12 = load i32, i32* %3
store i32 %12, i32* %2
%13 = load i32, i32* %4
%14 = load i32, i32* %3
%15 = srem i32 %13, %14
store i32 %15, i32* %3
br label %7
16: ; preds = %7
%17 = load i32, i32* %2
store i32 %17, i32* %4
%18 = load i32, i32* %4
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %18)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [29 x i8] c"greatest common divisor: %d\0A\00"
@str = [25 x i8] c"enter 2 integers:(xx xx)\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%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 ([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 %16, label %10
10: ; preds = %0, %10
%11 = phi i32 [ %13, %10 ], [ %7, %0 ]
%12 = phi i32 [ %11, %10 ], [ %8, %0 ]
%13 = srem i32 %12, %11
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %10
15: ; preds = %10
store i32 %11, i32* %1
store i32 0, i32* %2
br label %16
16: ; preds = %15, %0
%17 = phi i32 [ %11, %15 ], [ %8, %0 ]
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %17)
ret i32 0
}