#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 PATH_MAX;
scalar_t__ realpath(char const *, char *);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strcmp(char *, char *);
char *strcpy(char *, char const *);
char *strrchr(char *, char);
char *makePathAbsRec(const char *path_, char *resolved_) {
  char pathBuff[PATH_MAX];
  char *slashPos;
  char *child;
  if (realpath(path_, pathBuff)) {
    pathBuff[PATH_MAX - 1] = 0;
    return strcpy(resolved_, pathBuff);
  } else {
    strcpy(pathBuff, path_);
  }
  slashPos = strrchr(pathBuff, '/');
  if (!slashPos || slashPos == path_) {
    return NULL;
  }
  child = slashPos + 1;
  if (strcmp(child, ".") == 0 || strcmp(child, "..") == 0) {
    return NULL;
  }
  *slashPos = 0;
  if (makePathAbsRec(pathBuff, resolved_)) {
    strcat(resolved_, "/");
    strcat(resolved_, child);
    return resolved_;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<makePathAbsRec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    0x2e79(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rsi
sub    %rcx,%rsi
mov    %rsi,-0x48(%rbp)
mov    %rsi,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <realpath@plt>
cmp    $0x0,%rax
je     11de <makePathAbsRec+0x7e>
mov    -0x48(%rbp),%rsi
mov    0x2e36(%rip),%rax
mov    (%rax),%eax
sub    $0x1,%eax
cltq
movb   $0x0,(%rsi,%rax,1)
mov    -0x18(%rbp),%rdi
call   1040 <strcpy@plt>
mov    %rax,-0x8(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    12dc <makePathAbsRec+0x17c>
mov    -0x48(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x48(%rbp),%rdi
mov    $0x2f,%esi
call   1050 <strrchr@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     1216 <makePathAbsRec+0xb6>
mov    -0x30(%rbp),%rax
cmp    -0x10(%rbp),%rax
jne    122a <makePathAbsRec+0xca>
movq   $0x0,-0x8(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    12dc <makePathAbsRec+0x17c>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
lea    0xdc0(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     126a <makePathAbsRec+0x10a>
mov    -0x38(%rbp),%rdi
lea    0xda5(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    127e <makePathAbsRec+0x11e>
movq   $0x0,-0x8(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    12dc <makePathAbsRec+0x17c>
mov    -0x48(%rbp),%rdi
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rsi
call   1030 <makePathAbsRec@plt>
cmp    $0x0,%rax
je     12cd <makePathAbsRec+0x16d>
mov    -0x18(%rbp),%rdi
lea    0xd5c(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x18(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1080 <strcat@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    12dc <makePathAbsRec+0x17c>
movq   $0x0,-0x8(%rbp)
movl   $0x1,-0x3c(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x8(%rbp),%rax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<makePathAbsRec>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    0x2e78(%rip),%r12
mov    (%r12),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rsi
call   1070 <realpath@plt>
test   %rax,%rax
je     11be <makePathAbsRec+0x5e>
movslq (%r12),%rax
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
mov    %r14,%rax
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1050 <strrchr@plt>
mov    %rax,%r12
xor    %eax,%eax
test   %r12,%r12
je     11b1 <makePathAbsRec+0x51>
cmp    %r15,%r12
je     11b1 <makePathAbsRec+0x51>
lea    0x1(%r12),%r15
lea    0xe10(%rip),%rsi
mov    %r15,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1246 <makePathAbsRec+0xe6>
lea    0xdfb(%rip),%rsi
mov    %r15,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1246 <makePathAbsRec+0xe6>
movb   $0x0,(%r12)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <makePathAbsRec@plt>
test   %rax,%rax
je     1246 <makePathAbsRec+0xe6>
lea    0xdd5(%rip),%rsi
mov    %r14,%rdi
call   1080 <strcat@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1080 <strcat@plt>
jmp    11ae <makePathAbsRec+0x4e>
xor    %eax,%eax
jmp    11b1 <makePathAbsRec+0x51>

LLVM IR (-O0):
@PATH_MAX = global i32 0
@.str = [2 x i8] c".\00"
@.str.1 = [3 x i8] c"..\00"
@.str.2 = [2 x i8] c"/\00"
define i8* @makePathAbsRec(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%11 = load i32, i32* @PATH_MAX
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %6
%14 = alloca i8, i64 %12
store i64 %12, i64* %7
%15 = load i8*, i8** %4
%16 = call i64 @realpath(i8* %15, i8* %14)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %25
18: ; preds = %2
%19 = load i32, i32* @PATH_MAX
%20 = sub nsw i32 %19, 1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %14, i64 %21
store i8 0, i8* %22
%23 = load i8*, i8** %5
%24 = call i8* @strcpy(i8* %23, i8* %14)
store i8* %24, i8** %3
store i32 1, i32* %10
br label %61
25: ; preds = %2
%26 = load i8*, i8** %4
%27 = call i8* @strcpy(i8* %14, i8* %26)
br label %28
28: ; preds = %25
%29 = call i8* @strrchr(i8* %14, i8 signext 47)
store i8* %29, i8** %8
%30 = load i8*, i8** %8
%31 = icmp ne i8* %30, null
br i1 %31, label %32, label %36
32: ; preds = %28
%33 = load i8*, i8** %8
%34 = load i8*, i8** %4
%35 = icmp eq i8* %33, %34
br i1 %35, label %36, label %37
36: ; preds = %32, %28
store i8* null, i8** %3
store i32 1, i32* %10
br label %61
37: ; preds = %32
%38 = load i8*, i8** %8
%39 = getelementptr inbounds i8, i8* %38, i64 1
store i8* %39, i8** %9
%40 = load i8*, i8** %9
%41 = call i64 @strcmp(i8* %40, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%42 = icmp eq i64 %41, 0
br i1 %42, label %47, label %43
43: ; preds = %37
%44 = load i8*, i8** %9
%45 = call i64 @strcmp(i8* %44, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %48
47: ; preds = %43, %37
store i8* null, i8** %3
store i32 1, i32* %10
br label %61
48: ; preds = %43
%49 = load i8*, i8** %8
store i8 0, i8* %49
%50 = load i8*, i8** %5
%51 = call i8* @makePathAbsRec(i8* %14, i8* %50)
%52 = icmp ne i8* %51, null
br i1 %52, label %53, label %60
53: ; preds = %48
%54 = load i8*, i8** %5
%55 = call i32 @strcat(i8* %54, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%56 = load i8*, i8** %5
%57 = load i8*, i8** %9
%58 = call i32 @strcat(i8* %56, i8* %57)
%59 = load i8*, i8** %5
store i8* %59, i8** %3
store i32 1, i32* %10
br label %61
60: ; preds = %48
store i8* null, i8** %3
store i32 1, i32* %10
br label %61
61: ; preds = %60, %53, %47, %36, %18
%62 = load i8*, i8** %6
%63 = load i8*, i8** %3
ret i8* %63
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
@.str = [2 x i8] c".\00"
@.str.1 = [3 x i8] c"..\00"
@.str.2 = [2 x i8] c"/\00"
define i8* @makePathAbsRec(i8* %0, i8* %1) {
%3 = load i32, i32* @PATH_MAX
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
%6 = call i64 @realpath(i8* %0, i8* %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %14, label %8
8: ; preds = %2
%9 = load i32, i32* @PATH_MAX
%10 = add nsw i32 %9, -1
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %5, i64 %11
store i8 0, i8* %12
%13 = call i8* @strcpy(i8* dereferenceable(1) %1, i8* %5)
br label %33
14: ; preds = %2
%15 = call i8* @strcpy(i8* %5, i8* dereferenceable(1) %0)
%16 = call i8* @strrchr(i8* %5, i8 signext 47)
%17 = icmp eq i8* %16, null
%18 = icmp eq i8* %16, %0
%19 = or i1 %17, %18
br i1 %19, label %33, label %20
20: ; preds = %14
%21 = getelementptr inbounds i8, i8* %16, i64 1
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %33, label %24
24: ; preds = %20
%25 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %33, label %27
27: ; preds = %24
store i8 0, i8* %16
%28 = call i8* @makePathAbsRec(i8* %5, i8* %1)
%29 = icmp eq i8* %28, null
br i1 %29, label %33, label %30
30: ; preds = %27
%31 = call i32 @strcat(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%32 = call i32 @strcat(i8* %1, i8* %21)
br label %33
33: ; preds = %27, %20, %24, %14, %30, %8
%34 = phi i8* [ %1, %8 ], [ %1, %30 ], [ null, %14 ], [ null, %24 ], [ null, %20 ], [ null, %27 ]
ret i8* %34
}