#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;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ realpath(char *, char *);
int main(int argc, char **argv) {
  char absolutePath[PATH_MAX];
  if (argc != 2) {
    printf("Usage: realpath path\n");
    return 1;
  }
  realpath(argv[1], absolutePath);
  printf("%s\n", absolutePath);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2eb3(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     118d <main+0x6d>
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x24(%rbp)
jmp    11be <main+0x9e>
mov    -0x30(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <realpath@plt>
mov    -0x30(%rbp),%rsi
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
push   %rax
mov    0x2ec3(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
cmp    $0x2,%edi
jne    115d <main+0x3d>
mov    0x8(%rsi),%rdi
mov    %rbx,%rsi
call   1040 <realpath@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
jmp    116e <main+0x4e>
lea    0xe9c(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
lea    -0x8(%rbp),%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@PATH_MAX = global i32 0
@.str = [22 x i8] c"Usage: realpath path\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* @PATH_MAX
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %6
%12 = alloca i8, i64 %10
store i64 %10, i64* %7
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 2
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
store i32 1, i32* %8
br label %23
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @realpath(i8* %20, i8* %12)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %12)
store i32 0, i32* %3
store i32 1, i32* %8
br label %23
23: ; preds = %17, %15
%24 = load i8*, i8** %6
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
@str = [21 x i8] c"Usage: realpath path\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i32, i32* @PATH_MAX
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
%6 = icmp eq i32 %0, 2
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
br label %14
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = call i32 @realpath(i8* %11, i8* %5)
%13 = call i32 @puts(i8* %5)
br label %14
14: ; preds = %9, %7
%15 = phi i32 [ 1, %7 ], [ 0, %9 ]
ret i32 %15
}