#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 /*<<< orphan*/ printf(char *, int, int, ...);
int main() {
  printf("P6 %d %d 255 ", 509, 509);
  int i, j;
  for (i = 0; i < 509; ++i) {
    for (j = 0; j < 509; ++j) {
      int red = (i * 509 + j) % 256;
      int green = (j * 509 + i) % 256;
      int blue = (j + i) * 2 % 256;
      printf("%c%c%c", red, green, blue);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rdi
mov    $0x1fd,%edx
mov    %edx,%esi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x1fd,-0x8(%rbp)
jge    11d2 <main+0xc2>
movl   $0x0,-0xc(%rbp)
cmpl   $0x1fd,-0xc(%rbp)
jge    11bf <main+0xaf>
imul   $0x1fd,-0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
imul   $0x1fd,-0xc(%rbp),%eax
add    -0x8(%rbp),%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0xc(%rbp),%eax
add    -0x8(%rbp),%eax
shl    $0x1,%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114f <main+0x3f>
jmp    11c4 <main+0xb4>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    113b <main+0x2b>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xede(%rip),%rdi
mov    $0x1fd,%esi
mov    $0x1fd,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed4(%rip),%r12
xor    %ebx,%ebx
xor    %r15d,%r15d
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebx,0x4(%rsp)
mov    %r15d,%ebp
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
movzbl %bl,%esi
lea    (%r14,%r13,1),%eax
movzbl %al,%edx
mov    %ebp,%ecx
and    $0xfe,%ecx
mov    %r12,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1fd,%r14d
add    $0x2,%ebp
add    $0x1,%ebx
cmp    $0x3f409,%r14d
jne    1160 <main+0x50>
add    $0x1,%r13d
add    $0x2,%r15d
mov    0x4(%rsp),%ebx
add    $0x1fd,%ebx
cmp    $0x1fd,%r13d
jne    1150 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"P6 %d %d 255 \00"
@.str.1 = [7 x i8] c"%c%c%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 509, i32 509)
store i32 0, i32* %2
br label %8
8: ; preds = %39, %0
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 509
br i1 %10, label %11, label %42
11: ; preds = %8
store i32 0, i32* %3
br label %12
12: ; preds = %35, %11
%13 = load i32, i32* %3
%14 = icmp slt i32 %13, 509
br i1 %14, label %15, label %38
15: ; preds = %12
%16 = load i32, i32* %2
%17 = mul nsw i32 %16, 509
%18 = load i32, i32* %3
%19 = add nsw i32 %17, %18
%20 = srem i32 %19, 256
store i32 %20, i32* %4
%21 = load i32, i32* %3
%22 = mul nsw i32 %21, 509
%23 = load i32, i32* %2
%24 = add nsw i32 %22, %23
%25 = srem i32 %24, 256
store i32 %25, i32* %5
%26 = load i32, i32* %3
%27 = load i32, i32* %2
%28 = add nsw i32 %26, %27
%29 = mul nsw i32 %28, 2
%30 = srem i32 %29, 256
store i32 %30, i32* %6
%31 = load i32, i32* %4
%32 = load i32, i32* %5
%33 = load i32, i32* %6
%34 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %31, i32 %32, i32 %33)
br label %35
35: ; preds = %15
%36 = load i32, i32* %3
%37 = add nsw i32 %36, 1
store i32 %37, i32* %3
br label %12
38: ; preds = %12
br label %39
39: ; preds = %38
%40 = load i32, i32* %2
%41 = add nsw i32 %40, 1
store i32 %41, i32* %2
br label %8
42: ; preds = %8
%43 = load i32, i32* %1
ret i32 %43
}

LLVM IR (-O2):
@.str = [14 x i8] c"P6 %d %d 255 \00"
@.str.1 = [7 x i8] c"%c%c%c\00"
define i32 @main() {
%1 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 509, i32 509)
br label %2
2: ; preds = %0, %18
%3 = phi i32 [ 0, %0 ], [ %19, %18 ]
%4 = mul nuw nsw i32 %3, 509
br label %5
5: ; preds = %2, %5
%6 = phi i32 [ 0, %2 ], [ %16, %5 ]
%7 = add nuw nsw i32 %6, %4
%8 = and i32 %7, 255
%9 = mul nuw nsw i32 %6, 509
%10 = add nuw nsw i32 %9, %3
%11 = and i32 %10, 255
%12 = add nuw nsw i32 %6, %3
%13 = shl nuw nsw i32 %12, 1
%14 = and i32 %13, 254
%15 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %8, i32 %11, i32 %14)
%16 = add nuw nsw i32 %6, 1
%17 = icmp eq i32 %16, 509
br i1 %17, label %18, label %5
18: ; preds = %5
%19 = add nuw nsw i32 %3, 1
%20 = icmp eq i32 %19, 509
br i1 %20, label %21, label %2
21: ; preds = %18
ret i32 0
}