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

/* Variables and functions */
int ENOBUFS;
int PATH_MAX;
int make_path_absolute(char *, int, char const *);
int normalize_path(char *, size_t, char *);
int make_normalized_absolute_path(char *result_path, size_t result_path_size,
                                  const char *path) {
  int error;
  char absolute_path[PATH_MAX];
  if (!result_path || result_path_size < 1)
    return ENOBUFS;
  *result_path = 0;
  if ((error =
           make_path_absolute(absolute_path, sizeof(absolute_path), path)) != 0)
    return error;
  if ((error = normalize_path(result_path, result_path_size, absolute_path)) !=
      0)
    return error;
  return 0;
}


x86 assembly (clang, -O0):
<make_normalized_absolute_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    0x2ead(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x50(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     117a <make_normalized_absolute_path+0x5a>
cmpq   $0x1,-0x18(%rbp)
jae    1192 <make_normalized_absolute_path+0x72>
mov    0x2e77(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    1207 <make_normalized_absolute_path+0xe7>
mov    -0x48(%rbp),%rdi
mov    -0x50(%rbp),%rax
mov    -0x10(%rbp),%rcx
movb   $0x0,(%rcx)
mov    %eax,%esi
mov    -0x20(%rbp),%rdx
call   1030 <make_path_absolute@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
je     11ca <make_normalized_absolute_path+0xaa>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    1207 <make_normalized_absolute_path+0xe7>
mov    -0x48(%rbp),%rdx
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <normalize_path@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
je     11f9 <make_normalized_absolute_path+0xd9>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    1207 <make_normalized_absolute_path+0xe7>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_normalized_absolute_path>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    0x2eb4(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rbx
lea    0xf(%rsi),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
test   %rdi,%rdi
je     1173 <make_normalized_absolute_path+0x53>
test   %r14,%r14
je     1173 <make_normalized_absolute_path+0x53>
mov    %rdi,%r15
movb   $0x0,(%rdi)
mov    %rbx,%rdi
call   1030 <make_path_absolute@plt>
test   %eax,%eax
jne    117c <make_normalized_absolute_path+0x5c>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1040 <normalize_path@plt>
jmp    117c <make_normalized_absolute_path+0x5c>
mov    0x2e7e(%rip),%rax
mov    (%rax),%eax
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@PATH_MAX = global i32 0
@ENOBUFS = global i32 0
define i32 @make_normalized_absolute_path(i8* %0, i64 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i32
store i8* %0, i8** %5
store i64 %1, i64* %6
store i8* %2, i8** %7
%12 = load i32, i32* @PATH_MAX
%13 = zext i32 %12 to i64
%14 = call i8* @llvm.stacksave()
store i8* %14, i8** %9
%15 = alloca i8, i64 %13
store i64 %13, i64* %10
%16 = load i8*, i8** %5
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %21
18: ; preds = %3
%19 = load i64, i64* %6
%20 = icmp ult i64 %19, 1
br i1 %20, label %21, label %23
21: ; preds = %18, %3
%22 = load i32, i32* @ENOBUFS
store i32 %22, i32* %4
store i32 1, i32* %11
br label %39
23: ; preds = %18
%24 = load i8*, i8** %5
store i8 0, i8* %24
%25 = trunc i64 %13 to i32
%26 = load i8*, i8** %7
%27 = call i32 @make_path_absolute(i8* %15, i32 %25, i8* %26)
store i32 %27, i32* %8
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %23
%30 = load i32, i32* %8
store i32 %30, i32* %4
store i32 1, i32* %11
br label %39
31: ; preds = %23
%32 = load i8*, i8** %5
%33 = load i64, i64* %6
%34 = call i32 @normalize_path(i8* %32, i64 %33, i8* %15)
store i32 %34, i32* %8
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %31
%37 = load i32, i32* %8
store i32 %37, i32* %4
store i32 1, i32* %11
br label %39
38: ; preds = %31
store i32 0, i32* %4
store i32 1, i32* %11
br label %39
39: ; preds = %38, %36, %29, %21
%40 = load i8*, i8** %9
%41 = load i32, i32* %4
ret i32 %41
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
@ENOBUFS = global i32 0
define i32 @make_normalized_absolute_path(i8* %0, i64 %1, i8* %2) {
%4 = load i32, i32* @PATH_MAX
%5 = zext i32 %4 to i64
%6 = alloca i8, i64 %5
%7 = icmp eq i8* %0, null
%8 = icmp eq i64 %1, 0
%9 = or i1 %7, %8
br i1 %9, label %10, label %12
10: ; preds = %3
%11 = load i32, i32* @ENOBUFS
br label %17
12: ; preds = %3
store i8 0, i8* %0
%13 = call i32 @make_path_absolute(i8* %6, i32 %4, i8* %2)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = call i32 @normalize_path(i8* %0, i64 %1, i8* %6)
br label %17
17: ; preds = %15, %12, %10
%18 = phi i32 [ %11, %10 ], [ %13, %12 ], [ %16, %15 ]
ret i32 %18
}