#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 */

/* Variables and functions */
int blue(float);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/, char *, int *, ...);
int green(float);
int red(float);
int /*<<< orphan*/ skipline(int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int main(void) {
  int width, height;
  int resolution;
  int i, j;
  int value;
  float fvalue;
  skipline(stdin);
  fprintf(stdout, "P3\n");
  fscanf(stdin, "%d %d\n", &width, &height);
  fprintf(stdout, "%d %d\n", width, height);
  fscanf(stdin, "%d\n", &resolution);
  fprintf(stdout, "%d\n", resolution);
  for (i = 0; i < height; ++i) {
    for (j = 0; j < width; ++j) {
      fscanf(stdin, "%d", &value);
      fvalue = value / (float)resolution;
      fprintf(stdout, "%d %d %d ", (int)(red(fvalue) * resolution),
              (int)(green(fvalue) * resolution),
              (int)(blue(fvalue) * resolution));
    }
    fprintf(stdout, "\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e72(%rip),%rax
mov    (%rax),%edi
call   1040 <skipline@plt>
mov    0x2e54(%rip),%rax
mov    (%rax),%edi
lea    0xe73(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2e4d(%rip),%rax
mov    (%rax),%edi
lea    0xe60(%rip),%rsi
lea    -0x8(%rbp),%rdx
lea    -0xc(%rbp),%rcx
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xe3b(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2e11(%rip),%rax
mov    (%rax),%edi
lea    0xe27(%rip),%rsi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    0x2de6(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%edx
lea    0xe09(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    12e3 <main+0x183>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12be <main+0x15e>
mov    0x2db6(%rip),%rax
mov    (%rax),%edi
lea    0xdd0(%rip),%rsi
lea    -0x1c(%rbp),%rdx
mov    $0x0,%al
call   1050 <fscanf@plt>
cvtsi2ssl -0x1c(%rbp),%xmm0
cvtsi2ssl -0x10(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
mov    0x2d78(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
movss  -0x20(%rbp),%xmm0
call   1030 <red@plt>
imul   -0x10(%rbp),%eax
mov    %eax,-0x28(%rbp)
movss  -0x20(%rbp),%xmm0
call   1060 <green@plt>
imul   -0x10(%rbp),%eax
mov    %eax,-0x24(%rbp)
movss  -0x20(%rbp),%xmm0
call   1080 <blue@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    %eax,%r8d
imul   -0x10(%rbp),%r8d
lea    0xd65(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    121f <main+0xbf>
mov    0x2d13(%rip),%rax
mov    (%rax),%edi
lea    0xd34(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    120c <main+0xac>
xor    %eax,%eax
add    $0x30,%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    0x2e73(%rip),%r12
mov    (%r12),%edi
call   1040 <skipline@plt>
mov    0x2e53(%rip),%r13
mov    0x0(%r13),%edi
lea    0xe70(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%r12),%edi
lea    0xe62(%rip),%rbx
lea    0x14(%rsp),%rdx
lea    0x10(%rsp),%rcx
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    0x0(%r13),%edi
mov    0x14(%rsp),%edx
mov    0x10(%rsp),%ecx
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%r12),%edi
lea    0xe30(%rip),%rbx
lea    0xc(%rsp),%rdx
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    0x0(%r13),%edi
mov    0xc(%rsp),%edx
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
cmpl   $0x0,0x10(%rsp)
jle    1300 <main+0x1a0>
lea    0xe01(%rip),%rbx
lea    0x24(%rsp),%rbp
xor    %eax,%eax
jmp    1243 <main+0xe3>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x0(%r13),%edi
lea    0xdd7(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x1c(%rsp),%eax
add    $0x1,%eax
cmp    0x10(%rsp),%eax
jge    1300 <main+0x1a0>
mov    %eax,0x1c(%rsp)
cmpl   $0x0,0x14(%rsp)
jle    1220 <main+0xc0>
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r12),%edi
mov    %rbx,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1050 <fscanf@plt>
xorps  %xmm0,%xmm0
cvtsi2ssl 0x24(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtsi2ssl 0xc(%rsp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,0x18(%rsp)
mov    0x0(%r13),%eax
mov    %eax,0x20(%rsp)
call   1030 <red@plt>
mov    %eax,%ebx
imul   0xc(%rsp),%ebx
movss  0x18(%rsp),%xmm0
call   1060 <green@plt>
mov    %r12,%r15
mov    %eax,%r12d
imul   0xc(%rsp),%r12d
movss  0x18(%rsp),%xmm0
call   1080 <blue@plt>
imul   0xc(%rsp),%eax
mov    0x20(%rsp),%edi
lea    0xd3b(%rip),%rsi
mov    %ebx,%edx
lea    0xd2f(%rip),%rbx
mov    %r12d,%ecx
mov    %r15,%r12
mov    %eax,%r8d
xor    %eax,%eax
call   1070 <fprintf@plt>
add    $0x1,%r14d
cmp    0x14(%rsp),%r14d
jl     1260 <main+0x100>
jmp    1220 <main+0xc0>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
@stdout = global i32 0
@.str = [4 x i8] c"P3\0A\00"
@.str.1 = [7 x i8] c"%d %d\0A\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [10 x i8] c"%d %d %d \00"
@.str.5 = [2 x i8] c"\0A\00"
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 float
store i32 0, i32* %1
%9 = load i32, i32* @stdin
%10 = call i32 @skipline(i32 %9)
%11 = load i32, i32* @stdout
%12 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%13 = load i32, i32* @stdin
%14 = call i32 (i32, i8*, i32*, ...) @fscanf(i32 %13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%15 = load i32, i32* @stdout
%16 = load i32, i32* %2
%17 = load i32, i32* %3
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %16, i32 %17)
%19 = load i32, i32* @stdin
%20 = call i32 (i32, i8*, i32*, ...) @fscanf(i32 %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%21 = load i32, i32* @stdout
%22 = load i32, i32* %4
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %22)
store i32 0, i32* %5
br label %24
24: ; preds = %61, %0
%25 = load i32, i32* %5
%26 = load i32, i32* %3
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %64
28: ; preds = %24
store i32 0, i32* %6
br label %29
29: ; preds = %55, %28
%30 = load i32, i32* %6
%31 = load i32, i32* %2
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %58
33: ; preds = %29
%34 = load i32, i32* @stdin
%35 = call i32 (i32, i8*, i32*, ...) @fscanf(i32 %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %7)
%36 = load i32, i32* %7
%37 = sitofp i32 %36 to float
%38 = load i32, i32* %4
%39 = sitofp i32 %38 to float
%40 = fdiv float %37, %39
store float %40, float* %8
%41 = load i32, i32* @stdout
%42 = load float, float* %8
%43 = call i32 @red(float %42)
%44 = load i32, i32* %4
%45 = mul nsw i32 %43, %44
%46 = load float, float* %8
%47 = call i32 @green(float %46)
%48 = load i32, i32* %4
%49 = mul nsw i32 %47, %48
%50 = load float, float* %8
%51 = call i32 @blue(float %50)
%52 = load i32, i32* %4
%53 = mul nsw i32 %51, %52
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %45, i32 %49, i32 %53)
br label %55
55: ; preds = %33
%56 = load i32, i32* %6
%57 = add nsw i32 %56, 1
store i32 %57, i32* %6
br label %29
58: ; preds = %29
%59 = load i32, i32* @stdout
%60 = call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %61
61: ; preds = %58
%62 = load i32, i32* %5
%63 = add nsw i32 %62, 1
store i32 %63, i32* %5
br label %24
64: ; preds = %24
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@stdout = global i32 0
@.str = [4 x i8] c"P3\0A\00"
@.str.1 = [7 x i8] c"%d %d\0A\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [10 x i8] c"%d %d %d \00"
@.str.5 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = load i32, i32* @stdin
%10 = tail call i32 @skipline(i32 %9)
%11 = load i32, i32* @stdout
%12 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%13 = load i32, i32* @stdin
%14 = call i32 (i32, i8*, i32*, ...) @fscanf(i32 %13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%15 = load i32, i32* @stdout
%16 = load i32, i32* %1
%17 = load i32, i32* %2
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %16, i32 %17)
%19 = load i32, i32* @stdin
%20 = call i32 (i32, i8*, i32*, ...) @fscanf(i32 %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%21 = load i32, i32* @stdout
%22 = load i32, i32* %3
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %22)
%24 = load i32, i32* %2
%25 = icmp sgt i32 %24, 0
br i1 %25, label %26, label %59
26: ; preds = %0, %53
%27 = phi i32 [ %56, %53 ], [ 0, %0 ]
%28 = load i32, i32* %1
%29 = icmp sgt i32 %28, 0
br i1 %29, label %30, label %53
30: ; preds = %26, %30
%31 = phi i32 [ %50, %30 ], [ 0, %26 ]
%32 = load i32, i32* @stdin
%33 = call i32 (i32, i8*, i32*, ...) @fscanf(i32 %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %4)
%34 = load i32, i32* %4
%35 = sitofp i32 %34 to float
%36 = load i32, i32* %3
%37 = sitofp i32 %36 to float
%38 = fdiv float %35, %37
%39 = load i32, i32* @stdout
%40 = call i32 @red(float %38)
%41 = load i32, i32* %3
%42 = mul nsw i32 %41, %40
%43 = call i32 @green(float %38)
%44 = load i32, i32* %3
%45 = mul nsw i32 %44, %43
%46 = call i32 @blue(float %38)
%47 = load i32, i32* %3
%48 = mul nsw i32 %47, %46
%49 = call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %42, i32 %45, i32 %48)
%50 = add nuw nsw i32 %31, 1
%51 = load i32, i32* %1
%52 = icmp slt i32 %50, %51
br i1 %52, label %30, label %53
53: ; preds = %30, %26
%54 = load i32, i32* @stdout
%55 = call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%56 = add nuw nsw i32 %27, 1
%57 = load i32, i32* %2
%58 = icmp slt i32 %56, %57
br i1 %58, label %26, label %59
59: ; preds = %53, %0
ret i32 0
}