#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 *, char *, ...);
void foo(int i) {
  int x = 42;
  int *p = &x;
  int **pp = &p;
  printf("\n%s%s%s%s\n", "Variable  ", "Value     ", "Locat    ", "Derefs    ");
  printf("%s%s%s%s\n", "========  ", "========  ", "=======  ", "========  ");
  printf("%s%-10d%-10p%s\n", "x         ", x, &x, "N/A");
  printf("%s%-10p%-10p%-10d\n", "p         ", p, &p, *p);
  printf("%s%-10p%-10p%-10p\n", "pp        ", pp, &pp, *pp);
  if (i)
    foo(--i);
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x2a,-0x8(%rbp)
lea    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
lea    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    0xeb7(%rip),%rdi
lea    0xebb(%rip),%rsi
lea    0xebf(%rip),%rdx
lea    0xec3(%rip),%rcx
lea    0xec6(%rip),%r8
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe8e(%rip),%rdi
lea    0xebc(%rip),%r8
lea    0xeb6(%rip),%rcx
mov    %r8,%rsi
mov    %r8,%rdx
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%edx
lea    0xea9(%rip),%rdi
lea    0xeb2(%rip),%rsi
lea    -0x8(%rbp),%rcx
lea    0xeb2(%rip),%r8
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    (%rax),%r8d
lea    0xe9d(%rip),%rdi
lea    0xea9(%rip),%rsi
lea    -0x10(%rbp),%rcx
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdx
mov    -0x18(%rbp),%rax
mov    (%rax),%r8
lea    0xe97(%rip),%rdi
lea    0xea3(%rip),%rsi
lea    -0x18(%rbp),%rcx
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x4(%rbp)
je     1211 <foo+0xf1>
mov    -0x4(%rbp),%edi
add    $0xffffffff,%edi
mov    %edi,-0x4(%rbp)
call   1040 <foo@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %edi,%ebx
movl   $0x2a,0xc(%rsp)
lea    0xc(%rsp),%r15
mov    %r15,0x10(%rsp)
lea    0x10(%rsp),%r14
mov    %r14,0x18(%rsp)
lea    0xeb2(%rip),%rdi
lea    0xeb6(%rip),%rsi
lea    0xeba(%rip),%rdx
lea    0xebe(%rip),%rcx
lea    0xec1(%rip),%r8
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe89(%rip),%rdi
lea    0xeb8(%rip),%rcx
lea    0xeb0(%rip),%rdx
mov    %rdx,%rsi
mov    %rdx,%r8
xor    %eax,%eax
call   1030 <printf@plt>
mov    0xc(%rsp),%edx
lea    0xea3(%rip),%rdi
lea    0xeac(%rip),%rsi
lea    0xeb0(%rip),%r8
mov    %r15,%rcx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%rsp),%rdx
mov    (%rdx),%r8d
lea    0xe9b(%rip),%rdi
lea    0xea7(%rip),%rsi
mov    %r14,%rcx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%rsp),%r8
lea    0xe9c(%rip),%rdi
lea    0xea8(%rip),%rsi
lea    0x18(%rsp),%rcx
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
test   %ebx,%ebx
je     1206 <foo+0xe6>
add    $0xffffffff,%ebx
mov    %ebx,%edi
call   1040 <foo@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c"\0A%s%s%s%s\0A\00"
@.str.1 = [11 x i8] c"Variable \00"
@.str.2 = [11 x i8] c"Value \00"
@.str.3 = [10 x i8] c"Locat \00"
@.str.4 = [11 x i8] c"Derefs \00"
@.str.5 = [10 x i8] c"%s%s%s%s\0A\00"
@.str.6 = [11 x i8] c"======== \00"
@.str.7 = [10 x i8] c"======= \00"
@.str.8 = [16 x i8] c"%s%-10d%-10p%s\0A\00"
@.str.9 = [11 x i8] c"x \00"
@.str.10 = [4 x i8] c"N/A\00"
@.str.11 = [19 x i8] c"%s%-10p%-10p%-10d\0A\00"
@.str.12 = [11 x i8] c"p \00"
@.str.13 = [19 x i8] c"%s%-10p%-10p%-10p\0A\00"
@.str.14 = [11 x i8] c"pp \00"
define void @foo(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32**
store i32 %0, i32* %2
store i32 42, i32* %3
store i32* %3, i32** %4
store i32** %4, i32*** %5
%6 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%7 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
%8 = load i32, i32* %3
%9 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i32 %8, i32* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0))
%10 = load i32*, i32** %4
%11 = load i32*, i32** %4
%12 = load i32, i32* %11
%13 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.12, i64 0, i64 0), i32* %10, i32** %4, i32 %12)
%14 = load i32**, i32*** %5
%15 = load i32**, i32*** %5
%16 = load i32*, i32** %15
%17 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.14, i64 0, i64 0), i32** %14, i32*** %5, i32* %16)
%18 = load i32, i32* %2
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %1
%21 = load i32, i32* %2
%22 = add nsw i32 %21, -1
store i32 %22, i32* %2
br label %23
23: ; preds = %20, %1
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"\0A%s%s%s%s\0A\00"
@.str.1 = [11 x i8] c"Variable \00"
@.str.2 = [11 x i8] c"Value \00"
@.str.3 = [10 x i8] c"Locat \00"
@.str.4 = [11 x i8] c"Derefs \00"
@.str.5 = [10 x i8] c"%s%s%s%s\0A\00"
@.str.6 = [11 x i8] c"======== \00"
@.str.7 = [10 x i8] c"======= \00"
@.str.8 = [16 x i8] c"%s%-10d%-10p%s\0A\00"
@.str.9 = [11 x i8] c"x \00"
@.str.10 = [4 x i8] c"N/A\00"
@.str.11 = [19 x i8] c"%s%-10p%-10p%-10d\0A\00"
@.str.12 = [11 x i8] c"p \00"
@.str.13 = [19 x i8] c"%s%-10p%-10p%-10p\0A\00"
@.str.14 = [11 x i8] c"pp \00"
define void @foo(i32 %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32**
%5 = bitcast i32* %2 to i8*
store i32 42, i32* %2
%6 = bitcast i32** %3 to i8*
store i32* %2, i32** %3
%7 = bitcast i32*** %4 to i8*
store i32** %3, i32*** %4
%8 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%9 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
%10 = load i32, i32* %2
%11 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i32 %10, i32* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0))
%12 = load i32*, i32** %3
%13 = load i32, i32* %12
%14 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.12, i64 0, i64 0), i32* %12, i32** %3, i32 %13)
%15 = load i32*, i32** %3
%16 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.14, i64 0, i64 0), i32** %3, i32*** %4, i32* %15)
%17 = icmp eq i32 %0, 0
br i1 %17, label %20, label %18
18: ; preds = %1
%19 = add nsw i32 %0, -1
br label %20
20: ; preds = %18, %1
ret void
}