#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 atoi(char *);
int /*<<< orphan*/ buildmsgtable(char **);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
char *getErrString(int);
scalar_t__ isdigit(char);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ printmsgs(char **, char *);
int /*<<< orphan*/ stdin;
char *strchr(char *, char);
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  int err;
  int i;
  char s[10 + 2];
  char *tok;
  char *errstr;
  char *msgs[255 + 1];
  if (argc > 1 && strcmp(argv[1], "-h") == 0) {
    printf("USAGE: %s [<errno> ...]\n", argv[0]);
    return 0;
  }
  if (argc > 1) {
    for (i = 1; i < argc; i++) {
      if (isdigit(argv[i][0])) {
        err = atoi(argv[i]);
        printf("errno %d: %s\n", err, getErrString(err));
      } else {
        buildmsgtable(msgs);
        printmsgs(msgs, argv[i]);
      }
    }
  } else {
    buildmsgtable(msgs);
    do {
      printf("errno? ");
      fgets(s, 10, stdin);
      if (isdigit(s[0])) {
        err = atoi(s);
        if (err > 0)
          printf("errno %d: %s\n", err, getErrString(err));
      } else {
        tok = strchr(s, '\r');
        if (tok != NULL)
          *tok = '\0';
        tok = strchr(s, '\n');
        if (tok != NULL)
          *tok = '\0';
        printmsgs(msgs, s);
      }
    } while (err > 0);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x850,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11f2 <main+0x62>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe3e(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    11f2 <main+0x62>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    13a4 <main+0x214>
cmpl   $0x1,-0x8(%rbp)
jle    12aa <main+0x11a>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12a5 <main+0x115>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     126e <main+0xde>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x844(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <getErrString@plt>
mov    -0x844(%rbp),%esi
mov    %rax,%rdx
lea    0xdba(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1292 <main+0x102>
lea    -0x840(%rbp),%rdi
call   10a0 <buildmsgtable@plt>
lea    -0x840(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1090 <printmsgs@plt>
jmp    1297 <main+0x107>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1203 <main+0x73>
jmp    139d <main+0x20d>
lea    -0x840(%rbp),%rdi
call   10a0 <buildmsgtable@plt>
lea    0xd6d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x24(%rbp),%rdi
mov    0x2d19(%rip),%rax
mov    (%rax),%edx
mov    $0xa,%esi
call   1070 <fgets@plt>
movsbl -0x24(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     1331 <main+0x1a1>
lea    -0x24(%rbp),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    132c <main+0x19c>
mov    -0x14(%rbp),%eax
mov    %eax,-0x848(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <getErrString@plt>
mov    -0x848(%rbp),%esi
mov    %rax,%rdx
lea    0xcf7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1389 <main+0x1f9>
lea    -0x24(%rbp),%rdi
mov    $0xd,%esi
call   1050 <strchr@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     1355 <main+0x1c5>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x24(%rbp),%rdi
mov    $0xa,%esi
call   1050 <strchr@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     1379 <main+0x1e9>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x840(%rbp),%rdi
lea    -0x24(%rbp),%rsi
call   1090 <printmsgs@plt>
jmp    138e <main+0x1fe>
cmpl   $0x0,-0x14(%rbp)
jg     12b6 <main+0x126>
jmp    139d <main+0x20d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x850,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x818,%rsp
cmp    $0x2,%edi
jl     1238 <main+0xa8>
mov    %rsi,%r13
mov    %edi,%ebp
mov    0x8(%rsi),%rdi
lea    0xe46(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1300 <main+0x170>
mov    %ebp,%r12d
mov    $0x1,%ebx
lea    0x10(%rsp),%r14
lea    0xe40(%rip),%r15
jmp    1202 <main+0x72>
xchg   %ax,%ax
mov    %r14,%rdi
call   10a0 <buildmsgtable@plt>
mov    0x0(%r13,%rbx,8),%rsi
mov    %r14,%rdi
call   1090 <printmsgs@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
je     1312 <main+0x182>
mov    0x0(%r13,%rbx,8),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     11e0 <main+0x50>
mov    0x0(%r13,%rbx,8),%rdi
call   10b0 <atoi@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1040 <getErrString@plt>
mov    %r15,%rdi
mov    %ebp,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
jmp    11f5 <main+0x65>
lea    0x10(%rsp),%r14
mov    %r14,%rdi
call   10a0 <buildmsgtable@plt>
lea    0xdde(%rip),%r15
mov    0x2d95(%rip),%r13
lea    0x4(%rsp),%rbx
lea    0xdbd(%rip),%r12
jmp    127b <main+0xeb>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1090 <printmsgs@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x0(%r13),%edx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1070 <fgets@plt>
movsbl 0x4(%rsp),%edi
call   1030 <isdigit@plt>
mov    %rbx,%rdi
test   %rax,%rax
je     12d0 <main+0x140>
call   10b0 <atoi@plt>
test   %eax,%eax
jle    1312 <main+0x182>
mov    %eax,%ebp
mov    %eax,%edi
call   1040 <getErrString@plt>
mov    %r12,%rdi
mov    %ebp,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
jmp    127b <main+0xeb>
nopl   0x0(%rax,%rax,1)
mov    $0xd,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     12e2 <main+0x152>
movb   $0x0,(%rax)
mov    %rbx,%rdi
mov    $0xa,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     1270 <main+0xe0>
movb   $0x0,(%rax)
jmp    1270 <main+0xe0>
mov    0x0(%r13),%rsi
lea    0xcf8(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x818,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"-h\00"
@.str.1 = [25 x i8] c"USAGE: %s [<errno> ...]\0A\00"
@.str.2 = [14 x i8] c"errno %d: %s\0A\00"
@.str.3 = [8 x i8] c"errno? \00"
@stdin = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [12 x i8]
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca [256 x i8*]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp sgt i32 %12, 1
br i1 %13, label %14, label %25
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %14
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 0
%23 = load i8*, i8** %22
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %23)
store i32 0, i32* %3
br label %116
25: ; preds = %14, %2
%26 = load i32, i32* %4
%27 = icmp sgt i32 %26, 1
br i1 %27, label %28, label %69
28: ; preds = %25
store i32 1, i32* %7
br label %29
29: ; preds = %65, %28
%30 = load i32, i32* %7
%31 = load i32, i32* %4
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %68
33: ; preds = %29
%34 = load i8**, i8*** %5
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8*, i8** %34, i64 %36
%38 = load i8*, i8** %37
%39 = getelementptr inbounds i8, i8* %38, i64 0
%40 = load i8, i8* %39
%41 = call i64 @isdigit(i8 signext %40)
%42 = icmp ne i64 %41, 0
br i1 %42, label %43, label %54
43: ; preds = %33
%44 = load i8**, i8*** %5
%45 = load i32, i32* %7
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8*, i8** %44, i64 %46
%48 = load i8*, i8** %47
%49 = call i32 @atoi(i8* %48)
store i32 %49, i32* %6
%50 = load i32, i32* %6
%51 = load i32, i32* %6
%52 = call i8* @getErrString(i32 %51)
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %50, i8* %52)
br label %64
54: ; preds = %33
%55 = getelementptr inbounds [256 x i8*], [256 x i8*]* %11, i64 0, i64 0
%56 = call i32 @buildmsgtable(i8** %55)
%57 = getelementptr inbounds [256 x i8*], [256 x i8*]* %11, i64 0, i64 0
%58 = load i8**, i8*** %5
%59 = load i32, i32* %7
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8*, i8** %58, i64 %60
%62 = load i8*, i8** %61
%63 = call i32 @printmsgs(i8** %57, i8* %62)
br label %64
64: ; preds = %54, %43
br label %65
65: ; preds = %64
%66 = load i32, i32* %7
%67 = add nsw i32 %66, 1
store i32 %67, i32* %7
br label %29
68: ; preds = %29
br label %115
69: ; preds = %25
%70 = getelementptr inbounds [256 x i8*], [256 x i8*]* %11, i64 0, i64 0
%71 = call i32 @buildmsgtable(i8** %70)
br label %72
72: ; preds = %111, %69
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%74 = getelementptr inbounds [12 x i8], [12 x i8]* %8, i64 0, i64 0
%75 = load i32, i32* @stdin
%76 = call i32 @fgets(i8* %74, i32 10, i32 %75)
%77 = getelementptr inbounds [12 x i8], [12 x i8]* %8, i64 0, i64 0
%78 = load i8, i8* %77
%79 = call i64 @isdigit(i8 signext %78)
%80 = icmp ne i64 %79, 0
br i1 %80, label %81, label %92
81: ; preds = %72
%82 = getelementptr inbounds [12 x i8], [12 x i8]* %8, i64 0, i64 0
%83 = call i32 @atoi(i8* %82)
store i32 %83, i32* %6
%84 = load i32, i32* %6
%85 = icmp sgt i32 %84, 0
br i1 %85, label %86, label %91
86: ; preds = %81
%87 = load i32, i32* %6
%88 = load i32, i32* %6
%89 = call i8* @getErrString(i32 %88)
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %87, i8* %89)
br label %91
91: ; preds = %86, %81
br label %110
92: ; preds = %72
%93 = getelementptr inbounds [12 x i8], [12 x i8]* %8, i64 0, i64 0
%94 = call i8* @strchr(i8* %93, i8 signext 13)
store i8* %94, i8** %9
%95 = load i8*, i8** %9
%96 = icmp ne i8* %95, null
br i1 %96, label %97, label %99
97: ; preds = %92
%98 = load i8*, i8** %9
store i8 0, i8* %98
br label %99
99: ; preds = %97, %92
%100 = getelementptr inbounds [12 x i8], [12 x i8]* %8, i64 0, i64 0
%101 = call i8* @strchr(i8* %100, i8 signext 10)
store i8* %101, i8** %9
%102 = load i8*, i8** %9
%103 = icmp ne i8* %102, null
br i1 %103, label %104, label %106
104: ; preds = %99
%105 = load i8*, i8** %9
store i8 0, i8* %105
br label %106
106: ; preds = %104, %99
%107 = getelementptr inbounds [256 x i8*], [256 x i8*]* %11, i64 0, i64 0
%108 = getelementptr inbounds [12 x i8], [12 x i8]* %8, i64 0, i64 0
%109 = call i32 @printmsgs(i8** %107, i8* %108)
br label %110
110: ; preds = %106, %91
br label %111
111: ; preds = %110
%112 = load i32, i32* %6
%113 = icmp sgt i32 %112, 0
br i1 %113, label %72, label %114
114: ; preds = %111
br label %115
115: ; preds = %114, %68
store i32 0, i32* %3
br label %116
116: ; preds = %115, %20
%117 = load i32, i32* %3
ret i32 %117
}

LLVM IR (-O2):
@.str = [3 x i8] c"-h\00"
@.str.1 = [25 x i8] c"USAGE: %s [<errno> ...]\0A\00"
@.str.2 = [14 x i8] c"errno %d: %s\0A\00"
@.str.3 = [8 x i8] c"errno? \00"
@stdin = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [12 x i8]
%4 = alloca [256 x i8*]
%5 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 0
%6 = bitcast [256 x i8*]* %4 to i8*
%7 = icmp sgt i32 %0, 1
br i1 %7, label %8, label %38
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 ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %8
%14 = getelementptr inbounds [256 x i8*], [256 x i8*]* %4, i64 0, i64 0
%15 = zext i32 %0 to i64
br label %19
16: ; preds = %8
%17 = load i8*, i8** %1
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %17)
br label %65
19: ; preds = %13, %35
%20 = phi i64 [ 1, %13 ], [ %36, %35 ]
%21 = getelementptr inbounds i8*, i8** %1, i64 %20
%22 = load i8*, i8** %21
%23 = load i8, i8* %22
%24 = call i64 @isdigit(i8 signext %23)
%25 = icmp eq i64 %24, 0
br i1 %25, label %31, label %26
26: ; preds = %19
%27 = load i8*, i8** %21
%28 = call i32 @atoi(i8* %27)
%29 = call i8* @getErrString(i32 %28)
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %28, i8* %29)
br label %35
31: ; preds = %19
%32 = call i32 @buildmsgtable(i8** %14)
%33 = load i8*, i8** %21
%34 = call i32 @printmsgs(i8** %14, i8* %33)
br label %35
35: ; preds = %26, %31
%36 = add nuw nsw i64 %20, 1
%37 = icmp eq i64 %36, %15
br i1 %37, label %65, label %19
38: ; preds = %2
%39 = getelementptr inbounds [256 x i8*], [256 x i8*]* %4, i64 0, i64 0
%40 = call i32 @buildmsgtable(i8** %39)
br label %41
41: ; preds = %64, %38
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%43 = load i32, i32* @stdin
%44 = call i32 @fgets(i8* %5, i32 10, i32 %43)
%45 = load i8, i8* %5
%46 = call i64 @isdigit(i8 signext %45)
%47 = icmp eq i64 %46, 0
br i1 %47, label %54, label %48
48: ; preds = %41
%49 = call i32 @atoi(i8* %5)
%50 = icmp sgt i32 %49, 0
br i1 %50, label %51, label %65
51: ; preds = %48
%52 = call i8* @getErrString(i32 %49)
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %49, i8* %52)
br label %64
54: ; preds = %41
%55 = call i8* @strchr(i8* %5, i8 signext 13)
%56 = icmp eq i8* %55, null
br i1 %56, label %58, label %57
57: ; preds = %54
store i8 0, i8* %55
br label %58
58: ; preds = %57, %54
%59 = call i8* @strchr(i8* %5, i8 signext 10)
%60 = icmp eq i8* %59, null
br i1 %60, label %62, label %61
61: ; preds = %58
store i8 0, i8* %59
br label %62
62: ; preds = %61, %58
%63 = call i32 @printmsgs(i8** %39, i8* %5)
br label %64
64: ; preds = %62, %51
br label %41
65: ; preds = %48, %35, %16
ret i32 0
}