#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 */
struct option {
  char *member_0;
  int member_1;
  int member_3;
  int /*<<< orphan*/ member_2;
};

/* Variables and functions */
int /*<<< orphan*/ errno;
int getopt_long(int, char **, char *, struct option *, int /*<<< orphan*/ *);
int optind;
int /*<<< orphan*/ printf(char *, char *, ...);
char *realpath(char *, int /*<<< orphan*/ *);
char *strerror(int /*<<< orphan*/);
int main(int argc, char **argv) {
  int c;
  char *path = NULL;
  struct option opts[13] = {{"version", 0, 0, 0},
                            {"help", 0, 0, 1},
                            {"canonicalize-existing", 0, 0, 'e'},
                            {"canonicalize-missing", 0, 0, 'm'},
                            {"logical", 0, 0, 'L'},
                            {"physical", 0, 0, 'P'},
                            {"quiet", 0, 0, 'q'},
                            {"no-symlinks", 0, 0, 's'},
                            {"strip", 0, 0, 's'},
                            {"zero", 0, 0, 'z'},
                            {"relative-to", 1, 0, 2},
                            {"relative-base", 1, 0, 3},
                            {0, 0, 0, 0}};
  while ((c = getopt_long(argc, argv, "emLPqsz", opts, NULL)) != -1) {
    switch (c) {
    case 0:
      printf("%s v0.1\n", argv[0]);
      return 0;
    case 1:
      printf("%s --version|--help|-m|-e|... <file>\n", argv[0]);
      return 0;
    case 2:
      break;
    case 3:
      break;
    case '?':
      printf("wrong option, %s --help\n", argv[0]);
      return 1;
    }
  }
  if (optind == argc) {
    printf("need a file, %s --help\n", argv[0]);
    return 1;
  } else {
    while (optind < argc) {
      path = realpath(argv[optind], NULL);
      if (path == NULL) {
        printf("%s: %s\n", argv[optind], strerror(errno));
      } else
        printf("%s\n", path);
      optind++;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x170,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
lea    -0x160(%rbp),%rdi
lea    0x2b51(%rip),%rsi
mov    $0x138,%edx
call   1060 <memcpy@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x160(%rbp),%rcx
lea    0xee2(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r8d
call   1030 <getopt_long@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     128c <main+0x13c>
mov    -0x14(%rbp),%eax
mov    %eax,-0x164(%rbp)
test   %eax,%eax
je     121a <main+0xca>
jmp    11ca <main+0x7a>
mov    -0x164(%rbp),%eax
sub    $0x1,%eax
je     123b <main+0xeb>
jmp    11de <main+0x8e>
mov    -0x164(%rbp),%eax
sub    $0x2,%eax
je     125c <main+0x10c>
jmp    11f2 <main+0xa2>
mov    -0x164(%rbp),%eax
sub    $0x3,%eax
je     1261 <main+0x111>
jmp    1206 <main+0xb6>
mov    -0x164(%rbp),%eax
sub    $0x3f,%eax
je     1266 <main+0x116>
jmp    1287 <main+0x137>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    137c <main+0x22c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    137c <main+0x22c>
jmp    1287 <main+0x137>
jmp    1287 <main+0x137>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    137c <main+0x22c>
jmp    1189 <main+0x39>
mov    0x2d4d(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jne    12bf <main+0x16f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    137c <main+0x22c>
jmp    12c4 <main+0x174>
mov    0x2d15(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    1370 <main+0x220>
mov    -0x10(%rbp),%rax
mov    0x2cff(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <realpath@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1344 <main+0x1f4>
mov    -0x10(%rbp),%rax
mov    0x2cd5(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x170(%rbp)
mov    0x2cb0(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x170(%rbp),%rsi
mov    %rax,%rdx
lea    0xdb0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1356 <main+0x206>
mov    -0x20(%rbp),%rsi
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2c83(%rip),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    0x2c77(%rip),%rax
mov    %ecx,(%rax)
jmp    12c4 <main+0x174>
jmp    1375 <main+0x225>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x170,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x138,%rsp
mov    %rsi,%r12
mov    %edi,%ebp
lea    0x2b63(%rip),%rsi
mov    %rsp,%r14
mov    $0x138,%edx
mov    %r14,%rdi
call   1060 <memcpy@plt>
lea    0xefc(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebp,%edi
mov    %r12,%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
xor    %r8d,%r8d
call   1030 <getopt_long@plt>
test   %eax,%eax
jg     11c0 <main+0x70>
cmp    $0xffffffff,%eax
je     11e5 <main+0x95>
test   %eax,%eax
jne    1190 <main+0x40>
jmp    1203 <main+0xb3>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    $0x1,%eax
je     11d9 <main+0x89>
cmp    $0x3f,%eax
jne    1190 <main+0x40>
mov    $0x1,%r14d
lea    0xee0(%rip),%rdi
jmp    120d <main+0xbd>
xor    %r14d,%r14d
lea    0xeae(%rip),%rdi
jmp    120d <main+0xbd>
mov    0x2df4(%rip),%r13
mov    0x0(%r13),%eax
cmp    %ebp,%eax
jne    122d <main+0xdd>
mov    $0x1,%r14d
lea    0xecf(%rip),%rdi
jmp    120d <main+0xbd>
xor    %r14d,%r14d
lea    0xe7b(%rip),%rdi
mov    (%r12),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14d,%eax
add    $0x138,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %r14d,%r14d
cmp    %ebp,%eax
jge    1218 <main+0xc8>
lea    0xead(%rip),%r14
lea    0xeaa(%rip),%r15
jmp    126c <main+0x11c>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x0(%r13),%eax
add    $0x1,%eax
mov    %eax,0x0(%r13)
cmp    %ebp,%eax
jge    12a6 <main+0x156>
cltq
mov    (%r12,%rax,8),%rdi
xor    %esi,%esi
call   1050 <realpath@plt>
test   %rax,%rax
jne    1250 <main+0x100>
movslq 0x0(%r13),%rax
mov    (%r12,%rax,8),%rbx
mov    0x2d43(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    125d <main+0x10d>
xor    %r14d,%r14d
jmp    1218 <main+0xc8>

LLVM IR (-O0):
%struct.option = type { i8*, i32, i32, i32 }
@.str = [8 x i8] c"version\00"
@.str.1 = [5 x i8] c"help\00"
@.str.2 = [22 x i8] c"canonicalize-existing\00"
@.str.3 = [21 x i8] c"canonicalize-missing\00"
@.str.4 = [8 x i8] c"logical\00"
@.str.5 = [9 x i8] c"physical\00"
@.str.6 = [6 x i8] c"quiet\00"
@.str.7 = [12 x i8] c"no-symlinks\00"
@.str.8 = [6 x i8] c"strip\00"
@.str.9 = [5 x i8] c"zero\00"
@.str.10 = [12 x i8] c"relative-to\00"
@.str.11 = [14 x i8] c"relative-base\00"
@__const.main.opts = [13 x %struct.option] [%struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i32 0, i32 0, i32 0 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i32 0, i32 0, i32 1 }, %struct.option { i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i32 0, i32 0), i32 0, i32 0, i32 101 }, %struct.option { i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i32 0, i32 0), i32 0, i32 0, i32 109 }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i32 0, i32 0), i32 0, i32 0, i32 76 }, %struct.option { i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i32 0, i32 0), i32 0, i32 0, i32 80 }, %struct.option { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i32 0, i32 0), i32 0, i32 0, i32 113 }, %struct.option { i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i32 0, i32 0), i32 0, i32 0, i32 115 }, %struct.option { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i32 0, i32 0), i32 0, i32 0, i32 115 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i32 0, i32 0), i32 0, i32 0, i32 122 }, %struct.option { i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i32 0, i32 0), i32 1, i32 0, i32 2 }, %struct.option { i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i32 0, i32 0), i32 1, i32 0, i32 3 }, %struct.option zeroinitializer]
@.str.12 = [8 x i8] c"emLPqsz\00"
@.str.13 = [9 x i8] c"%s v0.1\0A\00"
@.str.14 = [38 x i8] c"%s --version|--help|-m|-e|... <file>\0A\00"
@.str.15 = [25 x i8] c"wrong option, %s --help\0A\00"
@optind = global i32 0
@.str.16 = [24 x i8] c"need a file, %s --help\0A\00"
@.str.17 = [8 x i8] c"%s: %s\0A\00"
@errno = global i32 0
@.str.18 = [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 i32
%7 = alloca i8*
%8 = alloca [13 x %struct.option]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %7
%9 = bitcast [13 x %struct.option]* %8 to i8*
br label %10
10: ; preds = %35, %2
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds [13 x %struct.option], [13 x %struct.option]* %8, i64 0, i64 0
%14 = call i32 @getopt_long(i32 %11, i8** %12, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0), %struct.option* %13, i32* null)
store i32 %14, i32* %6
%15 = icmp ne i32 %14, -1
br i1 %15, label %16, label %36
16: ; preds = %10
%17 = load i32, i32* %6
switch i32 %17, label %35 [
i32 0, label %18
i32 1, label %23
i32 2, label %28
i32 3, label %29
i32 63, label %30
]
18: ; preds = %16
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 0
%21 = load i8*, i8** %20
%22 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.13, i64 0, i64 0), i8* %21)
store i32 0, i32* %3
br label %76
23: ; preds = %16
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 0
%26 = load i8*, i8** %25
%27 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.14, i64 0, i64 0), i8* %26)
store i32 0, i32* %3
br label %76
28: ; preds = %16
br label %35
29: ; preds = %16
br label %35
30: ; preds = %16
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 0
%33 = load i8*, i8** %32
%34 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.15, i64 0, i64 0), i8* %33)
store i32 1, i32* %3
br label %76
35: ; preds = %16, %29, %28
br label %10
36: ; preds = %10
%37 = load i32, i32* @optind
%38 = load i32, i32* %4
%39 = icmp eq i32 %37, %38
br i1 %39, label %40, label %45
40: ; preds = %36
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 0
%43 = load i8*, i8** %42
%44 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.16, i64 0, i64 0), i8* %43)
store i32 1, i32* %3
br label %76
45: ; preds = %36
br label %46
46: ; preds = %71, %45
%47 = load i32, i32* @optind
%48 = load i32, i32* %4
%49 = icmp slt i32 %47, %48
br i1 %49, label %50, label %74
50: ; preds = %46
%51 = load i8**, i8*** %5
%52 = load i32, i32* @optind
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8*, i8** %51, i64 %53
%55 = load i8*, i8** %54
%56 = call i8* @realpath(i8* %55, i32* null)
store i8* %56, i8** %7
%57 = load i8*, i8** %7
%58 = icmp eq i8* %57, null
br i1 %58, label %59, label %68
59: ; preds = %50
%60 = load i8**, i8*** %5
%61 = load i32, i32* @optind
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8*, i8** %60, i64 %62
%64 = load i8*, i8** %63
%65 = load i32, i32* @errno
%66 = call i8* @strerror(i32 %65)
%67 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.17, i64 0, i64 0), i8* %64, i8* %66)
br label %71
68: ; preds = %50
%69 = load i8*, i8** %7
%70 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.18, i64 0, i64 0), i8* %69)
br label %71
71: ; preds = %68, %59
%72 = load i32, i32* @optind
%73 = add nsw i32 %72, 1
store i32 %73, i32* @optind
br label %46
74: ; preds = %46
br label %75
75: ; preds = %74
store i32 0, i32* %3
br label %76
76: ; preds = %75, %40, %30, %23, %18
%77 = load i32, i32* %3
ret i32 %77
}

