#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*/ ConvertLinedefs(char **);
int /*<<< orphan*/ ConvertSectors(char **);
int /*<<< orphan*/ ConvertThings(char **);
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ puts(char *);
int strlen(char *);
int main(int argc, char *argv[]) {
  if (argc != 3) {
    puts("Usage: lvlconv [filename] [mapnumber]");
    puts("Example: lvlconv wadfile.wad 01");
    return EXIT_FAILURE;
  }
  if (strlen(argv[2]) != 2 || strlen(argv[1]) > 32) {
    puts("nonono you screwed it up");
    return EXIT_FAILURE;
  }
  puts("\nConverting Things...");
  ConvertThings(argv);
  puts("\nConverting Sectors...");
  ConvertSectors(argv);
  puts("\nConverting Linedefs...");
  ConvertLinedefs(argv);
  puts("\nOkay, DONE!! Enjoy the NEWLY MODIFIED WAD FILE!!! HAVE A GOOD DAY!");
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1199 <main+0x49>
lea    0xe89(%rip),%rdi
call   1030 <puts@plt>
lea    0xea3(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e51(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1239 <main+0xe9>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1040 <strlen@plt>
cmp    $0x2,%eax
jne    11c5 <main+0x75>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <strlen@plt>
cmp    $0x20,%eax
jle    11e2 <main+0x92>
lea    0xe7a(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e08(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1239 <main+0xe9>
lea    0xe76(%rip),%rdi
call   1030 <puts@plt>
mov    -0x10(%rbp),%rdi
call   1050 <ConvertThings@plt>
lea    0xe77(%rip),%rdi
call   1030 <puts@plt>
mov    -0x10(%rbp),%rdi
call   1070 <ConvertSectors@plt>
lea    0xe79(%rip),%rdi
call   1030 <puts@plt>
mov    -0x10(%rbp),%rdi
call   1060 <ConvertLinedefs@plt>
lea    0xe7c(%rip),%rdi
call   1030 <puts@plt>
mov    0x2da4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
cmp    $0x3,%edi
jne    11d3 <main+0x83>
mov    %rsi,%r14
mov    0x10(%rsi),%rdi
call   1040 <strlen@plt>
mov    0x2e73(%rip),%r15
lea    0xed2(%rip),%rbx
cmp    $0x2,%eax
jne    11ed <main+0x9d>
mov    0x8(%r14),%rdi
call   1040 <strlen@plt>
cmp    $0x20,%eax
jg     11ed <main+0x9d>
lea    0xed1(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1050 <ConvertThings@plt>
lea    0xed3(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1070 <ConvertSectors@plt>
lea    0xed6(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1060 <ConvertLinedefs@plt>
mov    0x2e0e(%rip),%r15
lea    0xed3(%rip),%rbx
jmp    11ed <main+0x9d>
lea    0xe26(%rip),%rdi
call   1030 <puts@plt>
mov    0x2dfa(%rip),%r15
lea    0xe39(%rip),%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    (%r15),%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [38 x i8] c"Usage: lvlconv [filename] [mapnumber]\00"
@.str.1 = [32 x i8] c"Example: lvlconv wadfile.wad 01\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [25 x i8] c"nonono you screwed it up\00"
@.str.3 = [22 x i8] c"\0AConverting Things...\00"
@.str.4 = [23 x i8] c"\0AConverting Sectors...\00"
@.str.5 = [24 x i8] c"\0AConverting Linedefs...\00"
@.str.6 = [68 x i8] c"\0AOkay, DONE!! Enjoy the NEWLY MODIFIED WAD FILE!!! HAVE A GOOD DAY!\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp ne i32 %6, 3
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = call i32 @puts(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @puts(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%11 = load i32, i32* @EXIT_FAILURE
store i32 %11, i32* %3
br label %39
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 2
%15 = load i8*, i8** %14
%16 = call i32 @strlen(i8* %15)
%17 = icmp ne i32 %16, 2
br i1 %17, label %24, label %18
18: ; preds = %12
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @strlen(i8* %21)
%23 = icmp sgt i32 %22, 32
br i1 %23, label %24, label %27
24: ; preds = %18, %12
%25 = call i32 @puts(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%26 = load i32, i32* @EXIT_FAILURE
store i32 %26, i32* %3
br label %39
27: ; preds = %18
%28 = call i32 @puts(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%29 = load i8**, i8*** %5
%30 = call i32 @ConvertThings(i8** %29)
%31 = call i32 @puts(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%32 = load i8**, i8*** %5
%33 = call i32 @ConvertSectors(i8** %32)
%34 = call i32 @puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%35 = load i8**, i8*** %5
%36 = call i32 @ConvertLinedefs(i8** %35)
%37 = call i32 @puts(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.6, i64 0, i64 0))
%38 = load i32, i32* @EXIT_SUCCESS
store i32 %38, i32* %3
br label %39
39: ; preds = %27, %24, %8
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
@.str = [38 x i8] c"Usage: lvlconv [filename] [mapnumber]\00"
@.str.1 = [32 x i8] c"Example: lvlconv wadfile.wad 01\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [25 x i8] c"nonono you screwed it up\00"
@.str.3 = [22 x i8] c"\0AConverting Things...\00"
@.str.4 = [23 x i8] c"\0AConverting Sectors...\00"
@.str.5 = [24 x i8] c"\0AConverting Linedefs...\00"
@.str.6 = [68 x i8] c"\0AOkay, DONE!! Enjoy the NEWLY MODIFIED WAD FILE!!! HAVE A GOOD DAY!\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
br label %23
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 2
%8 = load i8*, i8** %7
%9 = tail call i32 @strlen(i8* %8)
%10 = icmp eq i32 %9, 2
br i1 %10, label %11, label %23
11: ; preds = %6
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32 @strlen(i8* %13)
%15 = icmp sgt i32 %14, 32
br i1 %15, label %23, label %16
16: ; preds = %11
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%18 = tail call i32 @ConvertThings(i8** %1)
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%20 = tail call i32 @ConvertSectors(i8** %1)
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%22 = tail call i32 @ConvertLinedefs(i8** %1)
br label %23
23: ; preds = %6, %11, %16, %4
%24 = phi i8* [ getelementptr inbounds ([68 x i8], [68 x i8]* @.str.6, i64 0, i64 0), %16 ], [ getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), %4 ], [ getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), %11 ], [ getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), %6 ]
%25 = phi i32* [ @EXIT_SUCCESS, %16 ], [ @EXIT_FAILURE, %4 ], [ @EXIT_FAILURE, %11 ], [ @EXIT_FAILURE, %6 ]
%26 = tail call i32 @puts(i8* dereferenceable(1) %24)
%27 = load i32, i32* %25
ret i32 %27
}