#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 */
void *codec2_create();
int /*<<< orphan*/ codec2_decode(void *, short *, unsigned char *);
int /*<<< orphan*/ codec2_destroy(void *);
int /*<<< orphan*/ codec2_encode(void *, unsigned char *, short *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
int fread(short *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(short *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  void *codec2;
  FILE *fin;
  FILE *fout;
  short buf[160];
  unsigned char bits[((50 + 7) / 8)];
  if (argc != 3) {
    printf("usage: %s InputRawSpeechFile OutputRawSpeechFile\n", argv[0]);
    exit(1);
  }
  if ((fin = fopen(argv[1], "rb")) == NULL) {
    fprintf(stderr, "Error opening input speech file: %s: %s.\n", argv[1],
            strerror(errno));
    exit(1);
  }
  if ((fout = fopen(argv[2], "wb")) == NULL) {
    fprintf(stderr, "Error opening output speech file: %s: %s.\n", argv[2],
            strerror(errno));
    exit(1);
  }
  codec2 = codec2_create();
  while (fread(buf, sizeof(short), 160, fin) == 160) {
    codec2_encode(codec2, bits, buf);
    codec2_decode(codec2, buf, bits);
    fwrite(buf, sizeof(short), 160, fout);
  }
  codec2_destroy(codec2);
  fclose(fin);
  fclose(fout);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1a0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1200 <main+0x40>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe0f(%rip),%rdi
call   1070 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe23(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1274 <main+0xb4>
mov    0x2db7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x184(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x180(%rbp)
mov    0x2d91(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x184(%rbp),%edi
mov    -0x180(%rbp),%rdx
mov    %rax,%rcx
lea    0xdd0(%rip),%rsi
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xddc(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    12e8 <main+0x128>
mov    0x2d43(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x194(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x190(%rbp)
mov    0x2d1d(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x194(%rbp),%edi
mov    -0x190(%rbp),%rdx
mov    %rax,%rcx
lea    0xd89(%rip),%rsi
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    $0x0,%al
call   10a0 <codec2_create@plt>
mov    %rax,-0x18(%rbp)
lea    -0x170(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x2,%esi
mov    $0xa0,%edx
call   1050 <fread@plt>
cmp    $0xa0,%eax
jne    1365 <main+0x1a5>
mov    -0x18(%rbp),%rdi
lea    -0x177(%rbp),%rsi
lea    -0x170(%rbp),%rdx
call   1080 <codec2_encode@plt>
mov    -0x18(%rbp),%rdi
lea    -0x170(%rbp),%rsi
lea    -0x177(%rbp),%rdx
call   1040 <codec2_decode@plt>
lea    -0x170(%rbp),%rdi
mov    -0x28(%rbp),%rcx
mov    $0x2,%esi
mov    $0xa0,%edx
call   10d0 <fwrite@plt>
jmp    12f3 <main+0x133>
mov    -0x18(%rbp),%rdi
call   1030 <codec2_destroy@plt>
mov    -0x20(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1060 <fclose@plt>
xor    %eax,%eax
add    $0x1a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x158,%rsp
mov    %rsi,%rbx
cmp    $0x3,%edi
jne    12c9 <main+0x109>
mov    0x8(%rbx),%rdi
lea    0xe4a(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     12e2 <main+0x122>
mov    %rax,%r14
mov    0x10(%rbx),%rdi
lea    0xe5b(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     1306 <main+0x146>
mov    %rax,%r15
xor    %eax,%eax
call   10a0 <codec2_create@plt>
mov    %rax,%r13
lea    0x10(%rsp),%rdi
mov    $0x2,%esi
mov    $0xa0,%edx
mov    %r14,%rcx
call   1050 <fread@plt>
cmp    $0xa0,%eax
jne    129d <main+0xdd>
lea    0x9(%rsp),%r12
lea    0x10(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1080 <codec2_encode@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
call   1040 <codec2_decode@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0xa0,%edx
mov    %r15,%rcx
call   10d0 <fwrite@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0xa0,%edx
mov    %r14,%rcx
call   1050 <fread@plt>
cmp    $0xa0,%eax
je     1250 <main+0x90>
mov    %r13,%rdi
call   1030 <codec2_destroy@plt>
mov    %r14,%rdi
call   1060 <fclose@plt>
mov    %r15,%rdi
call   1060 <fclose@plt>
xor    %eax,%eax
add    $0x158,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%rbx),%rsi
lea    0xd2d(%rip),%rdi
call   1070 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    0x2cf7(%rip),%rax
mov    (%rax),%ebp
mov    0x8(%rbx),%rbx
mov    0x2ce2(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xd31(%rip),%rsi
jmp    1328 <main+0x168>
mov    0x2cd3(%rip),%rax
mov    (%rax),%ebp
mov    0x10(%rbx),%rbx
mov    0x2cbe(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xd3a(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [50 x i8] c"usage: %s InputRawSpeechFile OutputRawSpeechFile\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.2 = [42 x i8] c"Error opening input speech file: %s: %s.\0A\00"
@errno = global i32 0
@.str.3 = [3 x i8] c"wb\00"
@.str.4 = [43 x i8] c"Error opening output speech file: %s: %s.\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 [160 x i16]
%10 = alloca [7 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 3
br i1 %12, label %13, label %19
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32* @fopen(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %23, i32** %7
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %34
25: ; preds = %19
%26 = load i32, i32* @stderr
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = load i32, i32* @errno
%31 = call i8* @strerror(i32 %30)
%32 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i8* %29, i8* %31)
%33 = call i32 @exit(i32 1)
unreachable
34: ; preds = %19
%35 = load i8**, i8*** %5
%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.3, i64 0, i64 0))
store i32* %38, i32** %8
%39 = icmp eq i32* %38, null
br i1 %39, label %40, label %49
40: ; preds = %34
%41 = load i32, i32* @stderr
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 2
%44 = load i8*, i8** %43
%45 = load i32, i32* @errno
%46 = call i8* @strerror(i32 %45)
%47 = call i32 @fprintf(i32 %41, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), i8* %44, i8* %46)
%48 = call i32 @exit(i32 1)
unreachable
49: ; preds = %34
%50 = call i8* (...) @codec2_create()
store i8* %50, i8** %6
br label %51
51: ; preds = %56, %49
%52 = getelementptr inbounds [160 x i16], [160 x i16]* %9, i64 0, i64 0
%53 = load i32*, i32** %7
%54 = call i32 @fread(i16* %52, i32 2, i32 160, i32* %53)
%55 = icmp eq i32 %54, 160
br i1 %55, label %56, label %68
56: ; preds = %51
%57 = load i8*, i8** %6
%58 = getelementptr inbounds [7 x i8], [7 x i8]* %10, i64 0, i64 0
%59 = getelementptr inbounds [160 x i16], [160 x i16]* %9, i64 0, i64 0
%60 = call i32 @codec2_encode(i8* %57, i8* %58, i16* %59)
%61 = load i8*, i8** %6
%62 = getelementptr inbounds [160 x i16], [160 x i16]* %9, i64 0, i64 0
%63 = getelementptr inbounds [7 x i8], [7 x i8]* %10, i64 0, i64 0
%64 = call i32 @codec2_decode(i8* %61, i16* %62, i8* %63)
%65 = getelementptr inbounds [160 x i16], [160 x i16]* %9, i64 0, i64 0
%66 = load i32*, i32** %8
%67 = call i32 @fwrite(i16* %65, i32 2, i32 160, i32* %66)
br label %51
68: ; preds = %51
%69 = load i8*, i8** %6
%70 = call i32 @codec2_destroy(i8* %69)
%71 = load i32*, i32** %7
%72 = call i32 @fclose(i32* %71)
%73 = load i32*, i32** %8
%74 = call i32 @fclose(i32* %73)
ret i32 0
}

LLVM IR (-O2):
@.str = [50 x i8] c"usage: %s InputRawSpeechFile OutputRawSpeechFile\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.2 = [42 x i8] c"Error opening input speech file: %s: %s.\0A\00"
@errno = global i32 0
@.str.3 = [3 x i8] c"wb\00"
@.str.4 = [43 x i8] c"Error opening output speech file: %s: %s.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [160 x i16]
%4 = alloca [7 x i8]
%5 = bitcast [160 x i16]* %3 to i8*
%6 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 0, i64 0
%7 = icmp eq i32 %0, 3
br i1 %7, label %12, label %8
8: ; preds = %2
%9 = load i8*, i8** %1
%10 = tail call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i8* %9)
%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 i32* @fopen(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %24
17: ; preds = %12
%18 = load i32, i32* @stderr
%19 = load i8*, i8** %13
%20 = load i32, i32* @errno
%21 = tail call i8* @strerror(i32 %20)
%22 = tail call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i8* %19, i8* %21)
%23 = tail call i32 @exit(i32 1)
unreachable
24: ; preds = %12
%25 = getelementptr inbounds i8*, i8** %1, i64 2
%26 = load i8*, i8** %25
%27 = tail call i32* @fopen(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %36
29: ; preds = %24
%30 = load i32, i32* @stderr
%31 = load i8*, i8** %25
%32 = load i32, i32* @errno
%33 = tail call i8* @strerror(i32 %32)
%34 = tail call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), i8* %31, i8* %33)
%35 = tail call i32 @exit(i32 1)
unreachable
36: ; preds = %24
%37 = tail call i8* (...) @codec2_create()
%38 = getelementptr inbounds [160 x i16], [160 x i16]* %3, i64 0, i64 0
%39 = call i32 @fread(i16* %38, i32 2, i32 160, i32* %15)
%40 = icmp eq i32 %39, 160
br i1 %40, label %41, label %47
41: ; preds = %36, %41
%42 = call i32 @codec2_encode(i8* %37, i8* %6, i16* %38)
%43 = call i32 @codec2_decode(i8* %37, i16* %38, i8* %6)
%44 = call i32 @fwrite(i16* %38, i32 2, i32 160, i32* %27)
%45 = call i32 @fread(i16* %38, i32 2, i32 160, i32* %15)
%46 = icmp eq i32 %45, 160
br i1 %46, label %41, label %47
47: ; preds = %41, %36
%48 = call i32 @codec2_destroy(i8* %37)
%49 = call i32 @fclose(i32* %15)
%50 = call i32 @fclose(i32* %27)
ret i32 0
}