#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 */
typedef int pid_t;

/* Variables and functions */
int custom_pid_time(int, int);
int get_pid_time(int procfd, pid_t pid) {
  static int init_pid_time = -1;
  if (init_pid_time < 0) {
    init_pid_time = custom_pid_time(procfd, 1);
  }
  if (pid == 1)
    return init_pid_time;
  return custom_pid_time(procfd, pid);
}


x86 assembly (clang, -O0):
<get_pid_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,0x2f03(%rip)
jge    113e <get_pid_time+0x2e>
mov    -0x8(%rbp),%edi
mov    $0x1,%esi
call   1030 <custom_pid_time@plt>
mov    %eax,0x2eea(%rip)
cmpl   $0x1,-0xc(%rbp)
jne    1156 <get_pid_time+0x46>
mov    0x2eda(%rip),%eax
mov    %eax,-0x4(%rbp)
jmp    1164 <get_pid_time+0x54>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <custom_pid_time@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_pid_time>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
mov    0x2f0b(%rip),%eax
test   %eax,%eax
js     112d <get_pid_time+0x1d>
cmp    $0x1,%ebx
jne    1144 <get_pid_time+0x34>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    %ebp,%edi
mov    $0x1,%esi
call   1030 <custom_pid_time@plt>
mov    %eax,0x2ee9(%rip)
cmp    $0x1,%ebx
je     1126 <get_pid_time+0x16>
mov    %ebp,%edi
mov    %ebx,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <custom_pid_time@plt>

LLVM IR (-O0):
@get_pid_time.init_pid_time = internal global i32 -1
define i32 @get_pid_time(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* @get_pid_time.init_pid_time
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i32, i32* %4
%10 = call i32 @custom_pid_time(i32 %9, i32 1)
store i32 %10, i32* @get_pid_time.init_pid_time
br label %11
11: ; preds = %8, %2
%12 = load i32, i32* %5
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = load i32, i32* @get_pid_time.init_pid_time
store i32 %15, i32* %3
br label %20
16: ; preds = %11
%17 = load i32, i32* %4
%18 = load i32, i32* %5
%19 = call i32 @custom_pid_time(i32 %17, i32 %18)
store i32 %19, i32* %3
br label %20
20: ; preds = %16, %14
%21 = load i32, i32* %3
ret i32 %21
}

LLVM IR (-O2):
@get_pid_time.init_pid_time = internal unnamed_addr global i32 -1
define i32 @get_pid_time(i32 %0, i32 %1) {
%3 = load i32, i32* @get_pid_time.init_pid_time
%4 = icmp slt i32 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @custom_pid_time(i32 %0, i32 1)
store i32 %6, i32* @get_pid_time.init_pid_time
br label %7
7: ; preds = %5, %2
%8 = phi i32 [ %6, %5 ], [ %3, %2 ]
%9 = icmp eq i32 %1, 1
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = tail call i32 @custom_pid_time(i32 %0, i32 %1)
br label %12
12: ; preds = %7, %10
%13 = phi i32 [ %11, %10 ], [ %8, %7 ]
ret i32 %13
}