#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;
long atoi(int /*<<< orphan*/);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getopt(int, char **, char *);
int /*<<< orphan*/ optarg;
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strncpy(char *, int /*<<< orphan*/, int);
void py_parse_cmdline(long *nx, long *threads, char *outfile, int *write,
                      int argc, char *argv[]) {
  int opt;
  while ((opt = getopt(argc, argv, "t:n:o:wq")) != -1) {
    switch (opt) {
    case 't':
      *threads = atoi(optarg);
      break;
    case 'n':
      *nx = atoi(optarg);
      break;
    case 'o':
      strncpy(outfile, optarg, 256);
      outfile[256 - 1] = '\0';
      break;
    case 'q':
      *write = 0;
      break;
    default:
      fprintf(stderr, "Usage: %s ", argv[0]);
      if (threads != NULL)
        fprintf(stderr, "[-t threads] ");
      fprintf(stderr, "[-n intervals] ");
      fprintf(stderr, "[-o outfile]");
      fprintf(stderr, "[-q]\n");
      exit(EXIT_FAILURE);
    }
  }
}


x86 assembly (clang, -O0):
<py_parse_cmdline>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x30(%rbp),%rsi
lea    0xe9e(%rip),%rdx
call   1050 <getopt@plt>
mov    %eax,-0x34(%rbp)
cmp    $0xffffffff,%eax
je     12c0 <py_parse_cmdline+0x170>
mov    -0x34(%rbp),%eax
add    $0xffffff92,%eax
mov    %eax,%ecx
mov    %rcx,-0x40(%rbp)
sub    $0x6,%eax
ja     1228 <py_parse_cmdline+0xd8>
mov    -0x40(%rbp),%rax
lea    0xe51(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
call   1060 <atoi@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
jmp    12bb <py_parse_cmdline+0x16b>
mov    0x2e1c(%rip),%rax
mov    (%rax),%edi
call   1060 <atoi@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
jmp    12bb <py_parse_cmdline+0x16b>
mov    -0x18(%rbp),%rdi
mov    0x2dfb(%rip),%rax
mov    (%rax),%esi
mov    $0x100,%edx
call   1030 <strncpy@plt>
mov    -0x18(%rbp),%rax
movb   $0x0,0xff(%rax)
jmp    12bb <py_parse_cmdline+0x16b>
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
jmp    12bb <py_parse_cmdline+0x16b>
mov    0x2da9(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rax
mov    (%rax),%rdx
lea    0xde6(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
cmpq   $0x0,-0x10(%rbp)
je     1268 <py_parse_cmdline+0x118>
mov    0x2d80(%rip),%rax
mov    (%rax),%edi
lea    0xdcf(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2d69(%rip),%rax
mov    (%rax),%edi
lea    0xdc6(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2d52(%rip),%rax
mov    (%rax),%edi
lea    0xdbf(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2d3b(%rip),%rax
mov    (%rax),%edi
lea    0xdb5(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2d1c(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
jmp    1170 <py_parse_cmdline+0x20>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<py_parse_cmdline>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,%rbx
mov    %r8d,%ebp
mov    %rcx,0x10(%rsp)
mov    %rdx,%r12
mov    %rsi,(%rsp)
mov    %rdi,0x8(%rsp)
lea    0xea0(%rip),%r14
lea    0xe7d(%rip),%r15
mov    0x2e6e(%rip),%r13
jmp    119b <py_parse_cmdline+0x4b>
nopl   0x0(%rax)
mov    0x10(%rsp),%rax
movl   $0x0,(%rax)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1050 <getopt@plt>
lea    -0x6e(%rax),%ecx
cmp    $0x6,%ecx
ja     1202 <py_parse_cmdline+0xb2>
movslq (%r15,%rcx,4),%rax
add    %r15,%rax
jmp    *%rax
mov    0x0(%r13),%edi
call   1060 <atoi@plt>
mov    0x8(%rsp),%rcx
mov    %rax,(%rcx)
jmp    119b <py_parse_cmdline+0x4b>
nopl   0x0(%rax)
mov    0x0(%r13),%esi
mov    %r12,%rdi
mov    $0x100,%edx
call   1030 <strncpy@plt>
movb   $0x0,0xff(%r12)
jmp    119b <py_parse_cmdline+0x4b>
nopl   0x0(%rax)
mov    0x0(%r13),%edi
call   1060 <atoi@plt>
mov    (%rsp),%rcx
mov    %rax,(%rcx)
jmp    119b <py_parse_cmdline+0x4b>
cmp    $0xffffffff,%eax
jne    1216 <py_parse_cmdline+0xc6>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2dbb(%rip),%rbp
mov    0x0(%rbp),%edi
mov    (%rbx),%rdx
lea    0xdfb(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
cmpq   $0x0,(%rsp)
je     1249 <py_parse_cmdline+0xf9>
mov    0x0(%rbp),%edi
lea    0xdee(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xdeb(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xdea(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xde6(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x2d4d(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"t:n:o:wq\00"
@optarg = global i32 0
@stderr = global i32 0
@.str.1 = [11 x i8] c"Usage: %s \00"
@.str.2 = [14 x i8] c"[-t threads] \00"
@.str.3 = [16 x i8] c"[-n intervals] \00"
@.str.4 = [13 x i8] c"[-o outfile]\00"
@.str.5 = [6 x i8] c"[-q]\0A\00"
@EXIT_FAILURE = global i32 0
define void @py_parse_cmdline(i64* %0, i64* %1, i8* %2, i32* %3, i32 %4, i8** %5) {
%7 = alloca i64*
%8 = alloca i64*
%9 = alloca i8*
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i8**
%13 = alloca i32
store i64* %0, i64** %7
store i64* %1, i64** %8
store i8* %2, i8** %9
store i32* %3, i32** %10
store i32 %4, i32* %11
store i8** %5, i8*** %12
br label %14
14: ; preds = %57, %6
%15 = load i32, i32* %11
%16 = load i8**, i8*** %12
%17 = call i32 @getopt(i32 %15, i8** %16, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
store i32 %17, i32* %13
%18 = icmp ne i32 %17, -1
br i1 %18, label %19, label %58
19: ; preds = %14
%20 = load i32, i32* %13
switch i32 %20, label %37 [
i32 116, label %21
i32 110, label %25
i32 111, label %29
i32 113, label %35
]
21: ; preds = %19
%22 = load i32, i32* @optarg
%23 = call i64 @atoi(i32 %22)
%24 = load i64*, i64** %8
store i64 %23, i64* %24
br label %57
25: ; preds = %19
%26 = load i32, i32* @optarg
%27 = call i64 @atoi(i32 %26)
%28 = load i64*, i64** %7
store i64 %27, i64* %28
br label %57
29: ; preds = %19
%30 = load i8*, i8** %9
%31 = load i32, i32* @optarg
%32 = call i32 @strncpy(i8* %30, i32 %31, i32 256)
%33 = load i8*, i8** %9
%34 = getelementptr inbounds i8, i8* %33, i64 255
store i8 0, i8* %34
br label %57
35: ; preds = %19
%36 = load i32*, i32** %10
store i32 0, i32* %36
br label %57
37: ; preds = %19
%38 = load i32, i32* @stderr
%39 = load i8**, i8*** %12
%40 = getelementptr inbounds i8*, i8** %39, i64 0
%41 = load i8*, i8** %40
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %41)
%43 = load i64*, i64** %8
%44 = icmp ne i64* %43, null
br i1 %44, label %45, label %48
45: ; preds = %37
%46 = load i32, i32* @stderr
%47 = call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %48
48: ; preds = %45, %37
%49 = load i32, i32* @stderr
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%51 = load i32, i32* @stderr
%52 = call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%53 = load i32, i32* @stderr
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%55 = load i32, i32* @EXIT_FAILURE
%56 = call i32 @exit(i32 %55)
unreachable
57: ; preds = %35, %29, %25, %21
br label %14
58: ; preds = %14
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"t:n:o:wq\00"
@optarg = global i32 0
@stderr = global i32 0
@.str.1 = [11 x i8] c"Usage: %s \00"
@.str.2 = [14 x i8] c"[-t threads] \00"
@.str.3 = [16 x i8] c"[-n intervals] \00"
@.str.4 = [13 x i8] c"[-o outfile]\00"
@.str.5 = [6 x i8] c"[-q]\0A\00"
@EXIT_FAILURE = global i32 0
define void @py_parse_cmdline(i64* nocapture writeonly %0, i64* writeonly %1, i8* %2, i32* nocapture writeonly %3, i32 %4, i8** %5) {
%7 = getelementptr inbounds i8, i8* %2, i64 255
br label %8
8: ; preds = %20, %6
%9 = tail call i32 @getopt(i32 %4, i8** %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
switch i32 %9, label %21 [
i32 -1, label %38
i32 116, label %10
i32 110, label %13
i32 111, label %16
i32 113, label %19
]
10: ; preds = %8
%11 = load i32, i32* @optarg
%12 = tail call i64 @atoi(i32 %11)
store i64 %12, i64* %1
br label %20
13: ; preds = %8
%14 = load i32, i32* @optarg
%15 = tail call i64 @atoi(i32 %14)
store i64 %15, i64* %0
br label %20
16: ; preds = %8
%17 = load i32, i32* @optarg
%18 = tail call i32 @strncpy(i8* %2, i32 %17, i32 256)
store i8 0, i8* %7
br label %20
19: ; preds = %8
store i32 0, i32* %3
br label %20
20: ; preds = %19, %16, %13, %10
br label %8
21: ; preds = %8
%22 = load i32, i32* @stderr
%23 = load i8*, i8** %5
%24 = tail call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %23)
%25 = icmp eq i64* %1, null
br i1 %25, label %29, label %26
26: ; preds = %21
%27 = load i32, i32* @stderr
%28 = tail call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %29
29: ; preds = %26, %21
%30 = load i32, i32* @stderr
%31 = tail call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%32 = load i32, i32* @stderr
%33 = tail call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%34 = load i32, i32* @stderr
%35 = tail call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%36 = load i32, i32* @EXIT_FAILURE
%37 = tail call i32 @exit(i32 %36)
unreachable
38: ; preds = %8
ret void
}