#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 EOF;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ putchar(int);
int /*<<< orphan*/ stdout;
extern void catFile(FILE *fp) {
  if (fp != NULL) {
    int c;
    fseek(fp, 0, SEEK_SET);
    while ((c = getc(fp)) != EOF)
      putchar(c);
    fflush(stdout);
  }
}


x86 assembly (clang, -O0):
<catFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11a1 <catFile+0x61>
mov    -0x8(%rbp),%rdi
mov    0x2e76(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1050 <fseek@plt>
mov    -0x8(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,-0xc(%rbp)
mov    0x2e6a(%rip),%rcx
cmp    (%rcx),%eax
je     1193 <catFile+0x53>
mov    -0xc(%rbp),%edi
call   1030 <putchar@plt>
jmp    116b <catFile+0x2b>
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<catFile>:
test   %rdi,%rdi
je     1199 <catFile+0x59>
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2e85(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1050 <fseek@plt>
mov    %rbx,%rdi
call   1060 <getc@plt>
mov    0x2e7d(%rip),%r14
cmp    (%r14),%eax
je     1184 <catFile+0x44>
mov    %eax,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1060 <getc@plt>
cmp    (%r14),%eax
jne    1170 <catFile+0x30>
mov    0x2e45(%rip),%rax
mov    (%rax),%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <fflush@plt>
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
@EOF = global i32 0
@stdout = global i32 0
define void @catFile(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
%4 = load i32*, i32** %2
%5 = icmp ne i32* %4, null
br i1 %5, label %6, label %21
6: ; preds = %1
%7 = load i32*, i32** %2
%8 = load i32, i32* @SEEK_SET
%9 = call i32 @fseek(i32* %7, i32 0, i32 %8)
br label %10
10: ; preds = %15, %6
%11 = load i32*, i32** %2
%12 = call i32 @getc(i32* %11)
store i32 %12, i32* %3
%13 = load i32, i32* @EOF
%14 = icmp ne i32 %12, %13
br i1 %14, label %15, label %18
15: ; preds = %10
%16 = load i32, i32* %3
%17 = call i32 @putchar(i32 %16)
br label %10
18: ; preds = %10
%19 = load i32, i32* @stdout
%20 = call i32 @fflush(i32 %19)
br label %21
21: ; preds = %18, %1
ret void
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
@EOF = global i32 0
@stdout = global i32 0
define void @catFile(i32* %0) {
%2 = icmp eq i32* %0, null
br i1 %2, label %18, label %3
3: ; preds = %1
%4 = load i32, i32* @SEEK_SET
%5 = tail call i32 @fseek(i32* %0, i32 0, i32 %4)
%6 = tail call i32 @getc(i32* %0)
%7 = load i32, i32* @EOF
%8 = icmp eq i32 %6, %7
br i1 %8, label %15, label %9
9: ; preds = %3, %9
%10 = phi i32 [ %12, %9 ], [ %6, %3 ]
%11 = tail call i32 @putchar(i32 %10)
%12 = tail call i32 @getc(i32* %0)
%13 = load i32, i32* @EOF
%14 = icmp eq i32 %12, %13
br i1 %14, label %15, label %9
15: ; preds = %9, %3
%16 = load i32, i32* @stdout
%17 = tail call i32 @fflush(i32 %16)
br label %18
18: ; preds = %15, %1
ret void
}