#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 /*<<< orphan*/ zBuf;

/* Variables and functions */
int /*<<< orphan*/ getcwd(char *, int);
int /*<<< orphan*/ sqlite3SetString(char **, char const *, char *, ...);
char *sqlite3OsFullPathname(const char *zRelative) {
  char *zFull = 0;
  if (zRelative[0] == '/') {
    sqlite3SetString(&zFull, zRelative, (char *)0);
  } else {
    char zBuf[5000];
    zBuf[0] = 0;
    sqlite3SetString(&zFull, getcwd(zBuf, sizeof(zBuf)), "/", zRelative,
                     (char *)0);
  }
  return zFull;
}


x86 assembly (clang, -O0):
<sqlite3OsFullPathname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x13a0,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    115f <sqlite3OsFullPathname+0x3f>
mov    -0x8(%rbp),%rsi
lea    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%edx
mov    $0x0,%al
call   1040 <sqlite3SetString@plt>
jmp    1195 <sqlite3OsFullPathname+0x75>
movb   $0x0,-0x13a0(%rbp)
lea    -0x13a0(%rbp),%rdi
mov    $0x1388,%esi
call   1030 <getcwd@plt>
movslq %eax,%rsi
mov    -0x8(%rbp),%rcx
lea    -0x10(%rbp),%rdi
lea    0xe77(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r8d
mov    $0x0,%al
call   1040 <sqlite3SetString@plt>
mov    -0x10(%rbp),%rax
add    $0x13a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sqlite3OsFullPathname>:
push   %rbx
sub    $0x13a0,%rsp
mov    %rdi,%rbx
movq   $0x0,0x8(%rsp)
cmpb   $0x2f,(%rdi)
jne    114c <sqlite3OsFullPathname+0x2c>
lea    0x8(%rsp),%rdi
mov    %rbx,%rsi
xor    %edx,%edx
xor    %eax,%eax
call   1040 <sqlite3SetString@plt>
jmp    117c <sqlite3OsFullPathname+0x5c>
movb   $0x0,0x10(%rsp)
lea    0x10(%rsp),%rdi
mov    $0x1388,%esi
call   1030 <getcwd@plt>
movslq %eax,%rsi
lea    0xe96(%rip),%rdx
lea    0x8(%rsp),%rdi
mov    %rbx,%rcx
xor    %r8d,%r8d
xor    %eax,%eax
call   1040 <sqlite3SetString@plt>
mov    0x8(%rsp),%rax
add    $0x13a0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"/\00"
define i8* @sqlite3OsFullPathname(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca [5000 x i8]
store i8* %0, i8** %2
store i8* null, i8** %3
%5 = load i8*, i8** %2
%6 = getelementptr inbounds i8, i8* %5, i64 0
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %8, 47
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = load i8*, i8** %2
%12 = call i32 (i8**, i8*, i8*, ...) @sqlite3SetString(i8** %3, i8* %11, i8* null)
br label %21
13: ; preds = %1
%14 = getelementptr inbounds [5000 x i8], [5000 x i8]* %4, i64 0, i64 0
store i8 0, i8* %14
%15 = getelementptr inbounds [5000 x i8], [5000 x i8]* %4, i64 0, i64 0
%16 = call i32 @getcwd(i8* %15, i32 5000)
%17 = sext i32 %16 to i64
%18 = inttoptr i64 %17 to i8*
%19 = load i8*, i8** %2
%20 = call i32 (i8**, i8*, i8*, ...) @sqlite3SetString(i8** %3, i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %19, i8* null)
br label %21
21: ; preds = %13, %10
%22 = load i8*, i8** %3
ret i8* %22
}

LLVM IR (-O2):
@.str = [2 x i8] c"/\00"
define i8* @sqlite3OsFullPathname(i8* %0) {
%2 = alloca i8*
%3 = alloca [5000 x i8]
%4 = bitcast i8** %2 to i8*
store i8* null, i8** %2
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 47
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i32 (i8**, i8*, i8*, ...) @sqlite3SetString(i8** %2, i8* %0, i8* null)
br label %15
9: ; preds = %1
%10 = getelementptr inbounds [5000 x i8], [5000 x i8]* %3, i64 0, i64 0
store i8 0, i8* %10
%11 = call i32 @getcwd(i8* %10, i32 5000)
%12 = sext i32 %11 to i64
%13 = inttoptr i64 %12 to i8*
%14 = call i32 (i8**, i8*, i8*, ...) @sqlite3SetString(i8** %2, i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %0, i8* null)
br label %15
15: ; preds = %9, %7
%16 = load i8*, i8** %2
ret i8* %16
}