#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*/ EINVAL;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int getopt(int, char **, char *);
int /*<<< orphan*/ isprint(int);
char *optarg;
scalar_t__ opterr;
int optopt;
int /*<<< orphan*/ show_usage();
int /*<<< orphan*/ stderr;
long strtol(char *, int /*<<< orphan*/ *, int);
int parse_cmd_line_args(int argc, char **argv, char **config_file,
                        int *workers) {
  int enable_help = 0;
  int c;
  long w;
  opterr = 0;
  while ((c = getopt(argc, argv, "hf:w:")) != -1) {
    switch (c) {
    case 'h':
      enable_help = 1;
      break;
    case 'f':
      *config_file = optarg;
      break;
    case 'w':
      w = strtol(optarg, NULL, 10);
      if (w == 0 && errno == EINVAL) {
        fprintf(stderr, "Option -%c requires a number.\n", optopt);
        break;
      }
      *workers = w;
      break;
    case '?':
      if (optopt == 'f')
        fprintf(stderr, "Option -%c requires a filename.\n", optopt);
      if (optopt == 'w')
        fprintf(stderr, "Option -%c requires a positive integer.\n", optopt);
      else if (isprint(optopt))
        fprintf(stderr, "Unknown option `-%c'.\n", optopt);
      else
        fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt);
      return 1;
    }
  }
  if (enable_help) {
    show_usage();
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<parse_cmd_line_args>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    0x2e4b(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe76(%rip),%rdx
call   1070 <getopt@plt>
mov    %eax,-0x28(%rbp)
cmp    $0xffffffff,%eax
je     1346 <parse_cmd_line_args+0x1f6>
mov    -0x28(%rbp),%eax
mov    %eax,-0x34(%rbp)
sub    $0x3f,%eax
je     1277 <parse_cmd_line_args+0x127>
jmp    11af <parse_cmd_line_args+0x5f>
mov    -0x34(%rbp),%eax
sub    $0x66,%eax
je     11ee <parse_cmd_line_args+0x9e>
jmp    11c0 <parse_cmd_line_args+0x70>
mov    -0x34(%rbp),%eax
sub    $0x68,%eax
je     11e2 <parse_cmd_line_args+0x92>
jmp    11d1 <parse_cmd_line_args+0x81>
mov    -0x34(%rbp),%eax
sub    $0x77,%eax
je     1204 <parse_cmd_line_args+0xb4>
jmp    1341 <parse_cmd_line_args+0x1f1>
movl   $0x1,-0x24(%rbp)
jmp    1341 <parse_cmd_line_args+0x1f1>
mov    0x2e03(%rip),%rax
mov    (%rax),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    1341 <parse_cmd_line_args+0x1f1>
mov    0x2ded(%rip),%rax
mov    (%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1266 <parse_cmd_line_args+0x116>
mov    0x2d96(%rip),%rax
mov    (%rax),%eax
mov    0x2d7d(%rip),%rcx
cmp    (%rcx),%eax
jne    1266 <parse_cmd_line_args+0x116>
mov    0x2d86(%rip),%rax
mov    (%rax),%edi
mov    0x2d8d(%rip),%rax
mov    (%rax),%edx
lea    0xdaa(%rip),%rsi
call   1030 <fprintf@plt>
jmp    1341 <parse_cmd_line_args+0x1f1>
mov    -0x30(%rbp),%rax
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
jmp    1341 <parse_cmd_line_args+0x1f1>
mov    0x2d62(%rip),%rax
cmpl   $0x66,(%rax)
jne    12a5 <parse_cmd_line_args+0x155>
mov    0x2d42(%rip),%rax
mov    (%rax),%edi
mov    0x2d49(%rip),%rax
mov    (%rax),%edx
lea    0xd85(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2d34(%rip),%rax
cmpl   $0x77,(%rax)
jne    12d8 <parse_cmd_line_args+0x188>
mov    0x2d14(%rip),%rax
mov    (%rax),%edi
mov    0x2d1b(%rip),%rax
mov    (%rax),%edx
lea    0xd78(%rip),%rsi
call   1030 <fprintf@plt>
jmp    1335 <parse_cmd_line_args+0x1e5>
mov    0x2d01(%rip),%rax
mov    (%rax),%edi
call   1050 <isprint@plt>
cmp    $0x0,%eax
je     1312 <parse_cmd_line_args+0x1c2>
mov    0x2cda(%rip),%rax
mov    (%rax),%edi
mov    0x2ce1(%rip),%rax
mov    (%rax),%edx
lea    0xd67(%rip),%rsi
call   1030 <fprintf@plt>
jmp    1330 <parse_cmd_line_args+0x1e0>
mov    0x2cb7(%rip),%rax
mov    (%rax),%edi
mov    0x2cbe(%rip),%rax
mov    (%rax),%edx
lea    0xd5b(%rip),%rsi
call   1030 <fprintf@plt>
jmp    1335 <parse_cmd_line_args+0x1e5>
movl   $0x1,-0x4(%rbp)
jmp    136a <parse_cmd_line_args+0x21a>
jmp    117c <parse_cmd_line_args+0x2c>
cmpl   $0x0,-0x24(%rbp)
je     1363 <parse_cmd_line_args+0x213>
mov    $0x0,%al
call   1060 <show_usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    136a <parse_cmd_line_args+0x21a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_cmd_line_args>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x2e53(%rip),%rax
movq   $0x0,(%rax)
mov    $0x1,%al
mov    %eax,0x4(%rsp)
lea    0xe7f(%rip),%r12
mov    0x2e70(%rip),%r13
jmp    119c <parse_cmd_line_args+0x4c>
nopw   0x0(%rax,%rax,1)
cmp    $0x66,%eax
jne    1205 <parse_cmd_line_args+0xb5>
mov    0x0(%r13),%rax
mov    %rax,(%r15)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
call   1070 <getopt@plt>
cmp    $0x67,%eax
jle    1190 <parse_cmd_line_args+0x40>
cmp    $0x77,%eax
jne    1211 <parse_cmd_line_args+0xc1>
mov    0x0(%r13),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <strtol@plt>
test   %rax,%rax
jne    1200 <parse_cmd_line_args+0xb0>
mov    0x2df9(%rip),%rcx
mov    (%rcx),%ecx
mov    0x2de0(%rip),%rdx
cmp    (%rdx),%ecx
jne    1200 <parse_cmd_line_args+0xb0>
mov    0x2ded(%rip),%rax
mov    (%rax),%edi
mov    0x2df4(%rip),%rax
mov    (%rax),%edx
lea    0xe11(%rip),%rsi
call   1030 <fprintf@plt>
jmp    119c <parse_cmd_line_args+0x4c>
nopl   0x0(%rax)
mov    %eax,(%r14)
jmp    119c <parse_cmd_line_args+0x4c>
cmp    $0xffffffff,%eax
je     1223 <parse_cmd_line_args+0xd3>
cmp    $0x3f,%eax
jne    119c <parse_cmd_line_args+0x4c>
jmp    1239 <parse_cmd_line_args+0xe9>
cmp    $0x68,%eax
jne    119c <parse_cmd_line_args+0x4c>
movl   $0x0,0x4(%rsp)
jmp    119c <parse_cmd_line_args+0x4c>
xor    %eax,%eax
testb  $0x1,0x4(%rsp)
jne    12b1 <parse_cmd_line_args+0x161>
xor    %eax,%eax
call   1060 <show_usage@plt>
jmp    12ac <parse_cmd_line_args+0x15c>
mov    0x2da0(%rip),%rbp
mov    0x0(%rbp),%ebx
cmp    $0x66,%ebx
jne    1265 <parse_cmd_line_args+0x115>
mov    0x2d81(%rip),%rax
mov    (%rax),%edi
lea    0xdcd(%rip),%rsi
mov    $0x66,%edx
call   1030 <fprintf@plt>
mov    0x0(%rbp),%ebx
cmp    $0x77,%ebx
jne    1281 <parse_cmd_line_args+0x131>
mov    0x2d5f(%rip),%rax
mov    (%rax),%edi
lea    0xdcc(%rip),%rsi
mov    $0x77,%edx
jmp    12a7 <parse_cmd_line_args+0x157>
mov    %ebx,%edi
call   1050 <isprint@plt>
mov    0x2d41(%rip),%rcx
mov    (%rcx),%edi
test   %eax,%eax
je     129e <parse_cmd_line_args+0x14e>
lea    0xdd3(%rip),%rsi
jmp    12a5 <parse_cmd_line_args+0x155>
lea    0xde1(%rip),%rsi
mov    %ebx,%edx
call   1030 <fprintf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@opterr = global i64 0
@.str = [6 x i8] c"hf:w:\00"
@optarg = global i8* null
@errno = global i32 0
@EINVAL = global i32 0
@stderr = global i32 0
@.str.1 = [31 x i8] c"Option -%c requires a number.\0A\00"
@optopt = global i32 0
@.str.2 = [33 x i8] c"Option -%c requires a filename.\0A\00"
@.str.3 = [41 x i8] c"Option -%c requires a positive integer.\0A\00"
@.str.4 = [23 x i8] c"Unknown option `-%c'.\0A\00"
@.str.5 = [34 x i8] c"Unknown option character `\\x%x'.\0A\00"
define i32 @parse_cmd_line_args(i32 %0, i8** %1, i8** %2, i32* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i8**
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i64
store i32 %0, i32* %6
store i8** %1, i8*** %7
store i8** %2, i8*** %8
store i32* %3, i32** %9
store i32 0, i32* %10
store i64 0, i64* @opterr
br label %13
13: ; preds = %69, %4
%14 = load i32, i32* %6
%15 = load i8**, i8*** %7
%16 = call i32 @getopt(i32 %14, i8** %15, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i32 %16, i32* %11
%17 = icmp ne i32 %16, -1
br i1 %17, label %18, label %70
18: ; preds = %13
%19 = load i32, i32* %11
switch i32 %19, label %69 [
i32 104, label %20
i32 102, label %21
i32 119, label %24
i32 63, label %41
]
20: ; preds = %18
store i32 1, i32* %10
br label %69
21: ; preds = %18
%22 = load i8*, i8** @optarg
%23 = load i8**, i8*** %8
store i8* %22, i8** %23
br label %69
24: ; preds = %18
%25 = load i8*, i8** @optarg
%26 = call i64 @strtol(i8* %25, i32* null, i32 10)
store i64 %26, i64* %12
%27 = load i64, i64* %12
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %37
29: ; preds = %24
%30 = load i32, i32* @errno
%31 = load i32, i32* @EINVAL
%32 = icmp eq i32 %30, %31
br i1 %32, label %33, label %37
33: ; preds = %29
%34 = load i32, i32* @stderr
%35 = load i32, i32* @optopt
%36 = call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %35)
br label %69
37: ; preds = %29, %24
%38 = load i64, i64* %12
%39 = trunc i64 %38 to i32
%40 = load i32*, i32** %9
store i32 %39, i32* %40
br label %69
41: ; preds = %18
%42 = load i32, i32* @optopt
%43 = icmp eq i32 %42, 102
br i1 %43, label %44, label %48
44: ; preds = %41
%45 = load i32, i32* @stderr
%46 = load i32, i32* @optopt
%47 = call i32 @fprintf(i32 %45, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %46)
br label %48
48: ; preds = %44, %41
%49 = load i32, i32* @optopt
%50 = icmp eq i32 %49, 119
br i1 %50, label %51, label %55
51: ; preds = %48
%52 = load i32, i32* @stderr
%53 = load i32, i32* @optopt
%54 = call i32 @fprintf(i32 %52, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0), i32 %53)
br label %68
55: ; preds = %48
%56 = load i32, i32* @optopt
%57 = call i32 @isprint(i32 %56)
%58 = icmp ne i32 %57, 0
br i1 %58, label %59, label %63
59: ; preds = %55
%60 = load i32, i32* @stderr
%61 = load i32, i32* @optopt
%62 = call i32 @fprintf(i32 %60, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %61)
br label %67
63: ; preds = %55
%64 = load i32, i32* @stderr
%65 = load i32, i32* @optopt
%66 = call i32 @fprintf(i32 %64, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i32 %65)
br label %67
67: ; preds = %63, %59
br label %68
68: ; preds = %67, %51
store i32 1, i32* %5
br label %76
69: ; preds = %18, %37, %33, %21, %20
br label %13
70: ; preds = %13
%71 = load i32, i32* %10
%72 = icmp ne i32 %71, 0
br i1 %72, label %73, label %75
73: ; preds = %70
%74 = call i32 (...) @show_usage()
store i32 1, i32* %5
br label %76
75: ; preds = %70
store i32 0, i32* %5
br label %76
76: ; preds = %75, %73, %68
%77 = load i32, i32* %5
ret i32 %77
}

LLVM IR (-O2):
@opterr = global i64 0
@.str = [6 x i8] c"hf:w:\00"
@optarg = global i8* null
@errno = global i32 0
@EINVAL = global i32 0
@stderr = global i32 0
@.str.1 = [31 x i8] c"Option -%c requires a number.\0A\00"
@optopt = global i32 0
@.str.2 = [33 x i8] c"Option -%c requires a filename.\0A\00"
@.str.3 = [41 x i8] c"Option -%c requires a positive integer.\0A\00"
@.str.4 = [23 x i8] c"Unknown option `-%c'.\0A\00"
@.str.5 = [34 x i8] c"Unknown option character `\\x%x'.\0A\00"
define i32 @parse_cmd_line_args(i32 %0, i8** %1, i8** nocapture writeonly %2, i32* nocapture writeonly %3) {
store i64 0, i64* @opterr
br label %5
5: ; preds = %7, %4
%6 = phi i1 [ true, %4 ], [ false, %7 ]
br label %7
7: ; preds = %9, %5
%8 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
switch i32 %8, label %9 [
i32 -1, label %47
i32 104, label %5
i32 102, label %10
i32 119, label %12
i32 63, label %26
]
9: ; preds = %7, %24, %20, %10
br label %7
10: ; preds = %7
%11 = load i8*, i8** @optarg
store i8* %11, i8** %2
br label %9
12: ; preds = %7
%13 = load i8*, i8** @optarg
%14 = tail call i64 @strtol(i8* nocapture %13, i32* null, i32 10)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %24
16: ; preds = %12
%17 = load i32, i32* @errno
%18 = load i32, i32* @EINVAL
%19 = icmp eq i32 %17, %18
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = load i32, i32* @stderr
%22 = load i32, i32* @optopt
%23 = tail call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %22)
br label %9
24: ; preds = %16, %12
%25 = trunc i64 %14 to i32
store i32 %25, i32* %3
br label %9
26: ; preds = %7
%27 = load i32, i32* @optopt
%28 = icmp eq i32 %27, 102
br i1 %28, label %29, label %33
29: ; preds = %26
%30 = load i32, i32* @stderr
%31 = tail call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 102)
%32 = load i32, i32* @optopt
br label %33
33: ; preds = %29, %26
%34 = phi i32 [ %32, %29 ], [ %27, %26 ]
%35 = icmp eq i32 %34, 119
br i1 %35, label %36, label %39
36: ; preds = %33
%37 = load i32, i32* @stderr
%38 = tail call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0), i32 119)
br label %50
39: ; preds = %33
%40 = tail call i32 @isprint(i32 %34)
%41 = icmp eq i32 %40, 0
%42 = load i32, i32* @stderr
br i1 %41, label %45, label %43
43: ; preds = %39
%44 = tail call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %34)
br label %50
45: ; preds = %39
%46 = tail call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i32 %34)
br label %50
47: ; preds = %7
br i1 %6, label %50, label %48
48: ; preds = %47
%49 = tail call i32 (...) @show_usage()
br label %50
50: ; preds = %47, %36, %45, %43, %48
%51 = phi i32 [ 1, %48 ], [ 1, %43 ], [ 1, %45 ], [ 1, %36 ], [ 0, %47 ]
ret i32 %51
}