#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 */
char *extend(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ putchar(char);
void type(char *name) {
  FILE *f = fopen(name = extend(name), "r");
  if (!f)
    perror(name);
  else {
    int c, d;
    while ((c = getc(f)) >= 0)
      putchar(d = c);
    fclose(f);
    if ('\n' != d && '\r' != d)
      putchar('\n');
  }
}


x86 assembly (clang, -O0):
<type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <extend@plt>
mov    %rax,%rdi
mov    %rdi,-0x8(%rbp)
lea    0xe7d(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11a5 <type+0x45>
mov    -0x8(%rbp),%rdi
call   1060 <perror@plt>
jmp    1206 <type+0xa6>
jmp    11aa <type+0x4a>
mov    -0x10(%rbp),%rdi
call   1080 <getc@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jl     11d2 <type+0x72>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
movsbl %al,%edi
call   1030 <putchar@plt>
jmp    11aa <type+0x4a>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
mov    $0xa,%eax
cmp    -0x18(%rbp),%eax
je     1201 <type+0xa1>
mov    $0xd,%eax
cmp    -0x18(%rbp),%eax
je     1201 <type+0xa1>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1206 <type+0xa6>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<type>:
push   %rbp
push   %r14
push   %rbx
call   1070 <extend@plt>
mov    %rax,%r14
lea    0xe8d(%rip),%rsi
mov    %rax,%rdi
call   1050 <fopen@plt>
test   %rax,%rax
je     11d4 <type+0x74>
mov    %rax,%rbx
mov    %rax,%rdi
call   1080 <getc@plt>
test   %eax,%eax
js     11be <type+0x5e>
nop
mov    %eax,%ebp
movsbl %bpl,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1080 <getc@plt>
test   %eax,%eax
jns    1190 <type+0x30>
mov    %rbx,%rdi
call   1040 <fclose@plt>
cmp    $0xa,%ebp
je     11b9 <type+0x59>
cmp    $0xd,%ebp
jne    11c6 <type+0x66>
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    $0xa,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <putchar@plt>
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1060 <perror@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
define void @type(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i8* @extend(i8* %6)
store i8* %7, i8** %2
%8 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %8, i32** %3
%9 = load i32*, i32** %3
%10 = icmp ne i32* %9, null
br i1 %10, label %14, label %11
11: ; preds = %1
%12 = load i8*, i8** %2
%13 = call i32 @perror(i8* %12)
br label %34
14: ; preds = %1
br label %15
15: ; preds = %19, %14
%16 = load i32*, i32** %3
%17 = call i32 @getc(i32* %16)
store i32 %17, i32* %4
%18 = icmp sge i32 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %15
%20 = load i32, i32* %4
store i32 %20, i32* %5
%21 = trunc i32 %20 to i8
%22 = call i32 @putchar(i8 signext %21)
br label %15
23: ; preds = %15
%24 = load i32*, i32** %3
%25 = call i32 @fclose(i32* %24)
%26 = load i32, i32* %5
%27 = icmp ne i32 10, %26
br i1 %27, label %28, label %33
28: ; preds = %23
%29 = load i32, i32* %5
%30 = icmp ne i32 13, %29
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = call i32 @putchar(i8 signext 10)
br label %33
33: ; preds = %31, %28, %23
br label %34
34: ; preds = %33, %11
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
define void @type(i8* %0) {
%2 = tail call i8* @extend(i8* %0)
%3 = tail call i32* @fopen(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %10, label %5
5: ; preds = %1
%6 = tail call i32 @getc(i32* %3)
%7 = icmp sgt i32 %6, -1
br i1 %7, label %12, label %8
8: ; preds = %5
%9 = tail call i32 @fclose(i32* %3)
br label %20
10: ; preds = %1
%11 = tail call i32 @perror(i8* %2)
br label %22
12: ; preds = %5, %12
%13 = phi i32 [ %16, %12 ], [ %6, %5 ]
%14 = trunc i32 %13 to i8
%15 = tail call i32 @putchar(i8 signext %14)
%16 = tail call i32 @getc(i32* %3)
%17 = icmp sgt i32 %16, -1
br i1 %17, label %12, label %18
18: ; preds = %12
%19 = tail call i32 @fclose(i32* %3)
switch i32 %13, label %20 [
i32 13, label %22
i32 10, label %22
]
20: ; preds = %8, %18
%21 = tail call i32 @putchar(i8 signext 10)
br label %22
22: ; preds = %20, %18, %18, %10
ret void
}