#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*/ derefI(int *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, int);
void checkForCallee2() {
  int *p1;
  int *p2;
  p1 = (int *)malloc(sizeof(int));
  printf("Init value is: %d\n", *p1);
  derefI(p1);
  if (p1) {
    derefI(p1);
  }
  p2 = p1;
  printf("Init value is: %d\n", *p2);
  derefI(p2);
}


x86 assembly (clang, -O0):
<checkForCallee2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x4,%edi
call   1050 <malloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
lea    0xead(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1040 <derefI@plt>
cmpq   $0x0,-0x8(%rbp)
je     1175 <checkForCallee2+0x45>
mov    -0x8(%rbp),%rdi
call   1040 <derefI@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    0xe76(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <derefI@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkForCallee2>:
push   %r14
push   %rbx
push   %rax
mov    $0x4,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    (%rax),%esi
lea    0xeb6(%rip),%r14
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <derefI@plt>
mov    %rbx,%rdi
call   1040 <derefI@plt>
mov    (%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <derefI@plt>

LLVM IR (-O0):
@.str = [19 x i8] c"Init value is: %d\0A\00"
define void @checkForCallee2() {
%1 = alloca i32*
%2 = alloca i32*
%3 = call i64 @malloc(i32 4)
%4 = inttoptr i64 %3 to i32*
store i32* %4, i32** %1
%5 = load i32*, i32** %1
%6 = load i32, i32* %5
%7 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = load i32*, i32** %1
%9 = call i32 @derefI(i32* %8)
%10 = load i32*, i32** %1
%11 = icmp ne i32* %10, null
br i1 %11, label %12, label %15
12: ; preds = %0
%13 = load i32*, i32** %1
%14 = call i32 @derefI(i32* %13)
br label %15
15: ; preds = %12, %0
%16 = load i32*, i32** %1
store i32* %16, i32** %2
%17 = load i32*, i32** %2
%18 = load i32, i32* %17
%19 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = load i32*, i32** %2
%21 = call i32 @derefI(i32* %20)
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"Init value is: %d\0A\00"
define void @checkForCallee2() {
%1 = tail call i64 @malloc(i32 4)
%2 = inttoptr i64 %1 to i32*
%3 = load i32, i32* %2
%4 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = tail call i32 @derefI(i32* %2)
%6 = tail call i32 @derefI(i32* %2)
%7 = load i32, i32* %2
%8 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = tail call i32 @derefI(i32* %2)
ret void
}