#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, divisor, small, large, c;
  printf("Enter two non-negative integers\n");
  scanf("%d %d", &a, &b);
  if (a <= b) {
    small = a;
    large = b;
  } else
    large = a;
  small = b;
  for (c = small; c > 0; c--) {
    if (small % c == 0 && large % c == 0) {
      divisor = c;
      break;
    }
  }
  printf("GCD of %d and %d is %d\n\n", small, large, divisor);
  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    0xedd(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     116e <main+0x4e>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1174 <main+0x54>
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    11c8 <main+0xa8>
mov    -0x14(%rbp),%eax
cltd
idivl  -0x1c(%rbp)
cmp    $0x0,%edx
jne    11b5 <main+0x95>
mov    -0x18(%rbp),%eax
cltd
idivl  -0x1c(%rbp)
cmp    $0x0,%edx
jne    11b5 <main+0x95>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    11c8 <main+0xa8>
jmp    11ba <main+0x9a>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    1180 <main+0x60>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe4f(%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    0xee7(%rip),%rdi
call   1030 <puts@plt>
lea    0xebc(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1050 <scanf@plt>
mov    0x4(%rsp),%r8d
mov    (%rsp),%esi
cmp    %esi,%r8d
cmovle %esi,%r8d
mov    %esi,%ecx
test   %esi,%esi
jle    1191 <main+0x61>
mov    %esi,%ecx
jmp    117a <main+0x4a>
nopw   0x0(%rax,%rax,1)
lea    -0x1(%rcx),%eax
cmp    $0x1,%ecx
mov    %eax,%ecx
jle    118f <main+0x5f>
mov    %esi,%eax
cltd
idiv   %ecx
test   %edx,%edx
jne    1170 <main+0x40>
mov    %r8d,%eax
cltd
idiv   %ecx
test   %edx,%edx
jne    1170 <main+0x40>
jmp    1191 <main+0x61>
xor    %ecx,%ecx
lea    0xe6e(%rip),%rdi
mov    %r8d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Enter two non-negative integers\0A\00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [25 x i8] c"GCD of %d and %d is %d\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%10 = load i32, i32* %2
%11 = load i32, i32* %3
%12 = icmp sle i32 %10, %11
br i1 %12, label %13, label %16
13: ; preds = %0
%14 = load i32, i32* %2
store i32 %14, i32* %5
%15 = load i32, i32* %3
store i32 %15, i32* %6
br label %18
16: ; preds = %0
%17 = load i32, i32* %2
store i32 %17, i32* %6
br label %18
18: ; preds = %16, %13
%19 = load i32, i32* %3
store i32 %19, i32* %5
%20 = load i32, i32* %5
store i32 %20, i32* %7
br label %21
21: ; preds = %37, %18
%22 = load i32, i32* %7
%23 = icmp sgt i32 %22, 0
br i1 %23, label %24, label %40
24: ; preds = %21
%25 = load i32, i32* %5
%26 = load i32, i32* %7
%27 = srem i32 %25, %26
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %36
29: ; preds = %24
%30 = load i32, i32* %6
%31 = load i32, i32* %7
%32 = srem i32 %30, %31
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %29
%35 = load i32, i32* %7
store i32 %35, i32* %4
br label %40
36: ; preds = %29, %24
br label %37
37: ; preds = %36
%38 = load i32, i32* %7
%39 = add nsw i32 %38, -1
store i32 %39, i32* %7
br label %21
40: ; preds = %34, %21
%41 = load i32, i32* %5
%42 = load i32, i32* %6
%43 = load i32, i32* %4
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %41, i32 %42, i32 %43)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [25 x i8] c"GCD of %d and %d is %d\0A\0A\00"
@str = [32 x i8] c"Enter two non-negative integers\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 ([32 x i8], [32 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 %7, i32 %8
%11 = icmp sgt i32 %8, 0
br i1 %11, label %12, label %22
12: ; preds = %0, %19
%13 = phi i32 [ %20, %19 ], [ %8, %0 ]
%14 = srem i32 %8, %13
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = srem i32 %10, %13
%18 = icmp eq i32 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %12, %16
%20 = add nsw i32 %13, -1
%21 = icmp sgt i32 %13, 1
br i1 %21, label %12, label %22
22: ; preds = %19, %16, %0
%23 = phi i32 [ %8, %0 ], [ %13, %16 ], [ 0, %19 ]
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %8, i32 %10, i32 %23)
ret i32 0
}