#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 gcd(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, int *);
int main() {
  int a, b;
  printf("-- The GCD Finder --\n");
  while (1) {
    printf("Enter two positive numbers: ");
    scanf("%d %d", &a, &b);
    if (a >= 1 && b >= 1)
      break;
    else
      printf("\nWrong input!\n");
  }
  printf("The GCD of given numbers is: %d\n", gcd(a, b));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec2(%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>
cmpl   $0x1,-0x8(%rbp)
jl     1188 <main+0x58>
cmpl   $0x1,-0xc(%rbp)
jl     1188 <main+0x58>
jmp    119b <main+0x6b>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    114d <main+0x1d>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <gcd@plt>
mov    %eax,%esi
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xef0(%rip),%rdi
call   1030 <puts@plt>
lea    0xea0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeaf(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1050 <scanf@plt>
mov    0xc(%rsp),%edi
test   %edi,%edi
jle    118d <main+0x4d>
mov    0x8(%rsp),%esi
test   %esi,%esi
jg     11e0 <main+0xa0>
lea    0xec5(%rip),%r14
lea    0xe65(%rip),%r15
lea    0xe7b(%rip),%r12
lea    0xc(%rsp),%r13
lea    0x8(%rsp),%rbx
nopl   0x0(%rax)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1050 <scanf@plt>
mov    0xc(%rsp),%edi
test   %edi,%edi
jle    11b0 <main+0x70>
mov    0x8(%rsp),%esi
test   %esi,%esi
jle    11b0 <main+0x70>
call   1060 <gcd@plt>
lea    0xe37(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [22 x i8] c"-- The GCD Finder --\0A\00"
@.str.1 = [29 x i8] c"Enter two positive numbers: \00"
@.str.2 = [6 x i8] c"%d %d\00"
@.str.3 = [15 x i8] c"\0AWrong input!\0A\00"
@.str.4 = [33 x i8] c"The GCD of given numbers is: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %0, %16
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %2, i32* %3)
%8 = load i32, i32* %2
%9 = icmp sge i32 %8, 1
br i1 %9, label %10, label %14
10: ; preds = %5
%11 = load i32, i32* %3
%12 = icmp sge i32 %11, 1
br i1 %12, label %13, label %14
13: ; preds = %10
br label %17
14: ; preds = %10, %5
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
br label %16
16: ; preds = %14
br label %5
17: ; preds = %13
%18 = load i32, i32* %2
%19 = load i32, i32* %3
%20 = call i32 @gcd(i32 %18, i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i32 %20)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [29 x i8] c"Enter two positive numbers: \00"
@.str.2 = [6 x i8] c"%d %d\00"
@.str.4 = [33 x i8] c"The GCD of given numbers is: %d\0A\00"
@str = [21 x i8] c"-- The GCD Finder --\00"
@str.5 = [14 x i8] c"\0AWrong input!\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 ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %1, i32* %2)
%8 = load i32, i32* %1
%9 = icmp sgt i32 %8, 0
%10 = load i32, i32* %2
%11 = icmp sgt i32 %10, 0
%12 = select i1 %9, i1 %11, i1 false
br i1 %12, label %22, label %13
13: ; preds = %0, %13
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.5, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %1, i32* %2)
%17 = load i32, i32* %1
%18 = icmp sgt i32 %17, 0
%19 = load i32, i32* %2
%20 = icmp sgt i32 %19, 0
%21 = select i1 %18, i1 %20, i1 false
br i1 %21, label %22, label %13
22: ; preds = %13, %0
%23 = phi i32 [ %8, %0 ], [ %17, %13 ]
%24 = phi i32 [ %10, %0 ], [ %19, %13 ]
%25 = call i32 @gcd(i32 %23, i32 %24)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i32 %25)
ret i32 0
}