#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 *, ...);
char *strerror(int);
int sys_nerr;
int main(int argc, char *argv[]) {
  int i;
  printf("Dump errno\n");
  for (i = 0; i < sys_nerr; i++)
    printf("error #%d:%s\n", i, strerror(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)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e9b(%rip),%rcx
cmp    (%rcx),%eax
jge    118d <main+0x6d>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <strerror@plt>
mov    -0x18(%rbp),%esi
mov    %rax,%rdx
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114b <main+0x2b>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
lea    0xed3(%rip),%rdi
call   1030 <puts@plt>
mov    0x2ea9(%rip),%r14
cmpl   $0x0,(%r14)
jle    117e <main+0x4e>
lea    0xeac(%rip),%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
mov    %ebp,%edi
call   1050 <strerror@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    (%r14),%ebp
jl     1160 <main+0x30>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"Dump errno\0A\00"
@sys_nerr = global i32 0
@.str.1 = [14 x i8] c"error #%d:%s\0A\00"
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
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %6
br label %8
8: ; preds = %17, %2
%9 = load i32, i32* %6
%10 = load i32, i32* @sys_nerr
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %20
12: ; preds = %8
%13 = load i32, i32* %6
%14 = load i32, i32* %6
%15 = call i8* @strerror(i32 %14)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %13, i8* %15)
br label %17
17: ; preds = %12
%18 = load i32, i32* %6
%19 = add nsw i32 %18, 1
store i32 %19, i32* %6
br label %8
20: ; preds = %8
ret i32 0
}

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