#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*/ fwrite(unsigned char *, int, int, int /*<<< orphan*/ *);
int writeFLVHeader(FILE *fp, int hasaudio, int hasvideo) {
  unsigned char bytes[9];
  bytes[0] = 'F';
  bytes[1] = 'L';
  bytes[2] = 'V';
  bytes[3] = 1;
  bytes[4] = 0;
  if (hasaudio == 1)
    bytes[4] |= 0x4;
  if (hasvideo == 1)
    bytes[4] |= 0x1;
  bytes[5] = ((9 >> 24) & 0xff);
  bytes[6] = ((9 >> 16) & 0xff);
  bytes[7] = ((9 >> 8) & 0xff);
  bytes[8] = ((9 >> 0) & 0xff);
  fwrite(bytes, 9, 1, fp);
  return 0;
}


x86 assembly (clang, -O0):
<writeFLVHeader>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movb   $0x46,-0x19(%rbp)
movb   $0x4c,-0x18(%rbp)
movb   $0x56,-0x17(%rbp)
movb   $0x1,-0x16(%rbp)
movb   $0x0,-0x15(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    114a <writeFLVHeader+0x3a>
movzbl -0x15(%rbp),%eax
or     $0x4,%eax
mov    %al,-0x15(%rbp)
cmpl   $0x1,-0x10(%rbp)
jne    115e <writeFLVHeader+0x4e>
movzbl -0x15(%rbp),%eax
or     $0x1,%eax
mov    %al,-0x15(%rbp)
movb   $0x0,-0x14(%rbp)
movb   $0x0,-0x13(%rbp)
movb   $0x0,-0x12(%rbp)
movb   $0x9,-0x11(%rbp)
lea    -0x19(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x9,%esi
mov    $0x1,%edx
call   1030 <fwrite@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writeFLVHeader>:
sub    $0x18,%rsp
mov    %rdi,%rcx
movl   $0x1564c46,0xf(%rsp)
01
cmp    $0x1,%esi
sete   %al
shl    $0x2,%al
cmp    $0x1,%edx
sete   %dl
or     %al,%dl
mov    %dl,0x13(%rsp)
movl   $0x9000000,0x14(%rsp)
09
lea    0xf(%rsp),%rdi
mov    $0x9,%esi
mov    $0x1,%edx
call   1030 <fwrite@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
define i32 @writeFLVHeader(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [9 x i8]
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = getelementptr inbounds [9 x i8], [9 x i8]* %7, i64 0, i64 0
store i8 70, i8* %8
%9 = getelementptr inbounds [9 x i8], [9 x i8]* %7, i64 0, i64 1
store i8 76, i8* %9
%10 = getelementptr inbounds [9 x i8], [9 x i8]* %7, i64 0, i64 2
store i8 86, i8* %10
%11 = getelementptr inbounds [9 x i8], [9 x i8]* %7, i64 0, i64 3
store i8 1, i8* %11
%12 = getelementptr inbounds [9 x i8], [9 x i8]* %7, i64 0, i64 4
store i8 0, i8* %12
%13 = load i32, i32* %5
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %21
15: ; preds = %3
%16 = getelementptr inbounds [9 x i8], [9 x i8]* %7, i64 0, i64 4
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
%19 = or i32 %18, 4
%20 = trunc i32 %19 to i8
store i8 %20, i8* %16
br label %21
21: ; preds = %15, %3
%22 = load i32, i32* %6
%23 = icmp eq i32 %22, 1
br i1 %23, label %24, label %30
24: ; preds = %21
%25 = getelementptr inbounds [9 x i8], [9 x i8]* %7, i64 0, i64 4
%26 = load i8, i8* %25
%27 = zext i8 %26 to i32
%28 = or i32 %27, 1
%29 = trunc i32 %28 to i8
store i8 %29, i8* %25
br label %30
30: ; preds = %24, %21
%31 = getelementptr inbounds [9 x i8], [9 x i8]* %7, i64 0, i64 5
store i8 0, i8* %31
%32 = getelementptr inbounds [9 x i8], [9 x i8]* %7, i64 0, i64 6
store i8 0, i8* %32
%33 = getelementptr inbounds [9 x i8], [9 x i8]* %7, i64 0, i64 7
store i8 0, i8* %33
%34 = getelementptr inbounds [9 x i8], [9 x i8]* %7, i64 0, i64 8
store i8 9, i8* %34
%35 = getelementptr inbounds [9 x i8], [9 x i8]* %7, i64 0, i64 0
%36 = load i32*, i32** %4
%37 = call i32 @fwrite(i8* %35, i32 9, i32 1, i32* %36)
ret i32 0
}

LLVM IR (-O2):
define i32 @writeFLVHeader(i32* nocapture %0, i32 %1, i32 %2) {
%4 = alloca [9 x i8]
%5 = getelementptr inbounds [9 x i8], [9 x i8]* %4, i64 0, i64 0
store i8 70, i8* %5
%6 = getelementptr inbounds [9 x i8], [9 x i8]* %4, i64 0, i64 1
store i8 76, i8* %6
%7 = getelementptr inbounds [9 x i8], [9 x i8]* %4, i64 0, i64 2
store i8 86, i8* %7
%8 = getelementptr inbounds [9 x i8], [9 x i8]* %4, i64 0, i64 3
store i8 1, i8* %8
%9 = icmp eq i32 %1, 1
%10 = select i1 %9, i8 4, i8 0
%11 = icmp eq i32 %2, 1
%12 = zext i1 %11 to i8
%13 = or i8 %10, %12
%14 = getelementptr inbounds [9 x i8], [9 x i8]* %4, i64 0, i64 4
store i8 %13, i8* %14
%15 = getelementptr inbounds [9 x i8], [9 x i8]* %4, i64 0, i64 5
store i8 0, i8* %15
%16 = getelementptr inbounds [9 x i8], [9 x i8]* %4, i64 0, i64 6
store i8 0, i8* %16
%17 = getelementptr inbounds [9 x i8], [9 x i8]* %4, i64 0, i64 7
store i8 0, i8* %17
%18 = getelementptr inbounds [9 x i8], [9 x i8]* %4, i64 0, i64 8
store i8 9, i8* %18
%19 = call i32 @fwrite(i8* %5, i32 9, i32 1, i32* %0)
ret i32 0
}