#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*/ printf(char *, long long, long long);
long long ack(long long i, long long j) {
  printf("%lld, %lld\n", i, j);
  long long ans;
  if (i == 0)
    ans = j + 1;
  else if (j == 0)
    ans = ack(i - 1, 1);
  else
    ans = ack(i - 1, ack(i, j - 1));
  return ans;
}


x86 assembly (clang, -O0):
<ack>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xec1(%rip),%rdi
call   1040 <printf@plt>
cmpq   $0x0,-0x8(%rbp)
jne    1160 <ack+0x40>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11b8 <ack+0x98>
cmpq   $0x0,-0x10(%rbp)
jne    1186 <ack+0x66>
mov    -0x8(%rbp),%rdi
sub    $0x1,%rdi
mov    $0x1,%esi
call   1030 <ack@plt>
mov    %rax,-0x18(%rbp)
jmp    11b3 <ack+0x93>
mov    -0x8(%rbp),%rax
sub    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
sub    $0x1,%rsi
call   1030 <ack@plt>
mov    -0x20(%rbp),%rdi
mov    %rax,%rsi
call   1030 <ack@plt>
mov    %rax,-0x18(%rbp)
jmp    11b8 <ack+0x98>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ack>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xece(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1040 <printf@plt>
test   %rbx,%rbx
je     1184 <ack+0x64>
lea    0xeb7(%rip),%r15
jmp    116b <ack+0x4b>
nopl   0x0(%rax,%rax,1)
mov    $0x1,%r14d
lea    -0x1(%rbx),%rsi
mov    %r15,%rdi
mov    %r14,%rdx
call   1040 <printf@plt>
add    $0xffffffffffffffff,%rbx
je     1184 <ack+0x64>
test   %r14,%r14
je     1150 <ack+0x30>
add    $0xffffffffffffffff,%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <ack@plt>
mov    %rax,%r14
jmp    1156 <ack+0x36>
add    $0x1,%r14
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [12 x i8] c"%lld, %lld\0A\00"
define i64 @ack(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 = load i64, i64* %4
%8 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i64 %6, i64 %7)
%9 = load i64, i64* %3
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i64, i64* %4
%13 = add nsw i64 %12, 1
store i64 %13, i64* %5
br label %30
14: ; preds = %2
%15 = load i64, i64* %4
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %14
%18 = load i64, i64* %3
%19 = sub nsw i64 %18, 1
%20 = call i64 @ack(i64 %19, i64 1)
store i64 %20, i64* %5
br label %29
21: ; preds = %14
%22 = load i64, i64* %3
%23 = sub nsw i64 %22, 1
%24 = load i64, i64* %3
%25 = load i64, i64* %4
%26 = sub nsw i64 %25, 1
%27 = call i64 @ack(i64 %24, i64 %26)
%28 = call i64 @ack(i64 %23, i64 %27)
store i64 %28, i64* %5
br label %29
29: ; preds = %21, %17
br label %30
30: ; preds = %29, %11
%31 = load i64, i64* %5
ret i64 %31
}

LLVM IR (-O2):
@.str = [12 x i8] c"%lld, %lld\0A\00"
define i64 @ack(i64 %0, i64 %1) {
%3 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i64 %0, i64 %1)
%4 = icmp eq i64 %0, 0
br i1 %4, label %5, label %8
5: ; preds = %12, %2
%6 = phi i64 [ %1, %2 ], [ %13, %12 ]
%7 = add nsw i64 %6, 1
ret i64 %7
8: ; preds = %2, %12
%9 = phi i64 [ %13, %12 ], [ %1, %2 ]
%10 = phi i64 [ %14, %12 ], [ %0, %2 ]
%11 = icmp eq i64 %9, 0
br i1 %11, label %12, label %17
12: ; preds = %8, %17
%13 = phi i64 [ %19, %17 ], [ 1, %8 ]
%14 = add nsw i64 %10, -1
%15 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i64 %14, i64 %13)
%16 = icmp eq i64 %14, 0
br i1 %16, label %5, label %8
17: ; preds = %8
%18 = add nsw i64 %9, -1
%19 = tail call i64 @ack(i64 %10, i64 %18)
br label %12
}