#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 /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int strlen(char *);
int main(void) {
  char path[1024];
  char output[2048];
  fgets(path, 1024, stdin);
  fputs(path, stdout);
  FILE *contents;
  path[strlen(path) - 1] = '\0';
  contents = fopen(path, "r");
  fread(output, 1, 1024, contents);
  int i = 0;
  for (i = 0; i < 1024; i++) {
    printf("%c", output[i]);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x410(%rbp),%rdi
mov    0x2e68(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   1070 <fgets@plt>
lea    -0x410(%rbp),%rdi
mov    0x2e3e(%rip),%rax
mov    (%rax),%esi
call   1060 <fputs@plt>
lea    -0x410(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x410(%rbp,%rax,1)
lea    -0x410(%rbp),%rdi
lea    0xe38(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0xc18(%rbp)
lea    -0xc10(%rbp),%rdi
mov    -0xc18(%rbp),%rcx
mov    $0x1,%esi
mov    $0x400,%edx
call   1030 <fread@plt>
movl   $0x0,-0xc1c(%rbp)
movl   $0x0,-0xc1c(%rbp)
cmpl   $0x400,-0xc1c(%rbp)
jge    1244 <main+0xe4>
movslq -0xc1c(%rbp),%rax
lea    0xddf(%rip),%rdi
movsbl -0xc10(%rbp,%rax,1),%esi
ff
call   1050 <printf@plt>
mov    -0xc1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc1c(%rbp)
jmp    1205 <main+0xa5>
mov    -0x4(%rbp),%eax
add    $0xc20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xc08,%rsp
mov    0x2e77(%rip),%rax
mov    (%rax),%edx
lea    0x800(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1070 <fgets@plt>
mov    0x2e49(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1060 <fputs@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
lea    0xe51(%rip),%rsi
mov    %rbx,%rdi
call   1080 <fopen@plt>
mov    %rsp,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %rax,%rcx
call   1030 <fread@plt>
xor    %ebx,%ebx
lea    0xe2d(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
movsbl (%rsp,%rbx,1),%esi
mov    %r14,%rdi
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    $0x400,%rbx
jne    11e0 <main+0x80>
xor    %eax,%eax
add    $0xc08,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@stdin = global i32 0
@stdout = global i32 0
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = alloca [2048 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 0
%5 = load i32, i32* @stdin
%6 = call i32 @fgets(i8* %3, i32 1024, i32 %5)
%7 = load i32, i32* @stdout
%8 = call i32 @fputs(i8* %3, i32 %7)
%9 = call i32 @strlen(i8* %3)
%10 = add nsw i32 %9, -1
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 %11
store i8 0, i8* %12
%13 = call i32* @fopen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @fread(i8* %4, i32 1, i32 1024, i32* %13)
br label %15
15: ; preds = %0, %15
%16 = phi i64 [ 0, %0 ], [ %20, %15 ]
%17 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext %18)
%20 = add nuw nsw i64 %16, 1
%21 = icmp eq i64 %20, 1024
br i1 %21, label %22, label %15
22: ; preds = %15
ret i32 0
}