#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*/ assert(int);
int rec(int i, int *ptr) {
  int top;
  int x = 17;
  if (i == 0) {
    rec(5, &x);
    assert(x == 17);
    x = 17;
    assert(x == 17);
  } else {
    x = 31;
    assert(*ptr == 31);
    if (top) {
      ptr = &x;
    }
    *ptr = 12;
    assert(*ptr == 12);
    assert(x == 12);
    if (*ptr == 12) {
      assert(x == 12);
    }
    assert(ptr == &x);
    x = 31;
    assert(x == 31);
  }
  return 0;
}


x86 assembly (clang, -O0):
<rec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x11,-0x18(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    117c <rec+0x5c>
mov    $0x5,%edi
lea    -0x18(%rbp),%rsi
call   1040 <rec@plt>
cmpl   $0x11,-0x18(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movl   $0x11,-0x18(%rbp)
cmpl   $0x11,-0x18(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
jmp    1223 <rec+0x103>
movl   $0x1f,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmpl   $0x1f,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x0,-0x14(%rbp)
je     11a9 <rec+0x89>
lea    -0x18(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movl   $0xc,(%rax)
mov    -0x10(%rbp),%rax
cmpl   $0xc,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0xc,-0x18(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x10(%rbp),%rax
cmpl   $0xc,(%rax)
jne    11f6 <rec+0xd6>
cmpl   $0xc,-0x18(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    -0x18(%rbp),%rax
cmp    %rax,-0x10(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movl   $0x1f,-0x18(%rbp)
cmpl   $0x1f,-0x18(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rec>:
push   %rbx
sub    $0x10,%rsp
movl   $0x11,0xc(%rsp)
test   %edi,%edi
je     117f <rec+0x5f>
mov    %rsi,%rbx
movl   $0x1f,0xc(%rsp)
xor    %edi,%edi
cmpl   $0x1f,(%rsi)
sete   %dil
call   1030 <assert@plt>
movl   $0xc,(%rbx)
mov    $0x1,%edi
call   1030 <assert@plt>
xor    %edi,%edi
call   1030 <assert@plt>
cmpl   $0xc,(%rbx)
jne    116d <rec+0x4d>
xor    %edi,%edi
call   1030 <assert@plt>
lea    0xc(%rsp),%rax
cmp    %rbx,%rax
sete   %al
mov    $0x1f,%ebx
jmp    119b <rec+0x7b>
lea    0xc(%rsp),%rsi
mov    $0x5,%edi
call   1040 <rec@plt>
cmpl   $0x11,0xc(%rsp)
sete   %al
mov    $0x11,%ebx
movzbl %al,%edi
call   1030 <assert@plt>
mov    %ebx,0xc(%rsp)
mov    $0x1,%edi
call   1030 <assert@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @rec(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i32* %1, i32** %4
store i32 17, i32* %6
%7 = load i32, i32* %3
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %19
9: ; preds = %2
%10 = call i32 @rec(i32 5, i32* %6)
%11 = load i32, i32* %6
%12 = icmp eq i32 %11, 17
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
store i32 17, i32* %6
%15 = load i32, i32* %6
%16 = icmp eq i32 %15, 17
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
br label %56
19: ; preds = %2
store i32 31, i32* %6
%20 = load i32*, i32** %4
%21 = load i32, i32* %20
%22 = icmp eq i32 %21, 31
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
%25 = load i32, i32* %5
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %19
store i32* %6, i32** %4
br label %28
28: ; preds = %27, %19
%29 = load i32*, i32** %4
store i32 12, i32* %29
%30 = load i32*, i32** %4
%31 = load i32, i32* %30
%32 = icmp eq i32 %31, 12
%33 = zext i1 %32 to i32
%34 = call i32 @assert(i32 %33)
%35 = load i32, i32* %6
%36 = icmp eq i32 %35, 12
%37 = zext i1 %36 to i32
%38 = call i32 @assert(i32 %37)
%39 = load i32*, i32** %4
%40 = load i32, i32* %39
%41 = icmp eq i32 %40, 12
br i1 %41, label %42, label %47
42: ; preds = %28
%43 = load i32, i32* %6
%44 = icmp eq i32 %43, 12
%45 = zext i1 %44 to i32
%46 = call i32 @assert(i32 %45)
br label %47
47: ; preds = %42, %28
%48 = load i32*, i32** %4
%49 = icmp eq i32* %48, %6
%50 = zext i1 %49 to i32
%51 = call i32 @assert(i32 %50)
store i32 31, i32* %6
%52 = load i32, i32* %6
%53 = icmp eq i32 %52, 31
%54 = zext i1 %53 to i32
%55 = call i32 @assert(i32 %54)
br label %56
56: ; preds = %47, %9
ret i32 0
}

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