#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*/ uint8_t;
struct freedv_vhf_deframer {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int fread(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(int /*<<< orphan*/ *);
struct freedv_vhf_deframer *fvhff_create_deframer(int, int /*<<< orphan*/);
scalar_t__ fvhff_deframe_bits(struct freedv_vhf_deframer *,
                              int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                              int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ fvhff_destroy_deframer(struct freedv_vhf_deframer *);
int fvhff_get_codec2_size(struct freedv_vhf_deframer *);
int fvhff_get_frame_size(struct freedv_vhf_deframer *);
int /*<<< orphan*/ fwrite(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ *stdout;
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  struct freedv_vhf_deframer *deframer;
  FILE *fin, *fout;
  uint8_t *bitbuf;
  uint8_t *c2buf;
  uint8_t zbuf[] = {0, 0, 0, 0, 0, 0, 0, 0};
  int frame_fmt = 0;
  int fsize, c2size;
  if (argc < 3) {
    fprintf(stderr, "usage: %s (A|B) InputOneBitPerCharFile OutputC2File\n",
            argv[0]);
    exit(1);
  }
  if (strcmp(argv[1], "A") == 0) {
    frame_fmt = 1;
  } else if (strcmp(argv[1], "B") == 0) {
    frame_fmt = 2;
  } else {
    fprintf(stderr, "usage: %s (A|B) InputOneBitPerCharFile OutputC2File\n",
            argv[0]);
    exit(1);
  }
  if (strcmp(argv[2], "-") == 0) {
    fin = stdin;
  } else {
    fin = fopen(argv[2], "r");
  }
  if (strcmp(argv[3], "-") == 0) {
    fout = stdout;
  } else {
    fout = fopen(argv[3], "w");
  }
  deframer = fvhff_create_deframer(frame_fmt, 0);
  if (fin == NULL || fout == NULL || deframer == NULL) {
    fprintf(stderr, "Couldn't open test vector files\n");
    goto cleanup;
  }
  c2size = fvhff_get_codec2_size(deframer);
  fsize = fvhff_get_frame_size(deframer);
  bitbuf = (uint8_t *)malloc(sizeof(uint8_t) * fsize);
  c2buf = (uint8_t *)malloc(sizeof(uint8_t) * c2size);
  while (fread(bitbuf, sizeof(uint8_t), fsize, fin) == fsize) {
    if (fvhff_deframe_bits(deframer, c2buf, NULL, NULL, bitbuf))
      fwrite(c2buf, sizeof(uint8_t), c2size, fout);
    else
      fwrite(zbuf, sizeof(uint8_t), c2size, fout);
    if (fin == stdin || fout == stdin) {
      fflush(fin);
      fflush(fout);
    }
  }
  free(bitbuf);
  free(c2buf);
cleanup:
  fclose(fin);
  fclose(fout);
  fvhff_destroy_deframer(deframer);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1070 <memset@plt>
movl   $0x0,-0x64(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    125f <main+0x5f>
mov    0x2d9a(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdb2(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdc7(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1289 <main+0x89>
movl   $0x1,-0x64(%rbp)
jmp    12e0 <main+0xe0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd9f(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    12b3 <main+0xb3>
movl   $0x2,-0x64(%rbp)
jmp    12db <main+0xdb>
mov    0x2d1e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd36(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
jmp    12e0 <main+0xe0>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd4a(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1311 <main+0x111>
mov    0x2ce3(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    1329 <main+0x129>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd1b(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xd01(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    135a <main+0x15a>
mov    0x2c82(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    1372 <main+0x172>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xcd4(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x64(%rbp),%edi
xor    %esi,%esi
call   10e0 <fvhff_create_deframer@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     13a1 <main+0x1a1>
cmpq   $0x0,-0x28(%rbp)
je     13a1 <main+0x1a1>
cmpq   $0x0,-0x18(%rbp)
jne    13bd <main+0x1bd>
mov    0x2c30(%rip),%rax
mov    (%rax),%edi
lea    0xc8e(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
jmp    14bb <main+0x2bb>
mov    -0x18(%rbp),%rdi
call   1060 <fvhff_get_codec2_size@plt>
mov    %eax,-0x6c(%rbp)
mov    -0x18(%rbp),%rdi
call   1110 <fvhff_get_frame_size@plt>
mov    %eax,-0x68(%rbp)
movslq -0x68(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x30(%rbp)
movslq -0x6c(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x68(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    $0x4,%esi
call   1040 <fread@plt>
cmp    -0x68(%rbp),%eax
jne    14a9 <main+0x2a9>
mov    -0x18(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x30(%rbp),%r8
xor    %eax,%eax
mov    %eax,%ecx
mov    %rcx,%rdx
call   1120 <fvhff_deframe_bits@plt>
cmp    $0x0,%rax
je     1455 <main+0x255>
mov    -0x38(%rbp),%rdi
mov    -0x6c(%rbp),%edx
mov    -0x28(%rbp),%rcx
mov    $0x4,%esi
call   1100 <fwrite@plt>
jmp    146a <main+0x26a>
lea    -0x60(%rbp),%rdi
mov    -0x6c(%rbp),%edx
mov    -0x28(%rbp),%rcx
mov    $0x4,%esi
call   1100 <fwrite@plt>
mov    -0x20(%rbp),%rax
mov    0x2b73(%rip),%rcx
cmp    (%rcx),%rax
je     1492 <main+0x292>
mov    -0x28(%rbp),%rax
mov    0x2b5f(%rip),%rcx
cmp    (%rcx),%rax
jne    14a4 <main+0x2a4>
mov    -0x20(%rbp),%rdi
call   10c0 <fflush@plt>
mov    -0x28(%rbp),%rdi
call   10c0 <fflush@plt>
jmp    13fb <main+0x1fb>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1080 <fvhff_destroy_deframer@plt>
xor    %edi,%edi
call   10f0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%rbx
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
cmp    $0x2,%edi
jg     1237 <main+0x47>
mov    0x2dbe(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xdda(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    0x8(%rbx),%rdi
lea    0xdf3(%rip),%rsi
call   1080 <strcmp@plt>
mov    $0x1,%ebp
test   %rax,%rax
je     126b <main+0x7b>
mov    0x8(%rbx),%rdi
lea    0xddb(%rip),%rsi
call   1080 <strcmp@plt>
mov    $0x2,%ebp
test   %rax,%rax
jne    1213 <main+0x23>
mov    0x10(%rbx),%rdi
lea    0xdc3(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    128c <main+0x9c>
mov    0x2d61(%rip),%rax
mov    (%rax),%r14
jmp    129f <main+0xaf>
mov    0x10(%rbx),%rdi
lea    0xda4(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,%r14
mov    0x18(%rbx),%rdi
lea    0xd8f(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    12c0 <main+0xd0>
mov    0x2d15(%rip),%rax
mov    (%rax),%r13
jmp    12d3 <main+0xe3>
mov    0x18(%rbx),%rdi
lea    0xd72(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,%r13
mov    %ebp,%edi
xor    %esi,%esi
call   10d0 <fvhff_create_deframer@plt>
mov    %rax,0x8(%rsp)
test   %r14,%r14
je     13bb <main+0x1cb>
test   %r13,%r13
je     13bb <main+0x1cb>
cmpq   $0x0,0x8(%rsp)
je     13bb <main+0x1cb>
mov    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <fvhff_get_codec2_size@plt>
mov    %eax,%r12d
mov    %rbx,%rdi
call   1100 <fvhff_get_frame_size@plt>
mov    %eax,%ebx
lea    0x0(,%rbx,4),%edi
call   10a0 <malloc@plt>
mov    %rax,%rbp
lea    0x0(,%r12,4),%edi
call   10a0 <malloc@plt>
mov    %rax,%r15
jmp    1350 <main+0x160>
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   10b0 <fflush@plt>
mov    %r13,%rdi
call   10b0 <fflush@plt>
mov    %rbp,%rdi
mov    $0x4,%esi
mov    %ebx,%edx
mov    %r14,%rcx
call   1040 <fread@plt>
cmp    %ebx,%eax
jne    13d4 <main+0x1e4>
mov    0x8(%rsp),%rdi
mov    %r15,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %rbp,%r8
call   1110 <fvhff_deframe_bits@plt>
test   %rax,%rax
je     1390 <main+0x1a0>
mov    %r15,%rdi
jmp    1395 <main+0x1a5>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0x10(%rsp),%rdi
mov    $0x4,%esi
mov    %r12d,%edx
mov    %r13,%rcx
call   10f0 <fwrite@plt>
mov    0x2c3c(%rip),%rax
mov    (%rax),%rax
cmp    %rax,%r14
je     1340 <main+0x150>
cmp    %rax,%r13
jne    1350 <main+0x160>
jmp    1340 <main+0x150>
mov    0x2c16(%rip),%rax
mov    (%rax),%edi
lea    0xc74(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    13e4 <main+0x1f4>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    %r13,%rdi
call   1050 <fclose@plt>
mov    0x8(%rsp),%rdi
call   1070 <fvhff_destroy_deframer@plt>
xor    %edi,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
%struct.freedv_vhf_deframer = type { i32 }
@stderr = global i32 0
@.str = [53 x i8] c"usage: %s (A|B) InputOneBitPerCharFile OutputC2File\0A\00"
@.str.1 = [2 x i8] c"A\00"
@.str.2 = [2 x i8] c"B\00"
@.str.3 = [2 x i8] c"-\00"
@stdin = global i32* null
@.str.4 = [2 x i8] c"r\00"
@stdout = global i32* null
@.str.5 = [2 x i8] c"w\00"
@.str.6 = [33 x i8] c"Couldn't open test vector files\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.freedv_vhf_deframer*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca [8 x i32]
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = bitcast [8 x i32]* %11 to i8*
store i32 0, i32* %12
%16 = load i32, i32* %4
%17 = icmp slt i32 %16, 3
br i1 %17, label %18, label %25
18: ; preds = %2
%19 = load i32, i32* @stderr
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i8* %22)
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %2
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %25
store i32 1, i32* %12
br label %47
32: ; preds = %25
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = call i64 @strcmp(i8* %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %32
store i32 2, i32* %12
br label %46
39: ; preds = %32
%40 = load i32, i32* @stderr
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 0
%43 = load i8*, i8** %42
%44 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i8* %43)
%45 = call i32 @exit(i32 1)
unreachable
46: ; preds = %38
br label %47
47: ; preds = %46, %31
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 2
%50 = load i8*, i8** %49
%51 = call i64 @strcmp(i8* %50, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %55
53: ; preds = %47
%54 = load i32*, i32** @stdin
store i32* %54, i32** %7
br label %60
55: ; preds = %47
%56 = load i8**, i8*** %5
%57 = getelementptr inbounds i8*, i8** %56, i64 2
%58 = load i8*, i8** %57
%59 = call i32* @fopen(i8* %58, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %59, i32** %7
br label %60
60: ; preds = %55, %53
%61 = load i8**, i8*** %5
%62 = getelementptr inbounds i8*, i8** %61, i64 3
%63 = load i8*, i8** %62
%64 = call i64 @strcmp(i8* %63, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%65 = icmp eq i64 %64, 0
br i1 %65, label %66, label %68
66: ; preds = %60
%67 = load i32*, i32** @stdout
store i32* %67, i32** %8
br label %73
68: ; preds = %60
%69 = load i8**, i8*** %5
%70 = getelementptr inbounds i8*, i8** %69, i64 3
%71 = load i8*, i8** %70
%72 = call i32* @fopen(i8* %71, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %72, i32** %8
br label %73
73: ; preds = %68, %66
%74 = load i32, i32* %12
%75 = call %struct.freedv_vhf_deframer* @fvhff_create_deframer(i32 %74, i32 0)
store %struct.freedv_vhf_deframer* %75, %struct.freedv_vhf_deframer** %6
%76 = load i32*, i32** %7
%77 = icmp eq i32* %76, null
br i1 %77, label %84, label %78
78: ; preds = %73
%79 = load i32*, i32** %8
%80 = icmp eq i32* %79, null
br i1 %80, label %84, label %81
81: ; preds = %78
%82 = load %struct.freedv_vhf_deframer*, %struct.freedv_vhf_deframer** %6
%83 = icmp eq %struct.freedv_vhf_deframer* %82, null
br i1 %83, label %84, label %87
84: ; preds = %81, %78, %73
%85 = load i32, i32* @stderr
%86 = call i32 (i32, i8*, ...) @fprintf(i32 %85, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0))
br label %146
87: ; preds = %81
%88 = load %struct.freedv_vhf_deframer*, %struct.freedv_vhf_deframer** %6
%89 = call i32 @fvhff_get_codec2_size(%struct.freedv_vhf_deframer* %88)
store i32 %89, i32* %14
%90 = load %struct.freedv_vhf_deframer*, %struct.freedv_vhf_deframer** %6
%91 = call i32 @fvhff_get_frame_size(%struct.freedv_vhf_deframer* %90)
store i32 %91, i32* %13
%92 = load i32, i32* %13
%93 = sext i32 %92 to i64
%94 = mul i64 4, %93
%95 = trunc i64 %94 to i32
%96 = call i64 @malloc(i32 %95)
%97 = inttoptr i64 %96 to i32*
store i32* %97, i32** %9
%98 = load i32, i32* %14
%99 = sext i32 %98 to i64
%100 = mul i64 4, %99
%101 = trunc i64 %100 to i32
%102 = call i64 @malloc(i32 %101)
%103 = inttoptr i64 %102 to i32*
store i32* %103, i32** %10
br label %104
104: ; preds = %140, %87
%105 = load i32*, i32** %9
%106 = load i32, i32* %13
%107 = load i32*, i32** %7
%108 = call i32 @fread(i32* %105, i32 4, i32 %106, i32* %107)
%109 = load i32, i32* %13
%110 = icmp eq i32 %108, %109
br i1 %110, label %111, label %141
111: ; preds = %104
%112 = load %struct.freedv_vhf_deframer*, %struct.freedv_vhf_deframer** %6
%113 = load i32*, i32** %10
%114 = load i32*, i32** %9
%115 = call i64 @fvhff_deframe_bits(%struct.freedv_vhf_deframer* %112, i32* %113, i32* null, i32* null, i32* %114)
%116 = icmp ne i64 %115, 0
br i1 %116, label %117, label %122
117: ; preds = %111
%118 = load i32*, i32** %10
%119 = load i32, i32* %14
%120 = load i32*, i32** %8
%121 = call i32 @fwrite(i32* %118, i32 4, i32 %119, i32* %120)
br label %127
122: ; preds = %111
%123 = getelementptr inbounds [8 x i32], [8 x i32]* %11, i64 0, i64 0
%124 = load i32, i32* %14
%125 = load i32*, i32** %8
%126 = call i32 @fwrite(i32* %123, i32 4, i32 %124, i32* %125)
br label %127
127: ; preds = %122, %117
%128 = load i32*, i32** %7
%129 = load i32*, i32** @stdin
%130 = icmp eq i32* %128, %129
br i1 %130, label %135, label %131
131: ; preds = %127
%132 = load i32*, i32** %8
%133 = load i32*, i32** @stdin
%134 = icmp eq i32* %132, %133
br i1 %134, label %135, label %140
135: ; preds = %131, %127
%136 = load i32*, i32** %7
%137 = call i32 @fflush(i32* %136)
%138 = load i32*, i32** %8
%139 = call i32 @fflush(i32* %138)
br label %140
140: ; preds = %135, %131
br label %104
141: ; preds = %104
%142 = load i32*, i32** %9
%143 = call i32 @free(i32* %142)
%144 = load i32*, i32** %10
%145 = call i32 @free(i32* %144)
br label %146
146: ; preds = %141, %84
%147 = load i32*, i32** %7
%148 = call i32 @fclose(i32* %147)
%149 = load i32*, i32** %8
%150 = call i32 @fclose(i32* %149)
%151 = load %struct.freedv_vhf_deframer*, %struct.freedv_vhf_deframer** %6
%152 = call i32 @fvhff_destroy_deframer(%struct.freedv_vhf_deframer* %151)
%153 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.freedv_vhf_deframer = type { i32 }
@stderr = global i32 0
@.str = [53 x i8] c"usage: %s (A|B) InputOneBitPerCharFile OutputC2File\0A\00"
@.str.1 = [2 x i8] c"A\00"
@.str.2 = [2 x i8] c"B\00"
@.str.3 = [2 x i8] c"-\00"
@stdin = global i32* null
@.str.4 = [2 x i8] c"r\00"
@stdout = global i32* null
@.str.5 = [2 x i8] c"w\00"
@.str.6 = [33 x i8] c"Couldn't open test vector files\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [8 x i32]
%4 = bitcast [8 x i32]* %3 to i8*
%5 = icmp slt i32 %0, 3
br i1 %5, label %6, label %11
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %25, label %16
16: ; preds = %11
%17 = load i8*, i8** %12
%18 = tail call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %25, label %20
20: ; preds = %16
%21 = load i32, i32* @stderr
%22 = load i8*, i8** %1
%23 = tail call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i8* %22)
%24 = tail call i32 @exit(i32 1)
unreachable
25: ; preds = %16, %11
%26 = phi i32 [ 1, %11 ], [ 2, %16 ]
%27 = getelementptr inbounds i8*, i8** %1, i64 2
%28 = load i8*, i8** %27
%29 = tail call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %25
%32 = load i32*, i32** @stdin
br label %36
33: ; preds = %25
%34 = load i8*, i8** %27
%35 = tail call i32* @fopen(i8* %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %36
36: ; preds = %33, %31
%37 = phi i32* [ %32, %31 ], [ %35, %33 ]
%38 = getelementptr inbounds i8*, i8** %1, i64 3
%39 = load i8*, i8** %38
%40 = tail call i64 @strcmp(i8* %39, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %36
%43 = load i32*, i32** @stdout
br label %47
44: ; preds = %36
%45 = load i8*, i8** %38
%46 = tail call i32* @fopen(i8* %45, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %47
47: ; preds = %44, %42
%48 = phi i32* [ %43, %42 ], [ %46, %44 ]
%49 = tail call %struct.freedv_vhf_deframer* @fvhff_create_deframer(i32 %26, i32 0)
%50 = icmp eq i32* %37, null
%51 = icmp eq i32* %48, null
%52 = select i1 %50, i1 true, i1 %51
%53 = icmp eq %struct.freedv_vhf_deframer* %49, null
%54 = select i1 %52, i1 true, i1 %53
br i1 %54, label %55, label %58
55: ; preds = %47
%56 = load i32, i32* @stderr
%57 = tail call i32 (i32, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0))
br label %92
58: ; preds = %47
%59 = tail call i32 @fvhff_get_codec2_size(%struct.freedv_vhf_deframer* %49)
%60 = tail call i32 @fvhff_get_frame_size(%struct.freedv_vhf_deframer* %49)
%61 = shl i32 %60, 2
%62 = tail call i64 @malloc(i32 %61)
%63 = inttoptr i64 %62 to i32*
%64 = shl i32 %59, 2
%65 = tail call i64 @malloc(i32 %64)
%66 = inttoptr i64 %65 to i32*
%67 = tail call i32 @fread(i32* %63, i32 4, i32 %60, i32* %37)
%68 = icmp eq i32 %67, %60
br i1 %68, label %69, label %89
69: ; preds = %58
%70 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 0
br label %71
71: ; preds = %69, %86
%72 = tail call i64 @fvhff_deframe_bits(%struct.freedv_vhf_deframer* %49, i32* %66, i32* null, i32* null, i32* %63)
%73 = icmp eq i64 %72, 0
br i1 %73, label %76, label %74
74: ; preds = %71
%75 = tail call i32 @fwrite(i32* %66, i32 4, i32 %59, i32* %48)
br label %78
76: ; preds = %71
%77 = call i32 @fwrite(i32* %70, i32 4, i32 %59, i32* %48)
br label %78
78: ; preds = %76, %74
%79 = load i32*, i32** @stdin
%80 = icmp eq i32* %37, %79
%81 = icmp eq i32* %48, %79
%82 = select i1 %80, i1 true, i1 %81
br i1 %82, label %83, label %86
83: ; preds = %78
%84 = tail call i32 @fflush(i32* %37)
%85 = tail call i32 @fflush(i32* %48)
br label %86
86: ; preds = %78, %83
%87 = tail call i32 @fread(i32* %63, i32 4, i32 %60, i32* %37)
%88 = icmp eq i32 %87, %60
br i1 %88, label %71, label %89
89: ; preds = %86, %58
%90 = tail call i32 @free(i32* %63)
%91 = tail call i32 @free(i32* %66)
br label %92
92: ; preds = %89, %55
%93 = tail call i32 @fclose(i32* %37)
%94 = tail call i32 @fclose(i32* %48)
%95 = tail call i32 @fvhff_destroy_deframer(%struct.freedv_vhf_deframer* %49)
%96 = tail call i32 @exit(i32 0)
unreachable
}