#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*/ abort();
int /*<<< orphan*/ bar(int **, int *);
int /*<<< orphan*/ baz(int **, int *);
int /*<<< orphan*/ foo(int **, int *);
int main(void) {
  int i = 42, j = 0;
  int *p = &i;
  foo(&p, &j);
  if (p - 1 != &i || j != 0 || i != 0)
    abort();
  i = 43;
  p = &i;
  bar(&p, &j);
  if (p - 1 != &i || j != 0 || i != 0)
    abort();
  i = 44;
  p = &i;
  baz(&p, &j);
  if (p - 1 != &i || j != 0 || i != 0)
    abort();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2a,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    -0x18(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <foo@plt>
mov    -0x18(%rbp),%rax
add    $0xfffffffffffffffc,%rax
lea    -0x8(%rbp),%rcx
cmp    %rcx,%rax
jne    119b <main+0x5b>
cmpl   $0x0,-0xc(%rbp)
jne    119b <main+0x5b>
cmpl   $0x0,-0x8(%rbp)
je     11a2 <main+0x62>
mov    $0x0,%al
call   1030 <abort@plt>
movl   $0x2b,-0x8(%rbp)
lea    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    -0x18(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <bar@plt>
mov    -0x18(%rbp),%rax
add    $0xfffffffffffffffc,%rax
lea    -0x8(%rbp),%rcx
cmp    %rcx,%rax
jne    11e7 <main+0xa7>
cmpl   $0x0,-0xc(%rbp)
jne    11e7 <main+0xa7>
cmpl   $0x0,-0x8(%rbp)
je     11ee <main+0xae>
mov    $0x0,%al
call   1030 <abort@plt>
movl   $0x2c,-0x8(%rbp)
lea    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    -0x18(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <baz@plt>
mov    -0x18(%rbp),%rax
add    $0xfffffffffffffffc,%rax
lea    -0x8(%rbp),%rcx
cmp    %rcx,%rax
jne    1233 <main+0xf3>
cmpl   $0x0,-0xc(%rbp)
jne    1233 <main+0xf3>
cmpl   $0x0,-0x8(%rbp)
je     123a <main+0xfa>
mov    $0x0,%al
call   1030 <abort@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movl   $0x2a,0x4(%rsp)
movl   $0x0,(%rsp)
lea    0x4(%rsp),%rbx
mov    %rbx,0x8(%rsp)
lea    0x8(%rsp),%rdi
mov    %rsp,%rsi
call   1060 <foo@plt>
mov    0x8(%rsp),%rax
add    $0xfffffffffffffffc,%rax
cmp    %rbx,%rax
jne    11f8 <main+0xb8>
cmpl   $0x0,(%rsp)
jne    11f8 <main+0xb8>
cmpl   $0x0,0x4(%rsp)
jne    11f8 <main+0xb8>
movl   $0x2b,0x4(%rsp)
mov    %rbx,0x8(%rsp)
lea    0x8(%rsp),%rdi
mov    %rsp,%rsi
call   1050 <bar@plt>
mov    0x8(%rsp),%rax
add    $0xfffffffffffffffc,%rax
cmp    %rbx,%rax
jne    11f8 <main+0xb8>
cmpl   $0x0,(%rsp)
jne    11f8 <main+0xb8>
cmpl   $0x0,0x4(%rsp)
jne    11f8 <main+0xb8>
movl   $0x2c,0x4(%rsp)
mov    %rbx,0x8(%rsp)
lea    0x8(%rsp),%rdi
mov    %rsp,%rsi
call   1040 <baz@plt>
mov    0x8(%rsp),%rax
add    $0xfffffffffffffffc,%rax
cmp    %rbx,%rax
jne    11f8 <main+0xb8>
cmpl   $0x0,(%rsp)
jne    11f8 <main+0xb8>
cmpl   $0x0,0x4(%rsp)
jne    11f8 <main+0xb8>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
store i32 0, i32* %1
store i32 42, i32* %2
store i32 0, i32* %3
store i32* %2, i32** %4
%5 = call i32 @foo(i32** %4, i32* %3)
%6 = load i32*, i32** %4
%7 = getelementptr inbounds i32, i32* %6, i64 -1
%8 = icmp ne i32* %7, %2
br i1 %8, label %15, label %9
9: ; preds = %0
%10 = load i32, i32* %3
%11 = icmp ne i32 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = load i32, i32* %2
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12, %9, %0
%16 = call i32 (...) @abort()
unreachable
17: ; preds = %12
store i32 43, i32* %2
store i32* %2, i32** %4
%18 = call i32 @bar(i32** %4, i32* %3)
%19 = load i32*, i32** %4
%20 = getelementptr inbounds i32, i32* %19, i64 -1
%21 = icmp ne i32* %20, %2
br i1 %21, label %28, label %22
22: ; preds = %17
%23 = load i32, i32* %3
%24 = icmp ne i32 %23, 0
br i1 %24, label %28, label %25
25: ; preds = %22
%26 = load i32, i32* %2
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %25, %22, %17
%29 = call i32 (...) @abort()
unreachable
30: ; preds = %25
store i32 44, i32* %2
store i32* %2, i32** %4
%31 = call i32 @baz(i32** %4, i32* %3)
%32 = load i32*, i32** %4
%33 = getelementptr inbounds i32, i32* %32, i64 -1
%34 = icmp ne i32* %33, %2
br i1 %34, label %41, label %35
35: ; preds = %30
%36 = load i32, i32* %3
%37 = icmp ne i32 %36, 0
br i1 %37, label %41, label %38
38: ; preds = %35
%39 = load i32, i32* %2
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %38, %35, %30
%42 = call i32 (...) @abort()
unreachable
43: ; preds = %38
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = bitcast i32* %1 to i8*
store i32 42, i32* %1
%5 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%6 = bitcast i32** %3 to i8*
store i32* %1, i32** %3
%7 = call i32 @foo(i32** %3, i32* %2)
%8 = load i32*, i32** %3
%9 = getelementptr inbounds i32, i32* %8, i64 -1
%10 = icmp ne i32* %9, %1
%11 = load i32, i32* %2
%12 = icmp ne i32 %11, 0
%13 = select i1 %10, i1 true, i1 %12
%14 = load i32, i32* %1
%15 = icmp ne i32 %14, 0
%16 = select i1 %13, i1 true, i1 %15
br i1 %16, label %17, label %19
17: ; preds = %0
%18 = call i32 (...) @abort()
unreachable
19: ; preds = %0
store i32 43, i32* %1
store i32* %1, i32** %3
%20 = call i32 @bar(i32** %3, i32* %2)
%21 = load i32*, i32** %3
%22 = getelementptr inbounds i32, i32* %21, i64 -1
%23 = icmp ne i32* %22, %1
%24 = load i32, i32* %2
%25 = icmp ne i32 %24, 0
%26 = select i1 %23, i1 true, i1 %25
%27 = load i32, i32* %1
%28 = icmp ne i32 %27, 0
%29 = select i1 %26, i1 true, i1 %28
br i1 %29, label %30, label %32
30: ; preds = %19
%31 = call i32 (...) @abort()
unreachable
32: ; preds = %19
store i32 44, i32* %1
store i32* %1, i32** %3
%33 = call i32 @baz(i32** %3, i32* %2)
%34 = load i32*, i32** %3
%35 = getelementptr inbounds i32, i32* %34, i64 -1
%36 = icmp ne i32* %35, %1
%37 = load i32, i32* %2
%38 = icmp ne i32 %37, 0
%39 = select i1 %36, i1 true, i1 %38
%40 = load i32, i32* %1
%41 = icmp ne i32 %40, 0
%42 = select i1 %39, i1 true, i1 %41
br i1 %42, label %43, label %45
43: ; preds = %32
%44 = call i32 (...) @abort()
unreachable
45: ; preds = %32
ret i32 0
}