LLVM IR (-O2):
%struct.option = type { i8*, i32, i32, i32 }
@.str = [8 x i8] c"version\00"
@.str.1 = [5 x i8] c"help\00"
@.str.2 = [22 x i8] c"canonicalize-existing\00"
@.str.3 = [21 x i8] c"canonicalize-missing\00"
@.str.4 = [8 x i8] c"logical\00"
@.str.5 = [9 x i8] c"physical\00"
@.str.6 = [6 x i8] c"quiet\00"
@.str.7 = [12 x i8] c"no-symlinks\00"
@.str.8 = [6 x i8] c"strip\00"
@.str.9 = [5 x i8] c"zero\00"
@.str.10 = [12 x i8] c"relative-to\00"
@.str.11 = [14 x i8] c"relative-base\00"
@__const.main.opts = [13 x %struct.option] [%struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i32 0, i32 0, i32 0 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i32 0, i32 0, i32 1 }, %struct.option { i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i32 0, i32 0), i32 0, i32 0, i32 101 }, %struct.option { i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i32 0, i32 0), i32 0, i32 0, i32 109 }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i32 0, i32 0), i32 0, i32 0, i32 76 }, %struct.option { i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i32 0, i32 0), i32 0, i32 0, i32 80 }, %struct.option { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i32 0, i32 0), i32 0, i32 0, i32 113 }, %struct.option { i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i32 0, i32 0), i32 0, i32 0, i32 115 }, %struct.option { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i32 0, i32 0), i32 0, i32 0, i32 115 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i32 0, i32 0), i32 0, i32 0, i32 122 }, %struct.option { i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i32 0, i32 0), i32 1, i32 0, i32 2 }, %struct.option { i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i32 0, i32 0), i32 1, i32 0, i32 3 }, %struct.option zeroinitializer]
@.str.12 = [8 x i8] c"emLPqsz\00"
@.str.13 = [9 x i8] c"%s v0.1\0A\00"
@.str.14 = [38 x i8] c"%s --version|--help|-m|-e|... <file>\0A\00"
@.str.15 = [25 x i8] c"wrong option, %s --help\0A\00"
@optind = global i32 0
@.str.16 = [24 x i8] c"need a file, %s --help\0A\00"
@.str.17 = [8 x i8] c"%s: %s\0A\00"
@errno = global i32 0
@.str.18 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [13 x %struct.option]
%4 = bitcast [13 x %struct.option]* %3 to i8*
%5 = getelementptr inbounds [13 x %struct.option], [13 x %struct.option]* %3, i64 0, i64 0
br label %6
6: ; preds = %6, %2
%7 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0), %struct.option* %5, i32* null)
switch i32 %7, label %6 [
i32 -1, label %8
i32 0, label %34
i32 1, label %35
i32 63, label %36
]
8: ; preds = %6
%9 = load i32, i32* @optind
%10 = icmp eq i32 %9, %0
br i1 %10, label %36, label %11
11: ; preds = %8
%12 = icmp slt i32 %9, %0
br i1 %12, label %13, label %41
13: ; preds = %11, %30
%14 = phi i32 [ %32, %30 ], [ %9, %11 ]
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8*, i8** %1, i64 %15
%17 = load i8*, i8** %16
%18 = call i8* @realpath(i8* %17, i32* null)
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %28
20: ; preds = %13
%21 = load i32, i32* @optind
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %1, i64 %22
%24 = load i8*, i8** %23
%25 = load i32, i32* @errno
%26 = call i8* @strerror(i32 %25)
%27 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.17, i64 0, i64 0), i8* %24, i8* %26)
br label %30
28: ; preds = %13
%29 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.18, i64 0, i64 0), i8* %18)
br label %30
30: ; preds = %28, %20
%31 = load i32, i32* @optind
%32 = add nsw i32 %31, 1
store i32 %32, i32* @optind
%33 = icmp slt i32 %32, %0
br i1 %33, label %13, label %41
34: ; preds = %6
br label %36
35: ; preds = %6
br label %36
36: ; preds = %6, %35, %34, %8
%37 = phi i8* [ getelementptr inbounds ([24 x i8], [24 x i8]* @.str.16, i64 0, i64 0), %8 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.13, i64 0, i64 0), %34 ], [ getelementptr inbounds ([38 x i8], [38 x i8]* @.str.14, i64 0, i64 0), %35 ], [ getelementptr inbounds ([25 x i8], [25 x i8]* @.str.15, i64 0, i64 0), %6 ]
%38 = phi i32 [ 1, %8 ], [ 0, %34 ], [ 0, %35 ], [ 1, %6 ]
%39 = load i8*, i8** %1
%40 = call i32 (i8*, i8*, ...) @printf(i8* %37, i8* %39)
br label %41
41: ; preds = %30, %36, %11
%42 = phi i32 [ 0, %11 ], [ %38, %36 ], [ 0, %30 ]
ret i32 %42
}