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

/* Variables and functions */
int /*<<< orphan*/ chainback_viterbi27(void *, unsigned char *, int,
                                       int /*<<< orphan*/);
void *create_viterbi27(int);
int /*<<< orphan*/ delete_viterbi27(void *);
int /*<<< orphan*/ flipBits(unsigned char *);
int /*<<< orphan*/ init_viterbi27(void *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ update_viterbi27_blk(void *, unsigned char *, int);
int easyVitDecoder(unsigned char symbols[], int framebits,
                   unsigned char data[]) {
  void *vp;
  unsigned char test = 53;
  flipBits(&test);
  if ((vp = create_viterbi27(framebits)) == NULL) {
    printf("create_viterbi27 failed\n");
    return 1;
  }
  init_viterbi27(vp, 0);
  update_viterbi27_blk(vp, symbols, framebits + 6);
  chainback_viterbi27(vp, data, framebits, 0);
  int i = 0;
  for (i = 0; i < framebits / 8; i++) {
    flipBits(data + i);
  }
  delete_viterbi27(vp);
  return 0;
}


x86 assembly (clang, -O0):
<easyVitDecoder>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
movb   $0x35,-0x29(%rbp)
lea    -0x29(%rbp),%rdi
call   1090 <flipBits@plt>
mov    -0x14(%rbp),%edi
call   1050 <create_viterbi27@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    11be <easyVitDecoder+0x4e>
lea    0xe53(%rip),%rdi
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1248 <easyVitDecoder+0xd8>
mov    -0x28(%rbp),%rdi
xor    %esi,%esi
call   1030 <init_viterbi27@plt>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
add    $0x6,%edx
call   1040 <update_viterbi27_blk@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x14(%rbp),%edx
xor    %ecx,%ecx
call   1070 <chainback_viterbi27@plt>
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
cmp    %ecx,%eax
jge    1238 <easyVitDecoder+0xc8>
mov    -0x20(%rbp),%rdi
movslq -0x30(%rbp),%rax
add    %rax,%rdi
call   1090 <flipBits@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11fc <easyVitDecoder+0x8c>
mov    -0x28(%rbp),%rdi
call   1080 <delete_viterbi27@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<easyVitDecoder>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%rbx
mov    %esi,%r14d
mov    %rdi,%r12
movb   $0x35,0xf(%rsp)
lea    0xf(%rsp),%rdi
call   1090 <flipBits@plt>
mov    %r14d,%edi
call   1050 <create_viterbi27@plt>
test   %rax,%rax
je     11fc <easyVitDecoder+0x8c>
mov    %rax,%rbp
xor    %r15d,%r15d
mov    %rax,%rdi
xor    %esi,%esi
call   1030 <init_viterbi27@plt>
lea    0x6(%r14),%edx
mov    %rbp,%rdi
mov    %r12,%rsi
call   1040 <update_viterbi27_blk@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
xor    %ecx,%ecx
call   1070 <chainback_viterbi27@plt>
cmp    $0x8,%r14d
jl     11f2 <easyVitDecoder+0x82>
shr    $0x3,%r14d
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1090 <flipBits@plt>
add    $0x1,%rbx
add    $0xffffffffffffffff,%r14
jne    11e0 <easyVitDecoder+0x70>
mov    %rbp,%rdi
call   1080 <delete_viterbi27@plt>
jmp    120e <easyVitDecoder+0x9e>
lea    0xdfd(%rip),%rdi
call   1060 <puts@plt>
mov    $0x1,%r15d
mov    %r15d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"create_viterbi27 failed\0A\00"
define i32 @easyVitDecoder(i8* %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8
%10 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i8 53, i8* %9
%11 = call i32 @flipBits(i8* %9)
%12 = load i32, i32* %6
%13 = call i8* @create_viterbi27(i32 %12)
store i8* %13, i8** %8
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %17
15: ; preds = %3
%16 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %4
br label %46
17: ; preds = %3
%18 = load i8*, i8** %8
%19 = call i32 @init_viterbi27(i8* %18, i32 0)
%20 = load i8*, i8** %8
%21 = load i8*, i8** %5
%22 = load i32, i32* %6
%23 = add nsw i32 %22, 6
%24 = call i32 @update_viterbi27_blk(i8* %20, i8* %21, i32 %23)
%25 = load i8*, i8** %8
%26 = load i8*, i8** %7
%27 = load i32, i32* %6
%28 = call i32 @chainback_viterbi27(i8* %25, i8* %26, i32 %27, i32 0)
store i32 0, i32* %10
store i32 0, i32* %10
br label %29
29: ; preds = %40, %17
%30 = load i32, i32* %10
%31 = load i32, i32* %6
%32 = sdiv i32 %31, 8
%33 = icmp slt i32 %30, %32
br i1 %33, label %34, label %43
34: ; preds = %29
%35 = load i8*, i8** %7
%36 = load i32, i32* %10
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = call i32 @flipBits(i8* %38)
br label %40
40: ; preds = %34
%41 = load i32, i32* %10
%42 = add nsw i32 %41, 1
store i32 %42, i32* %10
br label %29
43: ; preds = %29
%44 = load i8*, i8** %8
%45 = call i32 @delete_viterbi27(i8* %44)
store i32 0, i32* %4
br label %46
46: ; preds = %43, %15
%47 = load i32, i32* %4
ret i32 %47
}

LLVM IR (-O2):
@str = [24 x i8] c"create_viterbi27 failed\00"
define i32 @easyVitDecoder(i8* %0, i32 %1, i8* %2) {
%4 = alloca i8
store i8 53, i8* %4
%5 = call i32 @flipBits(i8* %4)
%6 = call i8* @create_viterbi27(i32 %1)
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %10
8: ; preds = %3
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
br label %27
10: ; preds = %3
%11 = call i32 @init_viterbi27(i8* %6, i32 0)
%12 = add nsw i32 %1, 6
%13 = call i32 @update_viterbi27_blk(i8* %6, i8* %0, i32 %12)
%14 = call i32 @chainback_viterbi27(i8* %6, i8* %2, i32 %1, i32 0)
%15 = icmp sgt i32 %1, 7
br i1 %15, label %16, label %25
16: ; preds = %10
%17 = lshr i32 %1, 3
%18 = zext i32 %17 to i64
br label %19
19: ; preds = %16, %19
%20 = phi i64 [ 0, %16 ], [ %23, %19 ]
%21 = getelementptr inbounds i8, i8* %2, i64 %20
%22 = call i32 @flipBits(i8* %21)
%23 = add nuw nsw i64 %20, 1
%24 = icmp eq i64 %23, %18
br i1 %24, label %25, label %19
25: ; preds = %19, %10
%26 = call i32 @delete_viterbi27(i8* %6)
br label %27
27: ; preds = %25, %8
%28 = phi i32 [ 1, %8 ], [ 0, %25 ]
ret i32 %28
}