#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int PATH_MAX;
int /*<<< orphan*/ exit(int);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ realpath(char *, char *);
int /*<<< orphan*/ *stdin;
int main(void) {
  int size = PATH_MAX + 1;
  char input[size];
  char fixed[size];
  fgets(input, size, stdin);
  if (!realpath(input, fixed)) {
    exit(1);
  } else {
    FILE *f = fopen(input, "r");
    while (fgets(input, size, f))
      puts(input);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e8a(%rip),%rax
mov    (%rax),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x38(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
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)
mov    -0x8(%rbp),%esi
mov    0x2e23(%rip),%rax
mov    (%rax),%rdx
call   1040 <fgets@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1050 <realpath@plt>
cmp    $0x0,%eax
jne    11e5 <main+0x95>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x38(%rbp),%rdi
lea    0xe10(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0x28(%rbp),%rdx
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     1221 <main+0xd1>
mov    -0x38(%rbp),%rdi
call   1030 <puts@plt>
jmp    11f9 <main+0xa9>
jmp    1226 <main+0xd6>
mov    -0x10(%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   %rbx
push   %rax
mov    0x2e8f(%rip),%rax
mov    (%rax),%r14d
add    $0x1,%r14d
mov    %rsp,%rbx
lea    0xf(%r14),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rsp,%r15
sub    %rax,%r15
mov    %r15,%rsp
mov    0x2e57(%rip),%rax
mov    (%rax),%rdx
mov    %rbx,%rdi
mov    %r14d,%esi
call   1040 <fgets@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <realpath@plt>
test   %eax,%eax
je     11fa <main+0xaa>
lea    0xe53(%rip),%rsi
mov    %rbx,%rdi
call   1060 <fopen@plt>
mov    %rax,%r15
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %rax,%rdx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
call   1040 <fgets@plt>
test   %rax,%rax
je     11ed <main+0x9d>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %r15,%rdx
jmp    11d0 <main+0x80>
xor    %eax,%eax
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@PATH_MAX = global i32 0
@stdin = global i32* null
@.str = [2 x i8] c"r\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i32*
store i32 0, i32* %1
%7 = load i32, i32* @PATH_MAX
%8 = add nsw i32 %7, 1
store i32 %8, i32* %2
%9 = load i32, i32* %2
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %3
%12 = alloca i8, i64 %10
store i64 %10, i64* %4
%13 = load i32, i32* %2
%14 = zext i32 %13 to i64
%15 = alloca i8, i64 %14
store i64 %14, i64* %5
%16 = load i32, i32* %2
%17 = load i32*, i32** @stdin
%18 = call i64 @fgets(i8* %12, i32 %16, i32* %17)
%19 = call i32 @realpath(i8* %12, i8* %15)
%20 = icmp ne i32 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %0
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %0
%24 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %24, i32** %6
br label %25
25: ; preds = %30, %23
%26 = load i32, i32* %2
%27 = load i32*, i32** %6
%28 = call i64 @fgets(i8* %12, i32 %26, i32* %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %25
%31 = call i32 @puts(i8* %12)
br label %25
32: ; preds = %25
br label %33
33: ; preds = %32
%34 = load i8*, i8** %3
%35 = load i32, i32* %1
ret i32 %35
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
@stdin = global i32* null
@.str = [2 x i8] c"r\00"
define i32 @main() {
%1 = load i32, i32* @PATH_MAX
%2 = add nsw i32 %1, 1
%3 = zext i32 %2 to i64
%4 = alloca i8, i64 %3
%5 = alloca i8, i64 %3
%6 = load i32*, i32** @stdin
%7 = call i64 @fgets(i8* %4, i32 %2, i32* %6)
%8 = call i32 @realpath(i8* %4, i8* %5)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %0
%13 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = call i64 @fgets(i8* %4, i32 %2, i32* %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %12, %16
%17 = call i32 @puts(i8* %4)
%18 = call i64 @fgets(i8* %4, i32 %2, i32* %13)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %16
20: ; preds = %16, %12
ret i32 0
}