#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 getopt(int, char **, char *);
scalar_t__ optind;
int /*<<< orphan*/ printf(char *, char *);
char *realpath(char const *, char *);
int /*<<< orphan*/ usage();
int /*<<< orphan*/ warn(char *, char const *);
int main(int argc, char *argv[]) {
  char buf[PATH_MAX];
  char *p;
  const char *path;
  int ch, qflag, rval;
  qflag = 0;
  while ((ch = getopt(argc, argv, "q")) != -1) {
    switch (ch) {
    case 'q':
      qflag = 1;
      break;
    case '?':
    default:
      usage();
    }
  }
  argc -= optind;
  argv += optind;
  path = *argv != NULL ? *argv++ : ".";
  rval = 0;
  do {
    if ((p = realpath(path, buf)) == NULL) {
      if (!qflag)
        warn("%s", path);
      rval = 1;
    } else
      (void)printf("%s\n", p);
  } while ((path = *argv++) != NULL);
  exit(rval);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e73(%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,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe49(%rip),%rdx
call   1070 <getopt@plt>
mov    %eax,-0x34(%rbp)
cmp    $0xffffffff,%eax
je     120a <main+0xaa>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4c(%rbp)
sub    $0x3f,%eax
je     11f9 <main+0x99>
jmp    11dc <main+0x7c>
mov    -0x4c(%rbp),%eax
sub    $0x71,%eax
jne    11fe <main+0x9e>
jmp    11ed <main+0x8d>
movl   $0x1,-0x38(%rbp)
jmp    1205 <main+0xa5>
jmp    11fe <main+0x9e>
mov    $0x0,%al
call   1060 <usage@plt>
jmp    11a9 <main+0x49>
mov    0x2dcf(%rip),%rax
mov    (%rax),%rcx
movslq -0x8(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    0x2dbb(%rip),%rax
mov    (%rax),%rax
shl    $0x3,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     125d <main+0xfd>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%rax
mov    %rax,-0x58(%rbp)
jmp    126d <main+0x10d>
lea    0xd9e(%rip),%rax
mov    %rax,-0x58(%rbp)
jmp    126d <main+0x10d>
mov    -0x58(%rbp),%rax
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x48(%rbp),%rsi
mov    -0x30(%rbp),%rdi
call   1050 <realpath@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    12bd <main+0x15d>
cmpl   $0x0,-0x38(%rbp)
jne    12b1 <main+0x151>
mov    -0x30(%rbp),%rsi
lea    0xd58(%rip),%rdi
call   1030 <warn@plt>
movl   $0x1,-0x3c(%rbp)
jmp    12cd <main+0x16d>
mov    -0x28(%rbp),%rsi
lea    0xd3f(%rip),%rdi
call   1040 <printf@plt>
jmp    12d2 <main+0x172>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    127c <main+0x11c>
mov    -0x3c(%rbp),%edi
call   1080 <exit@plt>

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    %edi,%ebx
mov    0x2e76(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r15
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    $0x1,%al
mov    %eax,-0x2c(%rbp)
lea    0xe67(%rip),%r12
jmp    11b0 <main+0x50>
movl   $0x0,-0x2c(%rbp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebx,%edi
mov    %r14,%rsi
mov    %r12,%rdx
call   1070 <getopt@plt>
cmp    $0x71,%eax
je     119b <main+0x3b>
cmp    $0xffffffff,%eax
je     11d0 <main+0x70>
xor    %eax,%eax
call   1060 <usage@plt>
jmp    11b0 <main+0x50>
mov    0x2e09(%rip),%rax
mov    (%rax),%rax
lea    (%r14,%rax,8),%rcx
mov    (%r14,%rax,8),%rax
xor    %edx,%edx
test   %rax,%rax
setne  %dl
lea    0xe11(%rip),%rbx
cmovne %rax,%rbx
lea    (%rcx,%rdx,8),%r12
xor    %r14d,%r14d
lea    0xe04(%rip),%r13
jmp    1228 <main+0xc8>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r13,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    (%r12),%rbx
add    $0x8,%r12
test   %rbx,%rbx
je     1255 <main+0xf5>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <realpath@plt>
test   %rax,%rax
jne    1210 <main+0xb0>
mov    $0x1,%r14d
testb  $0x1,-0x2c(%rbp)
je     121b <main+0xbb>
lea    0xdb9(%rip),%rdi
mov    %rbx,%rsi
call   1030 <warn@plt>
jmp    121b <main+0xbb>
mov    %r14d,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@PATH_MAX = global i32 0
@.str = [2 x i8] c"q\00"
@optind = global i64 0
@.str.1 = [2 x i8] c".\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [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 i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* @PATH_MAX
%14 = zext i32 %13 to i64
%15 = call i8* @llvm.stacksave()
store i8* %15, i8** %6
%16 = alloca i8, i64 %14
store i64 %14, i64* %7
store i32 0, i32* %11
br label %17
17: ; preds = %28, %2
%18 = load i32, i32* %4
%19 = load i8**, i8*** %5
%20 = call i32 @getopt(i32 %18, i8** %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 %20, i32* %10
%21 = icmp ne i32 %20, -1
br i1 %21, label %22, label %29
22: ; preds = %17
%23 = load i32, i32* %10
switch i32 %23, label %26 [
i32 113, label %24
i32 63, label %25
]
24: ; preds = %22
store i32 1, i32* %11
br label %28
25: ; preds = %22
br label %26
26: ; preds = %22, %25
%27 = call i32 (...) @usage()
br label %28
28: ; preds = %26, %24
br label %17
29: ; preds = %17
%30 = load i64, i64* @optind
%31 = load i32, i32* %4
%32 = sext i32 %31 to i64
%33 = sub nsw i64 %32, %30
%34 = trunc i64 %33 to i32
store i32 %34, i32* %4
%35 = load i64, i64* @optind
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 %35
store i8** %37, i8*** %5
%38 = load i8**, i8*** %5
%39 = load i8*, i8** %38
%40 = icmp ne i8* %39, null
br i1 %40, label %41, label %45
41: ; preds = %29
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i32 1
store i8** %43, i8*** %5
%44 = load i8*, i8** %42
br label %46
45: ; preds = %29
br label %46
46: ; preds = %45, %41
%47 = phi i8* [ %44, %41 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), %45 ]
store i8* %47, i8** %9
store i32 0, i32* %12
br label %48
48: ; preds = %63, %46
%49 = load i8*, i8** %9
%50 = call i8* @realpath(i8* %49, i8* %16)
store i8* %50, i8** %8
%51 = icmp eq i8* %50, null
br i1 %51, label %52, label %59
52: ; preds = %48
%53 = load i32, i32* %11
%54 = icmp ne i32 %53, 0
br i1 %54, label %58, label %55
55: ; preds = %52
%56 = load i8*, i8** %9
%57 = call i32 @warn(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %56)
br label %58
58: ; preds = %55, %52
store i32 1, i32* %12
br label %62
59: ; preds = %48
%60 = load i8*, i8** %8
%61 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %60)
br label %62
62: ; preds = %59, %58
br label %63
63: ; preds = %62
%64 = load i8**, i8*** %5
%65 = getelementptr inbounds i8*, i8** %64, i32 1
store i8** %65, i8*** %5
%66 = load i8*, i8** %64
store i8* %66, i8** %9
%67 = icmp ne i8* %66, null
br i1 %67, label %48, label %68
68: ; preds = %63
%69 = load i32, i32* %12
%70 = call i32 @exit(i32 %69)
unreachable
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
@.str = [2 x i8] c"q\00"
@optind = global i64 0
@.str.1 = [2 x i8] c".\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = load i32, i32* @PATH_MAX
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
br label %6
6: ; preds = %8, %2
%7 = phi i1 [ true, %2 ], [ false, %8 ]
br label %8
8: ; preds = %6, %10
%9 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
switch i32 %9, label %10 [
i32 -1, label %12
i32 113, label %6
]
10: ; preds = %8
%11 = tail call i32 (...) @usage()
br label %8
12: ; preds = %8
%13 = load i64, i64* @optind
%14 = getelementptr inbounds i8*, i8** %1, i64 %13
%15 = load i8*, i8** %14
%16 = icmp eq i8* %15, null
%17 = xor i1 %16, true
%18 = zext i1 %17 to i64
%19 = getelementptr i8*, i8** %14, i64 %18
%20 = select i1 %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* %15
br label %21
21: ; preds = %32, %12
%22 = phi i8** [ %19, %12 ], [ %34, %32 ]
%23 = phi i8* [ %20, %12 ], [ %35, %32 ]
%24 = phi i32 [ 0, %12 ], [ %33, %32 ]
%25 = call i8* @realpath(i8* %23, i8* %5)
%26 = icmp eq i8* %25, null
br i1 %26, label %27, label %30
27: ; preds = %21
br i1 %7, label %28, label %32
28: ; preds = %27
%29 = call i32 @warn(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %23)
br label %32
30: ; preds = %21
%31 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %25)
br label %32
32: ; preds = %27, %28, %30
%33 = phi i32 [ %24, %30 ], [ 1, %28 ], [ 1, %27 ]
%34 = getelementptr inbounds i8*, i8** %22, i64 1
%35 = load i8*, i8** %22
%36 = icmp eq i8* %35, null
br i1 %36, label %37, label %21
37: ; preds = %32
%38 = call i32 @exit(i32 %33)
unreachable
}