#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 a, b, gcd;
  printf("Enter two numbers: \n");
  scanf("%d %d", &a, &b);
  int i;
  gcd = 1;
  for (i = 1; i <= a && i <= b; i++)
    if (a % i == 0 && b % i == 0)
      gcd = i;
  printf("GCD for numbers %d and %d is %d", a, b, gcd);
  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    0xed1(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
movl   $0x1,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%ecx
xor    %eax,%eax
cmp    -0x8(%rbp),%ecx
mov    %al,-0x15(%rbp)
jg     117c <main+0x5c>
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
setle  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    118c <main+0x6c>
jmp    11c5 <main+0xa5>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x14(%rbp)
cmp    $0x0,%edx
jne    11b2 <main+0x92>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x14(%rbp)
cmp    $0x0,%edx
jne    11b2 <main+0x92>
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    11b7 <main+0x97>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115f <main+0x3f>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe46(%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    0xeee(%rip),%rdi
call   1030 <puts@plt>
lea    0xebc(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1050 <scanf@plt>
mov    0x4(%rsp),%esi
mov    (%rsp),%r8d
mov    $0x1,%ecx
test   %esi,%esi
jle    11a2 <main+0x72>
test   %r8d,%r8d
jle    11a2 <main+0x72>
mov    $0x1,%edi
mov    $0x1,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %esi,%eax
cltd
idiv   %edi
test   %edx,%edx
jne    1194 <main+0x64>
mov    %r8d,%eax
cltd
idiv   %edi
test   %edx,%edx
cmove  %edi,%ecx
cmp    %esi,%edi
jge    11a2 <main+0x72>
lea    0x1(%rdi),%eax
cmp    %r8d,%edi
mov    %eax,%edi
jl     1180 <main+0x50>
lea    0xe5d(%rip),%rdi
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 = [32 x i8] c"GCD for numbers %d and %d is %d\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
store i32 1, i32* %5
br label %8
8: ; preds = %31, %0
%9 = load i32, i32* %5
%10 = load i32, i32* %2
%11 = icmp sle i32 %9, %10
br i1 %11, label %12, label %16
12: ; preds = %8
%13 = load i32, i32* %5
%14 = load i32, i32* %3
%15 = icmp sle i32 %13, %14
br label %16
16: ; preds = %12, %8
%17 = phi i1 [ false, %8 ], [ %15, %12 ]
br i1 %17, label %18, label %34
18: ; preds = %16
%19 = load i32, i32* %2
%20 = load i32, i32* %5
%21 = srem i32 %19, %20
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %30
23: ; preds = %18
%24 = load i32, i32* %3
%25 = load i32, i32* %5
%26 = srem i32 %24, %25
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %23
%29 = load i32, i32* %5
store i32 %29, i32* %4
br label %30
30: ; preds = %28, %23, %18
br label %31
31: ; preds = %30
%32 = load i32, i32* %5
%33 = add nsw i32 %32, 1
store i32 %33, i32* %5
br label %8
34: ; preds = %16
%35 = load i32, i32* %2
%36 = load i32, i32* %3
%37 = load i32, i32* %4
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %35, i32 %36, i32 %37)
ret i32 0
}

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