#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*/ assert(int);
int /*<<< orphan*/ dumporder(int *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, int);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/);
int next_pixel(int *);
int /*<<< orphan*/ stderr;
int main() {
  int order[32 * 32];
  int i, n;
  for (i = 0; i < 32 * 32; i++)
    order[i] = -1;
  order[0] = 0;
  n = 1;
  while ((i = next_pixel(order)) >= 0) {
    assert(n < 32 * 32);
    assert(order[i] < 0);
    order[i] = n;
    n++;
    if (n % 10 == 0) {
      fprintf(stderr, "\r%4d/%4d", n, 32 * 32);
      fflush(stderr);
    }
  }
  assert(n == 32 * 32);
  fputc('\n', stderr);
  dumporder(order);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1020,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1014(%rbp)
cmpl   $0x400,-0x1014(%rbp)
jge    11b2 <main+0x52>
movslq -0x1014(%rbp),%rax
movl   $0xffffffff,-0x1010(%rbp,%rax,4)
ff ff ff ff
mov    -0x1014(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1014(%rbp)
jmp    117c <main+0x1c>
movl   $0x0,-0x1010(%rbp)
movl   $0x1,-0x1018(%rbp)
lea    -0x1010(%rbp),%rdi
call   1030 <next_pixel@plt>
mov    %eax,-0x1014(%rbp)
cmp    $0x0,%eax
jl     1281 <main+0x121>
cmpl   $0x400,-0x1018(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
movslq -0x1014(%rbp),%rax
cmpl   $0x0,-0x1010(%rbp,%rax,4)
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x1018(%rbp),%ecx
movslq -0x1014(%rbp),%rax
mov    %ecx,-0x1010(%rbp,%rax,4)
mov    -0x1018(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1018(%rbp)
mov    -0x1018(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    127c <main+0x11c>
mov    0x2d8b(%rip),%rax
mov    (%rax),%edi
mov    -0x1018(%rbp),%edx
lea    0xd9c(%rip),%rsi
mov    $0x400,%ecx
call   1070 <fprintf@plt>
mov    0x2d6b(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
jmp    11c6 <main+0x66>
cmpl   $0x400,-0x1018(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    0x2d41(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1050 <fputc@plt>
lea    -0x1010(%rbp),%rdi
call   1040 <dumporder@plt>
xor    %eax,%eax
add    $0x1020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1008,%rsp
mov    %rsp,%rbx
mov    $0x1000,%edx
mov    %rbx,%rdi
mov    $0xff,%esi
call   1050 <memset@plt>
movl   $0x0,(%rsp)
mov    %rbx,%rdi
call   1030 <next_pixel@plt>
test   %eax,%eax
js     1242 <main+0xd2>
mov    %eax,%ebp
mov    $0x2,%ebx
mov    0x2e25(%rip),%r13
mov    %rsp,%r15
jmp    11d1 <main+0x61>
mov    %r15,%rdi
call   1030 <next_pixel@plt>
mov    %eax,%ebp
add    $0x1,%ebx
test   %eax,%eax
js     1234 <main+0xc4>
lea    -0x1(%rbx),%r14d
mov    %ebx,%eax
mov    $0xcccccccd,%ecx
imul   %rcx,%rax
shr    $0x23,%rax
add    %eax,%eax
lea    (%rax,%rax,4),%r12d
xor    %edi,%edi
cmp    $0x400,%r14d
setb   %dil
call   1070 <assert@plt>
mov    %ebp,%ebp
mov    (%rsp,%rbp,4),%edi
shr    $0x1f,%edi
call   1070 <assert@plt>
mov    %r14d,(%rsp,%rbp,4)
cmp    %r12d,%ebx
jne    11c0 <main+0x50>
mov    0x0(%r13),%edi
lea    0xde3(%rip),%rsi
mov    %ebx,%edx
mov    $0x400,%ecx
call   1080 <fprintf@plt>
mov    0x0(%r13),%edi
call   1090 <fflush@plt>
jmp    11c0 <main+0x50>
xor    %edi,%edi
cmp    $0x401,%ebx
sete   %dil
jmp    1244 <main+0xd4>
xor    %edi,%edi
call   1070 <assert@plt>
mov    0x2d90(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1060 <fputc@plt>
mov    %rsp,%rdi
call   1040 <dumporder@plt>
xor    %eax,%eax
add    $0x1008,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [9 x i8] c"\0D%4d/%4d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1024 x i32]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
br label %5
5: ; preds = %12, %0
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 1024
br i1 %7, label %8, label %15
8: ; preds = %5
%9 = load i32, i32* %3
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [1024 x i32], [1024 x i32]* %2, i64 0, i64 %10
store i32 -1, i32* %11
br label %12
12: ; preds = %8
%13 = load i32, i32* %3
%14 = add nsw i32 %13, 1
store i32 %14, i32* %3
br label %5
15: ; preds = %5
%16 = getelementptr inbounds [1024 x i32], [1024 x i32]* %2, i64 0, i64 0
store i32 0, i32* %16
store i32 1, i32* %4
br label %17
17: ; preds = %48, %15
%18 = getelementptr inbounds [1024 x i32], [1024 x i32]* %2, i64 0, i64 0
%19 = call i32 @next_pixel(i32* %18)
store i32 %19, i32* %3
%20 = icmp sge i32 %19, 0
br i1 %20, label %21, label %49
21: ; preds = %17
%22 = load i32, i32* %4
%23 = icmp slt i32 %22, 1024
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
%26 = load i32, i32* %3
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [1024 x i32], [1024 x i32]* %2, i64 0, i64 %27
%29 = load i32, i32* %28
%30 = icmp slt i32 %29, 0
%31 = zext i1 %30 to i32
%32 = call i32 @assert(i32 %31)
%33 = load i32, i32* %4
%34 = load i32, i32* %3
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [1024 x i32], [1024 x i32]* %2, i64 0, i64 %35
store i32 %33, i32* %36
%37 = load i32, i32* %4
%38 = add nsw i32 %37, 1
store i32 %38, i32* %4
%39 = load i32, i32* %4
%40 = srem i32 %39, 10
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %48
42: ; preds = %21
%43 = load i32, i32* @stderr
%44 = load i32, i32* %4
%45 = call i32 @fprintf(i32 %43, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %44, i32 1024)
%46 = load i32, i32* @stderr
%47 = call i32 @fflush(i32 %46)
br label %48
48: ; preds = %42, %21
br label %17
49: ; preds = %17
%50 = load i32, i32* %4
%51 = icmp eq i32 %50, 1024
%52 = zext i1 %51 to i32
%53 = call i32 @assert(i32 %52)
%54 = load i32, i32* @stderr
%55 = call i32 @fputc(i8 signext 10, i32 %54)
%56 = getelementptr inbounds [1024 x i32], [1024 x i32]* %2, i64 0, i64 0
%57 = call i32 @dumporder(i32* %56)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [9 x i8] c"\0D%4d/%4d\00"
define i32 @main() {
%1 = alloca [1024 x i32]
%2 = bitcast [1024 x i32]* %1 to i8*
%3 = getelementptr inbounds [1024 x i32], [1024 x i32]* %1, i64 0, i64 0
store i32 0, i32* %3
%4 = call i32 @next_pixel(i32* %3)
%5 = icmp sgt i32 %4, -1
br i1 %5, label %6, label %31
6: ; preds = %0, %25
%7 = phi i32 [ %26, %25 ], [ %4, %0 ]
%8 = phi i32 [ %17, %25 ], [ 1, %0 ]
%9 = icmp ult i32 %8, 1024
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = zext i32 %7 to i64
%13 = getelementptr inbounds [1024 x i32], [1024 x i32]* %1, i64 0, i64 %12
%14 = load i32, i32* %13
%15 = lshr i32 %14, 31
%16 = call i32 @assert(i32 %15)
store i32 %8, i32* %13
%17 = add nuw nsw i32 %8, 1
%18 = urem i32 %17, 10
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %6
%21 = load i32, i32* @stderr
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %17, i32 1024)
%23 = load i32, i32* @stderr
%24 = call i32 @fflush(i32 %23)
br label %25
25: ; preds = %20, %6
%26 = call i32 @next_pixel(i32* %3)
%27 = icmp sgt i32 %26, -1
br i1 %27, label %6, label %28
28: ; preds = %25
%29 = icmp eq i32 %17, 1024
%30 = zext i1 %29 to i32
br label %31
31: ; preds = %28, %0
%32 = phi i32 [ 0, %0 ], [ %30, %28 ]
%33 = call i32 @assert(i32 %32)
%34 = load i32, i32* @stderr
%35 = call i32 @fputc(i8 signext 10, i32 %34)
%36 = call i32 @dumporder(i32* %3)
ret i32 0
}