#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(int /*<<< orphan*/);
scalar_t__ gen_get_js(int, int, int, int);
scalar_t__ gen_post_js(int, int, int, int);
int getopt(int, char **, char *);
int /*<<< orphan*/ optarg;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ usage(char *);
int main(int argc, char *argv[]) {
  int range_get = 26, range_post = 25;
  int opt, num = 0, sub = 0, debug = 0;
  while ((opt = getopt(argc, argv, "n:sd")) != -1) {
    switch (opt) {
    case 'n':
      num = atoi(optarg);
      break;
    case 's':
      sub = 1;
      break;
    case 'd':
      debug = 1;
      break;
    default:
      usage(argv[0]);
      return -1;
    }
  }
  if (num == 0) {
    usage(argv[0]);
    return -1;
  }
  if (debug)
    printf("args: range_get: %d, range_post: %d, number: %d\n", range_get,
           range_post, num);
  printf("/*\n");
  printf(" * Copyright (c) 2013 Neusoft Corperation., Ltd.\n");
  printf(" */\n");
  printf("\n");
  printf("\n");
  printf("#include <ngx_http_robot_mitigation.h>\n");
  printf("\n");
  printf("\n");
  if (gen_get_js(range_get, debug, sub, num) != 0) {
    return -1;
  }
  if (gen_post_js(range_post, debug, sub, num) != 0) {
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1a,-0x14(%rbp)
movl   $0x19,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe59(%rip),%rdx
call   1070 <getopt@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
je     1239 <main+0xd9>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
sub    $0x64,%eax
je     1210 <main+0xb0>
jmp    11cc <main+0x6c>
mov    -0x2c(%rbp),%eax
sub    $0x6e,%eax
je     11ee <main+0x8e>
jmp    11dd <main+0x7d>
mov    -0x2c(%rbp),%eax
sub    $0x73,%eax
je     1204 <main+0xa4>
jmp    121c <main+0xbc>
mov    0x2e03(%rip),%rax
mov    (%rax),%edi
call   1080 <atoi@plt>
mov    %eax,-0x20(%rbp)
jmp    1234 <main+0xd4>
movl   $0x1,-0x24(%rbp)
jmp    1234 <main+0xd4>
movl   $0x1,-0x28(%rbp)
jmp    1234 <main+0xd4>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <usage@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1341 <main+0x1e1>
jmp    1199 <main+0x39>
cmpl   $0x0,-0x20(%rbp)
jne    125b <main+0xfb>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <usage@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1341 <main+0x1e1>
cmpl   $0x0,-0x28(%rbp)
je     127c <main+0x11c>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x20(%rbp),%ecx
lea    0xd90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xda9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdcd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xda8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd53(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
mov    -0x28(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x20(%rbp),%ecx
call   1050 <gen_get_js@plt>
cmp    $0x0,%rax
je     1313 <main+0x1b3>
movl   $0xffffffff,-0x4(%rbp)
jmp    1341 <main+0x1e1>
mov    -0x18(%rbp),%edi
mov    -0x28(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x20(%rbp),%ecx
call   1040 <gen_post_js@plt>
cmp    $0x0,%rax
je     133a <main+0x1da>
movl   $0xffffffff,-0x4(%rbp)
jmp    1341 <main+0x1e1>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %edi,%ebx
xor    %r15d,%r15d
lea    0xe66(%rip),%r13
xor    %r14d,%r14d
xor    %ebp,%ebp
mov    %ebp,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ecx,%ebp
mov    %ebx,%edi
mov    %r12,%rsi
mov    %r13,%rdx
call   1090 <getopt@plt>
mov    $0x1,%ecx
cmp    $0x64,%eax
je     11b0 <main+0x30>
cmp    $0xffffffff,%eax
je     11f8 <main+0x78>
cmp    $0x73,%eax
je     11f0 <main+0x70>
cmp    $0x6e,%eax
jne    12b0 <main+0x130>
mov    0x2e15(%rip),%rax
mov    (%rax),%edi
call   10a0 <atoi@plt>
mov    %eax,%r15d
jmp    119f <main+0x1f>
nop
mov    $0x1,%r14d
jmp    119f <main+0x1f>
test   %r15d,%r15d
je     12b0 <main+0x130>
test   %ebp,%ebp
je     1220 <main+0xa0>
lea    0xdf9(%rip),%rdi
mov    $0x1a,%esi
mov    $0x19,%edx
mov    %r15d,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe0f(%rip),%rdi
call   1040 <puts@plt>
lea    0xe06(%rip),%rdi
call   1040 <puts@plt>
lea    0xe2b(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe0f(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x1a,%edi
mov    %ebp,%esi
mov    %r14d,%edx
mov    %r15d,%ecx
call   1070 <gen_get_js@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
test   %rcx,%rcx
jne    12be <main+0x13e>
mov    $0x19,%edi
mov    %ebp,%esi
mov    %r14d,%edx
mov    %r15d,%ecx
call   1060 <gen_post_js@plt>
neg    %rax
sbb    %eax,%eax
jmp    12be <main+0x13e>
mov    (%r12),%rdi
call   1080 <usage@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"n:sd\00"
@optarg = global i32 0
@.str.1 = [49 x i8] c"args: range_get: %d, range_post: %d, number: %d\0A\00"
@.str.2 = [4 x i8] c"/*\0A\00"
@.str.3 = [50 x i8] c" * Copyright (c) 2013 Neusoft Corperation., Ltd.\0A\00"
@.str.4 = [5 x i8] c" */\0A\00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [40 x i8] c"#include <ngx_http_robot_mitigation.h>\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 26, i32* %6
store i32 25, i32* %7
store i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
br label %12
12: ; preds = %29, %2
%13 = load i32, i32* %4
%14 = load i8**, i8*** %5
%15 = call i32 @getopt(i32 %13, i8** %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %15, i32* %8
%16 = icmp ne i32 %15, -1
br i1 %16, label %17, label %30
17: ; preds = %12
%18 = load i32, i32* %8
switch i32 %18, label %24 [
i32 110, label %19
i32 115, label %22
i32 100, label %23
]
19: ; preds = %17
%20 = load i32, i32* @optarg
%21 = call i32 @atoi(i32 %20)
store i32 %21, i32* %9
br label %29
22: ; preds = %17
store i32 1, i32* %10
br label %29
23: ; preds = %17
store i32 1, i32* %11
br label %29
24: ; preds = %17
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 0
%27 = load i8*, i8** %26
%28 = call i32 @usage(i8* %27)
store i32 -1, i32* %3
br label %71
29: ; preds = %23, %22, %19
br label %12
30: ; preds = %12
%31 = load i32, i32* %9
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %38
33: ; preds = %30
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 0
%36 = load i8*, i8** %35
%37 = call i32 @usage(i8* %36)
store i32 -1, i32* %3
br label %71
38: ; preds = %30
%39 = load i32, i32* %11
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %46
41: ; preds = %38
%42 = load i32, i32* %6
%43 = load i32, i32* %7
%44 = load i32, i32* %9
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i32 %42, i32 %43, i32 %44)
br label %46
46: ; preds = %41, %38
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0))
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0))
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%55 = load i32, i32* %6
%56 = load i32, i32* %11
%57 = load i32, i32* %10
%58 = load i32, i32* %9
%59 = call i64 @gen_get_js(i32 %55, i32 %56, i32 %57, i32 %58)
%60 = icmp ne i64 %59, 0
br i1 %60, label %61, label %62
61: ; preds = %46
store i32 -1, i32* %3
br label %71
62: ; preds = %46
%63 = load i32, i32* %7
%64 = load i32, i32* %11
%65 = load i32, i32* %10
%66 = load i32, i32* %9
%67 = call i64 @gen_post_js(i32 %63, i32 %64, i32 %65, i32 %66)
%68 = icmp ne i64 %67, 0
br i1 %68, label %69, label %70
69: ; preds = %62
store i32 -1, i32* %3
br label %71
70: ; preds = %62
store i32 0, i32* %3
br label %71
71: ; preds = %70, %69, %61, %33, %24
%72 = load i32, i32* %3
ret i32 %72
}

LLVM IR (-O2):
@.str = [5 x i8] c"n:sd\00"
@optarg = global i32 0
@.str.1 = [49 x i8] c"args: range_get: %d, range_post: %d, number: %d\0A\00"
@str = [3 x i8] c"/*\00"
@str.7 = [49 x i8] c" * Copyright (c) 2013 Neusoft Corperation., Ltd.\00"
@str.8 = [4 x i8] c" */\00"
@str.9 = [39 x i8] c"#include <ngx_http_robot_mitigation.h>\00"
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %13, %2
%4 = phi i32 [ %15, %13 ], [ 0, %2 ]
%5 = phi i32 [ %8, %13 ], [ 0, %2 ]
%6 = phi i32 [ %11, %13 ], [ 0, %2 ]
br label %7
7: ; preds = %10, %3
%8 = phi i32 [ %5, %3 ], [ 1, %10 ]
%9 = phi i32 [ %6, %3 ], [ %11, %10 ]
br label %10
10: ; preds = %10, %7
%11 = phi i32 [ %9, %7 ], [ 1, %10 ]
%12 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
switch i32 %12, label %16 [
i32 -1, label %19
i32 110, label %13
i32 115, label %7
i32 100, label %10
]
13: ; preds = %10
%14 = load i32, i32* @optarg
%15 = tail call i32 @atoi(i32 %14)
br label %3
16: ; preds = %10
%17 = load i8*, i8** %1
%18 = tail call i32 @usage(i8* %17)
br label %43
19: ; preds = %10
%20 = icmp eq i32 %4, 0
br i1 %20, label %21, label %24
21: ; preds = %19
%22 = load i8*, i8** %1
%23 = tail call i32 @usage(i8* %22)
br label %43
24: ; preds = %19
%25 = icmp eq i32 %11, 0
br i1 %25, label %28, label %26
26: ; preds = %24
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i32 26, i32 25, i32 %4)
br label %28
28: ; preds = %26, %24
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str.7, i64 0, i64 0))
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.8, i64 0, i64 0))
%32 = tail call i32 @putchar(i32 10)
%33 = tail call i32 @putchar(i32 10)
%34 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.9, i64 0, i64 0))
%35 = tail call i32 @putchar(i32 10)
%36 = tail call i32 @putchar(i32 10)
%37 = tail call i64 @gen_get_js(i32 26, i32 %11, i32 %8, i32 %4)
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %43
39: ; preds = %28
%40 = tail call i64 @gen_post_js(i32 25, i32 %11, i32 %8, i32 %4)
%41 = icmp ne i64 %40, 0
%42 = sext i1 %41 to i32
br label %43
43: ; preds = %39, %28, %21, %16
%44 = phi i32 [ -1, %16 ], [ -1, %21 ], [ -1, %28 ], [ %42, %39 ]
ret i32 %44
}