#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(double const *, int, char const *, int, int, int, int,
                        int *);
int /*<<< orphan*/ free(double *);
double *malloc(int);
int /*<<< orphan*/ memcpy(double *, double const *, int);
double calc_prob(const double *matrix, int read_length, const char *seq,
                 int seq_length, int pos, int *splice_pos, int *splice_offset,
                 int n_splice, 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(matrix, read_length, seq, seq_length, pos,
                                   start, end, 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(submatrix, r_len, seq, seq_length, g_pos,
                                      start, end, 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>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x60(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x60(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x5c(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x5c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
cmpl   $0x0,0x18(%rbp)
jne    11ea <calc_prob+0xaa>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
mov    -0x2c(%rbp),%r9d
mov    -0x30(%rbp),%r10d
mov    0x20(%rbp),%rax
mov    %r10d,(%rsp)
mov    %rax,0x8(%rsp)
call   1060 <calc_prob_region@plt>
movsd  %xmm0,-0x40(%rbp)
jmp    134b <calc_prob+0x20b>
movl   $0x0,-0x44(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x48(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    0x18(%rbp),%eax
jg     1346 <calc_prob+0x206>
mov    -0x34(%rbp),%eax
cmp    0x18(%rbp),%eax
jge    122f <calc_prob+0xef>
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
sub    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1238 <calc_prob+0xf8>
mov    -0xc(%rbp),%eax
sub    -0x44(%rbp),%eax
mov    %eax,-0x64(%rbp)
mov    -0x64(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x50(%rbp)
mov    -0x48(%rbp),%eax
sub    -0x50(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x48(%rbp),%eax
add    -0x50(%rbp),%eax
mov    %eax,-0x30(%rbp)
imul   $0x15,-0x4c(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x58(%rbp)
movl   $0x0,-0x38(%rbp)
cmpl   $0x15,-0x38(%rbp)
jge    12cc <calc_prob+0x18c>
mov    -0x58(%rbp),%rdi
mov    -0x4c(%rbp),%eax
imul   -0x38(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%eax
imul   -0x38(%rbp),%eax
add    -0x44(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rsi
movslq -0x4c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
call   1040 <memcpy@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    127a <calc_prob+0x13a>
mov    -0x58(%rbp),%rdi
mov    -0x4c(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x48(%rbp),%r8d
mov    -0x2c(%rbp),%r9d
mov    -0x30(%rbp),%r10d
mov    0x20(%rbp),%rax
mov    %r10d,(%rsp)
mov    %rax,0x8(%rsp)
call   1060 <calc_prob_region@plt>
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x58(%rbp)
mov    -0x4c(%rbp),%eax
mov    0x10(%rbp),%rcx
movslq -0x34(%rbp),%rdx
add    (%rcx,%rdx,4),%eax
add    -0x48(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11fe <calc_prob+0xbe>
jmp    134b <calc_prob+0x20b>
movsd  -0x40(%rbp),%xmm0
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_prob>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %r9,0x20(%rsp)
mov    %rdi,%r14
mov    0xa8(%rsp),%edi
test   %edi,%edi
je     12d4 <calc_prob+0x194>
js     12fc <calc_prob+0x1bc>
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)
xchg   %ax,%ax
cmp    0x28(%rsp),%rsi
mov    %rsi,0x60(%rsp)
jae    11d0 <calc_prob+0x90>
mov    0x20(%rsp),%rax
mov    (%rax,%rsi,4),%ebx
sub    %ebp,%ebx
add    $0x1,%ebx
jmp    11d8 <calc_prob+0x98>
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    1230 <calc_prob+0xf0>
mov    0x1c(%rsp),%ebp
mov    0x50(%rsp),%rax
add    %ebp,%eax
mov    0x48(%rsp),%r14
mov    %r14,%rdi
mov    0x58(%rsp),%rbx
mov    %ebx,%esi
mov    0x40(%rsp),%rdx
mov    0x14(%rsp),%ecx
mov    %ebp,%r8d
mov    0x18(%rsp),%r9d
push   0xb0(%rsp)
push   %rax
call   1060 <calc_prob_region@plt>
add    $0x10,%rsp
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
mov    %r14,%rdi
call   1030 <free@plt>
add    %ebp,%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    11b0 <calc_prob+0x70>
jmp    1306 <calc_prob+0x1c6>
mov    %esi,%eax
shr    $0x1f,%eax
add    %esi,%eax
sar    %eax
mov    %r8d,%r9d
sub    %eax,%r9d
add    %r8d,%eax
mov    %r14,%rdi
push   0xb0(%rsp)
push   %rax
call   1060 <calc_prob_region@plt>
add    $0x78,%rsp
jmp    1310 <calc_prob+0x1d0>
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(double* %0, i32 %1, i8* %2, i32 %3, i32 %4, i32* %5, i32* %6, i32 %7, i32* %8) {
%10 = alloca double*
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
%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 double
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = alloca i32
%28 = alloca double*
store double* %0, double** %10
store i32 %1, i32* %11
store i8* %2, i8** %12
store i32 %3, i32* %13
store i32 %4, i32* %14
store i32* %5, i32** %15
store i32* %6, i32** %16
store i32 %7, i32* %17
store i32* %8, i32** %18
%29 = load i32, i32* %14
%30 = load i32, i32* %11
%31 = sdiv i32 %30, 2
%32 = sub nsw i32 %29, %31
store i32 %32, i32* %19
%33 = load i32, i32* %14
%34 = load i32, i32* %11
%35 = sdiv i32 %34, 2
%36 = add nsw i32 %33, %35
store i32 %36, i32* %20
store double 0.000000e+00, double* %23
%37 = load i32, i32* %17
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %49
39: ; preds = %9
%40 = load double*, double** %10
%41 = load i32, i32* %11
%42 = load i8*, i8** %12
%43 = load i32, i32* %13
%44 = load i32, i32* %14
%45 = load i32, i32* %19
%46 = load i32, i32* %20
%47 = load i32*, i32** %18
%48 = call double @calc_prob_region(double* %40, i32 %41, i8* %42, i32 %43, i32 %44, i32 %45, i32 %46, i32* %47)
store double %48, double* %23
br label %147
49: ; preds = %9
store i32 0, i32* %24
%50 = load i32, i32* %14
store i32 %50, i32* %25
store i32 0, i32* %21
br label %51
51: ; preds = %143, %49
%52 = load i32, i32* %21
%53 = load i32, i32* %17
%54 = icmp sle i32 %52, %53
br i1 %54, label %55, label %146
55: ; preds = %51
%56 = load i32, i32* %21
%57 = load i32, i32* %17
%58 = icmp slt i32 %56, %57
br i1 %58, label %59, label %68
59: ; preds = %55
%60 = load i32*, i32** %15
%61 = load i32, i32* %21
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i32, i32* %60, i64 %62
%64 = load i32, i32* %63
%65 = load i32, i32* %24
%66 = sub nsw i32 %64, %65
%67 = add nsw i32 %66, 1
br label %72
68: ; preds = %55
%69 = load i32, i32* %11
%70 = load i32, i32* %24
%71 = sub nsw i32 %69, %70
br label %72
72: ; preds = %68, %59
%73 = phi i32 [ %67, %59 ], [ %71, %68 ]
store i32 %73, i32* %26
%74 = load i32, i32* %26
%75 = sdiv i32 %74, 2
store i32 %75, i32* %27
%76 = load i32, i32* %25
%77 = load i32, i32* %27
%78 = sub nsw i32 %76, %77
store i32 %78, i32* %19
%79 = load i32, i32* %25
%80 = load i32, i32* %27
%81 = add nsw i32 %79, %80
store i32 %81, i32* %20
%82 = load i32, i32* %26
%83 = mul nsw i32 21, %82
%84 = sext i32 %83 to i64
%85 = mul i64 %84, 8
%86 = trunc i64 %85 to i32
%87 = call double* @malloc(i32 %86)
store double* %87, double** %28
store i32 0, i32* %22
br label %88
88: ; preds = %111, %72
%89 = load i32, i32* %22
%90 = icmp slt i32 %89, 21
br i1 %90, label %91, label %114
91: ; preds = %88
%92 = load double*, double** %28
%93 = load i32, i32* %26
%94 = load i32, i32* %22
%95 = mul nsw i32 %93, %94
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds double, double* %92, i64 %96
%98 = load double*, double** %10
%99 = load i32, i32* %11
%100 = load i32, i32* %22
%101 = mul nsw i32 %99, %100
%102 = load i32, i32* %24
%103 = add nsw i32 %101, %102
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds double, double* %98, i64 %104
%106 = load i32, i32* %26
%107 = sext i32 %106 to i64
%108 = mul i64 %107, 8
%109 = trunc i64 %108 to i32
%110 = call i32 @memcpy(double* %97, double* %105, i32 %109)
br label %111
111: ; preds = %91
%112 = load i32, i32* %22
%113 = add nsw i32 %112, 1
store i32 %113, i32* %22
br label %88
114: ; preds = %88
%115 = load double*, double** %28
%116 = load i32, i32* %26
%117 = load i8*, i8** %12
%118 = load i32, i32* %13
%119 = load i32, i32* %25
%120 = load i32, i32* %19
%121 = load i32, i32* %20
%122 = load i32*, i32** %18
%123 = call double @calc_prob_region(double* %115, i32 %116, i8* %117, i32 %118, i32 %119, i32 %120, i32 %121, i32* %122)
%124 = load double, double* %23
%125 = fadd double %124, %123
store double %125, double* %23
%126 = load double*, double** %28
%127 = call i32 @free(double* %126)
store double* null, double** %28
%128 = load i32, i32* %26
%129 = load i32*, i32** %16
%130 = load i32, i32* %21
%131 = sext i32 %130 to i64
%132 = getelementptr inbounds i32, i32* %129, i64 %131
%133 = load i32, i32* %132
%134 = add nsw i32 %128, %133
%135 = load i32, i32* %25
%136 = add nsw i32 %135, %134
store i32 %136, i32* %25
%137 = load i32*, i32** %15
%138 = load i32, i32* %21
%139 = sext i32 %138 to i64
%140 = getelementptr inbounds i32, i32* %137, i64 %139
%141 = load i32, i32* %140
%142 = add nsw i32 %141, 1
store i32 %142, i32* %24
br label %143
143: ; preds = %114
%144 = load i32, i32* %21
%145 = add nsw i32 %144, 1
store i32 %145, i32* %21
br label %51
146: ; preds = %51
br label %147
147: ; preds = %146, %39
%148 = load double, double* %23
ret double %148
}

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