#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 */
int MAXPATHLEN;
int compressPathname(char *);
int /*<<< orphan*/ getcwd(char *, int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int normalizePathname(char *pathname) {
  char oldPathname[MAXPATHLEN], wd[MAXPATHLEN];
  if (pathname[0] != '/') {
    strcpy(oldPathname, pathname);
    getcwd(wd, MAXPATHLEN);
    strcpy(pathname, wd);
    strcat(pathname, "/");
    strcat(pathname, oldPathname);
  }
  return compressPathname(pathname);
}


x86 assembly (clang, -O0):
<normalizePathname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e95(%rip),%rax
mov    (%rax),%ecx
mov    %rsp,%rdx
mov    %rdx,-0x10(%rbp)
mov    %rcx,%rsi
add    $0xf,%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x30(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x18(%rbp)
mov    (%rax),%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
je     11ef <normalizePathname+0xaf>
mov    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x28(%rbp),%rdi
mov    0x2e2a(%rip),%rax
mov    (%rax),%esi
call   1040 <getcwd@plt>
mov    -0x28(%rbp),%rsi
mov    -0x8(%rbp),%rdi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
lea    0xe23(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x30(%rbp),%rsi
mov    -0x8(%rbp),%rdi
call   1060 <strcat@plt>
mov    -0x8(%rbp),%rdi
call   1050 <compressPathname@plt>
mov    -0x10(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<normalizePathname>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r14
mov    0x2e93(%rip),%r12
mov    (%r12),%eax
mov    %rsp,%r15
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    %rsp,%rbx
sub    %rax,%rbx
mov    %rbx,%rsp
cmpb   $0x2f,(%rdi)
je     11b4 <normalizePathname+0x74>
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    (%r12),%esi
mov    %rbx,%rdi
call   1040 <getcwd@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
lea    0xe5f(%rip),%rsi
mov    %r14,%rdi
call   1060 <strcat@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <strcat@plt>
mov    %r14,%rdi
call   1050 <compressPathname@plt>
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@MAXPATHLEN = global i32 0
@.str = [2 x i8] c"/\00"
define i32 @normalizePathname(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
store i8* %0, i8** %2
%6 = load i32, i32* @MAXPATHLEN
%7 = zext i32 %6 to i64
%8 = call i8* @llvm.stacksave()
store i8* %8, i8** %3
%9 = alloca i8, i64 %7
store i64 %7, i64* %4
%10 = load i32, i32* @MAXPATHLEN
%11 = zext i32 %10 to i64
%12 = alloca i8, i64 %11
store i64 %11, i64* %5
%13 = load i8*, i8** %2
%14 = getelementptr inbounds i8, i8* %13, i64 0
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 47
br i1 %17, label %18, label %29
18: ; preds = %1
%19 = load i8*, i8** %2
%20 = call i32 @strcpy(i8* %9, i8* %19)
%21 = load i32, i32* @MAXPATHLEN
%22 = call i32 @getcwd(i8* %12, i32 %21)
%23 = load i8*, i8** %2
%24 = call i32 @strcpy(i8* %23, i8* %12)
%25 = load i8*, i8** %2
%26 = call i32 @strcat(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%27 = load i8*, i8** %2
%28 = call i32 @strcat(i8* %27, i8* %9)
br label %29
29: ; preds = %18, %1
%30 = load i8*, i8** %2
%31 = call i32 @compressPathname(i8* %30)
%32 = load i8*, i8** %3
ret i32 %31
}

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