#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*/ exit(int /*<<< orphan*/);
int my_gcd(int, int);
int /*<<< orphan*/ printf(char *);
int scanf(char *, int *, int *);
int test_gcd(void) {
  int s, val1, val2;
  printf("\nGreatest Common Demoninator:\nPlease input two integers\n\n");
  s = scanf("%d %d", &val1, &val2);
  if (val1 == 0 || val2 == 0) {
    printf("\n ZERO is invalid input \n");
    exit(0);
  }
  if (s != 2) {
    printf("\nInput Error, Try again\n\n");
    exit(0);
  }
  return my_gcd(val1, val2);
}


x86 assembly (clang, -O0):
<test_gcd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
call   1030 <printf@plt>
lea    0xedf(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     117f <test_gcd+0x3f>
cmpl   $0x0,-0xc(%rbp)
jne    1192 <test_gcd+0x52>
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>
cmpl   $0x2,-0x4(%rbp)
je     11af <test_gcd+0x6f>
lea    0xeb7(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <my_gcd@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_gcd>:
push   %rax
lea    0xebe(%rip),%rdi
call   1030 <puts@plt>
lea    0xeac(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1040 <scanf@plt>
mov    0x4(%rsp),%edi
test   %edi,%edi
je     117c <test_gcd+0x3c>
mov    (%rsp),%esi
test   %esi,%esi
je     117c <test_gcd+0x3c>
cmp    $0x2,%eax
jne    1185 <test_gcd+0x45>
call   1050 <my_gcd@plt>
pop    %rcx
ret
lea    0xed5(%rip),%rdi
jmp    118c <test_gcd+0x4c>
lea    0xeb3(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [58 x i8] c"\0AGreatest Common Demoninator:\0APlease input two integers\0A\0A\00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [26 x i8] c"\0A ZERO is invalid input \0A\00"
@.str.3 = [26 x i8] c"\0AInput Error, Try again\0A\0A\00"
define i32 @test_gcd() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
store i32 %5, i32* %1
%6 = load i32, i32* %2
%7 = icmp eq i32 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %0
%9 = load i32, i32* %3
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %8, %0
%12 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @exit(i32 0)
unreachable
14: ; preds = %8
%15 = load i32, i32* %1
%16 = icmp ne i32 %15, 2
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%19 = call i32 @exit(i32 0)
unreachable
20: ; preds = %14
%21 = load i32, i32* %2
%22 = load i32, i32* %3
%23 = call i32 @my_gcd(i32 %21, i32 %22)
ret i32 %23
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"%d %d\00"
@str = [57 x i8] c"\0AGreatest Common Demoninator:\0APlease input two integers\0A\00"
@str.4 = [25 x i8] c"\0AInput Error, Try again\0A\00"
@str.5 = [25 x i8] c"\0A ZERO is invalid input \00"
define i32 @test_gcd() {
%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 ([57 x i8], [57 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 = icmp eq i32 %7, 0
%9 = load i32, i32* %2
%10 = icmp eq i32 %9, 0
%11 = select i1 %8, i1 true, i1 %10
br i1 %11, label %12, label %15
12: ; preds = %0
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.5, i64 0, i64 0))
%14 = call i32 @exit(i32 0)
unreachable
15: ; preds = %0
%16 = icmp eq i32 %6, 2
br i1 %16, label %20, label %17
17: ; preds = %15
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.4, i64 0, i64 0))
%19 = call i32 @exit(i32 0)
unreachable
20: ; preds = %15
%21 = call i32 @my_gcd(i32 %7, i32 %9)
ret i32 %21
}