#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 */
char EOF;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
char getopt(int, char **, char *);
int /*<<< orphan*/ printf(char *, char *, ...);
int /*<<< orphan*/ stderr;
char *strrchr(char *, char);
int /*<<< orphan*/ writeData(char *);
int /*<<< orphan*/ writeText(char *);
int main(int argc, char *argv[]) {
  char c_option;
  int helpflag;
  int decompileflag;
  char *p_progname;
  int i;
  helpflag = i = 0;
  if ((p_progname = strrchr(argv[0], '\\')) != NULL)
    p_progname++;
  else
    p_progname = argv[0];
  while ((c_option = getopt(argc, argv, "hvcd")) != EOF) {
    switch (c_option) {
    case 'v':
      printf("%s-%d.%d\n", p_progname, 0, 3);
      return (1);
    case 'h':
      helpflag++;
      break;
    case 'd':
      writeText(argv[2]);
      return (3);
      break;
    case 'c':
      writeData(argv[2]);
      return (4);
      break;
    default:
      fprintf(stderr, "Invalid option %s, usage: %s [-hvcd] arguments\n",
              argv[1], p_progname);
      return (5);
    }
    if (helpflag) {
      printf(
          "Usage: %s [-hvcd] input_file ['rb' mode] output_file ['wb' mode]\n",
          p_progname);
      return (2);
    }
  }
  if (argc == 1) {
    fprintf(stderr, "No input arguments entered. Usage: %s [-hvcd] arguments\n",
            p_progname);
    return (0);
  }
  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)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    $0x5c,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     11b4 <main+0x54>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    11bf <main+0x5f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    11c4 <main+0x64>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe7e(%rip),%rdx
