#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int PATH_MAX;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ *realpath(char *, char *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  char fullpath[PATH_MAX];
  int i;
  if (argc < 2) {
    fprintf(stderr, "invalid argument!\n");
    fprintf(stderr, "Usage: %s path [path ... path]\n", argv[0]);
    return EXIT_FAILURE;
  }
  for (i = 1; i < argc; i++) {
    if (realpath(argv[i], fullpath) == NULL) {
      fprintf(stderr, "error processing '%s'\n", argv[i]);
    }
    printf("%s\n", fullpath);
  }
  return EXIT_SUCCESS;
}


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,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11c9 <main+0x99>
mov    0x2e55(%rip),%rax
mov    (%rax),%edi
lea    0xe74(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe69(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e18(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x28(%rbp)
jmp    124f <main+0x11f>
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    123c <main+0x10c>
mov    -0x30(%rbp),%rsi
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <realpath@plt>
cmp    $0x0,%rax
jne    121e <main+0xee>
mov    0x2dd6(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe1c(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x30(%rbp),%rsi
lea    0xe21(%rip),%rdi
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11d0 <main+0xa0>
mov    0x2d85(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x28(%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   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    0x2ea8(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
cmp    $0x2,%edi
jge    1193 <main+0x63>
mov    0x2e71(%rip),%rbx
mov    (%rbx),%edi
lea    0xe90(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
mov    (%r14),%rdx
lea    0xe90(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x2e3f(%rip),%rax
jmp    11f9 <main+0xc9>
mov    %edi,%r13d
mov    $0x1,%r15d
lea    0xea7(%rip),%r12
jmp    11c4 <main+0x94>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
add    $0x1,%r15
cmp    %r15,%r13
je     11f2 <main+0xc2>
mov    (%r14,%r15,8),%rdi
mov    %rbx,%rsi
call   1050 <realpath@plt>
test   %rax,%rax
jne    11b0 <main+0x80>
mov    0x2dfc(%rip),%rax
mov    (%rax),%edi
mov    (%r14,%r15,8),%rdx
lea    0xe4a(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    11b0 <main+0x80>
mov    0x2dcf(%rip),%rax
mov    (%rax),%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@PATH_MAX = global i32 0
@stderr = global i32 0
@.str = [19 x i8] c"invalid argument!\0A\00"
@.str.1 = [32 x i8] c"Usage: %s path [path ... path]\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [23 x i8] c"error processing '%s'\0A\00"
@.str.3 = [4 x i8] c"%s\0A\00"
@EXIT_SUCCESS = global i32 0
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
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* @PATH_MAX
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %6
%13 = alloca i8, i64 %11
store i64 %11, i64* %7
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 2
br i1 %15, label %16, label %25
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%19 = load i32, i32* @stderr
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %22)
%24 = load i32, i32* @EXIT_FAILURE
store i32 %24, i32* %3
store i32 1, i32* %9
br label %53
25: ; preds = %2
store i32 1, i32* %8
br label %26
26: ; preds = %48, %25
%27 = load i32, i32* %8
%28 = load i32, i32* %4
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %51
30: ; preds = %26
%31 = load i8**, i8*** %5
%32 = load i32, i32* %8
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8*, i8** %31, i64 %33
%35 = load i8*, i8** %34
%36 = call i32* @realpath(i8* %35, i8* %13)
%37 = icmp eq i32* %36, null
br i1 %37, label %38, label %46
38: ; preds = %30
%39 = load i32, i32* @stderr
%40 = load i8**, i8*** %5
%41 = load i32, i32* %8
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8*, i8** %40, i64 %42
%44 = load i8*, i8** %43
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %44)
br label %46
46: ; preds = %38, %30
%47 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %13)
br label %48
48: ; preds = %46
%49 = load i32, i32* %8
%50 = add nsw i32 %49, 1
store i32 %50, i32* %8
br label %26
51: ; preds = %26
%52 = load i32, i32* @EXIT_SUCCESS
store i32 %52, i32* %3
store i32 1, i32* %9
br label %53
53: ; preds = %51, %16
%54 = load i8*, i8** %6
%55 = load i32, i32* %3
ret i32 %55
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
@stderr = global i32 0
@.str = [19 x i8] c"invalid argument!\0A\00"
@.str.1 = [32 x i8] c"Usage: %s path [path ... path]\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [23 x i8] c"error processing '%s'\0A\00"
@.str.3 = [4 x i8] c"%s\0A\00"
@EXIT_SUCCESS = global i32 0
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 slt i32 %0, 2
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = zext i32 %0 to i64
br label %15
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* @stderr
%13 = load i8*, i8** %1
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %13)
br label %29
15: ; preds = %7, %25
%16 = phi i64 [ 1, %7 ], [ %27, %25 ]
%17 = getelementptr inbounds i8*, i8** %1, i64 %16
%18 = load i8*, i8** %17
%19 = call i32* @realpath(i8* %18, i8* %5)
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %25
21: ; preds = %15
%22 = load i32, i32* @stderr
%23 = load i8*, i8** %17
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %23)
br label %25
25: ; preds = %21, %15
%26 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %5)
%27 = add nuw nsw i64 %16, 1
%28 = icmp eq i64 %27, %8
br i1 %28, label %29, label %15
29: ; preds = %25, %9
%30 = phi i32* [ @EXIT_FAILURE, %9 ], [ @EXIT_SUCCESS, %25 ]
%31 = load i32, i32* %30
ret i32 %31
}