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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(float *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(float *, int, int, int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  FILE *camera, *image;
  float data[640 * 420];
  if (argc < 3)
    return -1;
  camera = fopen(argv[1], "rb");
  image = fopen(argv[2], "wb");
  if ((camera == NULL) || (image == NULL))
    return -2;
  fread(data, sizeof(data[0]), 640 * 420, camera);
  fwrite(data, sizeof(data[0]), 640 * 420, image);
  fclose(camera);
  fclose(image);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x106820,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    116f <main+0x2f>
movl   $0xffffffff,-0x4(%rbp)
jmp    120e <main+0xce>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe82(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe6d(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11b5 <main+0x75>
cmpq   $0x0,-0x20(%rbp)
jne    11c1 <main+0x81>
movl   $0xfffffffe,-0x4(%rbp)
jmp    120e <main+0xce>
lea    -0x106820(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x4,%esi
mov    $0x41a00,%edx
call   1030 <fread@plt>
lea    -0x106820(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x4,%esi
mov    $0x41a00,%edx
call   1060 <fwrite@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x106820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x106800,%rsp
mov    $0xffffffff,%eax
cmp    $0x3,%edi
jl     11cd <main+0x8d>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe9c(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%r15
mov    0x10(%rbx),%rdi
lea    0xe8c(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%r14
mov    $0xfffffffe,%eax
test   %r15,%r15
je     11cd <main+0x8d>
test   %r14,%r14
je     11cd <main+0x8d>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x41a00,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x41a00,%edx
mov    %r14,%rcx
call   1060 <fwrite@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x106800,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\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 i32*
%8 = alloca [268800 x float]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 3
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 -1, i32* %3
br label %38
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %16, i32** %6
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 2
%19 = load i8*, i8** %18
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %20, i32** %7
%21 = load i32*, i32** %6
%22 = icmp eq i32* %21, null
br i1 %22, label %26, label %23
23: ; preds = %12
%24 = load i32*, i32** %7
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %27
26: ; preds = %23, %12
store i32 -2, i32* %3
br label %38
27: ; preds = %23
%28 = getelementptr inbounds [268800 x float], [268800 x float]* %8, i64 0, i64 0
%29 = load i32*, i32** %6
%30 = call i32 @fread(float* %28, i32 4, i32 268800, i32* %29)
%31 = getelementptr inbounds [268800 x float], [268800 x float]* %8, i64 0, i64 0
%32 = load i32*, i32** %7
%33 = call i32 @fwrite(float* %31, i32 4, i32 268800, i32* %32)
%34 = load i32*, i32** %6
%35 = call i32 @fclose(i32* %34)
%36 = load i32*, i32** %7
%37 = call i32 @fclose(i32* %36)
store i32 0, i32* %3
br label %38
38: ; preds = %27, %26, %11
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@.str.1 = [3 x i8] c"wb\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [268800 x float]
%4 = bitcast [268800 x float]* %3 to i8*
%5 = icmp slt i32 %0, 3
br i1 %5, label %22, label %6
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = tail call i32* @fopen(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32* %9, null
%14 = icmp eq i32* %12, null
%15 = or i1 %13, %14
br i1 %15, label %22, label %16
16: ; preds = %6
%17 = getelementptr inbounds [268800 x float], [268800 x float]* %3, i64 0, i64 0
%18 = call i32 @fread(float* %17, i32 4, i32 268800, i32* %9)
%19 = call i32 @fwrite(float* %17, i32 4, i32 268800, i32* %12)
%20 = tail call i32 @fclose(i32* %9)
%21 = tail call i32 @fclose(i32* %12)
br label %22
22: ; preds = %6, %2, %16
%23 = phi i32 [ 0, %16 ], [ -1, %2 ], [ -2, %6 ]
ret i32 %23
}