#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 */
char *determine_pid_dir_from(char const **);
int /*<<< orphan*/ free(char *);
char *local_pid_dir(char const *);
const char *determine_local_pid_dir(const char *local_dir) {
  const char *dir = local_pid_dir(local_dir);
  if (dir == NULL)
    return NULL;
  const char *candidates[] = {dir, NULL};
  const char *result = determine_pid_dir_from(candidates);
  free((char *)dir);
  return result;
}


x86 assembly (clang, -O0):
<determine_local_pid_dir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <local_pid_dir@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1161 <determine_local_pid_dir+0x31>
movq   $0x0,-0x8(%rbp)
jmp    118f <determine_local_pid_dir+0x5f>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
movq   $0x0,-0x28(%rbp)
lea    -0x30(%rbp),%rdi
call   1050 <determine_pid_dir_from@plt>
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<determine_local_pid_dir>:
push   %r14
push   %rbx
sub    $0x18,%rsp
call   1040 <local_pid_dir@plt>
test   %rax,%rax
je     1166 <determine_local_pid_dir+0x36>
mov    %rax,%rbx
mov    %rax,(%rsp)
movq   $0x0,0x8(%rsp)
mov    %rsp,%rdi
call   1050 <determine_pid_dir_from@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    1169 <determine_local_pid_dir+0x39>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @determine_local_pid_dir(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [2 x i8*]
%6 = alloca i8*
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = call i8* @local_pid_dir(i8* %7)
store i8* %8, i8** %4
%9 = load i8*, i8** %4
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %12
11: ; preds = %1
store i8* null, i8** %2
br label %21
12: ; preds = %1
%13 = getelementptr inbounds [2 x i8*], [2 x i8*]* %5, i64 0, i64 0
%14 = load i8*, i8** %4
store i8* %14, i8** %13
%15 = getelementptr inbounds i8*, i8** %13, i64 1
store i8* null, i8** %15
%16 = getelementptr inbounds [2 x i8*], [2 x i8*]* %5, i64 0, i64 0
%17 = call i8* @determine_pid_dir_from(i8** %16)
store i8* %17, i8** %6
%18 = load i8*, i8** %4
%19 = call i32 @free(i8* %18)
%20 = load i8*, i8** %6
store i8* %20, i8** %2
br label %21
21: ; preds = %12, %11
%22 = load i8*, i8** %2
ret i8* %22
}

LLVM IR (-O2):
define i8* @determine_local_pid_dir(i8* %0) {
%2 = alloca [2 x i8*]
%3 = tail call i8* @local_pid_dir(i8* %0)
%4 = icmp eq i8* %3, null
br i1 %4, label %11, label %5
5: ; preds = %1
%6 = bitcast [2 x i8*]* %2 to i8*
%7 = getelementptr inbounds [2 x i8*], [2 x i8*]* %2, i64 0, i64 0
store i8* %3, i8** %7
%8 = getelementptr inbounds [2 x i8*], [2 x i8*]* %2, i64 0, i64 1
store i8* null, i8** %8
%9 = call i8* @determine_pid_dir_from(i8** %7)
%10 = call i32 @free(i8* %3)
br label %11
11: ; preds = %1, %5
%12 = phi i8* [ %9, %5 ], [ null, %1 ]
ret i8* %12
}