#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 */
struct option {
  char *member_0;
  char member_3;
  int /*<<< orphan*/ *member_2;
  int /*<<< orphan*/ member_1;
};

/* Variables and functions */
int /*<<< orphan*/ abort();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int getopt_long(int, char **, char const *const, struct option const *,
                int /*<<< orphan*/ *);
int /*<<< orphan*/ logo_change(char *, int);
int /*<<< orphan*/ logo_extract(char *, int);
int optind;
int /*<<< orphan*/ print_usage(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ version_etc(int /*<<< orphan*/, char *, char *, char *,
                               char *);
int main(int argc, char *argv[]) {
  int next_option;
  const char *const short_options = "hkcev";
  const struct option long_options[] = {
      {"help", 0, NULL, 'h'},    {"dmk", 0, NULL, 'k'},
      {"change", 0, NULL, 'c'},  {"extract", 0, NULL, 'e'},
      {"version", 0, NULL, 'v'}, {NULL, 0, NULL, 0}};
  char *filename;
  int isdmk = 0, change_mode = 0, extract_mode = 0;
  do {
    next_option = getopt_long(argc, argv, short_options, long_options, NULL);
    switch (next_option) {
    case 'h':
      print_usage(stderr, argv[0], 0);
    case 'k':
      isdmk = 1;
      break;
    case 'c':
      change_mode = 1;
      break;
    case 'e':
      extract_mode = 1;
      break;
    case 'v':
      version_etc(stdout, "logotool", "mpio", "", "Salmoon");
      exit(0);
    case '?':
      print_usage(stderr, argv[0], 1);
    case -1:
      break;
    default:
      abort();
    }
  } while (next_option != -1);
  if (optind == argc || (change_mode | extract_mode) == 0) {
    fprintf(stderr, "Too few arguments.\n");
    print_usage(stderr, argv[0], 1);
  }
  filename = argv[optind];
  if (extract_mode)
    logo_extract(filename, isdmk);
  if (!extract_mode && change_mode)
    logo_change(filename, isdmk);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe50(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    -0xe0(%rbp),%rdi
lea    0x2b7e(%rip),%rsi
mov    $0xc0,%edx
call   1080 <memcpy@plt>
movl   $0x0,-0xec(%rbp)
movl   $0x0,-0xf0(%rbp)
movl   $0x0,-0xf4(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe08(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r8d
lea    -0xe0(%rbp),%rcx
call   1050 <getopt_long@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0xf8(%rbp)
sub    $0xffffffff,%eax
je     132a <main+0x19a>
jmp    1223 <main+0x93>
mov    -0xf8(%rbp),%eax
sub    $0x3f,%eax
je     1310 <main+0x180>
jmp    1237 <main+0xa7>
mov    -0xf8(%rbp),%eax
sub    $0x63,%eax
je     12c1 <main+0x131>
jmp    124b <main+0xbb>
mov    -0xf8(%rbp),%eax
sub    $0x65,%eax
je     12d0 <main+0x140>
jmp    125f <main+0xcf>
mov    -0xf8(%rbp),%eax
sub    $0x68,%eax
je     129b <main+0x10b>
jmp    1273 <main+0xe3>
mov    -0xf8(%rbp),%eax
sub    $0x6b,%eax
je     12b2 <main+0x122>
jmp    1287 <main+0xf7>
mov    -0xf8(%rbp),%eax
sub    $0x76,%eax
je     12df <main+0x14f>
jmp    132f <main+0x19f>
mov    0x2d2e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
xor    %edx,%edx
call   10b0 <print_usage@plt>
movl   $0x1,-0xec(%rbp)
jmp    1336 <main+0x1a6>
movl   $0x1,-0xf0(%rbp)
jmp    1336 <main+0x1a6>
movl   $0x1,-0xf4(%rbp)
jmp    1336 <main+0x1a6>
mov    0x2ce2(%rip),%rax
mov    (%rax),%edi
lea    0xd37(%rip),%rsi
lea    0xd39(%rip),%rdx
lea    0xd52(%rip),%rcx
lea    0xd30(%rip),%r8
call   1030 <version_etc@plt>
xor    %edi,%edi
call   10a0 <exit@plt>
mov    0x2cb9(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    $0x1,%edx
call   10b0 <print_usage@plt>
jmp    1336 <main+0x1a6>
mov    $0x0,%al
call   1040 <abort@plt>
jmp    133b <main+0x1ab>
cmpl   $0xffffffff,-0x14(%rbp)
jne    11ea <main+0x5a>
mov    0x2c94(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
je     136c <main+0x1dc>
mov    -0xf0(%rbp),%eax
or     -0xf4(%rbp),%eax
cmp    $0x0,%eax
jne    139b <main+0x20b>
mov    0x2c5d(%rip),%rax
mov    (%rax),%edi
lea    0xcc0(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2c48(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    $0x1,%edx
call   10b0 <print_usage@plt>
mov    -0x10(%rbp),%rax
mov    0x2c3a(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0xe8(%rbp)
cmpl   $0x0,-0xf4(%rbp)
je     13d3 <main+0x243>
mov    -0xe8(%rbp),%rdi
mov    -0xec(%rbp),%esi
call   1090 <logo_extract@plt>
cmpl   $0x0,-0xf4(%rbp)
jne    13ff <main+0x26f>
cmpl   $0x0,-0xf0(%rbp)
je     13ff <main+0x26f>
mov    -0xe8(%rbp),%rdi
mov    -0xec(%rbp),%esi
call   1060 <logo_change@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0x2b93(%rip),%rsi
lea    0x10(%rsp),%r15
mov    $0xc0,%edx
mov    %r15,%rdi
call   1080 <memcpy@plt>
xor    %r14d,%r14d
lea    0xe87(%rip),%r12
mov    0x2e00(%rip),%r13
movl   $0x0,0x8(%rsp)
movl   $0x0,0x4(%rsp)
mov    %r14d,%eax
mov    %r14d,0xc(%rsp)
jmp    1201 <main+0x71>
nopw   0x0(%rax,%rax,1)
mov    0x0(%r13),%edi
mov    (%rbx),%rsi
mov    $0x1,%edx
call   10b0 <print_usage@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
mov    %r15,%rcx
xor    %r8d,%r8d
call   1050 <getopt_long@plt>
cmp    $0x3f,%eax
je     11f0 <main+0x60>
lea    -0x63(%rax),%ecx
cmp    $0x13,%ecx
ja     1260 <main+0xd0>
mov    $0x1,%r14d
lea    0xdd2(%rip),%rdx
movslq (%rdx,%rcx,4),%rax
add    %rdx,%rax
jmp    *%rax
movl   $0x1,0x8(%rsp)
jmp    1201 <main+0x71>
movl   $0x1,0x4(%rsp)
jmp    1201 <main+0x71>
nopl   0x0(%rax,%rax,1)
mov    0x0(%r13),%edi
mov    (%rbx),%rsi
xor    %edx,%edx
call   10b0 <print_usage@plt>
jmp    11e0 <main+0x50>
cmp    $0xffffffff,%eax
jne    12de <main+0x14e>
mov    0x2d74(%rip),%r14
mov    (%r14),%eax
cmp    %ebp,%eax
mov    0x8(%rsp),%r15d
mov    0x4(%rsp),%ebp
je     1283 <main+0xf3>
mov    %ebp,%ecx
or     %r15d,%ecx
jne    12a7 <main+0x117>
mov    0x0(%r13),%edi
lea    0xdfe(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x0(%r13),%edi
mov    (%rbx),%rsi
mov    $0x1,%edx
call   10b0 <print_usage@plt>
mov    (%r14),%eax
cltq
mov    (%rbx,%rax,8),%rdi
test   %ebp,%ebp
je     12bc <main+0x12c>
mov    0xc(%rsp),%esi
call   1090 <logo_extract@plt>
jmp    12ca <main+0x13a>
test   %r15d,%r15d
je     12ca <main+0x13a>
mov    0xc(%rsp),%esi
call   1060 <logo_change@plt>
xor    %eax,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   1040 <abort@plt>
mov    0x2cdc(%rip),%rax
mov    (%rax),%edi
lea    0xd81(%rip),%rsi
lea    0xd83(%rip),%rdx
lea    0xd9c(%rip),%rcx
lea    0xd7a(%rip),%r8
call   1030 <version_etc@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
%struct.option = type { i8*, i8, i32*, i32 }
@.str = [6 x i8] c"hkcev\00"
@.str.1 = [5 x i8] c"help\00"
@.str.2 = [4 x i8] c"dmk\00"
@.str.3 = [7 x i8] c"change\00"
@.str.4 = [8 x i8] c"extract\00"
@.str.5 = [8 x i8] c"version\00"
@__const.main.long_options = [6 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i8 0, i32* null, i32 104 }, %struct.option { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i8 0, i32* null, i32 107 }, %struct.option { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i32 0, i32 0), i8 0, i32* null, i32 99 }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i32 0, i32 0), i8 0, i32* null, i32 101 }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i32 0, i32 0), i8 0, i32* null, i32 118 }, %struct.option zeroinitializer]
@stderr = global i32 0
@stdout = global i32 0
@.str.6 = [9 x i8] c"logotool\00"
@.str.7 = [5 x i8] c"mpio\00"
@.str.8 = [1 x i8] zeroinitializer
@.str.9 = [8 x i8] c"Salmoon\00"
@optind = global i32 0
@.str.10 = [20 x i8] c"Too few arguments.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca [6 x %struct.option]
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %7
%13 = bitcast [6 x %struct.option]* %8 to i8*
store i32 0, i32* %10
store i32 0, i32* %11
store i32 0, i32* %12
br label %14
14: ; preds = %43, %2
%15 = load i32, i32* %4
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds [6 x %struct.option], [6 x %struct.option]* %8, i64 0, i64 0
%18 = call i32 @getopt_long(i32 %15, i8** %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0), %struct.option* %17, i32* null)
store i32 %18, i32* %6
%19 = load i32, i32* %6
switch i32 %19, label %40 [
i32 104, label %20
i32 107, label %26
i32 99, label %27
i32 101, label %28
i32 118, label %29
i32 63, label %33
i32 -1, label %39
]
20: ; preds = %14
%21 = load i32, i32* @stderr
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 0
%24 = load i8*, i8** %23
%25 = call i32 @print_usage(i32 %21, i8* %24, i32 0)
br label %26
26: ; preds = %14, %20
store i32 1, i32* %10
br label %42
27: ; preds = %14
store i32 1, i32* %11
br label %42
28: ; preds = %14
store i32 1, i32* %12
br label %42
29: ; preds = %14
%30 = load i32, i32* @stdout
%31 = call i32 @version_etc(i32 %30, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
%32 = call i32 @exit(i32 0)
unreachable
33: ; preds = %14
%34 = load i32, i32* @stderr
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 0
%37 = load i8*, i8** %36
%38 = call i32 @print_usage(i32 %34, i8* %37, i32 1)
br label %39
39: ; preds = %14, %33
br label %42
40: ; preds = %14
%41 = call i32 (...) @abort()
unreachable
42: ; preds = %39, %28, %27, %26
br label %43
43: ; preds = %42
%44 = load i32, i32* %6
%45 = icmp ne i32 %44, -1
br i1 %45, label %14, label %46
46: ; preds = %43
%47 = load i32, i32* @optind
%48 = load i32, i32* %4
%49 = icmp eq i32 %47, %48
br i1 %49, label %55, label %50
50: ; preds = %46
%51 = load i32, i32* %11
%52 = load i32, i32* %12
%53 = or i32 %51, %52
%54 = icmp eq i32 %53, 0
br i1 %54, label %55, label %63
55: ; preds = %50, %46
%56 = load i32, i32* @stderr
%57 = call i32 @fprintf(i32 %56, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0))
%58 = load i32, i32* @stderr
%59 = load i8**, i8*** %5
%60 = getelementptr inbounds i8*, i8** %59, i64 0
%61 = load i8*, i8** %60
%62 = call i32 @print_usage(i32 %58, i8* %61, i32 1)
br label %63
63: ; preds = %55, %50
%64 = load i8**, i8*** %5
%65 = load i32, i32* @optind
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i8*, i8** %64, i64 %66
%68 = load i8*, i8** %67
store i8* %68, i8** %9
%69 = load i32, i32* %12
%70 = icmp ne i32 %69, 0
br i1 %70, label %71, label %75
71: ; preds = %63
%72 = load i8*, i8** %9
%73 = load i32, i32* %10
%74 = call i32 @logo_extract(i8* %72, i32 %73)
br label %75
75: ; preds = %71, %63
%76 = load i32, i32* %12
%77 = icmp ne i32 %76, 0
br i1 %77, label %85, label %78
78: ; preds = %75
%79 = load i32, i32* %11
%80 = icmp ne i32 %79, 0
br i1 %80, label %81, label %85
81: ; preds = %78
%82 = load i8*, i8** %9
%83 = load i32, i32* %10
%84 = call i32 @logo_change(i8* %82, i32 %83)
br label %85
85: ; preds = %81, %78, %75
ret i32 0
}

LLVM IR (-O2):
%struct.option = type { i8*, i8, i32*, i32 }
@.str = [6 x i8] c"hkcev\00"
@.str.1 = [5 x i8] c"help\00"
@.str.2 = [4 x i8] c"dmk\00"
@.str.3 = [7 x i8] c"change\00"
@.str.4 = [8 x i8] c"extract\00"
@.str.5 = [8 x i8] c"version\00"
@__const.main.long_options = [6 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i8 0, i32* null, i32 104 }, %struct.option { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i8 0, i32* null, i32 107 }, %struct.option { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i32 0, i32 0), i8 0, i32* null, i32 99 }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i32 0, i32 0), i8 0, i32* null, i32 101 }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i32 0, i32 0), i8 0, i32* null, i32 118 }, %struct.option zeroinitializer]
@stderr = global i32 0
@stdout = global i32 0
@.str.6 = [9 x i8] c"logotool\00"
@.str.7 = [5 x i8] c"mpio\00"
@.str.8 = [1 x i8] zeroinitializer
@.str.9 = [8 x i8] c"Salmoon\00"
@optind = global i32 0
@.str.10 = [20 x i8] c"Too few arguments.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [6 x %struct.option]
%4 = bitcast [6 x %struct.option]* %3 to i8*
%5 = getelementptr inbounds [6 x %struct.option], [6 x %struct.option]* %3, i64 0, i64 0
br label %6
6: ; preds = %21, %2
%7 = phi i32 [ 0, %2 ], [ 1, %21 ]
%8 = phi i32 [ 0, %2 ], [ %11, %21 ]
%9 = phi i32 [ 0, %2 ], [ %14, %21 ]
br label %10
10: ; preds = %15, %6
%11 = phi i32 [ %8, %6 ], [ 1, %15 ]
%12 = phi i32 [ %9, %6 ], [ %14, %15 ]
br label %13
13: ; preds = %15, %10
%14 = phi i32 [ %12, %10 ], [ 1, %15 ]
br label %15
15: ; preds = %13, %26
%16 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %struct.option* %5, i32* null)
switch i32 %16, label %30 [
i32 104, label %17
i32 107, label %21
i32 99, label %10
i32 101, label %13
i32 118, label %22
i32 63, label %26
i32 -1, label %32
]
17: ; preds = %15
%18 = load i32, i32* @stderr
%19 = load i8*, i8** %1
%20 = call i32 @print_usage(i32 %18, i8* %19, i32 0)
br label %21
21: ; preds = %15, %17
br label %6
22: ; preds = %15
%23 = load i32, i32* @stdout
%24 = call i32 @version_etc(i32 %23, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
%25 = call i32 @exit(i32 0)
unreachable
26: ; preds = %15
%27 = load i32, i32* @stderr
%28 = load i8*, i8** %1
%29 = call i32 @print_usage(i32 %27, i8* %28, i32 1)
br label %15
30: ; preds = %15
%31 = call i32 (...) @abort()
unreachable
32: ; preds = %15
%33 = load i32, i32* @optind
%34 = icmp eq i32 %33, %0
%35 = or i32 %14, %11
%36 = icmp eq i32 %35, 0
%37 = select i1 %34, i1 true, i1 %36
br i1 %37, label %38, label %45
38: ; preds = %32
%39 = load i32, i32* @stderr
%40 = call i32 @fprintf(i32 %39, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0))
%41 = load i32, i32* @stderr
%42 = load i8*, i8** %1
%43 = call i32 @print_usage(i32 %41, i8* %42, i32 1)
%44 = load i32, i32* @optind
br label %45
45: ; preds = %32, %38
%46 = phi i32 [ %33, %32 ], [ %44, %38 ]
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8*, i8** %1, i64 %47
%49 = load i8*, i8** %48
%50 = icmp eq i32 %14, 0
br i1 %50, label %53, label %51
51: ; preds = %45
%52 = call i32 @logo_extract(i8* %49, i32 %7)
br label %57
53: ; preds = %45
%54 = icmp eq i32 %11, 0
br i1 %54, label %57, label %55
55: ; preds = %53
%56 = call i32 @logo_change(i8* %49, i32 %7)
br label %57
57: ; preds = %51, %55, %53
ret i32 0
}