#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 **sys_errlist;
int sys_nerr;
main(int argc, char **argv) {
  int i;
  for (i = 0; i < sys_nerr; i++)
    printf("%d: %s\n", i, sys_errlist[i]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2eb1(%rip),%rcx
cmp    (%rcx),%eax
jge    116e <main+0x5e>
mov    -0x14(%rbp),%esi
mov    0x2eaf(%rip),%rax
mov    (%rax),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xea5(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    112d <main+0x1d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    0x2ec9(%rip),%r15
cmpl   $0x0,(%r15)
jle    115e <main+0x4e>
xor    %ebx,%ebx
mov    0x2eca(%rip),%r12
lea    0xecb(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r12),%rax
mov    (%rax,%rbx,8),%rdx
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
add    $0x1,%rbx
movslq (%r15),%rax
cmp    %rax,%rbx
jl     1140 <main+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@sys_nerr = global i32 0
@.str = [8 x i8] c"%d: %s\0A\00"
@sys_errlist = global i8** null
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @sys_nerr
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %16
5: ; preds = %2, %5
%6 = phi i64 [ %12, %5 ], [ 0, %2 ]
%7 = load i8**, i8*** @sys_errlist
%8 = getelementptr inbounds i8*, i8** %7, i64 %6
%9 = load i8*, i8** %8
%10 = trunc i64 %6 to i32
%11 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %10, i8* %9)
%12 = add nuw nsw i64 %6, 1
%13 = load i32, i32* @sys_nerr
%14 = sext i32 %13 to i64
%15 = icmp slt i64 %12, %14
br i1 %15, label %5, label %16
16: ; preds = %5, %2
ret i32 0
}