#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 distance(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ setbuf(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ stdout;
int twice(int);
main() {
  setbuf(stdout, NULL);
  printf("** main()\n");
  printf("** 1: %d\n", distance(1, -5));
  printf("** 2: %d\n", distance(twice(1), -5));
  printf("** 3: %d\n", distance(3, -5));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
mov    0x2e95(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <setbuf@plt>
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
mov    $0xfffffffb,%esi
call   1060 <distance@plt>
mov    %eax,%esi
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1040 <twice@plt>
mov    %eax,%edi
mov    $0xfffffffb,%esi
call   1060 <distance@plt>
mov    %eax,%esi
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x3,%edi
mov    $0xfffffffb,%esi
call   1060 <distance@plt>
mov    %eax,%esi
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x2e88(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1040 <setbuf@plt>
lea    0xeb6(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
mov    $0xfffffffb,%esi
call   1070 <distance@plt>
lea    0xe7d(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%edi
call   1050 <twice@plt>
mov    %eax,%edi
mov    $0xfffffffb,%esi
call   1070 <distance@plt>
lea    0xe61(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x3,%edi
mov    $0xfffffffb,%esi
call   1070 <distance@plt>
lea    0xe4c(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [11 x i8] c"** main()\0A\00"
@.str.1 = [10 x i8] c"** 1: %d\0A\00"
@.str.2 = [10 x i8] c"** 2: %d\0A\00"
@.str.3 = [10 x i8] c"** 3: %d\0A\00"
define i32 @main() {
%1 = load i32, i32* @stdout
%2 = call i32 @setbuf(i32 %1, i32* null)
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @distance(i32 1, i32 -5)
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %4)
%6 = call i32 @twice(i32 1)
%7 = call i32 @distance(i32 %6, i32 -5)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%9 = call i32 @distance(i32 3, i32 -5)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %9)
ret i32 0
}

LLVM IR (-O2):
@stdout = global i32 0
@.str.1 = [10 x i8] c"** 1: %d\0A\00"
@.str.2 = [10 x i8] c"** 2: %d\0A\00"
@.str.3 = [10 x i8] c"** 3: %d\0A\00"
@str = [10 x i8] c"** main()\00"
define i32 @main() {
%1 = load i32, i32* @stdout
%2 = tail call i32 @setbuf(i32 %1, i32* null)
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @distance(i32 1, i32 -5)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %4)
%6 = tail call i32 @twice(i32 1)
%7 = tail call i32 @distance(i32 %6, i32 -5)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%9 = tail call i32 @distance(i32 3, i32 -5)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %9)
ret i32 0
}