#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*/ gcd(long, long);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, long *, long *);
int main() {
  long num1, num2;
  printf("Example of Greatest Common Divisor "
         "Recursive Function\n\n");
  do {
    printf("Enter two values (0 to stop): ");
    scanf("%ld %ld", &num1, &num2);
    if (num1 == 0L || num2 == 0L)
      break;
    printf("The greatest common divisor of "
           "%ld and %ld is %ld.\n\n",
           num1, num2, gcd(num1, num2));
  } while (1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef5(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <scanf@plt>
cmpq   $0x0,-0x10(%rbp)
je     1185 <main+0x55>
cmpq   $0x0,-0x18(%rbp)
jne    118a <main+0x5a>
jmp    11ce <main+0x9e>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <gcd@plt>
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    %eax,%ecx
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%al
test   $0x1,%al
jne    114d <main+0x1d>
jmp    11ce <main+0x9e>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xf07(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb0(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1050 <scanf@plt>
mov    0x10(%rsp),%rbp
test   %rbp,%rbp
je     11fd <main+0xbd>
mov    0x8(%rsp),%r14
test   %r14,%r14
je     11fd <main+0xbd>
lea    0xe67(%rip),%r15
lea    0xe7f(%rip),%r12
lea    0x10(%rsp),%r13
lea    0x8(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    %r14,%rsi
call   1060 <gcd@plt>
lea    0xe65(%rip),%rdi
mov    %rbp,%rsi
mov    %r14,%rdx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@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    0x10(%rsp),%rbp
test   %rbp,%rbp
je     11fd <main+0xbd>
mov    0x8(%rsp),%r14
test   %r14,%r14
jne    11b0 <main+0x70>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [56 x i8] c"Example of Greatest Common Divisor Recursive Function\0A\0A\00"
@.str.1 = [31 x i8] c"Enter two values (0 to stop): \00"
@.str.2 = [8 x i8] c"%ld %ld\00"
@.str.3 = [53 x i8] c"The greatest common divisor of %ld and %ld is %ld.\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %21, %0
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i64* %2, i64* %3)
%8 = load i64, i64* %2
%9 = icmp eq i64 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %5
%11 = load i64, i64* %3
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %10, %5
br label %22
14: ; preds = %10
%15 = load i64, i64* %2
%16 = load i64, i64* %3
%17 = load i64, i64* %2
%18 = load i64, i64* %3
%19 = call i32 @gcd(i64 %17, i64 %18)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0), i64 %15, i64 %16, i32 %19)
br label %21
21: ; preds = %14
br i1 true, label %5, label %22
22: ; preds = %21, %13
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [31 x i8] c"Enter two values (0 to stop): \00"
@.str.2 = [8 x i8] c"%ld %ld\00"
@.str.3 = [53 x i8] c"The greatest common divisor of %ld and %ld is %ld.\0A\0A\00"
@str = [55 x i8] c"Example of Greatest Common Divisor Recursive Function\0A\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i64
%3 = bitcast i64* %1 to i8*
%4 = bitcast i64* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i64* %1, i64* %2)
%8 = load i64, i64* %1
%9 = icmp eq i64 %8, 0
%10 = load i64, i64* %2
%11 = icmp eq i64 %10, 0
%12 = select i1 %9, i1 true, i1 %11
br i1 %12, label %25, label %13
13: ; preds = %0, %13
%14 = phi i64 [ %22, %13 ], [ %10, %0 ]
%15 = phi i64 [ %20, %13 ], [ %8, %0 ]
%16 = call i32 @gcd(i64 %15, i64 %14)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0), i64 %15, i64 %14, i32 %16)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i64* %1, i64* %2)
%20 = load i64, i64* %1
%21 = icmp eq i64 %20, 0
%22 = load i64, i64* %2
%23 = icmp eq i64 %22, 0
%24 = select i1 %21, i1 true, i1 %23
br i1 %24, label %25, label %13
25: ; preds = %13, %0
ret i32 0
}