#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 */
typedef int /*<<< orphan*/ BIO;

/* Variables and functions */
int /*<<< orphan*/ BIO_NOCLOSE;
int /*<<< orphan*/ BIO_free_all(int /*<<< orphan*/ *);
int /*<<< orphan*/ *BIO_new(int /*<<< orphan*/);
int /*<<< orphan*/ BIO_s_file();
scalar_t__ BIO_set_fp(int /*<<< orphan*/ *, int /*<<< orphan*/,
                      int /*<<< orphan*/);
int /*<<< orphan*/ ERR_error_string_n(unsigned long, char *, int);
int /*<<< orphan*/ ERR_get_string_table();
int /*<<< orphan*/ lh_ERR_STRING_DATA_node_stats_bio(int /*<<< orphan*/,
                                                     int /*<<< orphan*/ *);
int /*<<< orphan*/
lh_ERR_STRING_DATA_node_usage_stats_bio(int /*<<< orphan*/,
                                        int /*<<< orphan*/ *);
int /*<<< orphan*/ lh_ERR_STRING_DATA_stats_bio(int /*<<< orphan*/,
                                                int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ sscanf(char *, char *, unsigned long *);
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char *, char *);
int errstr_main(int argc, char **argv) {
  int i, ret = 0;
  char buf[256];
  unsigned long l;
  if ((argc > 1) && (strcmp(argv[1], "-stats") == 0)) {
    BIO *out = NULL;
    out = BIO_new(BIO_s_file());
    if ((out != NULL) && BIO_set_fp(out, stdout, BIO_NOCLOSE)) {
      lh_ERR_STRING_DATA_node_stats_bio(ERR_get_string_table(), out);
      lh_ERR_STRING_DATA_stats_bio(ERR_get_string_table(), out);
      lh_ERR_STRING_DATA_node_usage_stats_bio(ERR_get_string_table(), out);
    }
    if (out != NULL)
      BIO_free_all(out);
    argc--;
    argv++;
  }
  for (i = 1; i < argc; i++) {
    if (sscanf(argv[i], "%lx", &l)) {
      ERR_error_string_n(l, buf, sizeof buf);
      printf("%s\n", buf);
    } else {
      printf("%s: bad error code\n", argv[i]);
      printf("usage: errstr [-stats] <errno> ...\n");
      ret++;
    }
  }
  return (ret);
}


