#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(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int strtol(char *, char **, int);
void parse_args(int argc, char **argv, char **infile, int *idx,
                char **outfile) {
  if (argc < 2 || argc > 4)
    goto usage;
  *infile = argv[1];
  *idx = 0;
  *outfile = NULL;
  if (argc >= 3) {
    char *endp;
    *idx = strtol(argv[2], &endp, 10);
    if (*argv[2] == '\0' || *endp != '\0' || *idx < 1)
      goto usage;
    if (argc >= 4)
      *outfile = argv[3];
  }
  return;
usage:
  fprintf(stderr, "Usage: gzdetect FILE [IDX [OUT]]\n");
  exit(-1);
}


x86 assembly (clang, -O0):
<parse_args>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
cmpl   $0x2,-0x4(%rbp)
jl     115f <parse_args+0x2f>
cmpl   $0x4,-0x4(%rbp)
jle    1164 <parse_args+0x34>
jmp    120a <parse_args+0xda>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x28(%rbp),%rax
movq   $0x0,(%rax)
cmpl   $0x3,-0x4(%rbp)
jl     1204 <parse_args+0xd4>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    -0x30(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11e1 <parse_args+0xb1>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11e1 <parse_args+0xb1>
mov    -0x20(%rbp),%rax
cmpl   $0x1,(%rax)
jge    11e6 <parse_args+0xb6>
jmp    120a <parse_args+0xda>
cmpl   $0x4,-0x4(%rbp)
jl     11ff <parse_args+0xcf>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
jmp    1204 <parse_args+0xd4>
add    $0x30,%rsp
pop    %rbp
ret
mov    0x2dcf(%rip),%rax
mov    (%rax),%edi
lea    0xde6(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<parse_args>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebx
lea    -0x5(%rbx),%eax
cmp    $0xfffffffd,%eax
jb     11a7 <parse_args+0x77>
mov    %r8,%r14
mov    %rcx,%r12
mov    %rsi,%r15
mov    0x8(%rsi),%rax
mov    %rax,(%rdx)
movl   $0x0,(%rcx)
movq   $0x0,(%r8)
cmp    $0x3,%ebx
jb     119b <parse_args+0x6b>
mov    0x10(%r15),%rdi
mov    %rsp,%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,(%r12)
mov    0x10(%r15),%rcx
cmpb   $0x0,(%rcx)
je     11a7 <parse_args+0x77>
mov    (%rsp),%rcx
cmpb   $0x0,(%rcx)
jne    11a7 <parse_args+0x77>
test   %eax,%eax
jle    11a7 <parse_args+0x77>
cmp    $0x4,%ebx
jb     119b <parse_args+0x6b>
mov    0x18(%r15),%rax
mov    %rax,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
lea    0xe49(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [34 x i8] c"Usage: gzdetect FILE [IDX [OUT]]\0A\00"
define void @parse_args(i32 %0, i8** %1, i8** %2, i32* %3, i8** %4) {
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i8**
%9 = alloca i32*
%10 = alloca i8**
%11 = alloca i8*
store i32 %0, i32* %6
store i8** %1, i8*** %7
store i8** %2, i8*** %8
store i32* %3, i32** %9
store i8** %4, i8*** %10
%12 = load i32, i32* %6
%13 = icmp slt i32 %12, 2
br i1 %13, label %17, label %14
14: ; preds = %5
%15 = load i32, i32* %6
%16 = icmp sgt i32 %15, 4
br i1 %16, label %17, label %18
17: ; preds = %14, %5
br label %59
18: ; preds = %14
%19 = load i8**, i8*** %7
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = load i8**, i8*** %8
store i8* %21, i8** %22
%23 = load i32*, i32** %9
store i32 0, i32* %23
%24 = load i8**, i8*** %10
store i8* null, i8** %24
%25 = load i32, i32* %6
%26 = icmp sge i32 %25, 3
br i1 %26, label %27, label %58
27: ; preds = %18
%28 = load i8**, i8*** %7
%29 = getelementptr inbounds i8*, i8** %28, i64 2
%30 = load i8*, i8** %29
%31 = call i32 @strtol(i8* %30, i8** %11, i32 10)
%32 = load i32*, i32** %9
store i32 %31, i32* %32
%33 = load i8**, i8*** %7
%34 = getelementptr inbounds i8*, i8** %33, i64 2
%35 = load i8*, i8** %34
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 0
br i1 %38, label %48, label %39
39: ; preds = %27
%40 = load i8*, i8** %11
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp ne i32 %42, 0
br i1 %43, label %48, label %44
44: ; preds = %39
%45 = load i32*, i32** %9
%46 = load i32, i32* %45
%47 = icmp slt i32 %46, 1
br i1 %47, label %48, label %49
48: ; preds = %44, %39, %27
br label %59
49: ; preds = %44
%50 = load i32, i32* %6
%51 = icmp sge i32 %50, 4
br i1 %51, label %52, label %57
52: ; preds = %49
%53 = load i8**, i8*** %7
%54 = getelementptr inbounds i8*, i8** %53, i64 3
%55 = load i8*, i8** %54
%56 = load i8**, i8*** %10
store i8* %55, i8** %56
br label %57
57: ; preds = %52, %49
br label %58
58: ; preds = %57, %18
ret void
59: ; preds = %48, %17
%60 = load i32, i32* @stderr
%61 = call i32 @fprintf(i32 %60, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%62 = call i32 @exit(i32 -1)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [34 x i8] c"Usage: gzdetect FILE [IDX [OUT]]\0A\00"
define void @parse_args(i32 %0, i8** nocapture %1, i8** nocapture writeonly %2, i32* nocapture writeonly %3, i8** nocapture writeonly %4) {
%6 = alloca i8*
%7 = add i32 %0, -5
%8 = icmp ult i32 %7, -3
br i1 %8, label %35, label %9
9: ; preds = %5
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
store i8* %11, i8** %2
store i32 0, i32* %3
store i8* null, i8** %4
%12 = icmp ugt i32 %0, 2
br i1 %12, label %13, label %34
13: ; preds = %9
%14 = bitcast i8** %6 to i8*
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = call i32 @strtol(i8* %16, i8** %6, i32 10)
store i32 %17, i32* %3
%18 = load i8*, i8** %15
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %33, label %21
21: ; preds = %13
%22 = load i8*, i8** %6
%23 = load i8, i8* %22
%24 = icmp ne i8 %23, 0
%25 = icmp slt i32 %17, 1
%26 = select i1 %24, i1 true, i1 %25
br i1 %26, label %33, label %27
27: ; preds = %21
%28 = icmp ugt i32 %0, 3
br i1 %28, label %29, label %32
29: ; preds = %27
%30 = getelementptr inbounds i8*, i8** %1, i64 3
%31 = load i8*, i8** %30
store i8* %31, i8** %4
br label %32
32: ; preds = %29, %27
br label %34
33: ; preds = %13, %21
br label %35
34: ; preds = %32, %9
ret void
35: ; preds = %33, %5
%36 = load i32, i32* @stderr
%37 = tail call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%38 = tail call i32 @exit(i32 -1)
unreachable
}