#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ *realpath(char *, char *);
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  char rlpath[PATH_MAX];
  if (argc == 2) {
    if (realpath(argv[1], rlpath) == NULL)
      exit(2);
    fprintf(stdout, "%s\n", rlpath);
    exit(0);
  }
  exit(1);
}


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    0x2ea3(%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,-0x28(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    11c1 <main+0x91>
mov    -0x28(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <realpath@plt>
cmp    $0x0,%rax
jne    11a1 <main+0x71>
mov    $0x2,%edi
call   1050 <exit@plt>
mov    -0x28(%rbp),%rdx
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
lea    0xe4b(%rip),%rsi
call   1030 <fprintf@plt>
xor    %edi,%edi
call   1050 <exit@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
push   %rax
mov    0x2eb3(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
cmp    $0x2,%edi
jne    1170 <main+0x40>
mov    0x8(%rsi),%rdi
mov    %rbx,%rsi
call   1040 <realpath@plt>
test   %rax,%rax
jne    117a <main+0x4a>
mov    $0x2,%edi
call   1050 <exit@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
lea    0xe76(%rip),%rsi
mov    %rbx,%rdx
call   1030 <fprintf@plt>
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@PATH_MAX = global i32 0
@stdout = global i32 0
@.str = [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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* @PATH_MAX
%9 = zext i32 %8 to i64
%10 = call i8* @llvm.stacksave()
store i8* %10, i8** %6
%11 = alloca i8, i64 %9
store i64 %9, i64* %7
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 2
br i1 %13, label %14, label %26
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32* @realpath(i8* %17, i8* %11)
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %22
20: ; preds = %14
%21 = call i32 @exit(i32 2)
unreachable
22: ; preds = %14
%23 = load i32, i32* @stdout
%24 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %11)
%25 = call i32 @exit(i32 0)
unreachable
26: ; preds = %2
%27 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
@stdout = global i32 0
@.str = [4 x i8] c"%s\0A\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 %7, label %18
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = call i32* @realpath(i8* %9, i8* %5)
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = call i32 @exit(i32 2)
unreachable
14: ; preds = %7
%15 = load i32, i32* @stdout
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %5)
%17 = call i32 @exit(i32 0)
unreachable
18: ; preds = %2
%19 = tail call i32 @exit(i32 1)
unreachable
}