call   1070 <getopt@plt>
mov    %al,-0x11(%rbp)
movsbl %al,%eax
mov    0x2e04(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     12da <main+0x17a>
movsbl -0x11(%rbp),%eax
add    $0xffffff9d,%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0x13,%eax
ja     127e <main+0x11e>
mov    -0x38(%rbp),%rax
lea    0xdf0(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x28(%rbp),%rsi
lea    0xe31(%rip),%rdi
xor    %edx,%edx
mov    $0x3,%ecx
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1312 <main+0x1b2>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    12ad <main+0x14d>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <writeText@plt>
movl   $0x3,-0x4(%rbp)
jmp    1312 <main+0x1b2>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1080 <writeData@plt>
movl   $0x4,-0x4(%rbp)
jmp    1312 <main+0x1b2>
mov    0x2d53(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x28(%rbp),%rcx
lea    0xdc5(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x5,-0x4(%rbp)
jmp    1312 <main+0x1b2>
cmpl   $0x0,-0x18(%rbp)
je     12d5 <main+0x175>
mov    -0x28(%rbp),%rsi
lea    0xdcd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1312 <main+0x1b2>
jmp    11c4 <main+0x64>
cmpl   $0x1,-0x8(%rbp)
jne    130b <main+0x1ab>
mov    0x2ced(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
lea    0xdd9(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1312 <main+0x1b2>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%ebp
mov    (%rsi),%rbx
mov    %rbx,%rdi
mov    $0x5c,%esi
call   1040 <strrchr@plt>
lea    0x1(%rax),%r14
test   %rax,%rax
cmove  %rbx,%r14
lea    0xec2(%rip),%rdx
mov    %ebp,%edi
mov    %r15,%rsi
call   1070 <getopt@plt>
mov    0x2e49(%rip),%rcx
cmp    (%rcx),%al
jne    11cf <main+0x6f>
xor    %ebx,%ebx
cmp    $0x1,%ebp
jne    1264 <main+0x104>
mov    0x2e23(%rip),%rax
mov    (%rax),%edi
lea    0xf13(%rip),%rsi
xor    %ebx,%ebx
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    1264 <main+0x104>
movsbl %al,%eax
add    $0xffffff9d,%eax
cmp    $0x13,%eax
ja     120a <main+0xaa>
lea    0xe1f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x10(%r15),%rdi
call   1080 <writeData@plt>
mov    $0x4,%ebx
jmp    1264 <main+0x104>
mov    0x10(%r15),%rdi
call   1060 <writeText@plt>
mov    $0x3,%ebx
jmp    1264 <main+0x104>
mov    0x2dc7(%rip),%rax
mov    (%rax),%edi
mov    0x8(%r15),%rdx
lea    0xe41(%rip),%rsi
mov    %r14,%rcx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x5,%ebx
jmp    1264 <main+0x104>
lea    0xe59(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x2,%ebx
jmp    1264 <main+0x104>
lea    0xe07(%rip),%rdi
mov    %r14,%rsi
xor    %edx,%edx
mov    $0x3,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"hvcd\00"
@EOF = global i8 0
@.str.1 = [10 x i8] c"%s-%d.%d\0A\00"
@stderr = global i32 0
@.str.2 = [48 x i8] c"Invalid option %s, usage: %s [-hvcd] arguments\0A\00"
@.str.3 = [66 x i8] c"Usage: %s [-hvcd] input_file ['rb' mode] output_file ['wb' mode]\0A\00"
@.str.4 = [57 x i8] c"No input arguments entered. Usage: %s [-hvcd] arguments\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %10
store i32 0, i32* %7
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i8* @strrchr(i8* %13, i8 signext 92)
store i8* %14, i8** %9
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = load i8*, i8** %9
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %9
br label %23
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
store i8* %22, i8** %9
br label %23
23: ; preds = %19, %16
br label %24
24: ; preds = %64, %23
%25 = load i32, i32* %4
%26 = load i8**, i8*** %5
%27 = call signext i8 @getopt(i32 %25, i8** %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8 %27, i8* %6
%28 = sext i8 %27 to i32
%29 = load i8, i8* @EOF
%30 = sext i8 %29 to i32
%31 = icmp ne i32 %28, %30
br i1 %31, label %32, label %65
32: ; preds = %24
%33 = load i8, i8* %6
%34 = sext i8 %33 to i32
switch i32 %34, label %51 [
i32 118, label %35
i32 104, label %38
i32 100, label %41
i32 99, label %46
]
35: ; preds = %32
%36 = load i8*, i8** %9
%37 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %36, i32 0, i32 3)
store i32 1, i32* %3
br label %73
38: ; preds = %32
%39 = load i32, i32* %7
%40 = add nsw i32 %39, 1
store i32 %40, i32* %7
br label %58
41: ; preds = %32
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 2
%44 = load i8*, i8** %43
%45 = call i32 @writeText(i8* %44)
store i32 3, i32* %3
br label %73
46: ; preds = %32
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 2
%49 = load i8*, i8** %48
%50 = call i32 @writeData(i8* %49)
store i32 4, i32* %3
br label %73
51: ; preds = %32
%52 = load i32, i32* @stderr
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 1
%55 = load i8*, i8** %54
%56 = load i8*, i8** %9
%57 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i8* %55, i8* %56)
store i32 5, i32* %3
br label %73
58: ; preds = %38
%59 = load i32, i32* %7
%60 = icmp ne i32 %59, 0
br i1 %60, label %61, label %64
61: ; preds = %58
%62 = load i8*, i8** %9
%63 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.3, i64 0, i64 0), i8* %62)
store i32 2, i32* %3
br label %73
64: ; preds = %58
br label %24
65: ; preds = %24
%66 = load i32, i32* %4
%67 = icmp eq i32 %66, 1
br i1 %67, label %68, label %72
68: ; preds = %65
%69 = load i32, i32* @stderr
%70 = load i8*, i8** %9
%71 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.4, i64 0, i64 0), i8* %70)
store i32 0, i32* %3
br label %73
72: ; preds = %65
store i32 0, i32* %3
br label %73
73: ; preds = %72, %68, %61, %51, %46, %41, %35
%74 = load i32, i32* %3
ret i32 %74
}

LLVM IR (-O2):
@.str = [5 x i8] c"hvcd\00"
@EOF = global i8 0
@.str.1 = [10 x i8] c"%s-%d.%d\0A\00"
@stderr = global i32 0
@.str.2 = [48 x i8] c"Invalid option %s, usage: %s [-hvcd] arguments\0A\00"
@.str.3 = [66 x i8] c"Usage: %s [-hvcd] input_file ['rb' mode] output_file ['wb' mode]\0A\00"
@.str.4 = [57 x i8] c"No input arguments entered. Usage: %s [-hvcd] arguments\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = load i8*, i8** %1
%4 = tail call i8* @strrchr(i8* dereferenceable(1) %3, i8 signext 92)
%5 = icmp eq i8* %4, null
%6 = getelementptr inbounds i8, i8* %4, i64 1
%7 = select i1 %5, i8* %3, i8* %6
%8 = tail call signext i8 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%9 = load i8, i8* @EOF
%10 = icmp eq i8 %8, %9
br i1 %10, label %30, label %11
11: ; preds = %2
%12 = sext i8 %8 to i32
switch i32 %12, label %23 [
i32 118, label %13
i32 104, label %28
i32 100, label %15
i32 99, label %19
]
13: ; preds = %11
%14 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %7, i32 0, i32 3)
br label %35
15: ; preds = %11
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = tail call i32 @writeText(i8* %17)
br label %35
19: ; preds = %11
%20 = getelementptr inbounds i8*, i8** %1, i64 2
%21 = load i8*, i8** %20
%22 = tail call i32 @writeData(i8* %21)
br label %35
23: ; preds = %11
%24 = load i32, i32* @stderr
%25 = getelementptr inbounds i8*, i8** %1, i64 1
%26 = load i8*, i8** %25
%27 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i8* %26, i8* %7)
br label %35
28: ; preds = %11
%29 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.3, i64 0, i64 0), i8* %7)
br label %35
30: ; preds = %2
%31 = icmp eq i32 %0, 1
br i1 %31, label %32, label %35
32: ; preds = %30
%33 = load i32, i32* @stderr
%34 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.4, i64 0, i64 0), i8* %7)
br label %35
35: ; preds = %30, %32, %28, %23, %19, %15, %13
%36 = phi i32 [ 5, %23 ], [ 4, %19 ], [ 3, %15 ], [ 2, %28 ], [ 1, %13 ], [ 0, %32 ], [ 0, %30 ]
ret i32 %36
}