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

/* Variables and functions */
size_t fread(char *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ fwrite(char *, int, size_t, int /*<<< orphan*/ *);
int /*<<< orphan*/ stdin;
void storeFLVFromStdin(FILE *fp) {
  char buf[4096];
  size_t bytes;
  while ((bytes = fread(buf, 1, sizeof(buf), stdin)) > 0)
    fwrite(buf, 1, bytes, fp);
  return;
}


x86 assembly (clang, -O0):
<storeFLVFromStdin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1020,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x1010(%rbp),%rdi
mov    0x2eab(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
mov    $0x1000,%edx
call   1030 <fread@plt>
mov    %rax,-0x1018(%rbp)
cmp    $0x0,%rax
jbe    1180 <storeFLVFromStdin+0x60>
lea    -0x1010(%rbp),%rdi
mov    -0x1018(%rbp),%rdx
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fwrite@plt>
jmp    112f <storeFLVFromStdin+0xf>
add    $0x1020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<storeFLVFromStdin>:
push   %r15
push   %r14
push   %rbx
sub    $0x1000,%rsp
mov    %rdi,%r14
mov    0x2eb2(%rip),%r15
mov    (%r15),%ecx
mov    %rsp,%rdi
mov    $0x1,%esi
mov    $0x1000,%edx
call   1030 <fread@plt>
test   %rax,%rax
je     118d <storeFLVFromStdin+0x6d>
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %rax,%rdx
mov    %r14,%rcx
call   1040 <fwrite@plt>
mov    (%r15),%ecx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1000,%edx
call   1030 <fread@plt>
test   %rax,%rax
jne    1160 <storeFLVFromStdin+0x40>
add    $0x1000,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdin = global i32 0
define void @storeFLVFromStdin(i32* %0) {
%2 = alloca i32*
%3 = alloca [4096 x i8]
%4 = alloca i64
store i32* %0, i32** %2
br label %5
5: ; preds = %10, %1
%6 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%7 = load i32, i32* @stdin
%8 = call i64 @fread(i8* %6, i32 1, i32 4096, i32 %7)
store i64 %8, i64* %4
%9 = icmp ugt i64 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %5
%11 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%12 = load i64, i64* %4
%13 = load i32*, i32** %2
%14 = call i32 @fwrite(i8* %11, i32 1, i64 %12, i32* %13)
br label %5
15: ; preds = %5
ret void
}

LLVM IR (-O2):
@stdin = global i32 0
define void @storeFLVFromStdin(i32* nocapture %0) {
%2 = alloca [4096 x i8]
%3 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%4 = load i32, i32* @stdin
%5 = call i64 @fread(i8* %3, i32 1, i32 4096, i32 %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %13, label %7
7: ; preds = %1, %7
%8 = phi i64 [ %11, %7 ], [ %5, %1 ]
%9 = call i32 @fwrite(i8* %3, i32 1, i64 %8, i32* %0)
%10 = load i32, i32* @stdin
%11 = call i64 @fread(i8* %3, i32 1, i32 4096, i32 %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %7
13: ; preds = %7, %1
ret void
}