#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 */
double calc_prob_region_dp(double const *, int, char const *, int, int, int,
                           int, int, int, int *);
int /*<<< orphan*/ free(double *);
double *malloc(int);
int /*<<< orphan*/ memcpy(double *, double const *, int);
double calc_prob_dp(const double *matrix, int read_length, const char *seq,
                    int seq_length, int pos, int *splice_pos,
                    int *splice_offset, int n_splice, int gap_op, int gap_ex,
                    int *seqnt_map) {
  int start = pos - (read_length / 2);
  int end = pos + (read_length / 2);
  int i, j;
  double probability = 0;
  if (n_splice == 0) {
    probability = calc_prob_region_dp(matrix, read_length, seq, seq_length, pos,
                                      start, end, gap_op, gap_ex, seqnt_map);
  } else {
    int r_pos = 0;
    int g_pos = pos;
    for (i = 0; i <= n_splice; i++) {
      int r_len =
          (i < n_splice) ? splice_pos[i] - r_pos + 1 : read_length - r_pos;
      int n = r_len / 2;
      start = g_pos - n;
      end = g_pos + n;
      double *submatrix = malloc(21 * r_len * sizeof(double));
      for (j = 0; j < 21; j++)
        memcpy(&submatrix[r_len * j], &matrix[read_length * j + r_pos],
               r_len * sizeof(double));
      probability +=
          calc_prob_region_dp(submatrix, r_len, seq, seq_length, g_pos, start,
                              end, gap_op, gap_ex, seqnt_map);
      free(submatrix);
      submatrix = NULL;
      g_pos += r_len + splice_offset[i];
      r_pos = splice_pos[i] + 1;
    }
  }
  return probability;
}


