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

/* Variables and functions */
int /*<<< orphan*/ _FillImage420(int /*<<< orphan*/ *, int, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fwrite(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  FILE *fp = fopen("out.yuv", "wb");
  uint8_t buffer[(int)(640 * 480 * 3 / 2)];
  _FillImage420(buffer, 640, 480);
  fwrite(buffer, sizeof(buffer), 1, fp);
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c2020,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea0(%rip),%rdi
lea    0xea1(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
lea    -0x1c2020(%rbp),%rdi
mov    $0x280,%esi
mov    $0x1e0,%edx
call   1040 <_FillImage420@plt>
lea    -0x1c2020(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x1c2000,%esi
mov    $0x1,%edx
call   1060 <fwrite@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x1c2020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x1c2008,%rsp
lea    0xeaf(%rip),%rdi
lea    0xeb0(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x280,%esi
mov    $0x1e0,%edx
call   1040 <_FillImage420@plt>
mov    %r14,%rdi
mov    $0x1c2000,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1060 <fwrite@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x1c2008,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [8 x i8] c"out.yuv\00"
@.str.1 = [3 x i8] c"wb\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [460800 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %6
%9 = getelementptr inbounds [460800 x i32], [460800 x i32]* %7, i64 0, i64 0
%10 = call i32 @_FillImage420(i32* %9, i32 640, i32 480)
%11 = getelementptr inbounds [460800 x i32], [460800 x i32]* %7, i64 0, i64 0
%12 = load i32*, i32** %6
%13 = call i32 @fwrite(i32* %11, i32 1843200, i32 1, i32* %12)
%14 = load i32*, i32** %6
%15 = call i32 @fclose(i32* %14)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"out.yuv\00"
@.str.1 = [3 x i8] c"wb\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [460800 x i32]
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%5 = bitcast [460800 x i32]* %3 to i8*
%6 = getelementptr inbounds [460800 x i32], [460800 x i32]* %3, i64 0, i64 0
%7 = call i32 @_FillImage420(i32* %6, i32 640, i32 480)
%8 = call i32 @fwrite(i32* %6, i32 1843200, i32 1, i32* %4)
%9 = call i32 @fclose(i32* %4)
ret i32 0
}