#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*/ g1(int);
int h(int *, int *);
int /*<<< orphan*/ link_error();
int g(void) {
  int t = 0, t1 = 2;
  int t2 = h(&t, &t1);
  if (t != 0)
    link_error();
  if (t1 != 2)
    link_error();
  g1(t2);
  if (t != 0)
    link_error();
  if (t1 != 2)
    link_error();
  return t2 == 2;
}


x86 assembly (clang, -O0):
<g>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2,-0x8(%rbp)
lea    -0x4(%rbp),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <h@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1167 <g+0x37>
mov    $0x0,%al
call   1050 <link_error@plt>
cmpl   $0x2,-0x8(%rbp)
je     1178 <g+0x48>
mov    $0x0,%al
call   1050 <link_error@plt>
mov    -0xc(%rbp),%edi
call   1030 <g1@plt>
cmpl   $0x0,-0x4(%rbp)
je     1191 <g+0x61>
mov    $0x0,%al
call   1050 <link_error@plt>
cmpl   $0x2,-0x8(%rbp)
je     11a2 <g+0x72>
mov    $0x0,%al
call   1050 <link_error@plt>
cmpl   $0x2,-0xc(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<g>:
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xc(%rsp)
movl   $0x2,0x8(%rsp)
lea    0xc(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1040 <h@plt>
mov    %eax,%ebx
cmpl   $0x0,0xc(%rsp)
je     1164 <g+0x34>
xor    %eax,%eax
call   1050 <link_error@plt>
cmpl   $0x2,0x8(%rsp)
je     1172 <g+0x42>
xor    %eax,%eax
call   1050 <link_error@plt>
mov    %ebx,%edi
call   1030 <g1@plt>
cmpl   $0x0,0xc(%rsp)
je     1187 <g+0x57>
xor    %eax,%eax
call   1050 <link_error@plt>
cmpl   $0x2,0x8(%rsp)
je     1195 <g+0x65>
xor    %eax,%eax
call   1050 <link_error@plt>
xor    %eax,%eax
cmp    $0x2,%ebx
sete   %al
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @g() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 2, i32* %2
%4 = call i32 @h(i32* %1, i32* %2)
store i32 %4, i32* %3
%5 = load i32, i32* %1
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 (...) @link_error()
br label %9
9: ; preds = %7, %0
%10 = load i32, i32* %2
%11 = icmp ne i32 %10, 2
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = call i32 (...) @link_error()
br label %14
14: ; preds = %12, %9
%15 = load i32, i32* %3
%16 = call i32 @g1(i32 %15)
%17 = load i32, i32* %1
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = call i32 (...) @link_error()
br label %21
21: ; preds = %19, %14
%22 = load i32, i32* %2
%23 = icmp ne i32 %22, 2
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = call i32 (...) @link_error()
br label %26
26: ; preds = %24, %21
%27 = load i32, i32* %3
%28 = icmp eq i32 %27, 2
%29 = zext i1 %28 to i32
ret i32 %29
}

LLVM IR (-O2):
define i32 @g() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%4 = bitcast i32* %2 to i8*
store i32 2, i32* %2
%5 = call i32 @h(i32* %1, i32* %2)
%6 = load i32, i32* %1
%7 = icmp eq i32 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %0
%9 = call i32 (...) @link_error()
br label %10
10: ; preds = %8, %0
%11 = load i32, i32* %2
%12 = icmp eq i32 %11, 2
br i1 %12, label %15, label %13
13: ; preds = %10
%14 = call i32 (...) @link_error()
br label %15
15: ; preds = %13, %10
%16 = call i32 @g1(i32 %5)
%17 = load i32, i32* %1
%18 = icmp eq i32 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %15
%20 = call i32 (...) @link_error()
br label %21
21: ; preds = %19, %15
%22 = load i32, i32* %2
%23 = icmp eq i32 %22, 2
br i1 %23, label %26, label %24
24: ; preds = %21
%25 = call i32 (...) @link_error()
br label %26
26: ; preds = %24, %21
%27 = icmp eq i32 %5, 2
%28 = zext i1 %27 to i32
ret i32 %28
}