#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*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getopt(int, char **, char const *const);
char *optarg;
int optind;
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ set_log_level(char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ usage(char *);
void procargs(int argc, char **argv, char **cfg_files, const int cfg_files_max,
              int *cfg_count) {
  int opt;
  const char *const option_spec = "b:c:hl:";
  int cfg_i = 1;
  if ((argc == 2) && strcmp(argv[1], "-version") == 0) {
    printf("Standard Version: %s\nNBIS Non-Export Control Software Version: "
           "%s\n",
           "ANSI/NIST-ITL 1-2007", "Release 4.1.0");
    exit(EXIT_SUCCESS);
  }
  while ((opt = getopt(argc, argv, option_spec)) != -1) {
    switch (opt) {
    case 'b':
      if (1 != cfg_i) {
        fprintf(stderr, "Override the default configuration first, "
                        "before adding to it.\n");
      }
      cfg_files[0] = optarg;
      break;
    case 'c':
      if (cfg_i == cfg_files_max) {
        fprintf(stderr, "Too many configuration files, max=%d.\n",
                cfg_files_max);
        exit(EXIT_FAILURE);
      }
      cfg_files[cfg_i++] = optarg;
      break;
    case 'h':
      usage(argv[0]);
      break;
    case 'l':
      if (set_log_level(optarg) < 0) {
        exit(EXIT_FAILURE);
      }
      break;
    case '?':
      usage(argv[0]);
      break;
    default:
      fprintf(stderr,
              "Programming error: "
              "incompletely implemented option: '%c'.\n",
              opt);
      exit(EXIT_FAILURE);
    }
  }
  if (optind == argc) {
    usage(argv[0]);
  }
  *cfg_count = cfg_i;
}


x86 assembly (clang, -O0):
<procargs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
lea    0xf27(%rip),%rax
mov    %rax,-0x38(%rbp)
movl   $0x1,-0x3c(%rbp)
cmpl   $0x2,-0x4(%rbp)
jne    11ec <procargs+0x7c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xf0b(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11ec <procargs+0x7c>
lea    0xefe(%rip),%rdi
lea    0xf3a(%rip),%rsi
lea    0xf48(%rip),%rdx
call   1030 <printf@plt>
mov    0x2ddb(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
jmp    11f1 <procargs+0x81>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xeb9(%rip),%rdx
call   1080 <getopt@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0xffffffff,%eax
je     1347 <procargs+0x1d7>
mov    -0x2c(%rbp),%eax
add    $0xffffffc1,%eax
mov    %eax,%ecx
mov    %rcx,-0x48(%rbp)
sub    $0x2d,%eax
ja     131a <procargs+0x1aa>
mov    -0x48(%rbp),%rax
lea    0xdd0(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x1,%eax
cmp    -0x3c(%rbp),%eax
je     125e <procargs+0xee>
mov    0x2d82(%rip),%rax
mov    (%rax),%edi
lea    0xed8(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2d93(%rip),%rax
mov    (%rax),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    1342 <procargs+0x1d2>
mov    -0x3c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jne    12a8 <procargs+0x138>
mov    0x2d49(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%edx
lea    0xedc(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2d27(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    0x2d49(%rip),%rax
mov    (%rax),%rdx
mov    -0x18(%rbp),%rax
mov    -0x3c(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x3c(%rbp)
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
jmp    1342 <procargs+0x1d2>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <usage@plt>
jmp    1342 <procargs+0x1d2>
mov    0x2d13(%rip),%rax
mov    (%rax),%rdi
call   1040 <set_log_level@plt>
cmp    $0x0,%eax
jge    1304 <procargs+0x194>
mov    0x2ccb(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
jmp    1342 <procargs+0x1d2>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <usage@plt>
jmp    1342 <procargs+0x1d2>
mov    0x2caf(%rip),%rax
mov    (%rax),%edi
mov    -0x2c(%rbp),%edx
lea    0xe69(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2c8d(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
jmp    11f1 <procargs+0x81>
mov    0x2c92(%rip),%rax
mov    (%rax),%eax
cmp    -0x4(%rbp),%eax
jne    1365 <procargs+0x1f5>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <usage@plt>
mov    -0x3c(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<procargs>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,0x10(%rsp)
mov    %ecx,0x4(%rsp)
mov    %rdx,0x8(%rsp)
mov    %rsi,%rbx
mov    %edi,%ebp
cmp    $0x2,%edi
jne    11af <procargs+0x3f>
mov    0x8(%rbx),%rdi
lea    0xf1f(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     12cb <procargs+0x15b>
mov    $0x1,%r15d
lea    0xefc(%rip),%r13
lea    0xe3d(%rip),%r14
mov    0x2e2e(%rip),%r12
jmp    11d8 <procargs+0x68>
nopl   0x0(%rax)
mov    (%rbx),%rdi
call   1070 <usage@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1080 <getopt@plt>
lea    -0x3f(%rax),%ecx
cmp    $0x2d,%ecx
ja     125f <procargs+0xef>
movslq (%r14,%rcx,4),%rcx
add    %r14,%rcx
jmp    *%rcx
cmp    $0x1,%r15d
je     1213 <procargs+0xa3>
mov    0x2dcd(%rip),%rax
mov    (%rax),%edi
lea    0xf23(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    (%r12),%rax
mov    0x8(%rsp),%rcx
mov    %rax,(%rcx)
jmp    11d8 <procargs+0x68>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r12),%rdi
call   1040 <set_log_level@plt>
test   %eax,%eax
jns    11d8 <procargs+0x68>
jmp    12a7 <procargs+0x137>
cmp    0x4(%rsp),%r15d
je     12b5 <procargs+0x145>
mov    (%r12),%rax
mov    %r15d,%ecx
add    $0x1,%r15d
mov    0x8(%rsp),%rdx
mov    %rax,(%rdx,%rcx,8)
jmp    11d8 <procargs+0x68>
cmp    $0xffffffff,%eax
jne    128e <procargs+0x11e>
mov    0x2d75(%rip),%rax
cmp    %ebp,(%rax)
jne    1277 <procargs+0x107>
mov    (%rbx),%rdi
call   1070 <usage@plt>
mov    0x10(%rsp),%rax
mov    %r15d,(%rax)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d3b(%rip),%rcx
mov    (%rcx),%edi
lea    0xef8(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x2d1a(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    0x2d14(%rip),%rax
mov    (%rax),%edi
lea    0xeaa(%rip),%rsi
mov    0x4(%rsp),%edx
jmp    12a0 <procargs+0x130>
lea    0xdf7(%rip),%rdi
lea    0xe33(%rip),%rsi
lea    0xe41(%rip),%rdx
call   1030 <printf@plt>
mov    0x2cd4(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"b:c:hl:\00"
@.str.1 = [9 x i8] c"-version\00"
@.str.2 = [67 x i8] c"Standard Version: %s\0ANBIS Non-Export Control Software Version: %s\0A\00"
@.str.3 = [21 x i8] c"ANSI/NIST-ITL 1-2007\00"
@.str.4 = [14 x i8] c"Release 4.1.0\00"
@EXIT_SUCCESS = global i32 0
@stderr = global i32 0
@.str.5 = [64 x i8] c"Override the default configuration first, before adding to it.\0A\00"
@optarg = global i8* null
@.str.6 = [39 x i8] c"Too many configuration files, max=%d.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.7 = [59 x i8] c"Programming error: incompletely implemented option: '%c'.\0A\00"
@optind = global i32 0
define void @procargs(i32 %0, i8** %1, i8** %2, i32 %3, i32* %4) {
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i8**
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32
store i32 %0, i32* %6
store i8** %1, i8*** %7
store i8** %2, i8*** %8
store i32 %3, i32* %9
store i32* %4, i32** %10
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %12
store i32 1, i32* %13
%14 = load i32, i32* %6
%15 = icmp eq i32 %14, 2
br i1 %15, label %16, label %26
16: ; preds = %5
%17 = load i8**, i8*** %7
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %16
%23 = call i32 @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%24 = load i32, i32* @EXIT_SUCCESS
%25 = call i32 @exit(i32 %24)
unreachable
26: ; preds = %16, %5
br label %27
27: ; preds = %85, %26
%28 = load i32, i32* %6
%29 = load i8**, i8*** %7
%30 = call i32 @getopt(i32 %28, i8** %29, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0))
store i32 %30, i32* %11
%31 = icmp ne i32 %30, -1
br i1 %31, label %32, label %86
32: ; preds = %27
%33 = load i32, i32* %11
switch i32 %33, label %79 [
i32 98, label %34
i32 99, label %44
i32 104, label %61
i32 108, label %66
i32 63, label %74
]
34: ; preds = %32
%35 = load i32, i32* %13
%36 = icmp ne i32 1, %35
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = load i32, i32* @stderr
%39 = call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.5, i64 0, i64 0))
br label %40
40: ; preds = %37, %34
%41 = load i8*, i8** @optarg
%42 = load i8**, i8*** %8
%43 = getelementptr inbounds i8*, i8** %42, i64 0
store i8* %41, i8** %43
br label %85
44: ; preds = %32
%45 = load i32, i32* %13
%46 = load i32, i32* %9
%47 = icmp eq i32 %45, %46
br i1 %47, label %48, label %54
48: ; preds = %44
%49 = load i32, i32* @stderr
%50 = load i32, i32* %9
%51 = call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0), i32 %50)
%52 = load i32, i32* @EXIT_FAILURE
%53 = call i32 @exit(i32 %52)
unreachable
54: ; preds = %44
%55 = load i8*, i8** @optarg
%56 = load i8**, i8*** %8
%57 = load i32, i32* %13
%58 = add nsw i32 %57, 1
store i32 %58, i32* %13
%59 = sext i32 %57 to i64
%60 = getelementptr inbounds i8*, i8** %56, i64 %59
store i8* %55, i8** %60
br label %85
61: ; preds = %32
%62 = load i8**, i8*** %7
%63 = getelementptr inbounds i8*, i8** %62, i64 0
%64 = load i8*, i8** %63
%65 = call i32 @usage(i8* %64)
br label %85
66: ; preds = %32
%67 = load i8*, i8** @optarg
%68 = call i32 @set_log_level(i8* %67)
%69 = icmp slt i32 %68, 0
br i1 %69, label %70, label %73
70: ; preds = %66
%71 = load i32, i32* @EXIT_FAILURE
%72 = call i32 @exit(i32 %71)
unreachable
73: ; preds = %66
br label %85
74: ; preds = %32
%75 = load i8**, i8*** %7
%76 = getelementptr inbounds i8*, i8** %75, i64 0
%77 = load i8*, i8** %76
%78 = call i32 @usage(i8* %77)
br label %85
79: ; preds = %32
%80 = load i32, i32* @stderr
%81 = load i32, i32* %11
%82 = call i32 (i32, i8*, ...) @fprintf(i32 %80, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.7, i64 0, i64 0), i32 %81)
%83 = load i32, i32* @EXIT_FAILURE
%84 = call i32 @exit(i32 %83)
unreachable
85: ; preds = %74, %73, %61, %54, %40
br label %27
86: ; preds = %27
%87 = load i32, i32* @optind
%88 = load i32, i32* %6
%89 = icmp eq i32 %87, %88
br i1 %89, label %90, label %95
90: ; preds = %86
%91 = load i8**, i8*** %7
%92 = getelementptr inbounds i8*, i8** %91, i64 0
%93 = load i8*, i8** %92
%94 = call i32 @usage(i8* %93)
br label %95
95: ; preds = %90, %86
%96 = load i32, i32* %13
%97 = load i32*, i32** %10
store i32 %96, i32* %97
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"b:c:hl:\00"
@.str.1 = [9 x i8] c"-version\00"
@.str.2 = [67 x i8] c"Standard Version: %s\0ANBIS Non-Export Control Software Version: %s\0A\00"
@.str.3 = [21 x i8] c"ANSI/NIST-ITL 1-2007\00"
@.str.4 = [14 x i8] c"Release 4.1.0\00"
@EXIT_SUCCESS = global i32 0
@stderr = global i32 0
@.str.5 = [64 x i8] c"Override the default configuration first, before adding to it.\0A\00"
@optarg = global i8* null
@.str.6 = [39 x i8] c"Too many configuration files, max=%d.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.7 = [59 x i8] c"Programming error: incompletely implemented option: '%c'.\0A\00"
@optind = global i32 0
define void @procargs(i32 %0, i8** %1, i8** nocapture writeonly %2, i32 %3, i32* nocapture writeonly %4) {
%6 = icmp eq i32 %0, 2
br i1 %6, label %8, label %7
7: ; preds = %8, %5
br label %37
8: ; preds = %5
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %7
13: ; preds = %8
%14 = tail call i32 @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%15 = load i32, i32* @EXIT_SUCCESS
%16 = tail call i32 @exit(i32 %15)
unreachable
17: ; preds = %47, %37
%18 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
switch i32 %18, label %54 [
i32 -1, label %59
i32 98, label %19
i32 99, label %25
i32 104, label %40
i32 108, label %43
i32 63, label %51
]
19: ; preds = %17
br i1 %39, label %23, label %20
20: ; preds = %19
%21 = load i32, i32* @stderr
%22 = tail call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.5, i64 0, i64 0))
br label %23
23: ; preds = %20, %19
%24 = load i8*, i8** @optarg
store i8* %24, i8** %2
br label %47
25: ; preds = %17
%26 = icmp eq i32 %38, %3
br i1 %26, label %27, label %32
27: ; preds = %25
%28 = load i32, i32* @stderr
%29 = tail call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0), i32 %3)
%30 = load i32, i32* @EXIT_FAILURE
%31 = tail call i32 @exit(i32 %30)
unreachable
32: ; preds = %25
%33 = load i8*, i8** @optarg
%34 = add nuw nsw i32 %38, 1
%35 = zext i32 %38 to i64
%36 = getelementptr inbounds i8*, i8** %2, i64 %35
store i8* %33, i8** %36
br label %37
37: ; preds = %7, %32
%38 = phi i32 [ 1, %7 ], [ %34, %32 ]
%39 = icmp eq i32 %38, 1
br label %17
40: ; preds = %17
%41 = load i8*, i8** %1
%42 = tail call i32 @usage(i8* %41)
br label %47
43: ; preds = %17
%44 = load i8*, i8** @optarg
%45 = tail call i32 @set_log_level(i8* %44)
%46 = icmp slt i32 %45, 0
br i1 %46, label %48, label %47
47: ; preds = %43, %51, %40, %23
br label %17
48: ; preds = %43
%49 = load i32, i32* @EXIT_FAILURE
%50 = tail call i32 @exit(i32 %49)
unreachable
51: ; preds = %17
%52 = load i8*, i8** %1
%53 = tail call i32 @usage(i8* %52)
br label %47
54: ; preds = %17
%55 = load i32, i32* @stderr
%56 = tail call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.7, i64 0, i64 0), i32 %18)
%57 = load i32, i32* @EXIT_FAILURE
%58 = tail call i32 @exit(i32 %57)
unreachable
59: ; preds = %17
%60 = load i32, i32* @optind
%61 = icmp eq i32 %60, %0
br i1 %61, label %62, label %65
62: ; preds = %59
%63 = load i8*, i8** %1
%64 = tail call i32 @usage(i8* %63)
br label %65
65: ; preds = %62, %59
store i32 %38, i32* %4
ret void
}