x86 assembly (clang, -O0):
<errstr_main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x1,-0x4(%rbp)
jle    12c5 <errstr_main+0x105>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe0e(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    12c5 <errstr_main+0x105>
movq   $0x0,-0x130(%rbp)
mov    $0x0,%al
call   10e0 <BIO_s_file@plt>
mov    %eax,%edi
call   1080 <BIO_new@plt>
mov    %rax,-0x130(%rbp)
cmpq   $0x0,-0x130(%rbp)
je     1296 <errstr_main+0xd6>
mov    -0x130(%rbp),%rdi
mov    0x2d9b(%rip),%rax
mov    (%rax),%esi
mov    0x2da2(%rip),%rax
mov    (%rax),%edx
call   10a0 <BIO_set_fp@plt>
cmp    $0x0,%rax
je     1296 <errstr_main+0xd6>
mov    $0x0,%al
call   10d0 <ERR_get_string_table@plt>
mov    %eax,%edi
mov    -0x130(%rbp),%rsi
call   1030 <lh_ERR_STRING_DATA_node_stats_bio@plt>
mov    $0x0,%al
call   10d0 <ERR_get_string_table@plt>
mov    %eax,%edi
mov    -0x130(%rbp),%rsi
call   1050 <lh_ERR_STRING_DATA_stats_bio@plt>
mov    $0x0,%al
call   10d0 <ERR_get_string_table@plt>
mov    %eax,%edi
mov    -0x130(%rbp),%rsi
call   10c0 <lh_ERR_STRING_DATA_node_usage_stats_bio@plt>
cmpq   $0x0,-0x130(%rbp)
je     12b0 <errstr_main+0xf0>
mov    -0x130(%rbp),%rdi
call   10b0 <BIO_free_all@plt>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1377 <errstr_main+0x1b7>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd1c(%rip),%rsi
lea    -0x128(%rbp),%rdx
call   1090 <sscanf@plt>
cmp    $0x0,%rax
je     1333 <errstr_main+0x173>
mov    -0x128(%rbp),%rdi
lea    -0x120(%rbp),%rsi
mov    $0x100,%edx
call   1060 <ERR_error_string_n@plt>
lea    -0x120(%rbp),%rsi
lea    0xce4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1364 <errstr_main+0x1a4>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xcc9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xccf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1369 <errstr_main+0x1a9>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12cc <errstr_main+0x10c>
mov    -0x18(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<errstr_main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
movl   $0x0,0x4(%rsp)
cmp    $0x2,%edi
jl     131c <errstr_main+0x14c>
mov    %rsi,%rbx
mov    %edi,%r14d
mov    0x8(%rsi),%rdi
lea    0xdfd(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    129b <errstr_main+0xcb>
movl   $0x0,0x4(%rsp)
xor    %eax,%eax
call   10f0 <BIO_s_file@plt>
mov    %eax,%edi
call   1090 <BIO_new@plt>
test   %rax,%rax
je     1289 <errstr_main+0xb9>
mov    %rax,%rbp
mov    0x2da2(%rip),%rax
mov    (%rax),%esi
mov    0x2da9(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
call   10b0 <BIO_set_fp@plt>
test   %rax,%rax
je     1281 <errstr_main+0xb1>
xor    %eax,%eax
call   10e0 <ERR_get_string_table@plt>
mov    %eax,%edi
mov    %rbp,%rsi
call   1030 <lh_ERR_STRING_DATA_node_stats_bio@plt>
xor    %eax,%eax
call   10e0 <ERR_get_string_table@plt>
mov    %eax,%edi
mov    %rbp,%rsi
call   1060 <lh_ERR_STRING_DATA_stats_bio@plt>
xor    %eax,%eax
call   10e0 <ERR_get_string_table@plt>
mov    %eax,%edi
mov    %rbp,%rsi
call   10d0 <lh_ERR_STRING_DATA_node_usage_stats_bio@plt>
mov    %rbp,%rdi
call   10c0 <BIO_free_all@plt>
add    $0xffffffff,%r14d
cmp    $0x2,%r14d
jb     131c <errstr_main+0x14c>
add    $0x8,%rbx
mov    %r14d,%r13d
mov    $0x1,%r15d
lea    0xd5c(%rip),%r14
lea    0x8(%rsp),%rbp
lea    0x10(%rsp),%r12
movl   $0x0,0x4(%rsp)
jmp    12e3 <errstr_main+0x113>
nop
mov    0x8(%rsp),%rdi
mov    %r12,%rsi
mov    $0x100,%edx
call   1070 <ERR_error_string_n@plt>
mov    %r12,%rdi
call   1040 <puts@plt>
add    $0x1,%r15
cmp    %r15,%r13
je     131c <errstr_main+0x14c>
mov    (%rbx,%r15,8),%rdi
mov    %r14,%rsi
mov    %rbp,%rdx
call   10a0 <sscanf@plt>
test   %rax,%rax
jne    12c0 <errstr_main+0xf0>
mov    (%rbx,%r15,8),%rsi
lea    0xd09(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xd0f(%rip),%rdi
call   1040 <puts@plt>
addl   $0x1,0x4(%rsp)
jmp    12da <errstr_main+0x10a>
mov    0x4(%rsp),%eax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"-stats\00"
@stdout = global i32 0
@BIO_NOCLOSE = global i32 0
@.str.1 = [4 x i8] c"%lx\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [20 x i8] c"%s: bad error code\0A\00"
@.str.4 = [36 x i8] c"usage: errstr [-stats] <errno> ...\0A\00"
define i32 @errstr_main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca [256 x i8]
%8 = alloca i64
%9 = alloca i32*
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i32 0, i32* %6
%10 = load i32, i32* %3
%11 = icmp sgt i32 %10, 1
br i1 %11, label %12, label %50
12: ; preds = %2
%13 = load i8**, i8*** %4
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %50
18: ; preds = %12
store i32* null, i32** %9
%19 = call i32 (...) @BIO_s_file()
%20 = call i32* @BIO_new(i32 %19)
store i32* %20, i32** %9
%21 = load i32*, i32** %9
%22 = icmp ne i32* %21, null
br i1 %22, label %23, label %39
23: ; preds = %18
%24 = load i32*, i32** %9
%25 = load i32, i32* @stdout
%26 = load i32, i32* @BIO_NOCLOSE
%27 = call i64 @BIO_set_fp(i32* %24, i32 %25, i32 %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %39
29: ; preds = %23
%30 = call i32 (...) @ERR_get_string_table()
%31 = load i32*, i32** %9
%32 = call i32 @lh_ERR_STRING_DATA_node_stats_bio(i32 %30, i32* %31)
%33 = call i32 (...) @ERR_get_string_table()
%34 = load i32*, i32** %9
%35 = call i32 @lh_ERR_STRING_DATA_stats_bio(i32 %33, i32* %34)
%36 = call i32 (...) @ERR_get_string_table()
%37 = load i32*, i32** %9
%38 = call i32 @lh_ERR_STRING_DATA_node_usage_stats_bio(i32 %36, i32* %37)
br label %39
39: ; preds = %29, %23, %18
%40 = load i32*, i32** %9
%41 = icmp ne i32* %40, null
br i1 %41, label %42, label %45
42: ; preds = %39
%43 = load i32*, i32** %9
%44 = call i32 @BIO_free_all(i32* %43)
br label %45
45: ; preds = %42, %39
%46 = load i32, i32* %3
%47 = add nsw i32 %46, -1
store i32 %47, i32* %3
%48 = load i8**, i8*** %4
%49 = getelementptr inbounds i8*, i8** %48, i32 1
store i8** %49, i8*** %4
br label %50
50: ; preds = %45, %12, %2
store i32 1, i32* %5
br label %51
51: ; preds = %80, %50
%52 = load i32, i32* %5
%53 = load i32, i32* %3
%54 = icmp slt i32 %52, %53
br i1 %54, label %55, label %83
55: ; preds = %51
%56 = load i8**, i8*** %4
%57 = load i32, i32* %5
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8*, i8** %56, i64 %58
%60 = load i8*, i8** %59
%61 = call i64 @sscanf(i8* %60, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %8)
%62 = icmp ne i64 %61, 0
br i1 %62, label %63, label %69
63: ; preds = %55
%64 = load i64, i64* %8
%65 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%66 = call i32 @ERR_error_string_n(i64 %64, i8* %65, i32 256)
%67 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %67)
br label %79
69: ; preds = %55
%70 = load i8**, i8*** %4
%71 = load i32, i32* %5
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds i8*, i8** %70, i64 %72
%74 = load i8*, i8** %73
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8* %74)
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0))
%77 = load i32, i32* %6
%78 = add nsw i32 %77, 1
store i32 %78, i32* %6
br label %79
79: ; preds = %69, %63
br label %80
80: ; preds = %79
%81 = load i32, i32* %5
%82 = add nsw i32 %81, 1
store i32 %82, i32* %5
br label %51
83: ; preds = %51
%84 = load i32, i32* %6
ret i32 %84
}

LLVM IR (-O2):
@.str = [7 x i8] c"-stats\00"
@stdout = global i32 0
@BIO_NOCLOSE = global i32 0
@.str.1 = [4 x i8] c"%lx\00"
@.str.3 = [20 x i8] c"%s: bad error code\0A\00"
@str = [35 x i8] c"usage: errstr [-stats] <errno> ...\00"
define i32 @errstr_main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i8]
%4 = alloca i64
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = bitcast i64* %4 to i8*
%7 = icmp sgt i32 %0, 1
br i1 %7, label %8, label %58
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %34
13: ; preds = %8
%14 = tail call i32 (...) @BIO_s_file()
%15 = tail call i32* @BIO_new(i32 %14)
%16 = icmp eq i32* %15, null
br i1 %16, label %31, label %17
17: ; preds = %13
%18 = load i32, i32* @stdout
%19 = load i32, i32* @BIO_NOCLOSE
%20 = tail call i64 @BIO_set_fp(i32* %15, i32 %18, i32 %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %29, label %22
22: ; preds = %17
%23 = tail call i32 (...) @ERR_get_string_table()
%24 = tail call i32 @lh_ERR_STRING_DATA_node_stats_bio(i32 %23, i32* %15)
%25 = tail call i32 (...) @ERR_get_string_table()
%26 = tail call i32 @lh_ERR_STRING_DATA_stats_bio(i32 %25, i32* %15)
%27 = tail call i32 (...) @ERR_get_string_table()
%28 = tail call i32 @lh_ERR_STRING_DATA_node_usage_stats_bio(i32 %27, i32* %15)
br label %29
29: ; preds = %17, %22
%30 = tail call i32 @BIO_free_all(i32* %15)
br label %31
31: ; preds = %29, %13
%32 = add nsw i32 %0, -1
%33 = icmp ugt i32 %32, 1
br i1 %33, label %34, label %58
34: ; preds = %8, %31
%35 = phi i8** [ %9, %31 ], [ %1, %8 ]
%36 = phi i32 [ %32, %31 ], [ %0, %8 ]
%37 = zext i32 %36 to i64
br label %38
38: ; preds = %34, %54
%39 = phi i64 [ 1, %34 ], [ %56, %54 ]
%40 = phi i32 [ 0, %34 ], [ %55, %54 ]
%41 = getelementptr inbounds i8*, i8** %35, i64 %39
%42 = load i8*, i8** %41
%43 = call i64 @sscanf(i8* %42, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %4)
%44 = icmp eq i64 %43, 0
br i1 %44, label %49, label %45
45: ; preds = %38
%46 = load i64, i64* %4
%47 = call i32 @ERR_error_string_n(i64 %46, i8* %5, i32 256)
%48 = call i32 @puts(i8* %5)
br label %54
49: ; preds = %38
%50 = load i8*, i8** %41
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8* %50)
%52 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%53 = add nsw i32 %40, 1
br label %54
54: ; preds = %45, %49
%55 = phi i32 [ %40, %45 ], [ %53, %49 ]
%56 = add nuw nsw i64 %39, 1
%57 = icmp eq i64 %56, %37
br i1 %57, label %58, label %38
58: ; preds = %54, %2, %31
%59 = phi i32 [ 0, %31 ], [ 0, %2 ], [ %55, %54 ]
ret i32 %59
}