#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 */
unsigned long error_message(int);
int /*<<< orphan*/ printf(char *, ...);
void main() {
  int i, j;
  unsigned long err_string;
  for (i = 0; i < 800; ++i) {
    j = i % 2 ? i : -i;
    err_string = error_message(j);
    printf("%5d: ", j);
    if (!err_string) {
      printf("Unknown error\n");
    } else {
      printf("%ls\n", err_string);
    }
  }
  for (i = 0; i < 800; ++i) {
    j = i % 2 ? -i : i;
    err_string = error_message(j);
    printf("%5d: ", j);
    if (!err_string) {
      printf("Unknown error\n");
    } else {
      printf("%ls\n", err_string);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
cmpl   $0x320,-0x4(%rbp)
jge    11c9 <main+0xa9>
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     115b <main+0x3b>
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1163 <main+0x43>
xor    %eax,%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <error_message@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpq   $0x0,-0x10(%rbp)
jne    11a4 <main+0x84>
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b6 <main+0x96>
mov    -0x10(%rbp),%rsi
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11bb <main+0x9b>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    112f <main+0xf>
movl   $0x0,-0x4(%rbp)
cmpl   $0x320,-0x4(%rbp)
jge    126a <main+0x14a>
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11fe <main+0xde>
xor    %eax,%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1204 <main+0xe4>
mov    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <error_message@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%esi
lea    0xde0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpq   $0x0,-0x10(%rbp)
jne    1245 <main+0x125>
lea    0xdcd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1257 <main+0x137>
mov    -0x10(%rbp),%rsi
lea    0xdc5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    125c <main+0x13c>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11d0 <main+0xb0>
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    0xebe(%rip),%r12
lea    0xebd(%rip),%r15
xor    %ebx,%ebx
xor    %r14d,%r14d
jmp    116c <main+0x3c>
mov    %r15,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r14d
add    $0xffffffff,%ebx
cmp    $0xfffffce0,%ebx
je     119f <main+0x6f>
test   $0x1,%r14b
mov    %r14d,%ebp
cmove  %ebx,%ebp
mov    %ebp,%edi
call   1050 <error_message@plt>
mov    %rax,%r13
mov    %r12,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r13,%r13
jne    1150 <main+0x20>
lea    0xe73(%rip),%rdi
call   1030 <puts@plt>
jmp    115d <main+0x2d>
lea    0xe5a(%rip),%r12
lea    0xe59(%rip),%r15
xor    %ebx,%ebx
xor    %r14d,%r14d
jmp    11dc <main+0xac>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r14d
add    $0xffffffff,%ebx
cmp    $0xfffffce0,%ebx
je     120f <main+0xdf>
test   $0x1,%r14b
mov    %ebx,%ebp
cmove  %r14d,%ebp
mov    %ebp,%edi
call   1050 <error_message@plt>
mov    %rax,%r13
mov    %r12,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r13,%r13
jne    11c0 <main+0x90>
lea    0xe03(%rip),%rdi
call   1030 <puts@plt>
jmp    11cd <main+0x9d>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%5d: \00"
@.str.1 = [15 x i8] c"Unknown error\0A\00"
@.str.2 = [5 x i8] c"%ls\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i64
store i32 0, i32* %1
br label %4
4: ; preds = %30, %0
%5 = load i32, i32* %1
%6 = icmp slt i32 %5, 800
br i1 %6, label %7, label %33
7: ; preds = %4
%8 = load i32, i32* %1
%9 = srem i32 %8, 2
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = load i32, i32* %1
br label %16
13: ; preds = %7
%14 = load i32, i32* %1
%15 = sub nsw i32 0, %14
br label %16
16: ; preds = %13, %11
%17 = phi i32 [ %12, %11 ], [ %15, %13 ]
store i32 %17, i32* %2
%18 = load i32, i32* %2
%19 = call i64 @error_message(i32 %18)
store i64 %19, i64* %3
%20 = load i32, i32* %2
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %20)
%22 = load i64, i64* %3
%23 = icmp ne i64 %22, 0
br i1 %23, label %26, label %24
24: ; preds = %16
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %29
26: ; preds = %16
%27 = load i64, i64* %3
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %27)
br label %29
29: ; preds = %26, %24
br label %30
30: ; preds = %29
%31 = load i32, i32* %1
%32 = add nsw i32 %31, 1
store i32 %32, i32* %1
br label %4
33: ; preds = %4
store i32 0, i32* %1
br label %34
34: ; preds = %60, %33
%35 = load i32, i32* %1
%36 = icmp slt i32 %35, 800
br i1 %36, label %37, label %63
37: ; preds = %34
%38 = load i32, i32* %1
%39 = srem i32 %38, 2
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %37
%42 = load i32, i32* %1
%43 = sub nsw i32 0, %42
br label %46
44: ; preds = %37
%45 = load i32, i32* %1
br label %46
46: ; preds = %44, %41
%47 = phi i32 [ %43, %41 ], [ %45, %44 ]
store i32 %47, i32* %2
%48 = load i32, i32* %2
%49 = call i64 @error_message(i32 %48)
store i64 %49, i64* %3
%50 = load i32, i32* %2
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %50)
%52 = load i64, i64* %3
%53 = icmp ne i64 %52, 0
br i1 %53, label %56, label %54
54: ; preds = %46
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %59
56: ; preds = %46
%57 = load i64, i64* %3
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %57)
br label %59
59: ; preds = %56, %54
br label %60
60: ; preds = %59
%61 = load i32, i32* %1
%62 = add nsw i32 %61, 1
store i32 %62, i32* %1
br label %34
63: ; preds = %34
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%5d: \00"
@.str.2 = [5 x i8] c"%ls\0A\00"
@str.3 = [14 x i8] c"Unknown error\00"
define void @main() {
br label %1
1: ; preds = %0, %14
%2 = phi i32 [ 0, %0 ], [ %15, %14 ]
%3 = and i32 %2, 1
%4 = icmp eq i32 %3, 0
%5 = sub nsw i32 0, %2
%6 = select i1 %4, i32 %5, i32 %2
%7 = tail call i64 @error_message(i32 %6)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %6)
%9 = icmp eq i64 %7, 0
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.3, i64 0, i64 0))
br label %14
12: ; preds = %1
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %7)
br label %14
14: ; preds = %10, %12
%15 = add nuw nsw i32 %2, 1
%16 = icmp eq i32 %15, 800
br i1 %16, label %17, label %1
17: ; preds = %14, %30
%18 = phi i32 [ %31, %30 ], [ 0, %14 ]
%19 = and i32 %18, 1
%20 = icmp eq i32 %19, 0
%21 = sub nsw i32 0, %18
%22 = select i1 %20, i32 %18, i32 %21
%23 = tail call i64 @error_message(i32 %22)
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %22)
%25 = icmp eq i64 %23, 0
br i1 %25, label %26, label %28
26: ; preds = %17
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.3, i64 0, i64 0))
br label %30
28: ; preds = %17
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %23)
br label %30
30: ; preds = %26, %28
%31 = add nuw nsw i32 %18, 1
%32 = icmp eq i32 %31, 800
br i1 %32, label %33, label %17
33: ; preds = %30
ret void
}