#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 /*<<< orphan*/ fclose(int /*<<< orphan*/);
int fputs(char *, int /*<<< orphan*/);
int perror(char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ realpath(char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
int main(int argc, char **argv) {
  int i;
  char path[argc][8192];
  if (argc > 1 && !strcmp(argv[1], "-q"))
    --argc, ++argv, fclose(stderr);
  if (argc < 2)
    return fputs("usage: realpath [-q] path [...]\n", stderr), 1;
  for (i = 1; i < argc; ++i)
    if (!realpath(argv[i], path[i]))
      return perror(argv[i]), 1;
  for (i = 1; i < argc; ++i)
    puts(path[i]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rdx
shl    $0xd,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11e2 <main+0x82>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe4f(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    11e2 <main+0x82>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
call   1040 <fclose@plt>
cmpl   $0x2,-0x8(%rbp)
jge    1214 <main+0xb4>
mov    0x2ded(%rip),%rax
mov    (%rax),%esi
lea    0xe07(%rip),%rdi
call   1050 <fputs@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x2c(%rbp)
jmp    12ca <main+0x16a>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1287 <main+0x127>
mov    -0x38(%rbp),%rsi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
movslq -0x14(%rbp),%rax
shl    $0xd,%rax
add    %rax,%rsi
call   1070 <realpath@plt>
cmp    $0x0,%eax
jne    1274 <main+0x114>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1080 <perror@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x2c(%rbp)
jmp    12ca <main+0x16a>
jmp    1279 <main+0x119>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    121b <main+0xbb>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12bc <main+0x15c>
mov    -0x38(%rbp),%rdi
movslq -0x14(%rbp),%rax
shl    $0xd,%rax
add    %rax,%rdi
call   1030 <puts@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    128e <main+0x12e>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    -0x20(%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    %edi,%eax
mov    %rsp,%r12
shl    $0xd,%rax
sub    %rax,%r12
mov    %r12,%rsp
cmp    $0x2,%edi
jl     11b4 <main+0x54>
mov    %rsi,%r14
mov    %edi,%r15d
mov    0x8(%rsi),%rdi
lea    0xe6d(%rip),%rsi
call   1060 <strcmp@plt>
test   %eax,%eax
jne    11d4 <main+0x74>
add    $0xffffffff,%r15d
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
call   1040 <fclose@plt>
cmp    $0x2,%r15d
jae    11d0 <main+0x70>
mov    0x2e25(%rip),%rax
mov    (%rax),%esi
lea    0xe3f(%rip),%rdi
call   1050 <fputs@plt>
mov    $0x1,%eax
jmp    1237 <main+0xd7>
add    $0x8,%r14
mov    %r15d,%r15d
lea    0x2000(%r12),%r13
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r14,%rbx,8),%rdi
mov    %r13,%rsi
call   1070 <realpath@plt>
test   %eax,%eax
je     1246 <main+0xe6>
add    $0x1,%rbx
add    $0x2000,%r13
cmp    %rbx,%r15
jne    11f0 <main+0x90>
add    $0x2000,%r12
add    $0xffffffffffffffff,%r15
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1030 <puts@plt>
add    $0x2000,%r12
add    $0xffffffffffffffff,%r15
jne    1220 <main+0xc0>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %ebx,%eax
mov    (%r14,%rax,8),%rdi
call   1080 <perror@plt>
mov    $0x1,%eax
jmp    1237 <main+0xd7>

LLVM IR (-O0):
@.str = [3 x i8] c"-q\00"
@stderr = global i32 0
@.str.1 = [33 x i8] c"usage: realpath [-q] path [...]\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %7
%13 = alloca [8192 x i8], i64 %11
store i64 %11, i64* %8
%14 = load i32, i32* %4
%15 = icmp sgt i32 %14, 1
br i1 %15, label %16, label %29
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32 @strcmp(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%21 = icmp ne i32 %20, 0
br i1 %21, label %29, label %22
22: ; preds = %16
%23 = load i32, i32* %4
%24 = add nsw i32 %23, -1
store i32 %24, i32* %4
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i32 1
store i8** %26, i8*** %5
%27 = load i32, i32* @stderr
%28 = call i32 @fclose(i32 %27)
br label %29
29: ; preds = %22, %16, %2
%30 = load i32, i32* %4
%31 = icmp slt i32 %30, 2
br i1 %31, label %32, label %35
32: ; preds = %29
%33 = load i32, i32* @stderr
%34 = call i32 @fputs(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 %33)
store i32 1, i32* %3
store i32 1, i32* %9
br label %78
35: ; preds = %29
store i32 1, i32* %6
br label %36
36: ; preds = %60, %35
%37 = load i32, i32* %6
%38 = load i32, i32* %4
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %63
40: ; preds = %36
%41 = load i8**, i8*** %5
%42 = load i32, i32* %6
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8*, i8** %41, i64 %43
%45 = load i8*, i8** %44
%46 = load i32, i32* %6
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [8192 x i8], [8192 x i8]* %13, i64 %47
%49 = getelementptr inbounds [8192 x i8], [8192 x i8]* %48, i64 0, i64 0
%50 = call i32 @realpath(i8* %45, i8* %49)
%51 = icmp ne i32 %50, 0
br i1 %51, label %59, label %52
52: ; preds = %40
%53 = load i8**, i8*** %5
%54 = load i32, i32* %6
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8*, i8** %53, i64 %55
%57 = load i8*, i8** %56
%58 = call i32 @perror(i8* %57)
store i32 1, i32* %3
store i32 1, i32* %9
br label %78
59: ; preds = %40
br label %60
60: ; preds = %59
%61 = load i32, i32* %6
%62 = add nsw i32 %61, 1
store i32 %62, i32* %6
br label %36
63: ; preds = %36
store i32 1, i32* %6
br label %64
64: ; preds = %74, %63
%65 = load i32, i32* %6
%66 = load i32, i32* %4
%67 = icmp slt i32 %65, %66
br i1 %67, label %68, label %77
68: ; preds = %64
%69 = load i32, i32* %6
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [8192 x i8], [8192 x i8]* %13, i64 %70
%72 = getelementptr inbounds [8192 x i8], [8192 x i8]* %71, i64 0, i64 0
%73 = call i32 @puts(i8* %72)
br label %74
74: ; preds = %68
%75 = load i32, i32* %6
%76 = add nsw i32 %75, 1
store i32 %76, i32* %6
br label %64
77: ; preds = %64
store i32 0, i32* %3
store i32 1, i32* %9
br label %78
78: ; preds = %77, %52, %32
%79 = load i8*, i8** %7
%80 = load i32, i32* %3
ret i32 %80
}

LLVM IR (-O2):
@.str = [3 x i8] c"-q\00"
@stderr = global i32 0
@.str.1 = [33 x i8] c"usage: realpath [-q] path [...]\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = zext i32 %0 to i64
%4 = alloca [8192 x i8], i64 %3
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %20
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @strcmp(i8* dereferenceable(1) %8, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %6
%12 = add nsw i32 %0, -1
%13 = load i32, i32* @stderr
%14 = tail call i32 @fclose(i32 %13)
%15 = icmp ult i32 %12, 2
br i1 %15, label %20, label %16
16: ; preds = %6, %11
%17 = phi i32 [ %12, %11 ], [ %0, %6 ]
%18 = phi i8** [ %7, %11 ], [ %1, %6 ]
%19 = zext i32 %17 to i64
br label %25
20: ; preds = %2, %11
%21 = load i32, i32* @stderr
%22 = tail call i32 @fputs(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 %21)
br label %46
23: ; preds = %37
%24 = zext i32 %17 to i64
br label %40
25: ; preds = %16, %37
%26 = phi i64 [ 1, %16 ], [ %38, %37 ]
%27 = getelementptr inbounds i8*, i8** %18, i64 %26
%28 = load i8*, i8** %27
%29 = getelementptr inbounds [8192 x i8], [8192 x i8]* %4, i64 %26, i64 0
%30 = call i32 @realpath(i8* %28, i8* %29)
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %37
32: ; preds = %25
%33 = and i64 %26, 4294967295
%34 = getelementptr inbounds i8*, i8** %18, i64 %33
%35 = load i8*, i8** %34
%36 = call i32 @perror(i8* %35)
br label %46
37: ; preds = %25
%38 = add nuw nsw i64 %26, 1
%39 = icmp eq i64 %38, %19
br i1 %39, label %23, label %25
40: ; preds = %23, %40
%41 = phi i64 [ 1, %23 ], [ %44, %40 ]
%42 = getelementptr inbounds [8192 x i8], [8192 x i8]* %4, i64 %41, i64 0
%43 = call i32 @puts(i8* %42)
%44 = add nuw nsw i64 %41, 1
%45 = icmp eq i64 %44, %24
br i1 %45, label %46, label %40
46: ; preds = %40, %32, %20
%47 = phi i32 [ 1, %20 ], [ 1, %32 ], [ 0, %40 ]
ret i32 %47
}