#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() {
  int num1, num2, divisor, gcd;
  printf("Enter two numbers: \n");
  scanf("%d %d", &num1, &num2);
  for (divisor = 1; divisor <= (num1 <= num2 ? num1 : num2); divisor++)
    if (num1 % divisor == 0 && num2 % divisor == 0)
      gcd = divisor;
  printf("GCD of %d and %d is %d\n", num1, num2, gcd);
}


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    0xed1(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1175 <main+0x55>
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    117b <main+0x5b>
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x1c(%rbp),%ecx
cmp    %ecx,%eax
jg     11c2 <main+0xa2>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
jne    11af <main+0x8f>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
jne    11af <main+0x8f>
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    11b4 <main+0x94>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1158 <main+0x38>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xe49(%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    0xee6(%rip),%rdi
call   1030 <puts@plt>
lea    0xebc(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1050 <scanf@plt>
mov    0x4(%rsp),%r9d
mov    (%rsp),%r8d
cmp    %r8d,%r9d
mov    %r9d,%edi
cmovg  %r8d,%edi
neg    %edi
mov    $0x1,%esi
jmp    1182 <main+0x52>
nopl   (%rax)
lea    (%rdi,%rsi,1),%eax
add    $0x1,%eax
mov    %esi,%edx
add    $0x1,%edx
mov    %edx,%esi
cmp    $0x1,%eax
je     1199 <main+0x69>
mov    %r9d,%eax
cltd
idiv   %esi
test   %edx,%edx
jne    1170 <main+0x40>
mov    %r8d,%eax
cltd
idiv   %esi
test   %edx,%edx
cmove  %esi,%ecx
jmp    1170 <main+0x40>
lea    0xe66(%rip),%rdi
mov    %r9d,%esi
mov    %r8d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

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