#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*/ subtest(int, int *);
void c_proc(bool present, int *val) {
  int val2;
  if (!present && val)
    abort();
  else if (present) {
    if (!val)
      abort();
    if (*val != 4)
      abort();
    *val = 7;
  }
  val2 = 43;
  subtest(1, &val2);
  subtest(0, NULL);
  if (val2 != -45)
    abort();
}


x86 assembly (clang, -O0):
<c_proc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    114b <c_proc+0x2b>
cmpq   $0x0,-0x10(%rbp)
je     114b <c_proc+0x2b>
mov    $0x0,%al
call   1030 <abort@plt>
cmpl   $0x0,-0x4(%rbp)
je     1185 <c_proc+0x65>
cmpq   $0x0,-0x10(%rbp)
jne    1167 <c_proc+0x47>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x10(%rbp),%rax
cmpl   $0x4,(%rax)
je     117b <c_proc+0x5b>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x10(%rbp),%rax
movl   $0x7,(%rax)
jmp    118a <c_proc+0x6a>
movl   $0x2b,-0x14(%rbp)
mov    $0x1,%edi
lea    -0x14(%rbp),%rsi
call   1040 <subtest@plt>
xor    %edi,%edi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <subtest@plt>
cmpl   $0xffffffd3,-0x14(%rbp)
je     11bb <c_proc+0x9b>
mov    $0x0,%al
call   1030 <abort@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<c_proc>:
push   %rax
test   %edi,%edi
jne    112a <c_proc+0xa>
test   %rsi,%rsi
jne    1167 <c_proc+0x47>
test   %edi,%edi
je     113e <c_proc+0x1e>
test   %rsi,%rsi
je     1167 <c_proc+0x47>
cmpl   $0x4,(%rsi)
jne    1167 <c_proc+0x47>
movl   $0x7,(%rsi)
movl   $0x2b,0x4(%rsp)
lea    0x4(%rsp),%rsi
mov    $0x1,%edi
call   1040 <subtest@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1040 <subtest@plt>
cmpl   $0xffffffd3,0x4(%rsp)
jne    1167 <c_proc+0x47>
pop    %rax
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
define void @c_proc(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
store i32 %0, i32* %3
store i32* %1, i32** %4
%6 = load i32, i32* %3
%7 = icmp ne i32 %6, 0
br i1 %7, label %13, label %8
8: ; preds = %2
%9 = load i32*, i32** %4
%10 = icmp ne i32* %9, null
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = call i32 (...) @abort()
unreachable
13: ; preds = %8, %2
%14 = load i32, i32* %3
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %29
16: ; preds = %13
%17 = load i32*, i32** %4
%18 = icmp ne i32* %17, null
br i1 %18, label %21, label %19
19: ; preds = %16
%20 = call i32 (...) @abort()
unreachable
21: ; preds = %16
%22 = load i32*, i32** %4
%23 = load i32, i32* %22
%24 = icmp ne i32 %23, 4
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = call i32 (...) @abort()
unreachable
27: ; preds = %21
%28 = load i32*, i32** %4
store i32 7, i32* %28
br label %29
29: ; preds = %27, %13
br label %30
30: ; preds = %29
store i32 43, i32* %5
%31 = call i32 @subtest(i32 1, i32* %5)
%32 = call i32 @subtest(i32 0, i32* null)
%33 = load i32, i32* %5
%34 = icmp ne i32 %33, -45
br i1 %34, label %35, label %37
35: ; preds = %30
%36 = call i32 (...) @abort()
unreachable
37: ; preds = %30
ret void
}

LLVM IR (-O2):
define void @c_proc(i32 %0, i32* %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = icmp eq i32 %0, 0
%6 = icmp ne i32* %1, null
%7 = and i1 %5, %6
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = tail call i32 (...) @abort()
unreachable
10: ; preds = %2
br i1 %5, label %20, label %11
11: ; preds = %10
br i1 %6, label %14, label %12
12: ; preds = %11
%13 = tail call i32 (...) @abort()
unreachable
14: ; preds = %11
%15 = load i32, i32* %1
%16 = icmp eq i32 %15, 4
br i1 %16, label %19, label %17
17: ; preds = %14
%18 = tail call i32 (...) @abort()
unreachable
19: ; preds = %14
store i32 7, i32* %1
br label %20
20: ; preds = %10, %19
store i32 43, i32* %3
%21 = call i32 @subtest(i32 1, i32* %3)
%22 = call i32 @subtest(i32 0, i32* null)
%23 = load i32, i32* %3
%24 = icmp eq i32 %23, -45
br i1 %24, label %27, label %25
25: ; preds = %20
%26 = call i32 (...) @abort()
unreachable
27: ; preds = %20
ret void
}