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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2ea8(%rip),%rcx
cmp    (%rcx),%eax
jge    117e <main+0x5e>
mov    -0x8(%rbp),%esi
mov    0x2ea6(%rip),%rax
mov    (%rax),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe9c(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1136 <main+0x16>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    0x2eb9(%rip),%r15
cmpl   $0x0,(%r15)
jle    1175 <main+0x55>
mov    0x2ebc(%rip),%r12
lea    0xebd(%rip),%r14
xor    %ebx,%ebx
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>
xor    %eax,%eax
call   1040 <getchar@plt>
add    $0x1,%rbx
movslq (%r15),%rax
cmp    %rax,%rbx
jl     1150 <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 = [15 x i8] c"Error: %d, %s\0A\00"
@sys_errlist = global i8** null
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
br label %3
3: ; preds = %16, %0
%4 = load i32, i32* %2
%5 = load i32, i32* @sys_nerr
%6 = icmp slt i32 %4, %5
br i1 %6, label %7, label %19
7: ; preds = %3
%8 = load i32, i32* %2
%9 = load i8**, i8*** @sys_errlist
%10 = load i32, i32* %2
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8*, i8** %9, i64 %11
%13 = load i8*, i8** %12
%14 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %8, i8* %13)
%15 = call i32 (...) @getchar()
br label %16
16: ; preds = %7
%17 = load i32, i32* %2
%18 = add nsw i32 %17, 1
store i32 %18, i32* %2
br label %3
19: ; preds = %3
%20 = load i32, i32* %1
ret i32 %20
}

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