#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, char *);
char *strerror(int);
int /*<<< orphan*/ *strstr(char *, char *);
int main(void) {
  char *errstr;
  int n = 0;
  for (n = 0; n < 4096; n++) {
    errstr = strerror(n);
    if (strstr(errstr, "Unknown") == NULL)
      printf("[%04d]: %s\n", n, errstr);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x1000,-0x14(%rbp)
jge    11a6 <main+0x76>
mov    -0x14(%rbp),%edi
call   1040 <strerror@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe8f(%rip),%rsi
call   1050 <strstr@plt>
cmp    $0x0,%rax
jne    1193 <main+0x63>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%rdx
lea    0xe7a(%rip),%rdi
call   1030 <printf@plt>
jmp    1198 <main+0x68>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114d <main+0x1d>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
xor    %ebx,%ebx
lea    0xebf(%rip),%r14
lea    0xec0(%rip),%r15
jmp    115b <main+0x2b>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebx
cmp    $0x1000,%ebx
je     1184 <main+0x54>
mov    %ebx,%edi
call   1040 <strerror@plt>
mov    %rax,%r12
mov    %rax,%rdi
mov    %r14,%rsi
call   1050 <strstr@plt>
test   %rax,%rax
jne    1150 <main+0x20>
mov    %r15,%rdi
mov    %ebx,%esi
mov    %r12,%rdx
call   1030 <printf@plt>
jmp    1150 <main+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [8 x i8] c"Unknown\00"
@.str.1 = [12 x i8] c"[%04d]: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %3
br label %4
4: ; preds = %18, %0
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 4096
br i1 %6, label %7, label %21
7: ; preds = %4
%8 = load i32, i32* %3
%9 = call i8* @strerror(i32 %8)
store i8* %9, i8** %2
%10 = load i8*, i8** %2
%11 = call i32* @strstr(i8* %10, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %17
13: ; preds = %7
%14 = load i32, i32* %3
%15 = load i8*, i8** %2
%16 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %14, i8* %15)
br label %17
17: ; preds = %13, %7
br label %18
18: ; preds = %17
%19 = load i32, i32* %3
%20 = add nsw i32 %19, 1
store i32 %20, i32* %3
br label %4
21: ; preds = %4
%22 = load i32, i32* %1
ret i32 %22
}

LLVM IR (-O2):
@.str = [8 x i8] c"Unknown\00"
@.str.1 = [12 x i8] c"[%04d]: %s\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %8
%2 = phi i32 [ 0, %0 ], [ %9, %8 ]
%3 = tail call i8* @strerror(i32 %2)
%4 = tail call i32* @strstr(i8* dereferenceable(1) %3, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %2, i8* %3)
br label %8
8: ; preds = %1, %6
%9 = add nuw nsw i32 %2, 1
%10 = icmp eq i32 %9, 4096
br i1 %10, label %11, label %1
11: ; preds = %8
ret i32 0
}