#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 uint8_t;

/* Variables and functions */
int EXIT_SUCCESS;
scalar_t__ fread(int *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ fwrite(int *, int, int, int /*<<< orphan*/);
int *malloc(int);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int main() {
  int width = 256, heigh = 192, pixelsPerFrame = width * heigh,
      RGBframeBufferSize = pixelsPerFrame * 3;
  uint8_t *pixels = malloc(RGBframeBufferSize), *pix;
  while (1) {
    if (fread(pixels, 1, RGBframeBufferSize, stdin) <= 0) {
      break;
    }
    pix = pixels;
    for (int q = 0; q < pixelsPerFrame; q++) {
      *pix++ = *pix * 2;
      *pix++ = *pix + 120;
      *pix++ = *pix + q / 10;
    }
    fwrite(pixels, 1, RGBframeBufferSize, stdout);
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x100,-0x8(%rbp)
movl   $0xc0,-0xc(%rbp)
mov    -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
imul   $0x3,-0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    0x2e70(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1030 <fread@plt>
cmp    $0x0,%rax
jg     1193 <main+0x63>
jmp    1233 <main+0x103>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1214 <main+0xe4>
mov    -0x28(%rbp),%rax
mov    (%rax),%ecx
shl    $0x1,%ecx
mov    -0x28(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x28(%rbp)
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
mov    (%rax),%ecx
add    $0x78,%ecx
mov    -0x28(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x28(%rbp)
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
mov    (%rax),%ecx
mov    -0x2c(%rbp),%eax
mov    $0xa,%esi
cltd
idiv   %esi
add    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x28(%rbp)
mov    %ecx,(%rax)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11a2 <main+0x72>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    0x2db6(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1050 <fwrite@plt>
jmp    116a <main+0x3a>
mov    0x2d96(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    $0x24000,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
mov    0x2e9f(%rip),%r14
mov    (%r14),%ecx
mov    %rax,%rdi
mov    $0x1,%esi
mov    $0x24000,%edx
call   1030 <fread@plt>
test   %rax,%rax
jle    11cb <main+0x9b>
xor    %ecx,%ecx
mov    0x2e6c(%rip),%r15
mov    %rbx,%rdx
nop
shll   (%rdx)
addl   $0x78,0x4(%rdx)
movzwl %cx,%eax
imul   $0xcccd,%eax,%eax
shr    $0x13,%eax
add    %eax,0x8(%rdx)
add    $0xc,%rdx
add    $0x1,%ecx
cmp    $0xc000,%ecx
jne    1170 <main+0x40>
mov    (%r15),%ecx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x24000,%edx
call   1050 <fwrite@plt>
mov    (%r14),%ecx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x24000,%edx
call   1030 <fread@plt>
mov    $0x0,%ecx
mov    %rbx,%rdx
test   %rax,%rax
jg     1170 <main+0x40>
mov    0x2dfe(%rip),%rax
mov    (%rax),%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdin = global i32 0
@stdout = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
store i32 0, i32* %1
store i32 256, i32* %2
store i32 192, i32* %3
%9 = load i32, i32* %2
%10 = load i32, i32* %3
%11 = mul nsw i32 %9, %10
store i32 %11, i32* %4
%12 = load i32, i32* %4
%13 = mul nsw i32 %12, 3
store i32 %13, i32* %5
%14 = load i32, i32* %5
%15 = call i32* @malloc(i32 %14)
store i32* %15, i32** %6
br label %16
16: ; preds = %0, %50
%17 = load i32*, i32** %6
%18 = load i32, i32* %5
%19 = load i32, i32* @stdin
%20 = call i64 @fread(i32* %17, i32 1, i32 %18, i32 %19)
%21 = icmp sle i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %16
br label %55
23: ; preds = %16
%24 = load i32*, i32** %6
store i32* %24, i32** %7
store i32 0, i32* %8
br label %25
25: ; preds = %47, %23
%26 = load i32, i32* %8
%27 = load i32, i32* %4
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %50
29: ; preds = %25
%30 = load i32*, i32** %7
%31 = load i32, i32* %30
%32 = mul nsw i32 %31, 2
%33 = load i32*, i32** %7
%34 = getelementptr inbounds i32, i32* %33, i32 1
store i32* %34, i32** %7
store i32 %32, i32* %33
%35 = load i32*, i32** %7
%36 = load i32, i32* %35
%37 = add nsw i32 %36, 120
%38 = load i32*, i32** %7
%39 = getelementptr inbounds i32, i32* %38, i32 1
store i32* %39, i32** %7
store i32 %37, i32* %38
%40 = load i32*, i32** %7
%41 = load i32, i32* %40
%42 = load i32, i32* %8
%43 = sdiv i32 %42, 10
%44 = add nsw i32 %41, %43
%45 = load i32*, i32** %7
%46 = getelementptr inbounds i32, i32* %45, i32 1
store i32* %46, i32** %7
store i32 %44, i32* %45
br label %47
47: ; preds = %29
%48 = load i32, i32* %8
%49 = add nsw i32 %48, 1
store i32 %49, i32* %8
br label %25
50: ; preds = %25
%51 = load i32*, i32** %6
%52 = load i32, i32* %5
%53 = load i32, i32* @stdout
%54 = call i32 @fwrite(i32* %51, i32 1, i32 %52, i32 %53)
br label %16
55: ; preds = %22
%56 = load i32, i32* @EXIT_SUCCESS
ret i32 %56
}

LLVM IR (-O2):
@stdin = global i32 0
@stdout = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = tail call i32* @malloc(i32 147456)
%2 = load i32, i32* @stdin
%3 = tail call i64 @fread(i32* %1, i32 1, i32 147456, i32 %2)
%4 = icmp slt i64 %3, 1
br i1 %4, label %31, label %11
5: ; preds = %11
%6 = load i32, i32* @stdout
%7 = tail call i32 @fwrite(i32* %1, i32 1, i32 147456, i32 %6)
%8 = load i32, i32* @stdin
%9 = tail call i64 @fread(i32* %1, i32 1, i32 147456, i32 %8)
%10 = icmp slt i64 %9, 1
br i1 %10, label %31, label %28
11: ; preds = %0, %28
%12 = phi i32 [ %29, %28 ], [ 0, %0 ]
%13 = phi i32* [ %30, %28 ], [ %1, %0 ]
%14 = load i32, i32* %13
%15 = shl nsw i32 %14, 1
%16 = getelementptr inbounds i32, i32* %13, i64 1
store i32 %15, i32* %13
%17 = load i32, i32* %16
%18 = add nsw i32 %17, 120
%19 = getelementptr inbounds i32, i32* %13, i64 2
store i32 %18, i32* %16
%20 = load i32, i32* %19
%21 = trunc i32 %12 to i16
%22 = udiv i16 %21, 10
%23 = zext i16 %22 to i32
%24 = add nsw i32 %20, %23
%25 = getelementptr inbounds i32, i32* %13, i64 3
store i32 %24, i32* %19
%26 = add nuw nsw i32 %12, 1
%27 = icmp eq i32 %26, 49152
br i1 %27, label %5, label %28
28: ; preds = %11, %5
%29 = phi i32 [ %26, %11 ], [ 0, %5 ]
%30 = phi i32* [ %25, %11 ], [ %1, %5 ]
br label %11
31: ; preds = %5, %0
%32 = load i32, i32* @EXIT_SUCCESS
ret i32 %32
}