#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__ getExePath(char *);
int /*<<< orphan*/ pathToLong();
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
bool getLocalPath(char path[]) {
  if (getExePath(path)) {
    if (strlen(path) + strlen("items.lst") < 1024) {
      strcat(path, "items.lst");
      return true;
    } else {
      pathToLong();
    }
  }
  return false;
}


x86 assembly (clang, -O0):
<getLocalPath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <getExePath@plt>
cmp    $0x0,%rax
je     11b1 <getLocalPath+0x71>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
lea    0xe8e(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
add    %ecx,%eax
cmp    $0x400,%eax
jge    11a5 <getLocalPath+0x65>
mov    -0x10(%rbp),%rdi
lea    0xe6c(%rip),%rsi
call   1060 <strcat@plt>
movl   $0x1,-0x4(%rbp)
jmp    11b8 <getLocalPath+0x78>
mov    $0x0,%al
call   1030 <pathToLong@plt>
jmp    11b1 <getLocalPath+0x71>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getLocalPath>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1050 <getExePath@plt>
test   %rax,%rax
je     1185 <getLocalPath+0x45>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
lea    0xe9f(%rip),%rdi
call   1040 <strlen@plt>
add    %ebp,%eax
cmp    $0x3ff,%eax
jg     1189 <getLocalPath+0x49>
lea    0xe8a(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
mov    $0x1,%ebx
jmp    1192 <getLocalPath+0x52>
xor    %ebx,%ebx
jmp    1192 <getLocalPath+0x52>
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <pathToLong@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"items.lst\00"
define i32 @getLocalPath(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i64 @getExePath(i8* %4)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %19
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = call i32 @strlen(i8* %8)
%10 = call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%11 = add nsw i32 %9, %10
%12 = icmp slt i32 %11, 1024
br i1 %12, label %13, label %16
13: ; preds = %7
%14 = load i8*, i8** %3
%15 = call i32 @strcat(i8* %14, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %2
br label %20
16: ; preds = %7
%17 = call i32 (...) @pathToLong()
br label %18
18: ; preds = %16
br label %19
19: ; preds = %18, %1
store i32 0, i32* %2
br label %20
20: ; preds = %19, %13
%21 = load i32, i32* %2
ret i32 %21
}

LLVM IR (-O2):
@.str = [10 x i8] c"items.lst\00"
define i32 @getLocalPath(i8* %0) {
%2 = tail call i64 @getExePath(i8* %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %13, label %4
4: ; preds = %1
%5 = tail call i32 @strlen(i8* %0)
%6 = tail call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%7 = add nsw i32 %6, %5
%8 = icmp slt i32 %7, 1024
br i1 %8, label %9, label %11
9: ; preds = %4
%10 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %13
11: ; preds = %4
%12 = tail call i32 (...) @pathToLong()
br label %13
13: ; preds = %1, %11, %9
%14 = phi i32 [ 1, %9 ], [ 0, %11 ], [ 0, %1 ]
ret i32 %14
}