#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 */
unsigned char atoi(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, unsigned int);
int getline(char **, size_t *, int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int main(int argc, char *argv[]) {
  FILE *inFile = fopen(argv[1], "r");
  FILE *outFile = fopen(argv[2], "w");
  char *line = (char *)malloc(256);
  size_t len = 255;
  int ret = -1;
  int i = 0;
  ret = getline(&line, &len, inFile);
  ret = getline(&line, &len, inFile);
  ret = getline(&line, &len, inFile);
  ret = getline(&line, &len, inFile);
  for (i = 0; i < 640 * 480; i += 4) {
    int j = 0;
    unsigned int word = 0;
    for (j = 0; j < 4; j++) {
      unsigned char r, g, b, pixel = 0;
      ret = getline(&line, &len, inFile);
      r = atoi(line);
      ret = getline(&line, &len, inFile);
      g = atoi(line);
      ret = getline(&line, &len, inFile);
      b = atoi(line);
      pixel |= (r & 0xe0);
      pixel |= (g & 0xe0) >> 3;
      pixel |= (b & 0xc0) >> 6;
      word |= pixel << 8 * j;
    }
    fprintf(outFile, ".word 0x%x\n", word);
  }
  fclose(inFile);
  fclose(outFile);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe7b(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe65(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    $0x100,%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
movq   $0xff,-0x30(%rbp)
movl   $0xffffffff,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x18(%rbp),%rdx
lea    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1080 <getline@plt>
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rdx
lea    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1080 <getline@plt>
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rdx
lea    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1080 <getline@plt>
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rdx
lea    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1080 <getline@plt>
mov    %eax,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
cmpl   $0x4b000,-0x38(%rbp)
jge    1331 <main+0x1d1>
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
movl   $0x0,-0x3c(%rbp)
cmpl   $0x4,-0x3c(%rbp)
jge    1310 <main+0x1b0>
movb   $0x0,-0x44(%rbp)
mov    -0x18(%rbp),%rdx
lea    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1080 <getline@plt>
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%rdi
call   1070 <atoi@plt>
mov    %al,-0x41(%rbp)
mov    -0x18(%rbp),%rdx
lea    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1080 <getline@plt>
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%rdi
call   1070 <atoi@plt>
mov    %al,-0x42(%rbp)
mov    -0x18(%rbp),%rdx
lea    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1080 <getline@plt>
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%rdi
call   1070 <atoi@plt>
mov    %al,-0x43(%rbp)
movzbl -0x41(%rbp),%ecx
and    $0xe0,%ecx
movzbl -0x44(%rbp),%eax
or     %ecx,%eax
mov    %al,-0x44(%rbp)
movzbl -0x42(%rbp),%ecx
and    $0xe0,%ecx
sar    $0x3,%ecx
movzbl -0x44(%rbp),%eax
or     %ecx,%eax
mov    %al,-0x44(%rbp)
movzbl -0x43(%rbp),%ecx
and    $0xc0,%ecx
sar    $0x6,%ecx
movzbl -0x44(%rbp),%eax
or     %ecx,%eax
mov    %al,-0x44(%rbp)
movzbl -0x44(%rbp),%eax
mov    -0x3c(%rbp),%ecx
shl    $0x3,%ecx
shl    %cl,%eax
or     -0x40(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1243 <main+0xe3>
mov    -0x20(%rbp),%rdi
mov    -0x40(%rbp),%edx
lea    0xce6(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x38(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x38(%rbp)
jmp    1221 <main+0xc1>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe84(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbp
mov    0x10(%rbx),%rdi
lea    0xe73(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,0x20(%rsp)
mov    $0x100,%edi
call   1050 <malloc@plt>
mov    %rax,0x8(%rsp)
movq   $0xff,0x10(%rsp)
lea    0x8(%rsp),%rbx
lea    0x10(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rbp,%rdx
call   1080 <getline@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rbp,%rdx
call   1080 <getline@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rbp,%rdx
call   1080 <getline@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rbp,%rdx
call   1080 <getline@plt>
mov    $0xfffffffc,%eax
nopl   0x0(%rax,%rax,1)
mov    %eax,0x1c(%rsp)
lea    0x8(%rsp),%r14
mov    %r14,%rdi
lea    0x10(%rsp),%r12
mov    %r12,%rsi
mov    %rbp,%rdx
call   1080 <getline@plt>
mov    0x8(%rsp),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebx
mov    %r14,%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
call   1080 <getline@plt>
mov    0x8(%rsp),%rdi
call   1070 <atoi@plt>
mov    %eax,%r13d
mov    %r14,%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
call   1080 <getline@plt>
mov    0x8(%rsp),%rdi
call   1070 <atoi@plt>
and    $0xe0,%bl
shr    $0x3,%r13b
and    $0x1c,%r13b
or     %bl,%r13b
shr    $0x6,%al
or     %r13b,%al
movzbl %al,%eax
mov    %eax,0x18(%rsp)
mov    %r14,%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
call   1080 <getline@plt>
mov    0x8(%rsp),%rdi
call   1070 <atoi@plt>
mov    %eax,%r13d
mov    %r14,%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
call   1080 <getline@plt>
mov    0x8(%rsp),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebx
mov    %r14,%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
call   1080 <getline@plt>
mov    0x8(%rsp),%rdi
call   1070 <atoi@plt>
and    $0xe0,%r13b
shr    $0x3,%bl
and    $0x1c,%bl
or     %r13b,%bl
shr    $0x6,%al
or     %bl,%al
movzbl %al,%r15d
shl    $0x8,%r15d
add    0x18(%rsp),%r15d
mov    %r14,%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
call   1080 <getline@plt>
mov    0x8(%rsp),%rdi
call   1070 <atoi@plt>
mov    %eax,%r13d
mov    %r14,%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
call   1080 <getline@plt>
mov    0x8(%rsp),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebx
mov    %r14,%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
call   1080 <getline@plt>
mov    0x8(%rsp),%rdi
call   1070 <atoi@plt>
and    $0xe0,%r13b
shr    $0x3,%bl
and    $0x1c,%bl
or     %r13b,%bl
shr    $0x6,%al
or     %bl,%al
movzbl %al,%r12d
shl    $0x10,%r12d
or     %r15d,%r12d
mov    %r14,%rdi
lea    0x10(%rsp),%r15
mov    %r15,%rsi
mov    %rbp,%rdx
call   1080 <getline@plt>
mov    0x8(%rsp),%rdi
call   1070 <atoi@plt>
mov    %eax,%r13d
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbp,%rdx
call   1080 <getline@plt>
mov    0x8(%rsp),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbp,%rdx
call   1080 <getline@plt>
mov    0x8(%rsp),%rdi
call   1070 <atoi@plt>
and    $0xe0,%r13b
shr    $0x3,%bl
and    $0x1c,%bl
or     %r13b,%bl
shr    $0x6,%al
or     %bl,%al
movzbl %al,%edx
shl    $0x18,%edx
or     %r12d,%edx
mov    0x20(%rsp),%rdi
lea    0xc3f(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x1c(%rsp),%eax
add    $0x4,%eax
cmp    $0x4affc,%eax
jb     1200 <main+0xa0>
mov    %rbp,%rdi
call   1030 <fclose@plt>
mov    0x20(%rsp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [12 x i8] c".word 0x%x\0A\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 i8*
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8
%15 = alloca i8
%16 = alloca i8
%17 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %21, i32** %6
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
%25 = call i32* @fopen(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %25, i32** %7
%26 = call i64 @malloc(i32 256)
%27 = inttoptr i64 %26 to i8*
store i8* %27, i8** %8
store i64 255, i64* %9
store i32 -1, i32* %10
store i32 0, i32* %11
%28 = load i32*, i32** %6
%29 = call i32 @getline(i8** %8, i64* %9, i32* %28)
store i32 %29, i32* %10
%30 = load i32*, i32** %6
%31 = call i32 @getline(i8** %8, i64* %9, i32* %30)
store i32 %31, i32* %10
%32 = load i32*, i32** %6
%33 = call i32 @getline(i8** %8, i64* %9, i32* %32)
store i32 %33, i32* %10
%34 = load i32*, i32** %6
%35 = call i32 @getline(i8** %8, i64* %9, i32* %34)
store i32 %35, i32* %10
store i32 0, i32* %11
br label %36
36: ; preds = %93, %2
%37 = load i32, i32* %11
%38 = icmp slt i32 %37, 307200
br i1 %38, label %39, label %96
39: ; preds = %36
store i32 0, i32* %12
store i32 0, i32* %13
store i32 0, i32* %12
br label %40
40: ; preds = %86, %39
%41 = load i32, i32* %12
%42 = icmp slt i32 %41, 4
br i1 %42, label %43, label %89
43: ; preds = %40
store i8 0, i8* %17
%44 = load i32*, i32** %6
%45 = call i32 @getline(i8** %8, i64* %9, i32* %44)
store i32 %45, i32* %10
%46 = load i8*, i8** %8
%47 = call zeroext i8 @atoi(i8* %46)
store i8 %47, i8* %14
%48 = load i32*, i32** %6
%49 = call i32 @getline(i8** %8, i64* %9, i32* %48)
store i32 %49, i32* %10
%50 = load i8*, i8** %8
%51 = call zeroext i8 @atoi(i8* %50)
store i8 %51, i8* %15
%52 = load i32*, i32** %6
%53 = call i32 @getline(i8** %8, i64* %9, i32* %52)
store i32 %53, i32* %10
%54 = load i8*, i8** %8
%55 = call zeroext i8 @atoi(i8* %54)
store i8 %55, i8* %16
%56 = load i8, i8* %14
%57 = zext i8 %56 to i32
%58 = and i32 %57, 224
%59 = load i8, i8* %17
%60 = zext i8 %59 to i32
%61 = or i32 %60, %58
%62 = trunc i32 %61 to i8
store i8 %62, i8* %17
%63 = load i8, i8* %15
%64 = zext i8 %63 to i32
%65 = and i32 %64, 224
%66 = ashr i32 %65, 3
%67 = load i8, i8* %17
%68 = zext i8 %67 to i32
%69 = or i32 %68, %66
%70 = trunc i32 %69 to i8
store i8 %70, i8* %17
%71 = load i8, i8* %16
%72 = zext i8 %71 to i32
%73 = and i32 %72, 192
%74 = ashr i32 %73, 6
%75 = load i8, i8* %17
%76 = zext i8 %75 to i32
%77 = or i32 %76, %74
%78 = trunc i32 %77 to i8
store i8 %78, i8* %17
%79 = load i8, i8* %17
%80 = zext i8 %79 to i32
%81 = load i32, i32* %12
%82 = mul nsw i32 8, %81
%83 = shl i32 %80, %82
%84 = load i32, i32* %13
%85 = or i32 %84, %83
store i32 %85, i32* %13
br label %86
86: ; preds = %43
%87 = load i32, i32* %12
%88 = add nsw i32 %87, 1
store i32 %88, i32* %12
br label %40
89: ; preds = %40
%90 = load i32*, i32** %7
%91 = load i32, i32* %13
%92 = call i32 @fprintf(i32* %90, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %91)
br label %93
93: ; preds = %89
%94 = load i32, i32* %11
%95 = add nsw i32 %94, 4
store i32 %95, i32* %11
br label %36
96: ; preds = %36
%97 = load i32*, i32** %6
%98 = call i32 @fclose(i32* %97)
%99 = load i32*, i32** %7
%100 = call i32 @fclose(i32* %99)
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [12 x i8] c".word 0x%x\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds i8*, i8** %1, i64 2
%9 = load i8*, i8** %8
%10 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = bitcast i8** %3 to i8*
%12 = tail call i64 @malloc(i32 256)
%13 = inttoptr i64 %12 to i8*
store i8* %13, i8** %3
%14 = bitcast i64* %4 to i8*
store i64 255, i64* %4
%15 = call i32 @getline(i8** %3, i64* %4, i32* %7)
%16 = call i32 @getline(i8** %3, i64* %4, i32* %7)
%17 = call i32 @getline(i8** %3, i64* %4, i32* %7)
%18 = call i32 @getline(i8** %3, i64* %4, i32* %7)
br label %19
19: ; preds = %2, %19
%20 = phi i32 [ 0, %2 ], [ %92, %19 ]
%21 = call i32 @getline(i8** %3, i64* %4, i32* %7)
%22 = load i8*, i8** %3
%23 = call zeroext i8 @atoi(i8* %22)
%24 = call i32 @getline(i8** %3, i64* %4, i32* %7)
%25 = load i8*, i8** %3
%26 = call zeroext i8 @atoi(i8* %25)
%27 = call i32 @getline(i8** %3, i64* %4, i32* %7)
%28 = load i8*, i8** %3
%29 = call zeroext i8 @atoi(i8* %28)
%30 = and i8 %23, -32
%31 = lshr i8 %26, 3
%32 = and i8 %31, 28
%33 = or i8 %32, %30
%34 = lshr i8 %29, 6
%35 = or i8 %33, %34
%36 = zext i8 %35 to i32
%37 = call i32 @getline(i8** %3, i64* %4, i32* %7)
%38 = load i8*, i8** %3
%39 = call zeroext i8 @atoi(i8* %38)
%40 = call i32 @getline(i8** %3, i64* %4, i32* %7)
%41 = load i8*, i8** %3
%42 = call zeroext i8 @atoi(i8* %41)
%43 = call i32 @getline(i8** %3, i64* %4, i32* %7)
%44 = load i8*, i8** %3
%45 = call zeroext i8 @atoi(i8* %44)
%46 = and i8 %39, -32
%47 = lshr i8 %42, 3
%48 = and i8 %47, 28
%49 = or i8 %48, %46
%50 = lshr i8 %45, 6
%51 = or i8 %49, %50
%52 = zext i8 %51 to i32
%53 = shl nuw nsw i32 %52, 8
%54 = or i32 %53, %36
%55 = call i32 @getline(i8** %3, i64* %4, i32* %7)
%56 = load i8*, i8** %3
%57 = call zeroext i8 @atoi(i8* %56)
%58 = call i32 @getline(i8** %3, i64* %4, i32* %7)
%59 = load i8*, i8** %3
%60 = call zeroext i8 @atoi(i8* %59)
%61 = call i32 @getline(i8** %3, i64* %4, i32* %7)
%62 = load i8*, i8** %3
%63 = call zeroext i8 @atoi(i8* %62)
%64 = and i8 %57, -32
%65 = lshr i8 %60, 3
%66 = and i8 %65, 28
%67 = or i8 %66, %64
%68 = lshr i8 %63, 6
%69 = or i8 %67, %68
%70 = zext i8 %69 to i32
%71 = shl nuw nsw i32 %70, 16
%72 = or i32 %71, %54
%73 = call i32 @getline(i8** %3, i64* %4, i32* %7)
%74 = load i8*, i8** %3
%75 = call zeroext i8 @atoi(i8* %74)
%76 = call i32 @getline(i8** %3, i64* %4, i32* %7)
%77 = load i8*, i8** %3
%78 = call zeroext i8 @atoi(i8* %77)
%79 = call i32 @getline(i8** %3, i64* %4, i32* %7)
%80 = load i8*, i8** %3
%81 = call zeroext i8 @atoi(i8* %80)
%82 = and i8 %75, -32
%83 = lshr i8 %78, 3
%84 = and i8 %83, 28
%85 = or i8 %84, %82
%86 = lshr i8 %81, 6
%87 = or i8 %85, %86
%88 = zext i8 %87 to i32
%89 = shl nuw i32 %88, 24
%90 = or i32 %89, %72
%91 = call i32 @fprintf(i32* %10, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %90)
%92 = add nuw nsw i32 %20, 4
%93 = icmp ult i32 %20, 307196
br i1 %93, label %19, label %94
94: ; preds = %19
%95 = call i32 @fclose(i32* %7)
%96 = call i32 @fclose(i32* %10)
ret i32 0
}