#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 */
long long build_value(unsigned long long, int /*<<< orphan*/);
unsigned long long extract_value(long long, int *);
unsigned long long int_gcd(unsigned long long, unsigned long long);
long long int intGCD(long long int y, long long int x) {
  int s;
  unsigned long long int xv = extract_value(x, &s);
  unsigned long long int yv = extract_value(y, &s);
  unsigned long long int v;
  if (xv == 0)
    v = yv;
  else if (yv == 0)
    v = xv;
  else
    v = int_gcd(xv, yv);
  return build_value(v, 0);
}


x86 assembly (clang, -O0):
<intGCD>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <extract_value@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <extract_value@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    117a <intGCD+0x4a>
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    11a8 <intGCD+0x78>
cmpq   $0x0,-0x28(%rbp)
jne    1192 <intGCD+0x62>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    11a3 <intGCD+0x73>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1050 <int_gcd@plt>
mov    %rax,-0x30(%rbp)
jmp    11a8 <intGCD+0x78>
mov    -0x30(%rbp),%rdi
xor    %esi,%esi
call   1030 <build_value@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<intGCD>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
lea    0xc(%rsp),%r15
mov    %rsi,%rdi
mov    %r15,%rsi
call   1040 <extract_value@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <extract_value@plt>
test   %rbx,%rbx
je     1174 <intGCD+0x44>
test   %rax,%rax
je     1171 <intGCD+0x41>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1050 <int_gcd@plt>
jmp    1174 <intGCD+0x44>
mov    %rbx,%rax
mov    %rax,%rdi
xor    %esi,%esi
call   1030 <build_value@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @intGCD(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i32
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
store i64 %0, i64* %3
store i64 %1, i64* %4
%9 = load i64, i64* %4
%10 = call i64 @extract_value(i64 %9, i32* %5)
store i64 %10, i64* %6
%11 = load i64, i64* %3
%12 = call i64 @extract_value(i64 %11, i32* %5)
store i64 %12, i64* %7
%13 = load i64, i64* %6
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = load i64, i64* %7
store i64 %16, i64* %8
br label %27
17: ; preds = %2
%18 = load i64, i64* %7
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = load i64, i64* %6
store i64 %21, i64* %8
br label %26
22: ; preds = %17
%23 = load i64, i64* %6
%24 = load i64, i64* %7
%25 = call i64 @int_gcd(i64 %23, i64 %24)
store i64 %25, i64* %8
br label %26
26: ; preds = %22, %20
br label %27
27: ; preds = %26, %15
%28 = load i64, i64* %8
%29 = call i64 @build_value(i64 %28, i32 0)
ret i64 %29
}

LLVM IR (-O2):
define i64 @intGCD(i64 %0, i64 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i64 @extract_value(i64 %1, i32* %3)
%6 = call i64 @extract_value(i64 %0, i32* %3)
%7 = icmp eq i64 %5, 0
br i1 %7, label %12, label %8
8: ; preds = %2
%9 = icmp eq i64 %6, 0
br i1 %9, label %12, label %10
10: ; preds = %8
%11 = call i64 @int_gcd(i64 %5, i64 %6)
br label %12
12: ; preds = %8, %2, %10
%13 = phi i64 [ %11, %10 ], [ %6, %2 ], [ %5, %8 ]
%14 = call i64 @build_value(i64 %13, i32 0)
ret i64 %14
}