#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*/ crcTableInit();
double pow(int, double);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ randominit();
int /*<<< orphan*/ set_taus_seed();
double sqrt(double);
int test_viterbi(double, unsigned int, unsigned int, int, unsigned int *,
                 unsigned int *);
int main(int argc, char *argv[]) {
  int ret;
  unsigned int errors, crc_misses;
  unsigned int block_length = 132;
  unsigned int crc_len = 3;
  double SNR;
  double sigma;
  randominit();
  set_taus_seed();
  crcTableInit();
  printf("EbN0, sigma, BER, FER\n");
  for (SNR = 0; SNR < 10; SNR++) {
    sigma = sqrt(1.0 / pow(10, SNR / 10.0));
    ret = test_viterbi(sigma, block_length, crc_len, 100000, &errors,
                       &crc_misses);
    printf("%f, %f, %f, %f\n", SNR, sigma, ((double)errors) / (100000),
           (double)crc_misses / 100000);
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x84,-0x20(%rbp)
movl   $0x3,-0x24(%rbp)
mov    $0x0,%al
call   1090 <randominit@plt>
mov    $0x0,%al
call   1040 <set_taus_seed@plt>
mov    $0x0,%al
call   1060 <crcTableInit@plt>
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe39(%rip),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    127d <main+0x10d>
movsd  -0x30(%rbp),%xmm0
movsd  0xe21(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    $0xa,%edi
call   1070 <pow@plt>
movaps %xmm0,%xmm1
movsd  0xe18(%rip),%xmm0
divsd  %xmm1,%xmm0
call   1080 <sqrt@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
mov    -0x20(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    $0x186a0,%edx
lea    -0x18(%rbp),%rcx
lea    -0x1c(%rbp),%r8
call   1030 <test_viterbi@plt>
mov    %eax,-0x14(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
mov    -0x18(%rbp),%eax
cvtsi2sd %rax,%xmm2
movsd  0xdc8(%rip),%xmm3
divsd  %xmm3,%xmm2
mov    -0x1c(%rbp),%eax
cvtsi2sd %rax,%xmm3
movsd  0xdb4(%rip),%xmm4
divsd  %xmm4,%xmm3
lea    0xdd0(%rip),%rdi
mov    $0x4,%al
call   1050 <printf@plt>
movsd  0xda2(%rip),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    11bf <main+0x4f>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
xor    %eax,%eax
call   10a0 <randominit@plt>
xor    %eax,%eax
call   1050 <set_taus_seed@plt>
xor    %eax,%eax
call   1070 <crcTableInit@plt>
lea    0xe8a(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%ebp
lea    0x4(%rsp),%r14
mov    %rsp,%r15
lea    0xe61(%rip),%rbx
xorpd  %xmm0,%xmm0
jmp    124d <main+0xcd>
nopl   0x0(%rax,%rax,1)
call   1090 <sqrt@plt>
movsd  %xmm0,0x10(%rsp)
mov    $0x84,%edi
mov    $0x3,%esi
mov    $0x186a0,%edx
mov    %r14,%rcx
mov    %r15,%r8
call   1030 <test_viterbi@plt>
mov    0x4(%rsp),%eax
xorps  %xmm2,%xmm2
cvtsi2sd %rax,%xmm2
movsd  0xe07(%rip),%xmm0
divsd  %xmm0,%xmm2
mov    (%rsp),%eax
xorps  %xmm3,%xmm3
cvtsi2sd %rax,%xmm3
divsd  %xmm0,%xmm3
mov    %rbx,%rdi
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
mov    $0x4,%al
call   1060 <printf@plt>
movsd  0xdce(%rip),%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0xffffffff,%ebp
je     128c <main+0x10c>
movsd  %xmm0,0x8(%rsp)
divsd  0xda5(%rip),%xmm0
mov    $0xa,%edi
call   1080 <pow@plt>
movapd %xmm0,%xmm1
movsd  0xd97(%rip),%xmm0
divsd  %xmm1,%xmm0
ucomisd 0xd9b(%rip),%xmm0
jb     11d0 <main+0x50>
sqrtsd %xmm0,%xmm0
jmp    11d5 <main+0x55>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"EbN0, sigma, BER, FER\0A\00"
@.str.1 = [16 x i8] c"%f, %f, %f, %f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca double
%12 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 132, i32* %9
store i32 3, i32* %10
%13 = call i32 (...) @randominit()
%14 = call i32 (...) @set_taus_seed()
%15 = call i32 (...) @crcTableInit()
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
store double 0.000000e+00, double* %11
br label %17
17: ; preds = %39, %2
%18 = load double, double* %11
%19 = fcmp olt double %18, 1.000000e+01
br i1 %19, label %20, label %42
20: ; preds = %17
%21 = load double, double* %11
%22 = fdiv double %21, 1.000000e+01
%23 = call double @pow(i32 10, double %22)
%24 = fdiv double 1.000000e+00, %23
%25 = call double @sqrt(double %24)
store double %25, double* %12
%26 = load double, double* %12
%27 = load i32, i32* %9
%28 = load i32, i32* %10
%29 = call i32 @test_viterbi(double %26, i32 %27, i32 %28, i32 100000, i32* %7, i32* %8)
store i32 %29, i32* %6
%30 = load double, double* %11
%31 = load double, double* %12
%32 = load i32, i32* %7
%33 = uitofp i32 %32 to double
%34 = fdiv double %33, 1.000000e+05
%35 = load i32, i32* %8
%36 = uitofp i32 %35 to double
%37 = fdiv double %36, 1.000000e+05
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), double %30, double %31, double %34, double %37)
br label %39
39: ; preds = %20
%40 = load double, double* %11
%41 = fadd double %40, 1.000000e+00
store double %41, double* %11
br label %17
42: ; preds = %17
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [16 x i8] c"%f, %f, %f, %f\0A\00"
@str = [22 x i8] c"EbN0, sigma, BER, FER\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = tail call i32 (...) @randominit()
%8 = tail call i32 (...) @set_taus_seed()
%9 = tail call i32 (...) @crcTableInit()
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
br label %11
11: ; preds = %2, %11
%12 = phi i32 [ 0, %2 ], [ %26, %11 ]
%13 = sitofp i32 %12 to double
%14 = fdiv double %13, 1.000000e+01
%15 = call double @pow(i32 10, double %14)
%16 = fdiv double 1.000000e+00, %15
%17 = call double @sqrt(double %16)
%18 = call i32 @test_viterbi(double %17, i32 132, i32 3, i32 100000, i32* %3, i32* %4)
%19 = load i32, i32* %3
%20 = uitofp i32 %19 to double
%21 = fdiv double %20, 1.000000e+05
%22 = load i32, i32* %4
%23 = uitofp i32 %22 to double
%24 = fdiv double %23, 1.000000e+05
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), double %13, double %17, double %21, double %24)
%26 = add nuw nsw i32 %12, 1
%27 = icmp eq i32 %26, 10
br i1 %27, label %28, label %11
28: ; preds = %11
ret i32 0
}