#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*/ DumpData(char *, char *, int);
int /*<<< orphan*/ Extract(char *);
int /*<<< orphan*/ MakeDataObj(char *, char *, char const *, char const *, int);
int atoi(char *);
int /*<<< orphan*/ printf(char *);
int main(int argc, char *argv[]) {
  if (argc < 3) {
    printf("Converts file to OMF.\nUseage:\n  ./makeobj [fx] <input> ...\n");
    return 0;
  }
  switch (argv[1][0]) {
  case 'c':
    if (argc < 4) {
      printf("Need an output location. (Extra parms: <output> [<symbol>])\n");
      return 0;
    } else {
      const char *symname = NULL;
      if (argc >= 5)
        symname = argv[4];
      MakeDataObj(argv[2], argv[3], NULL, symname, 1);
    }
    break;
  default:
  case 'f':
    if (argc < 4) {
      printf("Need an output location. (Extra parms: <output> [<segname> "
             "<symbol>])\n");
      return 0;
    } else {
      const char *segname = NULL, *symname = NULL;
      if (argc >= 6) {
        segname = argv[4];
        symname = argv[5];
      }
      MakeDataObj(argv[2], argv[3], segname, symname, 0);
    }
    break;
  case 'x':
    Extract(argv[2]);
    break;
  case 's':
    if (argc < 4) {
      printf("Need an output location. (Extra parms: <output> [<skip>])\n");
      return 0;
    } else {
      int skip = 0;
      if (argc >= 5) {
        skip = atoi(argv[4]);
      }
      DumpData(argv[2], argv[3], skip);
    }
    break;
    break;
  }
  return 0;
}


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   $0x3,-0x8(%rbp)
jge    1188 <main+0x38>
lea    0xee1(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1318 <main+0x1c8>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
add    $0xffffff9d,%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0x15,%eax
ja     1221 <main+0xd1>
mov    -0x38(%rbp),%rax
lea    0xe50(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cmpl   $0x4,-0x8(%rbp)
jge    11db <main+0x8b>
lea    0xeca(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1318 <main+0x1c8>
movq   $0x0,-0x18(%rbp)
cmpl   $0x5,-0x8(%rbp)
jl     11f9 <main+0xa9>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%edx
mov    $0x1,%r8d
call   1060 <MakeDataObj@plt>
jmp    1311 <main+0x1c1>
jmp    1226 <main+0xd6>
cmpl   $0x4,-0x8(%rbp)
jge    1248 <main+0xf8>
lea    0xe9a(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1318 <main+0x1c8>
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
cmpl   $0x6,-0x8(%rbp)
jl     127a <main+0x12a>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
xor    %r8d,%r8d
call   1060 <MakeDataObj@plt>
jmp    1311 <main+0x1c1>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <Extract@plt>
jmp    1311 <main+0x1c1>
cmpl   $0x4,-0x8(%rbp)
jge    12d3 <main+0x183>
lea    0xe56(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1318 <main+0x1c8>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x5,-0x8(%rbp)
jl     12f4 <main+0x1a4>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
mov    -0x2c(%rbp),%edx
call   1050 <DumpData@plt>
jmp    1311 <main+0x1c1>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x2,%edi
jg     1167 <main+0x17>
lea    0xf5f(%rip),%rdi
call   1040 <puts@plt>
jmp    122d <main+0xdd>
mov    %rsi,%rbx
mov    0x8(%rsi),%rax
movsbl (%rax),%eax
cmp    $0x78,%eax
je     1196 <main+0x46>
cmp    $0x73,%eax
je     11a4 <main+0x54>
cmp    $0x63,%eax
jne    11b7 <main+0x67>
cmp    $0x3,%edi
ja     11ca <main+0x7a>
lea    0xeae(%rip),%rdi
call   1040 <puts@plt>
jmp    122d <main+0xdd>
mov    0x10(%rbx),%rdi
call   1030 <Extract@plt>
jmp    122d <main+0xdd>
cmp    $0x3,%edi
ja     11d3 <main+0x83>
lea    0xe50(%rip),%rdi
call   1040 <puts@plt>
jmp    122d <main+0xdd>
cmp    $0x3,%edi
ja     11f4 <main+0xa4>
lea    0xeb3(%rip),%rdi
call   1040 <puts@plt>
jmp    122d <main+0xdd>
cmp    $0x4,%edi
jne    1203 <main+0xb3>
xor    %ecx,%ecx
jmp    1207 <main+0xb7>
xor    %edx,%edx
cmp    $0x4,%edi
je     11e5 <main+0x95>
mov    0x20(%rbx),%rdi
call   1070 <atoi@plt>
mov    %eax,%edx
mov    0x10(%rbx),%rdi
mov    0x18(%rbx),%rsi
call   1050 <DumpData@plt>
jmp    122d <main+0xdd>
cmp    $0x6,%edi
jb     1219 <main+0xc9>
mov    0x20(%rbx),%rdx
mov    0x28(%rbx),%rcx
jmp    121d <main+0xcd>
mov    0x20(%rbx),%rcx
mov    0x10(%rbx),%rdi
mov    0x18(%rbx),%rsi
xor    %edx,%edx
mov    $0x1,%r8d
jmp    1228 <main+0xd8>
xor    %edx,%edx
xor    %ecx,%ecx
mov    0x10(%rbx),%rdi
mov    0x18(%rbx),%rsi
xor    %r8d,%r8d
call   1060 <MakeDataObj@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [60 x i8] c"Converts file to OMF.\0AUseage:\0A ./makeobj [fx] <input> ...\0A\00"
@.str.1 = [61 x i8] c"Need an output location. (Extra parms: <output> [<symbol>])\0A\00"
@.str.2 = [71 x i8] c"Need an output location. (Extra parms: <output> [<segname> <symbol>])\0A\00"
@.str.3 = [59 x i8] c"Need an output location. (Extra parms: <output> [<skip>])\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 3
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %99
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = getelementptr inbounds i8, i8* %17, i64 0
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
switch i32 %20, label %43 [
i32 99, label %21
i32 102, label %44
i32 120, label %70
i32 115, label %75
]
21: ; preds = %14
%22 = load i32, i32* %4
%23 = icmp slt i32 %22, 4
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = call i32 @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %99
26: ; preds = %21
store i8* null, i8** %6
%27 = load i32, i32* %4
%28 = icmp sge i32 %27, 5
br i1 %28, label %29, label %33
29: ; preds = %26
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 4
%32 = load i8*, i8** %31
store i8* %32, i8** %6
br label %33
33: ; preds = %29, %26
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 2
%36 = load i8*, i8** %35
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 3
%39 = load i8*, i8** %38
%40 = load i8*, i8** %6
%41 = call i32 @MakeDataObj(i8* %36, i8* %39, i8* null, i8* %40, i32 1)
br label %42
42: ; preds = %33
br label %98
43: ; preds = %14
br label %44
44: ; preds = %14, %43
%45 = load i32, i32* %4
%46 = icmp slt i32 %45, 4
br i1 %46, label %47, label %49
47: ; preds = %44
%48 = call i32 @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %99
49: ; preds = %44
store i8* null, i8** %7
store i8* null, i8** %8
%50 = load i32, i32* %4
%51 = icmp sge i32 %50, 6
br i1 %51, label %52, label %59
52: ; preds = %49
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 4
%55 = load i8*, i8** %54
store i8* %55, i8** %7
%56 = load i8**, i8*** %5
%57 = getelementptr inbounds i8*, i8** %56, i64 5
%58 = load i8*, i8** %57
store i8* %58, i8** %8
br label %59
59: ; preds = %52, %49
%60 = load i8**, i8*** %5
%61 = getelementptr inbounds i8*, i8** %60, i64 2
%62 = load i8*, i8** %61
%63 = load i8**, i8*** %5
%64 = getelementptr inbounds i8*, i8** %63, i64 3
%65 = load i8*, i8** %64
%66 = load i8*, i8** %7
%67 = load i8*, i8** %8
%68 = call i32 @MakeDataObj(i8* %62, i8* %65, i8* %66, i8* %67, i32 0)
br label %69
69: ; preds = %59
br label %98
70: ; preds = %14
%71 = load i8**, i8*** %5
%72 = getelementptr inbounds i8*, i8** %71, i64 2
%73 = load i8*, i8** %72
%74 = call i32 @Extract(i8* %73)
br label %98
75: ; preds = %14
%76 = load i32, i32* %4
%77 = icmp slt i32 %76, 4
br i1 %77, label %78, label %80
78: ; preds = %75
%79 = call i32 @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %99
80: ; preds = %75
store i32 0, i32* %9
%81 = load i32, i32* %4
%82 = icmp sge i32 %81, 5
br i1 %82, label %83, label %88
83: ; preds = %80
%84 = load i8**, i8*** %5
%85 = getelementptr inbounds i8*, i8** %84, i64 4
%86 = load i8*, i8** %85
%87 = call i32 @atoi(i8* %86)
store i32 %87, i32* %9
br label %88
88: ; preds = %83, %80
%89 = load i8**, i8*** %5
%90 = getelementptr inbounds i8*, i8** %89, i64 2
%91 = load i8*, i8** %90
%92 = load i8**, i8*** %5
%93 = getelementptr inbounds i8*, i8** %92, i64 3
%94 = load i8*, i8** %93
%95 = load i32, i32* %9
%96 = call i32 @DumpData(i8* %91, i8* %94, i32 %95)
br label %97
97: ; preds = %88
br label %98
98: ; preds = %97, %70, %69, %42
store i32 0, i32* %3
br label %99
99: ; preds = %98, %78, %47, %24, %12
%100 = load i32, i32* %3
ret i32 %100
}

LLVM IR (-O2):
@str = [58 x i8] c"Need an output location. (Extra parms: <output> [<skip>])\00"
@str.4 = [60 x i8] c"Need an output location. (Extra parms: <output> [<symbol>])\00"
@str.5 = [70 x i8] c"Need an output location. (Extra parms: <output> [<segname> <symbol>])\00"
@str.6 = [59 x i8] c"Converts file to OMF.\0AUseage:\0A ./makeobj [fx] <input> ...\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str.6, i64 0, i64 0))
br label %67
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
switch i32 %10, label %27 [
i32 99, label %11
i32 115, label %50
i32 120, label %46
]
11: ; preds = %6
%12 = icmp ult i32 %0, 4
br i1 %12, label %13, label %15
13: ; preds = %11
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @str.4, i64 0, i64 0))
br label %67
15: ; preds = %11
%16 = icmp eq i32 %0, 4
br i1 %16, label %20, label %17
17: ; preds = %15
%18 = getelementptr inbounds i8*, i8** %1, i64 4
%19 = load i8*, i8** %18
br label %20
20: ; preds = %17, %15
%21 = phi i8* [ %19, %17 ], [ null, %15 ]
%22 = getelementptr inbounds i8*, i8** %1, i64 2
%23 = load i8*, i8** %22
%24 = getelementptr inbounds i8*, i8** %1, i64 3
%25 = load i8*, i8** %24
%26 = tail call i32 @MakeDataObj(i8* %23, i8* %25, i8* null, i8* %21, i32 1)
br label %67
27: ; preds = %6
%28 = icmp ult i32 %0, 4
br i1 %28, label %29, label %31
29: ; preds = %27
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @str.5, i64 0, i64 0))
br label %67
31: ; preds = %27
%32 = icmp ugt i32 %0, 5
br i1 %32, label %33, label %38
33: ; preds = %31
%34 = getelementptr inbounds i8*, i8** %1, i64 4
%35 = load i8*, i8** %34
%36 = getelementptr inbounds i8*, i8** %1, i64 5
%37 = load i8*, i8** %36
br label %38
38: ; preds = %33, %31
%39 = phi i8* [ %35, %33 ], [ null, %31 ]
%40 = phi i8* [ %37, %33 ], [ null, %31 ]
%41 = getelementptr inbounds i8*, i8** %1, i64 2
%42 = load i8*, i8** %41
%43 = getelementptr inbounds i8*, i8** %1, i64 3
%44 = load i8*, i8** %43
%45 = tail call i32 @MakeDataObj(i8* %42, i8* %44, i8* %39, i8* %40, i32 0)
br label %67
46: ; preds = %6
%47 = getelementptr inbounds i8*, i8** %1, i64 2
%48 = load i8*, i8** %47
%49 = tail call i32 @Extract(i8* %48)
br label %67
50: ; preds = %6
%51 = icmp ult i32 %0, 4
br i1 %51, label %52, label %54
52: ; preds = %50
%53 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @str, i64 0, i64 0))
br label %67
54: ; preds = %50
%55 = icmp eq i32 %0, 4
br i1 %55, label %60, label %56
56: ; preds = %54
%57 = getelementptr inbounds i8*, i8** %1, i64 4
%58 = load i8*, i8** %57
%59 = tail call i32 @atoi(i8* %58)
br label %60
60: ; preds = %56, %54
%61 = phi i32 [ %59, %56 ], [ 0, %54 ]
%62 = getelementptr inbounds i8*, i8** %1, i64 2
%63 = load i8*, i8** %62
%64 = getelementptr inbounds i8*, i8** %1, i64 3
%65 = load i8*, i8** %64
%66 = tail call i32 @DumpData(i8* %63, i8* %65, i32 %61)
br label %67
67: ; preds = %20, %38, %46, %60, %52, %29, %13, %4
ret i32 0
}