#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 atoi(char *);
int gcdGen(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, char *argv[]) {
  int aNum = 0, bNum = 0;
  do {
    if (argc == 3) {
      aNum = atoi(argv[1]);
      bNum = atoi(argv[2]);
    } else {
      printf("\nPlease enter first number:\n");
      scanf("%d", &aNum);
      printf("\nPlease enter second number:\n");
      scanf("%d", &bNum);
    }
    if (aNum == 0 || bNum == 0) {
      printf("Please enter non-zero numbers.\n");
    } else {
      break;
    }
  } while (1);
  printf("The greatest common divisor of %d and %d is %d.\n", aNum, bNum,
         gcdGen(aNum, bNum));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    1193 <main+0x53>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x18(%rbp)
jmp    11cf <main+0x8f>
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe75(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe57(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x14(%rbp)
je     11e3 <main+0xa3>
cmpl   $0x0,-0x18(%rbp)
jne    11f6 <main+0xb6>
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11fb <main+0xbb>
jmp    120f <main+0xcf>
jmp    1200 <main+0xc0>
mov    $0x1,%al
test   $0x1,%al
jne    1164 <main+0x24>
jmp    120f <main+0xcf>
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1030 <gcdGen@plt>
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    %eax,%ecx
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
movl   $0x0,0x4(%rsp)
movl   $0x0,(%rsp)
lea    0xef7(%rip),%r14
lea    0xe83(%rip),%r12
jmp    1188 <main+0x38>
nop
mov    %r14,%rdi
call   1030 <puts@plt>
cmp    $0x3,%ebp
jne    11c0 <main+0x70>
mov    0x8(%rbx),%rdi
call   1070 <atoi@plt>
mov    %eax,%r15d
mov    %eax,0x4(%rsp)
mov    0x10(%rbx),%rdi
call   1070 <atoi@plt>
mov    %eax,%r13d
mov    %eax,(%rsp)
test   %r15d,%r15d
jne    11fe <main+0xae>
jmp    1180 <main+0x30>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0xe6d(%rip),%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
lea    0xe70(%rip),%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
mov    %rsp,%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%r15d
mov    (%rsp),%r13d
test   %r15d,%r15d
je     1180 <main+0x30>
test   %r13d,%r13d
je     1180 <main+0x30>
mov    %r15d,%edi
mov    %r13d,%esi
call   1040 <gcdGen@plt>
lea    0xdea(%rip),%rdi
mov    %r15d,%esi
mov    %r13d,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"\0APlease enter first number:\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [30 x i8] c"\0APlease enter second number:\0A\00"
@.str.3 = [32 x i8] c"Please enter non-zero numbers.\0A\00"
@.str.4 = [49 x i8] c"The greatest common divisor of %d and %d is %d.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %35, %2
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 3
br i1 %10, label %11, label %20
11: ; preds = %8
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @atoi(i8* %14)
store i32 %15, i32* %6
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 2
%18 = load i8*, i8** %17
%19 = call i32 @atoi(i8* %18)
store i32 %19, i32* %7
br label %25
20: ; preds = %8
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
br label %25
25: ; preds = %20, %11
%26 = load i32, i32* %6
%27 = icmp eq i32 %26, 0
br i1 %27, label %31, label %28
28: ; preds = %25
%29 = load i32, i32* %7
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %28, %25
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
br label %34
33: ; preds = %28
br label %36
34: ; preds = %31
br label %35
35: ; preds = %34
br i1 true, label %8, label %36
36: ; preds = %35, %33
%37 = load i32, i32* %6
%38 = load i32, i32* %7
%39 = load i32, i32* %6
%40 = load i32, i32* %7
%41 = call i32 @gcdGen(i32 %39, i32 %40)
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0), i32 %37, i32 %38, i32 %41)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.4 = [49 x i8] c"The greatest common divisor of %d and %d is %d.\0A\00"
@str = [28 x i8] c"\0APlease enter first number:\00"
@str.5 = [29 x i8] c"\0APlease enter second number:\00"
@str.6 = [31 x i8] c"Please enter non-zero numbers.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%6 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%7 = icmp eq i32 %0, 3
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = getelementptr inbounds i8*, i8** %1, i64 2
br label %10
10: ; preds = %29, %2
br i1 %7, label %11, label %16
11: ; preds = %10
%12 = load i8*, i8** %8
%13 = call i32 @atoi(i8* %12)
store i32 %13, i32* %3
%14 = load i8*, i8** %9
%15 = call i32 @atoi(i8* %14)
store i32 %15, i32* %4
br label %23
16: ; preds = %10
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.5, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%21 = load i32, i32* %3
%22 = load i32, i32* %4
br label %23
23: ; preds = %16, %11
%24 = phi i32 [ %22, %16 ], [ %15, %11 ]
%25 = phi i32 [ %21, %16 ], [ %13, %11 ]
%26 = icmp eq i32 %25, 0
%27 = icmp eq i32 %24, 0
%28 = select i1 %26, i1 true, i1 %27
br i1 %28, label %29, label %31
29: ; preds = %23
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.6, i64 0, i64 0))
br label %10
31: ; preds = %23
%32 = call i32 @gcdGen(i32 %25, i32 %24)
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0), i32 %25, i32 %24, i32 %32)
ret i32 0
}