#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 */
typedef int /*<<< orphan*/ file2;
typedef int /*<<< orphan*/ file;

/* Variables and functions */
int /*<<< orphan*/ banner();
int /*<<< orphan*/ degcompress(char *, char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
int /*<<< orphan*/ gcompress(char *, char *);
int /*<<< orphan*/ helpme();
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ xorfile(char *, char *);
int main(int argc, char **argv) {
  char file[128];
  char file2[128];
  banner();
  if (argc != 3) {
    helpme();
    exit(1);
  }
  if (strcmp(argv[1], "-d") == 0) {
    snprintf((char *)&file, sizeof(file), "%s-dexor", argv[2]);
    snprintf((char *)&file2, sizeof(file2), "%s.gz", file);
    xorfile(argv[2], (char *)&file2);
    degcompress((char *)&file2, (char *)&file);
    fprintf(stderr, "written %s and %s\n", (char *)&file2, (char *)&file);
  } else if (strcmp(argv[1], "-c") == 0) {
    snprintf((char *)&file, sizeof(file), "%s.hpe", argv[2]);
    snprintf((char *)&file2, sizeof(file2), "%s.gz", argv[2]);
    gcompress(argv[2], (char *)&file2);
    xorfile((char *)&file2, (char *)&file);
    fprintf(stderr, "written %s and %s\n", (char *)&file2, (char *)&file);
  } else
    helpme();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1070 <banner@plt>
cmpl   $0x3,-0x8(%rbp)
je     11cb <main+0x3b>
mov    $0x0,%al
call   1030 <helpme@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe26(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1277 <main+0xe7>
lea    -0x90(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rcx
mov    $0x80,%esi
lea    0xdff(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x110(%rbp),%rdi
lea    -0x90(%rbp),%rcx
mov    $0x80,%esi
lea    0xde9(%rip),%rdx
call   1050 <snprintf@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    -0x110(%rbp),%rsi
call   1060 <xorfile@plt>
lea    -0x110(%rbp),%rdi
lea    -0x90(%rbp),%rsi
call   1040 <degcompress@plt>
mov    0x2d8a(%rip),%rax
mov    (%rax),%edi
lea    -0x110(%rbp),%rdx
lea    -0x90(%rbp),%rcx
lea    0xda5(%rip),%rsi
call   1090 <fprintf@plt>
jmp    1330 <main+0x1a0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd9f(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1324 <main+0x194>
lea    -0x90(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rcx
mov    $0x80,%esi
lea    0xd78(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x110(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rcx
mov    $0x80,%esi
lea    0xd3c(%rip),%rdx
call   1050 <snprintf@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    -0x110(%rbp),%rsi
call   10a0 <gcompress@plt>
lea    -0x110(%rbp),%rdi
lea    -0x90(%rbp),%rsi
call   1060 <xorfile@plt>
mov    0x2cdd(%rip),%rax
mov    (%rax),%edi
lea    -0x110(%rbp),%rdx
lea    -0x90(%rbp),%rcx
lea    0xcf8(%rip),%rsi
call   1090 <fprintf@plt>
jmp    132b <main+0x19b>
mov    $0x0,%al
call   1030 <helpme@plt>
jmp    1330 <main+0x1a0>
mov    -0x4(%rbp),%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %eax,%eax
call   1070 <banner@plt>
cmp    $0x3,%ebp
jne    12b4 <main+0x124>
mov    0x8(%rbx),%rdi
lea    0xe45(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     11e6 <main+0x56>
mov    0x8(%rbx),%rdi
lea    0xe55(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1239 <main+0xa9>
xor    %eax,%eax
call   1030 <helpme@plt>
jmp    12a6 <main+0x116>
mov    0x10(%rbx),%rcx
lea    0xe12(%rip),%rdx
lea    0x80(%rsp),%r14
mov    %r14,%rdi
mov    $0x80,%esi
call   1050 <snprintf@plt>
lea    0xdff(%rip),%rdx
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    $0x80,%esi
mov    %r14,%rcx
call   1050 <snprintf@plt>
mov    0x10(%rbx),%rdi
mov    %rbp,%rsi
call   1060 <xorfile@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   1040 <degcompress@plt>
jmp    128b <main+0xfb>
mov    0x10(%rbx),%rcx
lea    0xde4(%rip),%rdx
lea    0x80(%rsp),%r14
mov    %r14,%rdi
mov    $0x80,%esi
call   1050 <snprintf@plt>
mov    0x10(%rbx),%rcx
lea    0xda8(%rip),%rdx
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    $0x80,%esi
call   1050 <snprintf@plt>
mov    0x10(%rbx),%rdi
mov    %rbp,%rsi
call   10a0 <gcompress@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   1060 <xorfile@plt>
mov    0x2d4e(%rip),%rax
mov    (%rax),%edi
lea    0xd77(%rip),%rsi
mov    %rbp,%rdx
mov    %r14,%rcx
call   1090 <fprintf@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %eax,%eax
call   1030 <helpme@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"-d\00"
@.str.1 = [9 x i8] c"%s-dexor\00"
@.str.2 = [6 x i8] c"%s.gz\00"
@stderr = global i32 0
@.str.3 = [19 x i8] c"written %s and %s\0A\00"
@.str.4 = [3 x i8] c"-c\00"
@.str.5 = [7 x i8] c"%s.hpe\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [128 x i8]
%7 = alloca [128 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 (...) @banner()
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 3
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = call i32 (...) @helpme()
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %41
20: ; preds = %14
%21 = bitcast [128 x i8]* %6 to i8*
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
%25 = call i32 @snprintf(i8* %21, i32 128, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %24)
%26 = bitcast [128 x i8]* %7 to i8*
%27 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%28 = call i32 @snprintf(i8* %26, i32 128, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %27)
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 2
%31 = load i8*, i8** %30
%32 = bitcast [128 x i8]* %7 to i8*
%33 = call i32 @xorfile(i8* %31, i8* %32)
%34 = bitcast [128 x i8]* %7 to i8*
%35 = bitcast [128 x i8]* %6 to i8*
%36 = call i32 @degcompress(i8* %34, i8* %35)
%37 = load i32, i32* @stderr
%38 = bitcast [128 x i8]* %7 to i8*
%39 = bitcast [128 x i8]* %6 to i8*
%40 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %38, i8* %39)
br label %73
41: ; preds = %14
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 1
%44 = load i8*, i8** %43
%45 = call i64 @strcmp(i8* %44, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %70
47: ; preds = %41
%48 = bitcast [128 x i8]* %6 to i8*
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 2
%51 = load i8*, i8** %50
%52 = call i32 @snprintf(i8* %48, i32 128, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* %51)
%53 = bitcast [128 x i8]* %7 to i8*
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 2
%56 = load i8*, i8** %55
%57 = call i32 @snprintf(i8* %53, i32 128, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %56)
%58 = load i8**, i8*** %5
%59 = getelementptr inbounds i8*, i8** %58, i64 2
%60 = load i8*, i8** %59
%61 = bitcast [128 x i8]* %7 to i8*
%62 = call i32 @gcompress(i8* %60, i8* %61)
%63 = bitcast [128 x i8]* %7 to i8*
%64 = bitcast [128 x i8]* %6 to i8*
%65 = call i32 @xorfile(i8* %63, i8* %64)
%66 = load i32, i32* @stderr
%67 = bitcast [128 x i8]* %7 to i8*
%68 = bitcast [128 x i8]* %6 to i8*
%69 = call i32 @fprintf(i32 %66, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %67, i8* %68)
br label %72
70: ; preds = %41
%71 = call i32 (...) @helpme()
br label %72
72: ; preds = %70, %47
br label %73
73: ; preds = %72, %20
%74 = load i32, i32* %3
ret i32 %74
}

LLVM IR (-O2):
@.str = [3 x i8] c"-d\00"
@.str.1 = [9 x i8] c"%s-dexor\00"
@.str.2 = [6 x i8] c"%s.gz\00"
@stderr = global i32 0
@.str.3 = [19 x i8] c"written %s and %s\0A\00"
@.str.4 = [3 x i8] c"-c\00"
@.str.5 = [7 x i8] c"%s.hpe\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [128 x i8]
%4 = alloca [128 x i8]
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%7 = tail call i32 (...) @banner()
%8 = icmp eq i32 %0, 3
br i1 %8, label %12, label %9
9: ; preds = %2
%10 = tail call i32 (...) @helpme()
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %27
17: ; preds = %12
%18 = getelementptr inbounds i8*, i8** %1, i64 2
%19 = load i8*, i8** %18
%20 = call i32 @snprintf(i8* %6, i32 128, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %19)
%21 = call i32 @snprintf(i8* %5, i32 128, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%22 = load i8*, i8** %18
%23 = call i32 @xorfile(i8* %22, i8* %5)
%24 = call i32 @degcompress(i8* %5, i8* %6)
%25 = load i32, i32* @stderr
%26 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %5, i8* %6)
br label %44
27: ; preds = %12
%28 = load i8*, i8** %13
%29 = tail call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %42
31: ; preds = %27
%32 = getelementptr inbounds i8*, i8** %1, i64 2
%33 = load i8*, i8** %32
%34 = call i32 @snprintf(i8* %6, i32 128, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* %33)
%35 = load i8*, i8** %32
%36 = call i32 @snprintf(i8* %5, i32 128, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %35)
%37 = load i8*, i8** %32
%38 = call i32 @gcompress(i8* %37, i8* %5)
%39 = call i32 @xorfile(i8* %5, i8* %6)
%40 = load i32, i32* @stderr
%41 = call i32 @fprintf(i32 %40, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %5, i8* %6)
br label %44
42: ; preds = %27
%43 = tail call i32 (...) @helpme()
br label %44
44: ; preds = %31, %42, %17
ret i32 0
}