#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 */
scalar_t__ iposix_path_execwd(char *, int);
const char *iposix_get_execwd(void) {
  static int inited = 0;
  static char ptr[((1024) + 8) + 10];
  if (inited == 0) {
    if (iposix_path_execwd(ptr, 1024) != 0) {
      inited = -1;
      return "";
    }
    inited = 1;
  }
  if (inited < 0)
    return "";
  return ptr;
}


x86 assembly (clang, -O0):
<iposix_get_execwd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
cmpl   $0x0,0x2f21(%rip)
jne    1164 <iposix_get_execwd+0x54>
lea    0x2f24(%rip),%rdi
mov    $0x400,%esi
call   1030 <iposix_path_execwd@plt>
cmp    $0x0,%rax
je     115a <iposix_get_execwd+0x4a>
movl   $0xffffffff,0x2ef6(%rip)
ff ff ff
lea    0xeaf(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    118c <iposix_get_execwd+0x7c>
movl   $0x1,0x2edc(%rip)
cmpl   $0x0,0x2ed5(%rip)
jge    1181 <iposix_get_execwd+0x71>
lea    0xe88(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    118c <iposix_get_execwd+0x7c>
lea    0x2ec8(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iposix_get_execwd>:
push   %rbx
cmpl   $0x0,0x2f28(%rip)
je     112e <iposix_get_execwd+0x1e>
lea    0xedf(%rip),%rcx
lea    0x2f28(%rip),%rax
cmovs  %rcx,%rax
pop    %rbx
ret
lea    0x2f1b(%rip),%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1030 <iposix_path_execwd@plt>
mov    %rax,%rcx
neg    %rcx
sbb    %ecx,%ecx
or     $0x1,%ecx
test   %rax,%rax
lea    0xea9(%rip),%rax
cmove  %rbx,%rax
mov    %ecx,0x2edf(%rip)
pop    %rbx
ret

LLVM IR (-O0):
@iposix_get_execwd.inited = internal global i32 0
@iposix_get_execwd.ptr = internal global [1042 x i8] zeroinitializer
@.str = [1 x i8] zeroinitializer
define i8* @iposix_get_execwd() {
%1 = alloca i8*
%2 = load i32, i32* @iposix_get_execwd.inited
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %9
4: ; preds = %0
%5 = call i64 @iposix_path_execwd(i8* getelementptr inbounds ([1042 x i8], [1042 x i8]* @iposix_get_execwd.ptr, i64 0, i64 0), i32 1024)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %4
store i32 -1, i32* @iposix_get_execwd.inited
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %1
br label %14
8: ; preds = %4
store i32 1, i32* @iposix_get_execwd.inited
br label %9
9: ; preds = %8, %0
%10 = load i32, i32* @iposix_get_execwd.inited
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %9
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %1
br label %14
13: ; preds = %9
store i8* getelementptr inbounds ([1042 x i8], [1042 x i8]* @iposix_get_execwd.ptr, i64 0, i64 0), i8** %1
br label %14
14: ; preds = %13, %12, %7
%15 = load i8*, i8** %1
ret i8* %15
}

LLVM IR (-O2):
@iposix_get_execwd.inited = internal unnamed_addr global i32 0
@iposix_get_execwd.ptr = internal global [1042 x i8] zeroinitializer
@.str = [1 x i8] zeroinitializer
define i8* @iposix_get_execwd() {
%1 = load i32, i32* @iposix_get_execwd.inited
%2 = icmp eq i32 %1, 0
br i1 %2, label %3, label %8
3: ; preds = %0
%4 = tail call i64 @iposix_path_execwd(i8* getelementptr inbounds ([1042 x i8], [1042 x i8]* @iposix_get_execwd.ptr, i64 0, i64 0), i32 1024)
%5 = icmp eq i64 %4, 0
%6 = select i1 %5, i32 1, i32 -1
%7 = select i1 %5, i8* getelementptr inbounds ([1042 x i8], [1042 x i8]* @iposix_get_execwd.ptr, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0)
store i32 %6, i32* @iposix_get_execwd.inited
br label %11
8: ; preds = %0
%9 = icmp slt i32 %1, 0
%10 = select i1 %9, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1042 x i8], [1042 x i8]* @iposix_get_execwd.ptr, i64 0, i64 0)
br label %11
11: ; preds = %8, %3
%12 = phi i8* [ %10, %8 ], [ %7, %3 ]
ret i8* %12
}