#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ CWVCompress(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ CWVDecompress(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *);
scalar_t__ strcmp(char *, char *);
void main(int argc, char *argv[]) {
  FILE *wav, *cwv;
  if (strcmp("-c", argv[1]) == 0) {
    wav = fopen(argv[2], "rb");
    cwv = fopen(argv[3], "wb");
    CWVCompress(cwv, wav);
    fclose(cwv);
    fclose(wav);
  } else if (strcmp("-d", argv[1]) == 0) {
    cwv = fopen(argv[2], "rb");
    wav = fopen(argv[3], "wb");
    CWVDecompress(wav, cwv);
    fclose(cwv);
    fclose(wav);
  } else {
    printf("WAVE File Compressor.\n");
    printf("USAGE: $ cwv [-c|-d] [input file] [output file]\n");
    printf("\t-c\tCompress.\n");
    printf("\t-d\tDecompress.\n");
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe82(%rip),%rdi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    11e1 <main+0x81>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe67(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe52(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1080 <CWVCompress@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
jmp    1294 <main+0x134>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe19(%rip),%rdi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1253 <main+0xf3>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdf5(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xde0(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <CWVDecompress@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
jmp    128f <main+0x12f>
lea    0xdb2(%rip),%rdi
call   1040 <printf@plt>
lea    0xdbd(%rip),%rdi
call   1040 <printf@plt>
lea    0xde2(%rip),%rdi
call   1040 <printf@plt>
lea    0xde5(%rip),%rdi
call   1040 <printf@plt>
lea    0xd97(%rip),%rdi
call   1040 <printf@plt>
jmp    1294 <main+0x134>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    0x8(%rsi),%rsi
lea    0xe7e(%rip),%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     11e2 <main+0x72>
mov    0x8(%rbx),%rsi
lea    0xe72(%rip),%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1220 <main+0xb0>
lea    0xe64(%rip),%rdi
call   1040 <puts@plt>
lea    0xe6e(%rip),%rdi
call   1040 <puts@plt>
lea    0xe92(%rip),%rdi
call   1040 <puts@plt>
lea    0xe94(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <putchar@plt>
mov    0x10(%rbx),%rdi
lea    0xe16(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
mov    0x18(%rbx),%rdi
lea    0xe06(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1090 <CWVCompress@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    %r14,%rdi
jmp    125c <main+0xec>
mov    0x10(%rbx),%rdi
lea    0xdd8(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
mov    0x18(%rbx),%rdi
lea    0xdc8(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1060 <CWVDecompress@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <fclose@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"-c\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [3 x i8] c"wb\00"
@.str.3 = [3 x i8] c"-d\00"
@.str.4 = [23 x i8] c"WAVE File Compressor.\0A\00"
@.str.5 = [49 x i8] c"USAGE: $ cwv [-c|-d] [input file] [output file]\0A\00"
@.str.6 = [15 x i8] c"\09-c\09Compress.\0A\00"
@.str.7 = [17 x i8] c"\09-d\09Decompress.\0A\00"
@.str.8 = [2 x i8] c"\0A\00"
define void @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32*
%6 = alloca i32*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%7 = load i8**, i8*** %4
%8 = getelementptr inbounds i8*, i8** %7, i64 1
%9 = load i8*, i8** %8
%10 = call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %28
12: ; preds = %2
%13 = load i8**, i8*** %4
%14 = getelementptr inbounds i8*, i8** %13, i64 2
%15 = load i8*, i8** %14
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %16, i32** %5
%17 = load i8**, i8*** %4
%18 = getelementptr inbounds i8*, i8** %17, i64 3
%19 = load i8*, i8** %18
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %20, i32** %6
%21 = load i32*, i32** %6
%22 = load i32*, i32** %5
%23 = call i32 @CWVCompress(i32* %21, i32* %22)
%24 = load i32*, i32** %6
%25 = call i32 @fclose(i32* %24)
%26 = load i32*, i32** %5
%27 = call i32 @fclose(i32* %26)
br label %57
28: ; preds = %2
%29 = load i8**, i8*** %4
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %31)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %50
34: ; preds = %28
%35 = load i8**, i8*** %4
%36 = getelementptr inbounds i8*, i8** %35, i64 2
%37 = load i8*, i8** %36
%38 = call i32* @fopen(i8* %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %38, i32** %6
%39 = load i8**, i8*** %4
%40 = getelementptr inbounds i8*, i8** %39, i64 3
%41 = load i8*, i8** %40
%42 = call i32* @fopen(i8* %41, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %42, i32** %5
%43 = load i32*, i32** %5
%44 = load i32*, i32** %6
%45 = call i32 @CWVDecompress(i32* %43, i32* %44)
%46 = load i32*, i32** %6
%47 = call i32 @fclose(i32* %46)
%48 = load i32*, i32** %5
%49 = call i32 @fclose(i32* %48)
br label %56
50: ; preds = %28
%51 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%52 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0))
%53 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
%54 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
%55 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %56
56: ; preds = %50, %34
br label %57
57: ; preds = %56, %12
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"-c\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [3 x i8] c"wb\00"
@.str.3 = [3 x i8] c"-d\00"
@str = [22 x i8] c"WAVE File Compressor.\00"
@str.9 = [48 x i8] c"USAGE: $ cwv [-c|-d] [input file] [output file]\00"
@str.10 = [14 x i8] c"\09-c\09Compress.\00"
@str.11 = [16 x i8] c"\09-d\09Decompress.\00"
define void @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %17
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 2
%9 = load i8*, i8** %8
%10 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%11 = getelementptr inbounds i8*, i8** %1, i64 3
%12 = load i8*, i8** %11
%13 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%14 = tail call i32 @CWVCompress(i32* %13, i32* %10)
%15 = tail call i32 @fclose(i32* %13)
%16 = tail call i32 @fclose(i32* %10)
br label %37
17: ; preds = %2
%18 = load i8*, i8** %3
%19 = tail call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %31
21: ; preds = %17
%22 = getelementptr inbounds i8*, i8** %1, i64 2
%23 = load i8*, i8** %22
%24 = tail call i32* @fopen(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%25 = getelementptr inbounds i8*, i8** %1, i64 3
%26 = load i8*, i8** %25
%27 = tail call i32* @fopen(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%28 = tail call i32 @CWVDecompress(i32* %27, i32* %24)
%29 = tail call i32 @fclose(i32* %24)
%30 = tail call i32 @fclose(i32* %27)
br label %37
31: ; preds = %17
%32 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%33 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.9, i64 0, i64 0))
%34 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.10, i64 0, i64 0))
%35 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.11, i64 0, i64 0))
%36 = tail call i32 @putchar(i32 10)
br label %37
37: ; preds = %21, %31, %7
ret void
}