#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);
long labs(long);
long maxe(long, long);
long mine(long, long);
long qassem(long a, long b) {
  long c;
  if (a == 0 && b == 0) {
    exit(1);
    c = 0;
  } else {
    c = labs(a);
    a = labs(maxe(a, b));
    b = labs(mine(b, c));
    c = a % b;
    while (c != 0) {
      a = b;
      b = c;
      c = a % b;
    }
    c = b;
  }
  return c;
}


x86 assembly (clang, -O0):
<qassem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1170 <qassem+0x30>
cmpq   $0x0,-0x10(%rbp)
jne    1170 <qassem+0x30>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%rdi
call   1030 <labs@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <maxe@plt>
mov    %rax,%rdi
call   1030 <labs@plt>
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <mine@plt>
mov    %rax,%rdi
call   1030 <labs@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cqto
idivq  -0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11eb <qassem+0xab>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cqto
idivq  -0x10(%rbp)
mov    %rdx,-0x18(%rbp)
jmp    11bd <qassem+0x7d>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<qassem>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rax
or     %rdi,%rax
je     11d7 <qassem+0xa7>
mov    %rsi,%r14
mov    %rdi,%rbx
neg    %rbx
cmovs  %rdi,%rbx
call   1040 <maxe@plt>
mov    %rax,%r15
neg    %r15
cmovs  %rax,%r15
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <mine@plt>
mov    %rax,%rcx
neg    %rcx
cmovs  %rax,%rcx
mov    %r15,%rax
or     %rcx,%rax
shr    $0x20,%rax
je     118d <qassem+0x5d>
mov    %r15,%rax
xor    %edx,%edx
div    %rcx
test   %rdx,%rdx
jne    11c0 <qassem+0x90>
jmp    1199 <qassem+0x69>
mov    %r15d,%eax
xor    %edx,%edx
div    %ecx
test   %rdx,%rdx
jne    11c0 <qassem+0x90>
mov    %rcx,%rsi
mov    %rsi,%rax
pop    %rbx
pop    %r14
pop    %r15
ret
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rcx,%rax
cqto
idiv   %rsi
mov    %rsi,%rcx
test   %rdx,%rdx
je     119c <qassem+0x6c>
mov    %rdx,%rsi
mov    %rcx,%rax
or     %rdx,%rax
shr    $0x20,%rax
jne    11b0 <qassem+0x80>
mov    %ecx,%eax
xor    %edx,%edx
div    %esi
jmp    11b8 <qassem+0x88>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
define i64 @qassem(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
store i64 %0, i64* %3
store i64 %1, i64* %4
%6 = load i64, i64* %3
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = load i64, i64* %4
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %8, %2
%14 = load i64, i64* %3
%15 = call i64 @labs(i64 %14)
store i64 %15, i64* %5
%16 = load i64, i64* %3
%17 = load i64, i64* %4
%18 = call i64 @maxe(i64 %16, i64 %17)
%19 = call i64 @labs(i64 %18)
store i64 %19, i64* %3
%20 = load i64, i64* %4
%21 = load i64, i64* %5
%22 = call i64 @mine(i64 %20, i64 %21)
%23 = call i64 @labs(i64 %22)
store i64 %23, i64* %4
%24 = load i64, i64* %3
%25 = load i64, i64* %4
%26 = srem i64 %24, %25
store i64 %26, i64* %5
br label %27
27: ; preds = %30, %13
%28 = load i64, i64* %5
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %36
30: ; preds = %27
%31 = load i64, i64* %4
store i64 %31, i64* %3
%32 = load i64, i64* %5
store i64 %32, i64* %4
%33 = load i64, i64* %3
%34 = load i64, i64* %4
%35 = srem i64 %33, %34
store i64 %35, i64* %5
br label %27
36: ; preds = %27
%37 = load i64, i64* %4
store i64 %37, i64* %5
br label %38
38: ; preds = %36
%39 = load i64, i64* %5
ret i64 %39
}

LLVM IR (-O2):
define i64 @qassem(i64 %0, i64 %1) {
%3 = or i64 %1, %0
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %2
%8 = tail call i64 @llvm.abs.i64(i64 %0, i1 true)
%9 = tail call i64 @maxe(i64 %0, i64 %1)
%10 = tail call i64 @llvm.abs.i64(i64 %9, i1 true)
%11 = tail call i64 @mine(i64 %1, i64 %8)
%12 = tail call i64 @llvm.abs.i64(i64 %11, i1 true)
%13 = urem i64 %10, %12
%14 = icmp eq i64 %13, 0
br i1 %14, label %20, label %15
15: ; preds = %7, %15
%16 = phi i64 [ %18, %15 ], [ %13, %7 ]
%17 = phi i64 [ %16, %15 ], [ %12, %7 ]
%18 = srem i64 %17, %16
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %15
20: ; preds = %15, %7
%21 = phi i64 [ %12, %7 ], [ %16, %15 ]
ret i64 %21
}