x86 assembly (clang, -O0):
<calc_prob_dp>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x88,%rsp
mov    0x30(%rbp),%rax
mov    0x28(%rbp),%eax
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8d,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x68(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x68(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x64(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x64(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
cmpl   $0x0,0x18(%rbp)
jne    1201 <calc_prob_dp+0xc1>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
mov    -0x34(%rbp),%r9d
mov    -0x38(%rbp),%ebx
mov    0x20(%rbp),%r11d
mov    0x28(%rbp),%r10d
mov    0x30(%rbp),%rax
mov    %ebx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %rax,0x18(%rsp)
call   1060 <calc_prob_region_dp@plt>
movsd  %xmm0,-0x48(%rbp)
jmp    1372 <calc_prob_dp+0x232>
movl   $0x0,-0x4c(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x50(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    0x18(%rbp),%eax
jg     136d <calc_prob_dp+0x22d>
mov    -0x3c(%rbp),%eax
cmp    0x18(%rbp),%eax
jge    1246 <calc_prob_dp+0x106>
mov    -0x30(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
sub    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    124f <calc_prob_dp+0x10f>
mov    -0x14(%rbp),%eax
sub    -0x4c(%rbp),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x54(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x58(%rbp)
mov    -0x50(%rbp),%eax
sub    -0x58(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x50(%rbp),%eax
add    -0x58(%rbp),%eax
mov    %eax,-0x38(%rbp)
imul   $0x15,-0x54(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x60(%rbp)
movl   $0x0,-0x40(%rbp)
cmpl   $0x15,-0x40(%rbp)
jge    12e3 <calc_prob_dp+0x1a3>
mov    -0x60(%rbp),%rdi
mov    -0x54(%rbp),%eax
imul   -0x40(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%eax
imul   -0x40(%rbp),%eax
add    -0x4c(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rsi
movslq -0x54(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
call   1040 <memcpy@plt>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1291 <calc_prob_dp+0x151>
mov    -0x60(%rbp),%rdi
mov    -0x54(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x50(%rbp),%r8d
mov    -0x34(%rbp),%r9d
mov    -0x38(%rbp),%ebx
mov    0x20(%rbp),%r11d
mov    0x28(%rbp),%r10d
mov    0x30(%rbp),%rax
mov    %ebx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %rax,0x18(%rsp)
call   1060 <calc_prob_region_dp@plt>
addsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x60(%rbp)
mov    -0x54(%rbp),%eax
mov    0x10(%rbp),%rcx
movslq -0x3c(%rbp),%rdx
add    (%rcx,%rdx,4),%eax
add    -0x50(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x30(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1215 <calc_prob_dp+0xd5>
jmp    1372 <calc_prob_dp+0x232>
movsd  -0x48(%rbp),%xmm0
add    $0x88,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_prob_dp>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %r9,0x20(%rsp)
mov    %rdi,%r14
mov    0xb8(%rsp),%ebx
mov    0xb0(%rsp),%ebp
mov    0xa8(%rsp),%edi
test   %edi,%edi
je     12f7 <calc_prob_dp+0x1b7>
js     1324 <calc_prob_dp+0x1e4>
mov    %rdi,%rax
mov    %esi,0x10(%rsp)
movslq %esi,%r12
mov    %eax,%esi
mov    %rsi,0x28(%rsp)
add    $0x1,%eax
mov    %rax,0x30(%rsp)
shl    $0x3,%r12
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %esi,%esi
xor    %ebp,%ebp
mov    %ecx,0x14(%rsp)
mov    %rdx,0x40(%rsp)
mov    %r14,0x38(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    0x28(%rsp),%rsi
mov    %rsi,0x60(%rsp)
jae    11e0 <calc_prob_dp+0xa0>
mov    0x20(%rsp),%rax
mov    (%rax,%rsi,4),%ebx
sub    %ebp,%ebx
add    $0x1,%ebx
jmp    11e8 <calc_prob_dp+0xa8>
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp),%eax
mov    %eax,%ebx
sub    %ebp,%ebx
mov    %ebx,%eax
shr    $0x1f,%eax
add    %ebx,%eax
sar    %eax
mov    %r8d,0x1c(%rsp)
mov    %rax,0x50(%rsp)
sub    %eax,%r8d
mov    %r8d,0x18(%rsp)
imul   $0xa8,%ebx,%edi
call   1050 <malloc@plt>
mov    %rax,%r15
lea    0x0(,%rbx,8),%r13d
mov    %rbx,0x58(%rsp)
movslq %ebx,%rbx
movslq %ebp,%rax
lea    (%r14,%rax,8),%rbp
shl    $0x3,%rbx
mov    $0x15,%r14d
mov    %r15,0x48(%rsp)
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %r13d,%edx
call   1040 <memcpy@plt>
add    %r12,%rbp
add    %rbx,%r15
add    $0xffffffffffffffff,%r14
jne    1240 <calc_prob_dp+0x100>
mov    0x1c(%rsp),%r14d
mov    0x50(%rsp),%rbp
add    %r14d,%ebp
mov    0x48(%rsp),%r15
mov    %r15,%rdi
mov    0x58(%rsp),%rbx
mov    %ebx,%esi
mov    0x40(%rsp),%rdx
mov    0x14(%rsp),%ecx
mov    %r14d,%r8d
mov    0x18(%rsp),%r9d
push   0xc0(%rsp)
mov    0xc0(%rsp),%eax
push   %rax
mov    0xc0(%rsp),%eax
push   %rax
push   %rbp
call   1060 <calc_prob_region_dp@plt>
add    $0x20,%rsp
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
mov    %r15,%rdi
call   1030 <free@plt>
add    %r14d,%ebx
mov    0xa0(%rsp),%rax
mov    0x60(%rsp),%rsi
add    (%rax,%rsi,4),%ebx
mov    0x20(%rsp),%rax
mov    (%rax,%rsi,4),%ebp
add    $0x1,%ebp
add    $0x1,%rsi
mov    %ebx,%r8d
cmp    0x30(%rsp),%rsi
mov    0x38(%rsp),%r14
jne    11c0 <calc_prob_dp+0x80>
jmp    132e <calc_prob_dp+0x1ee>
mov    %esi,%eax
shr    $0x1f,%eax
add    %esi,%eax
sar    %eax
mov    %r8d,%r9d
sub    %eax,%r9d
add    %r8d,%eax
mov    %r14,%rdi
push   0xc0(%rsp)
push   %rbx
push   %rbp
push   %rax
call   1060 <calc_prob_region_dp@plt>
add    $0x88,%rsp
jmp    1338 <calc_prob_dp+0x1f8>
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @calc_prob_dp(double* %0, i32 %1, i8* %2, i32 %3, i32 %4, i32* %5, i32* %6, i32 %7, i32 %8, i32 %9, i32* %10) {
%12 = alloca double*
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32*
%18 = alloca i32*
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32*
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = alloca double
%28 = alloca i32
%29 = alloca i32
%30 = alloca i32
%31 = alloca i32
%32 = alloca double*
store double* %0, double** %12
store i32 %1, i32* %13
store i8* %2, i8** %14
store i32 %3, i32* %15
store i32 %4, i32* %16
store i32* %5, i32** %17
store i32* %6, i32** %18
store i32 %7, i32* %19
store i32 %8, i32* %20
store i32 %9, i32* %21
store i32* %10, i32** %22
%33 = load i32, i32* %16
%34 = load i32, i32* %13
%35 = sdiv i32 %34, 2
%36 = sub nsw i32 %33, %35
store i32 %36, i32* %23
%37 = load i32, i32* %16
%38 = load i32, i32* %13
%39 = sdiv i32 %38, 2
%40 = add nsw i32 %37, %39
store i32 %40, i32* %24
store double 0.000000e+00, double* %27
%41 = load i32, i32* %19
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %55
43: ; preds = %11
%44 = load double*, double** %12
%45 = load i32, i32* %13
%46 = load i8*, i8** %14
%47 = load i32, i32* %15
%48 = load i32, i32* %16
%49 = load i32, i32* %23
%50 = load i32, i32* %24
%51 = load i32, i32* %20
%52 = load i32, i32* %21
%53 = load i32*, i32** %22
%54 = call double @calc_prob_region_dp(double* %44, i32 %45, i8* %46, i32 %47, i32 %48, i32 %49, i32 %50, i32 %51, i32 %52, i32* %53)
store double %54, double* %27
br label %155
55: ; preds = %11
store i32 0, i32* %28
%56 = load i32, i32* %16
store i32 %56, i32* %29
store i32 0, i32* %25
br label %57
57: ; preds = %151, %55
%58 = load i32, i32* %25
%59 = load i32, i32* %19
%60 = icmp sle i32 %58, %59
br i1 %60, label %61, label %154
61: ; preds = %57
%62 = load i32, i32* %25
%63 = load i32, i32* %19
%64 = icmp slt i32 %62, %63
br i1 %64, label %65, label %74
65: ; preds = %61
%66 = load i32*, i32** %17
%67 = load i32, i32* %25
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i32, i32* %66, i64 %68
%70 = load i32, i32* %69
%71 = load i32, i32* %28
%72 = sub nsw i32 %70, %71
%73 = add nsw i32 %72, 1
br label %78
74: ; preds = %61
%75 = load i32, i32* %13
%76 = load i32, i32* %28
%77 = sub nsw i32 %75, %76
br label %78
78: ; preds = %74, %65
%79 = phi i32 [ %73, %65 ], [ %77, %74 ]
store i32 %79, i32* %30
%80 = load i32, i32* %30
%81 = sdiv i32 %80, 2
store i32 %81, i32* %31
%82 = load i32, i32* %29
%83 = load i32, i32* %31
%84 = sub nsw i32 %82, %83
store i32 %84, i32* %23
%85 = load i32, i32* %29
%86 = load i32, i32* %31
%87 = add nsw i32 %85, %86
store i32 %87, i32* %24
%88 = load i32, i32* %30
%89 = mul nsw i32 21, %88
%90 = sext i32 %89 to i64
%91 = mul i64 %90, 8
%92 = trunc i64 %91 to i32
%93 = call double* @malloc(i32 %92)
store double* %93, double** %32
store i32 0, i32* %26
br label %94
94: ; preds = %117, %78
%95 = load i32, i32* %26
%96 = icmp slt i32 %95, 21
br i1 %96, label %97, label %120
97: ; preds = %94
%98 = load double*, double** %32
%99 = load i32, i32* %30
%100 = load i32, i32* %26
%101 = mul nsw i32 %99, %100
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds double, double* %98, i64 %102
%104 = load double*, double** %12
%105 = load i32, i32* %13
%106 = load i32, i32* %26
%107 = mul nsw i32 %105, %106
%108 = load i32, i32* %28
%109 = add nsw i32 %107, %108
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds double, double* %104, i64 %110
%112 = load i32, i32* %30
%113 = sext i32 %112 to i64
%114 = mul i64 %113, 8
%115 = trunc i64 %114 to i32
%116 = call i32 @memcpy(double* %103, double* %111, i32 %115)
br label %117
117: ; preds = %97
%118 = load i32, i32* %26
%119 = add nsw i32 %118, 1
store i32 %119, i32* %26
br label %94
120: ; preds = %94
%121 = load double*, double** %32
%122 = load i32, i32* %30
%123 = load i8*, i8** %14
%124 = load i32, i32* %15
%125 = load i32, i32* %29
%126 = load i32, i32* %23
%127 = load i32, i32* %24
%128 = load i32, i32* %20
%129 = load i32, i32* %21
%130 = load i32*, i32** %22
%131 = call double @calc_prob_region_dp(double* %121, i32 %122, i8* %123, i32 %124, i32 %125, i32 %126, i32 %127, i32 %128, i32 %129, i32* %130)
%132 = load double, double* %27
%133 = fadd double %132, %131
store double %133, double* %27
%134 = load double*, double** %32
%135 = call i32 @free(double* %134)
store double* null, double** %32
%136 = load i32, i32* %30
%137 = load i32*, i32** %18
%138 = load i32, i32* %25
%139 = sext i32 %138 to i64
%140 = getelementptr inbounds i32, i32* %137, i64 %139
%141 = load i32, i32* %140
%142 = add nsw i32 %136, %141
%143 = load i32, i32* %29
%144 = add nsw i32 %143, %142
store i32 %144, i32* %29
%145 = load i32*, i32** %17
%146 = load i32, i32* %25
%147 = sext i32 %146 to i64
%148 = getelementptr inbounds i32, i32* %145, i64 %147
%149 = load i32, i32* %148
%150 = add nsw i32 %149, 1
store i32 %150, i32* %28
br label %151
151: ; preds = %120
%152 = load i32, i32* %25
%153 = add nsw i32 %152, 1
store i32 %153, i32* %25
br label %57
154: ; preds = %57
br label %155
155: ; preds = %154, %43
%156 = load double, double* %27
ret double %156
}

LLVM IR (-O2):
define double @calc_prob_dp(double* %0, i32 %1, i8* %2, i32 %3, i32 %4, i32* nocapture %5, i32* nocapture %6, i32 %7, i32 %8, i32 %9, i32* %10) {
%12 = sdiv i32 %1, 2
%13 = icmp eq i32 %7, 0
br i1 %13, label %21, label %14
14: ; preds = %11
%15 = icmp slt i32 %7, 0
br i1 %15, label %71, label %16
16: ; preds = %14
%17 = sext i32 %1 to i64
%18 = zext i32 %7 to i64
%19 = add nuw i32 %7, 1
%20 = zext i32 %19 to i64
br label %25
21: ; preds = %11
%22 = add nsw i32 %12, %4
%23 = sub nsw i32 %4, %12
%24 = tail call double @calc_prob_region_dp(double* %0, i32 %1, i8* %2, i32 %3, i32 %4, i32 %23, i32 %22, i32 %8, i32 %9, i32* %10)
br label %71
25: ; preds = %16, %57
%26 = phi i64 [ 0, %16 ], [ %69, %57 ]
%27 = phi i32 [ %4, %16 ], [ %65, %57 ]
%28 = phi i32 [ 0, %16 ], [ %68, %57 ]
%29 = phi double [ 0.000000e+00, %16 ], [ %60, %57 ]
%30 = icmp ult i64 %26, %18
br i1 %30, label %31, label %36
31: ; preds = %25
%32 = getelementptr inbounds i32, i32* %5, i64 %26
%33 = load i32, i32* %32
%34 = sub i32 1, %28
%35 = add i32 %34, %33
br label %38
36: ; preds = %25
%37 = sub nsw i32 %1, %28
br label %38
38: ; preds = %36, %31
%39 = phi i32 [ %35, %31 ], [ %37, %36 ]
%40 = sdiv i32 %39, 2
%41 = sub nsw i32 %27, %40
%42 = mul i32 %39, 168
%43 = tail call double* @malloc(i32 %42)
%44 = shl i32 %39, 3
%45 = sext i32 %39 to i64
%46 = sext i32 %28 to i64
br label %47
47: ; preds = %38, %47
%48 = phi i64 [ 0, %38 ], [ %55, %47 ]
%49 = mul nsw i64 %48, %45
%50 = getelementptr inbounds double, double* %43, i64 %49
%51 = mul nsw i64 %48, %17
%52 = add nsw i64 %51, %46
%53 = getelementptr inbounds double, double* %0, i64 %52
%54 = tail call i32 @memcpy(double* %50, double* %53, i32 %44)
%55 = add nuw nsw i64 %48, 1
%56 = icmp eq i64 %55, 21
br i1 %56, label %57, label %47
57: ; preds = %47
%58 = add nsw i32 %40, %27
%59 = tail call double @calc_prob_region_dp(double* %43, i32 %39, i8* %2, i32 %3, i32 %27, i32 %41, i32 %58, i32 %8, i32 %9, i32* %10)
%60 = fadd double %29, %59
%61 = tail call i32 @free(double* %43)
%62 = getelementptr inbounds i32, i32* %6, i64 %26
%63 = load i32, i32* %62
%64 = add i32 %39, %27
%65 = add i32 %64, %63
%66 = getelementptr inbounds i32, i32* %5, i64 %26
%67 = load i32, i32* %66
%68 = add nsw i32 %67, 1
%69 = add nuw nsw i64 %26, 1
%70 = icmp eq i64 %69, %20
br i1 %70, label %71, label %25
71: ; preds = %57, %14, %21
%72 = phi double [ %24, %21 ], [ 0.000000e+00, %14 ], [ %60, %57 ]
ret double %72
}