#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 */
struct v {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ chainback_viterbi(struct v *, unsigned char *, int,
                                     int /*<<< orphan*/);
int /*<<< orphan*/ init_viterbi(struct v *, int /*<<< orphan*/);
int /*<<< orphan*/ update_viterbi_blk_SPIRAL(struct v *, unsigned char *, int);
void viterbi(void *p, unsigned char *symbols, unsigned char *data,
             int framebits) {
  struct v *vp = p;
  init_viterbi(vp, 0);
  update_viterbi_blk_SPIRAL(vp, symbols, framebits + (7 - 1));
  chainback_viterbi(vp, data, framebits, 0);
}


x86 assembly (clang, -O0):
<viterbi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
xor    %esi,%esi
call   1040 <init_viterbi@plt>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
add    $0x6,%edx
call   1050 <update_viterbi_blk_SPIRAL@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
xor    %ecx,%ecx
call   1030 <chainback_viterbi@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<viterbi>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r12d
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
xor    %esi,%esi
call   1040 <init_viterbi@plt>
lea    0x6(%r12),%edx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <update_viterbi_blk_SPIRAL@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r12d,%edx
xor    %ecx,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <chainback_viterbi@plt>

LLVM IR (-O0):
%struct.v = type { i32 }
define void @viterbi(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca %struct.v*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%10 = load i8*, i8** %5
%11 = bitcast i8* %10 to %struct.v*
store %struct.v* %11, %struct.v** %9
%12 = load %struct.v*, %struct.v** %9
%13 = call i32 @init_viterbi(%struct.v* %12, i32 0)
%14 = load %struct.v*, %struct.v** %9
%15 = load i8*, i8** %6
%16 = load i32, i32* %8
%17 = add nsw i32 %16, 6
%18 = call i32 @update_viterbi_blk_SPIRAL(%struct.v* %14, i8* %15, i32 %17)
%19 = load %struct.v*, %struct.v** %9
%20 = load i8*, i8** %7
%21 = load i32, i32* %8
%22 = call i32 @chainback_viterbi(%struct.v* %19, i8* %20, i32 %21, i32 0)
ret void
}

LLVM IR (-O2):
%struct.v = type { i32 }
define void @viterbi(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = bitcast i8* %0 to %struct.v*
%6 = tail call i32 @init_viterbi(%struct.v* %5, i32 0)
%7 = add nsw i32 %3, 6
%8 = tail call i32 @update_viterbi_blk_SPIRAL(%struct.v* %5, i8* %1, i32 %7)
%9 = tail call i32 @chainback_viterbi(%struct.v* %5, i8* %2, i32 %3, i32 0)
ret void
}