#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*/ gen_bit_reverse_table(int);
int /*<<< orphan*/ gen_run_length_table(int, int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  bool header;
  if (argc != 2) {
    fprintf(stderr, "wrong arg count\n");
    exit(2);
  }
  if (strcmp(argv[1], "-h") == 0)
    header = 1;
  else if (strcmp(argv[1], "-c") == 0)
    header = 0;
  else {
    fprintf(stderr, "wrong args\n");
    exit(2);
  }
  printf("/* This file is automatically generated; do not edit */\n");
  printf("\n");
  if (!header) {
    printf("#include <stdint.h>\n");
    printf("#include \"bitblt_tables.h\"\n");
    printf("\n");
  }
  gen_bit_reverse_table(header);
  printf("\n");
  gen_run_length_table(header, 0, "rle_tab");
  printf("\n");
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     119f <main+0x3f>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
lea    0xe70(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x2,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe63(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11c9 <main+0x69>
movl   $0x1,-0x14(%rbp)
jmp    1217 <main+0xb7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe3c(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11f3 <main+0x93>
movl   $0x0,-0x14(%rbp)
jmp    1212 <main+0xb2>
mov    0x2de6(%rip),%rax
mov    (%rax),%edi
lea    0xe14(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x2,%edi
call   1070 <exit@plt>
jmp    1217 <main+0xb7>
lea    0xe05(%rip),%rdi
call   1030 <printf@plt>
lea    0xe61(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x0,-0x14(%rbp)
jne    125d <main+0xfd>
lea    0xe1c(%rip),%rdi
call   1030 <printf@plt>
lea    0xe25(%rip),%rdi
call   1030 <printf@plt>
lea    0xe33(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
call   1060 <gen_bit_reverse_table@plt>
lea    0xe1f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
xor    %esi,%esi
lea    0xe10(%rip),%rdx
call   1080 <gen_run_length_table@plt>
lea    0xe02(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    1239 <main+0xc9>
mov    %rsi,%rbp
mov    0x8(%rsi),%rdi
lea    0xe87(%rip),%rsi
call   1050 <strcmp@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11c3 <main+0x53>
mov    0x8(%rbp),%rdi
lea    0xe72(%rip),%rsi
call   1050 <strcmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     11c8 <main+0x58>
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
lea    0xe59(%rip),%rsi
jmp    1249 <main+0xd9>
mov    $0x1,%ebp
lea    0xe5c(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
test   %rbx,%rbx
je     1205 <main+0x95>
lea    0xe79(%rip),%rdi
call   1040 <puts@plt>
lea    0xe81(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %ebp,%edi
call   1070 <gen_bit_reverse_table@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe06(%rip),%rdx
mov    %ebp,%edi
xor    %esi,%esi
call   1090 <gen_run_length_table@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2da0(%rip),%rax
mov    (%rax),%edi
lea    0xdb7(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x2,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [17 x i8] c"wrong arg count\0A\00"
@.str.1 = [3 x i8] c"-h\00"
@.str.2 = [3 x i8] c"-c\00"
@.str.3 = [12 x i8] c"wrong args\0A\00"
@.str.4 = [57 x i8] c"/* This file is automatically generated; do not edit */\0A\00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [21 x i8] c"#include <stdint.h>\0A\00"
@.str.7 = [28 x i8] c"#include \22bitblt_tables.h\22\0A\00"
@.str.8 = [8 x i8] c"rle_tab\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 2
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @exit(i32 2)
unreachable
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %13
store i32 1, i32* %6
br label %32
20: ; preds = %13
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %20
store i32 0, i32* %6
br label %31
27: ; preds = %20
%28 = load i32, i32* @stderr
%29 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%30 = call i32 @exit(i32 2)
unreachable
31: ; preds = %26
br label %32
32: ; preds = %31, %19
%33 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.4, i64 0, i64 0))
%34 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%35 = load i32, i32* %6
%36 = icmp ne i32 %35, 0
br i1 %36, label %41, label %37
37: ; preds = %32
%38 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
%39 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0))
%40 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %41
41: ; preds = %37, %32
%42 = load i32, i32* %6
%43 = call i32 @gen_bit_reverse_table(i32 %42)
%44 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%45 = load i32, i32* %6
%46 = call i32 @gen_run_length_table(i32 %45, i32 0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
%47 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [17 x i8] c"wrong arg count\0A\00"
@.str.1 = [3 x i8] c"-h\00"
@.str.2 = [3 x i8] c"-c\00"
@.str.3 = [12 x i8] c"wrong args\0A\00"
@.str.8 = [8 x i8] c"rle_tab\00"
@str = [56 x i8] c"/* This file is automatically generated; do not edit */\00"
@str.9 = [20 x i8] c"#include <stdint.h>\00"
@str.10 = [27 x i8] c"#include \22bitblt_tables.h\22\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 2)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %21, label %13
13: ; preds = %8
%14 = load i8*, i8** %9
%15 = tail call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %21, label %17
17: ; preds = %13
%18 = load i32, i32* @stderr
%19 = tail call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%20 = tail call i32 @exit(i32 2)
unreachable
21: ; preds = %13, %8
%22 = phi i32 [ 1, %8 ], [ 0, %13 ]
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str, i64 0, i64 0))
%24 = tail call i32 @putchar(i32 10)
br i1 %12, label %29, label %25
25: ; preds = %21
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.9, i64 0, i64 0))
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.10, i64 0, i64 0))
%28 = tail call i32 @putchar(i32 10)
br label %29
29: ; preds = %25, %21
%30 = tail call i32 @gen_bit_reverse_table(i32 %22)
%31 = tail call i32 @putchar(i32 10)
%32 = tail call i32 @gen_run_length_table(i32 %22, i32 0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
%33 = tail call i32 @putchar(i32 10)
ret i32 0
}