#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*/ errno;
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, char *, ...);
char *realpath(char *, int /*<<< orphan*/ *);
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  char *p;
  int i;
  if (argc < 2)
    usage();
  for (i = 1; i < argc; i++) {
    p = realpath(argv[i], NULL);
    if (!p)
      printf("realpath: %s: %s\n", argv[i], strerror(errno));
    else
      printf("%s\n", p);
    free(p);
  }
  return 0;
}


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)
cmpl   $0x2,-0x8(%rbp)
jge    1177 <main+0x27>
mov    $0x0,%al
call   1060 <usage@plt>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    120f <main+0xbf>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <realpath@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11e6 <main+0x96>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
mov    0x2e1b(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x28(%rbp),%rsi
mov    %rax,%rdx
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11f8 <main+0xa8>
mov    -0x18(%rbp),%rsi
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    117e <main+0x2e>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x1,%edi
jg     1178 <main+0x28>
xor    %eax,%eax
call   1060 <usage@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsi,%r12
mov    %edi,%ebp
mov    $0x1,%r14d
lea    0xe84(%rip),%r15
jmp    11ae <main+0x5e>
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
add    $0x1,%r14
cmp    %r14,%rbp
je     1167 <main+0x17>
mov    (%r12,%r14,8),%rdi
xor    %esi,%esi
call   1050 <realpath@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1190 <main+0x40>
mov    (%r12,%r14,8),%r13
mov    0x2e14(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe26(%rip),%rdi
mov    %r13,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    119d <main+0x4d>

LLVM IR (-O0):
@.str = [18 x i8] c"realpath: %s: %s\0A\00"
@errno = global i32 0
@.str.1 = [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 i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 (...) @usage()
br label %12
12: ; preds = %10, %2
store i32 1, i32* %7
br label %13
13: ; preds = %41, %12
%14 = load i32, i32* %7
%15 = load i32, i32* %4
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %44
17: ; preds = %13
%18 = load i8**, i8*** %5
%19 = load i32, i32* %7
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %18, i64 %20
%22 = load i8*, i8** %21
%23 = call i8* @realpath(i8* %22, i32* null)
store i8* %23, i8** %6
%24 = load i8*, i8** %6
%25 = icmp ne i8* %24, null
br i1 %25, label %35, label %26
26: ; preds = %17
%27 = load i8**, i8*** %5
%28 = load i32, i32* %7
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %27, i64 %29
%31 = load i8*, i8** %30
%32 = load i32, i32* @errno
%33 = call i8* @strerror(i32 %32)
%34 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %31, i8* %33)
br label %38
35: ; preds = %17
%36 = load i8*, i8** %6
%37 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %36)
br label %38
38: ; preds = %35, %26
%39 = load i8*, i8** %6
%40 = call i32 @free(i8* %39)
br label %41
41: ; preds = %38
%42 = load i32, i32* %7
%43 = add nsw i32 %42, 1
store i32 %43, i32* %7
br label %13
44: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"realpath: %s: %s\0A\00"
@errno = global i32 0
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 (...) @usage()
br label %25
6: ; preds = %2
%7 = zext i32 %0 to i64
br label %8
8: ; preds = %6, %21
%9 = phi i64 [ 1, %6 ], [ %23, %21 ]
%10 = getelementptr inbounds i8*, i8** %1, i64 %9
%11 = load i8*, i8** %10
%12 = tail call i8* @realpath(i8* %11, i32* null)
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %19
14: ; preds = %8
%15 = load i8*, i8** %10
%16 = load i32, i32* @errno
%17 = tail call i8* @strerror(i32 %16)
%18 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %15, i8* %17)
br label %21
19: ; preds = %8
%20 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %12)
br label %21
21: ; preds = %19, %14
%22 = tail call i32 @free(i8* %12)
%23 = add nuw nsw i64 %9, 1
%24 = icmp eq i64 %23, %7
br i1 %24, label %25, label %8
25: ; preds = %21, %4
ret i32 0
}