#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_with_usage(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int make_randbitmap(unsigned int, double, unsigned int, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcmp(char *, char *);
double strtod(char *, char **);
unsigned int strtoul(char *, char **, int);
int main(int argc, char *argv[]) {
  unsigned int seed;
  double density;
  unsigned int bitsnumber;
  char *filename;
  if (argc == 2) {
    if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help"))
      exit_with_usage(stdout);
    else
      exit_with_usage(stderr);
  }
  if (argc != 5)
    exit_with_usage(stderr);
  char *check;
  seed = strtoul(argv[1], &check, 10);
  if (*check != '\0') {
    fprintf(stderr, "Seed error\n\n");
    exit_with_usage(stderr);
  }
  density = strtod(argv[2], &check);
  if (*check != '\0') {
    fprintf(stderr, "Density error\n\n");
    exit_with_usage(stderr);
  }
  bitsnumber = strtoul(argv[3], &check, 10);
  if (*check != '\0') {
    fprintf(stderr, "Bitsnumber error\n\n");
    exit_with_usage(stderr);
  }
  filename = argv[4];
  return make_randbitmap(seed, density, bitsnumber, filename);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    11e0 <main+0x80>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe71(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
je     11ba <main+0x5a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe57(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11cd <main+0x6d>
mov    0x2e17(%rip),%rax
mov    (%rax),%edi
call   1060 <exit_with_usage@plt>
jmp    11db <main+0x7b>
mov    0x2e0c(%rip),%rax
mov    (%rax),%edi
call   1060 <exit_with_usage@plt>
jmp    11e0 <main+0x80>
cmpl   $0x5,-0x8(%rbp)
je     11f8 <main+0x98>
mov    0x2def(%rip),%rax
mov    (%rax),%edi
call   1060 <exit_with_usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x38(%rbp),%rsi
mov    $0xa,%edx
call   1080 <strtoul@plt>
mov    %eax,-0x14(%rbp)
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1244 <main+0xe4>
mov    0x2db8(%rip),%rax
mov    (%rax),%edi
lea    0xdd9(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2da3(%rip),%rax
mov    (%rax),%edi
call   1060 <exit_with_usage@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    -0x38(%rbp),%rsi
call   1030 <strtod@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     128d <main+0x12d>
mov    0x2d6f(%rip),%rax
mov    (%rax),%edi
lea    0xd9d(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2d5a(%rip),%rax
mov    (%rax),%edi
call   1060 <exit_with_usage@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    -0x38(%rbp),%rsi
mov    $0xa,%edx
call   1080 <strtoul@plt>
mov    %eax,-0x24(%rbp)
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     12d9 <main+0x179>
mov    0x2d23(%rip),%rax
mov    (%rax),%edi
lea    0xd61(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2d0e(%rip),%rax
mov    (%rax),%edi
call   1060 <exit_with_usage@plt>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x14(%rbp),%edi
movsd  -0x20(%rbp),%xmm0
mov    -0x24(%rbp),%esi
mov    -0x30(%rbp),%rdx
call   1070 <make_randbitmap@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
cmp    $0x5,%edi
je     11c6 <main+0x66>
cmp    $0x2,%edi
jne    11b8 <main+0x58>
mov    0x8(%rbx),%rbp
lea    0xe7e(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11a1 <main+0x41>
lea    0xe6e(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
jne    11aa <main+0x4a>
mov    0x2e30(%rip),%rax
jmp    11b1 <main+0x51>
mov    0x2e2f(%rip),%rax
mov    (%rax),%edi
call   1060 <exit_with_usage@plt>
mov    0x2e21(%rip),%rax
mov    (%rax),%edi
call   1060 <exit_with_usage@plt>
mov    0x8(%rbx),%rdi
lea    0x8(%rsp),%rsi
mov    $0xa,%edx
call   1080 <strtoul@plt>
mov    %eax,%r14d
mov    0x8(%rsp),%rax
cmpb   $0x0,(%rax)
je     1204 <main+0xa4>
mov    0x2df3(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xe13(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x0(%rbp),%edi
call   1060 <exit_with_usage@plt>
mov    0x10(%rbx),%rdi
lea    0x8(%rsp),%rsi
call   1030 <strtod@plt>
movsd  %xmm0,0x10(%rsp)
mov    0x8(%rsp),%rax
cmpb   $0x0,(%rax)
je     1240 <main+0xe0>
mov    0x2db7(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xde4(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x0(%rbp),%edi
call   1060 <exit_with_usage@plt>
mov    0x18(%rbx),%rdi
lea    0x8(%rsp),%rsi
mov    $0xa,%edx
call   1080 <strtoul@plt>
mov    %eax,%ebp
mov    0x8(%rsp),%rax
cmpb   $0x0,(%rax)
je     127d <main+0x11d>
mov    0x2d7a(%rip),%r15
mov    (%r15),%edi
lea    0xdb7(%rip),%rsi
call   1050 <fprintf@plt>
mov    (%r15),%edi
call   1060 <exit_with_usage@plt>
mov    0x20(%rbx),%rdx
mov    %r14d,%edi
movsd  0x10(%rsp),%xmm0
mov    %ebp,%esi
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <make_randbitmap@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"-h\00"
@.str.1 = [7 x i8] c"--help\00"
@stdout = global i32 0
@stderr = global i32 0
@.str.2 = [13 x i8] c"Seed error\0A\0A\00"
@.str.3 = [16 x i8] c"Density error\0A\0A\00"
@.str.4 = [19 x i8] c"Bitsnumber error\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca double
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 2
br i1 %12, label %13, label %32
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @strcmp(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %13
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @strcmp(i8* %22, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%24 = icmp ne i32 %23, 0
br i1 %24, label %28, label %25
25: ; preds = %19, %13
%26 = load i32, i32* @stdout
%27 = call i32 @exit_with_usage(i32 %26)
br label %31
28: ; preds = %19
%29 = load i32, i32* @stderr
%30 = call i32 @exit_with_usage(i32 %29)
br label %31
31: ; preds = %28, %25
br label %32
32: ; preds = %31, %2
%33 = load i32, i32* %4
%34 = icmp ne i32 %33, 5
br i1 %34, label %35, label %38
35: ; preds = %32
%36 = load i32, i32* @stderr
%37 = call i32 @exit_with_usage(i32 %36)
br label %38
38: ; preds = %35, %32
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 1
%41 = load i8*, i8** %40
%42 = call i32 @strtoul(i8* %41, i8** %10, i32 10)
store i32 %42, i32* %6
%43 = load i8*, i8** %10
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %52
47: ; preds = %38
%48 = load i32, i32* @stderr
%49 = call i32 @fprintf(i32 %48, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%50 = load i32, i32* @stderr
%51 = call i32 @exit_with_usage(i32 %50)
br label %52
52: ; preds = %47, %38
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 2
%55 = load i8*, i8** %54
%56 = call double @strtod(i8* %55, i8** %10)
store double %56, double* %7
%57 = load i8*, i8** %10
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
%60 = icmp ne i32 %59, 0
br i1 %60, label %61, label %66
61: ; preds = %52
%62 = load i32, i32* @stderr
%63 = call i32 @fprintf(i32 %62, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%64 = load i32, i32* @stderr
%65 = call i32 @exit_with_usage(i32 %64)
br label %66
66: ; preds = %61, %52
%67 = load i8**, i8*** %5
%68 = getelementptr inbounds i8*, i8** %67, i64 3
%69 = load i8*, i8** %68
%70 = call i32 @strtoul(i8* %69, i8** %10, i32 10)
store i32 %70, i32* %8
%71 = load i8*, i8** %10
%72 = load i8, i8* %71
%73 = sext i8 %72 to i32
%74 = icmp ne i32 %73, 0
br i1 %74, label %75, label %80
75: ; preds = %66
%76 = load i32, i32* @stderr
%77 = call i32 @fprintf(i32 %76, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%78 = load i32, i32* @stderr
%79 = call i32 @exit_with_usage(i32 %78)
br label %80
80: ; preds = %75, %66
%81 = load i8**, i8*** %5
%82 = getelementptr inbounds i8*, i8** %81, i64 4
%83 = load i8*, i8** %82
store i8* %83, i8** %9
%84 = load i32, i32* %6
%85 = load double, double* %7
%86 = load i32, i32* %8
%87 = load i8*, i8** %9
%88 = call i32 @make_randbitmap(i32 %84, double %85, i32 %86, i8* %87)
ret i32 %88
}

LLVM IR (-O2):
@.str = [3 x i8] c"-h\00"
@.str.1 = [7 x i8] c"--help\00"
@stdout = global i32 0
@stderr = global i32 0
@.str.2 = [13 x i8] c"Seed error\0A\0A\00"
@.str.3 = [16 x i8] c"Density error\0A\0A\00"
@.str.4 = [19 x i8] c"Bitsnumber error\0A\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
switch i32 %0, label %17 [
i32 2, label %4
i32 5, label %20
]
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %4
%10 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
%12 = select i1 %11, i32* @stdout, i32* @stderr
br label %13
13: ; preds = %9, %4
%14 = phi i32* [ @stdout, %4 ], [ %12, %9 ]
%15 = load i32, i32* %14
%16 = tail call i32 @exit_with_usage(i32 %15)
br label %17
17: ; preds = %13, %2
%18 = load i32, i32* @stderr
%19 = tail call i32 @exit_with_usage(i32 %18)
br label %20
20: ; preds = %2, %17
%21 = bitcast i8** %3 to i8*
%22 = getelementptr inbounds i8*, i8** %1, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @strtoul(i8* %23, i8** %3, i32 10)
%25 = load i8*, i8** %3
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 0
br i1 %27, label %33, label %28
28: ; preds = %20
%29 = load i32, i32* @stderr
%30 = tail call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%31 = load i32, i32* @stderr
%32 = tail call i32 @exit_with_usage(i32 %31)
br label %33
33: ; preds = %28, %20
%34 = getelementptr inbounds i8*, i8** %1, i64 2
%35 = load i8*, i8** %34
%36 = call double @strtod(i8* %35, i8** %3)
%37 = load i8*, i8** %3
%38 = load i8, i8* %37
%39 = icmp eq i8 %38, 0
br i1 %39, label %45, label %40
40: ; preds = %33
%41 = load i32, i32* @stderr
%42 = tail call i32 @fprintf(i32 %41, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%43 = load i32, i32* @stderr
%44 = tail call i32 @exit_with_usage(i32 %43)
br label %45
45: ; preds = %40, %33
%46 = getelementptr inbounds i8*, i8** %1, i64 3
%47 = load i8*, i8** %46
%48 = call i32 @strtoul(i8* %47, i8** %3, i32 10)
%49 = load i8*, i8** %3
%50 = load i8, i8* %49
%51 = icmp eq i8 %50, 0
br i1 %51, label %57, label %52
52: ; preds = %45
%53 = load i32, i32* @stderr
%54 = tail call i32 @fprintf(i32 %53, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%55 = load i32, i32* @stderr
%56 = tail call i32 @exit_with_usage(i32 %55)
br label %57
57: ; preds = %52, %45
%58 = getelementptr inbounds i8*, i8** %1, i64 4
%59 = load i8*, i8** %58
%60 = tail call i32 @make_randbitmap(i32 %24, double %36, i32 %48, i8* %59)
ret i32 %60
}