#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 */
typedef int /*<<< orphan*/ uint64_t;
typedef int int64_t;
typedef int /*<<< orphan*/ int16_t;

/* Variables and functions */
int /*<<< orphan*/ align_cpu(char *, int /*<<< orphan*/ *, int, int, int, int,
                             int, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
void cpu_cal_align_score(char *content, uint64_t *preprocess_reads,
                         int16_t *align_results, int ref_len, int ref_count,
                         int read_len, int read_count, int ref_start,
                         int ref_end, int word_num, int chunk_read_num,
                         uint64_t *dvdh_bit_mem) {
  int i = 0, j = 0;
  char *ref_itr;
  uint64_t *read_itr;
  int64_t align_index_start;
  int loop_num = read_count / 1;
  int loop_num_temp = loop_num;
  int index = 0;
  int rest_read_num;
  int tmp_read_num;
  if (loop_num % chunk_read_num == 0) {
    loop_num = loop_num / chunk_read_num;
    rest_read_num = chunk_read_num;
  } else {
    rest_read_num = loop_num % chunk_read_num;
    loop_num = loop_num / chunk_read_num + 1;
  }
#pragma omp parallel for default(none) num_threads(cpu_threads) private(       \
    i, j, read_itr, ref_itr, align_index_start, tmp_read_num)                  \
    shared(ref_len, read_len, ref_start, ref_end, content, align_results,      \
           preprocess_reads, loop_num, loop_num_temp, word_num, dvdh_bit_mem,  \
           chunk_read_num, rest_read_num) schedule(guided) collapse(2)
  for (i = ref_start; i < ref_end; i++) {
    for (j = 0; j < loop_num; j++) {
      if (j == loop_num - 1) {
        tmp_read_num = rest_read_num;
      } else {
        tmp_read_num = chunk_read_num;
      }
      ref_itr = &content[i * (ref_len + 1)];
      align_index_start = (i - ref_start) * loop_num_temp;
      read_itr = &preprocess_reads[5 * 1 * j * word_num * chunk_read_num];
      align_cpu(ref_itr, read_itr, ref_len, read_len, word_num, tmp_read_num,
                align_index_start + j * chunk_read_num, align_results,
                dvdh_bit_mem);
    }
  }
}


x86 assembly (clang, -O0):
<cpu_cal_align_score>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    0x38(%rbp),%rax
mov    0x30(%rbp),%eax
mov    0x28(%rbp),%eax
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    0x10(%rbp),%eax
mov    $0x1,%ecx
cltd
idiv   %ecx
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%eax
mov    %eax,-0x4c(%rbp)
movl   $0x0,-0x50(%rbp)
mov    -0x48(%rbp),%eax
cltd
idivl  0x30(%rbp)
cmp    $0x0,%edx
jne    1190 <cpu_cal_align_score+0x80>
mov    -0x48(%rbp),%eax
cltd
idivl  0x30(%rbp)
mov    %eax,-0x48(%rbp)
mov    0x30(%rbp),%eax
mov    %eax,-0x54(%rbp)
jmp    11a7 <cpu_cal_align_score+0x97>
mov    -0x48(%rbp),%eax
cltd
idivl  0x30(%rbp)
mov    %edx,-0x54(%rbp)
mov    -0x48(%rbp),%eax
cltd
idivl  0x30(%rbp)
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
mov    0x18(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    0x20(%rbp),%eax
jge    1293 <cpu_cal_align_score+0x183>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x48(%rbp),%eax
jge    1280 <cpu_cal_align_score+0x170>
mov    -0x2c(%rbp),%eax
mov    -0x48(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    11e8 <cpu_cal_align_score+0xd8>
mov    -0x54(%rbp),%eax
mov    %eax,-0x58(%rbp)
jmp    11ee <cpu_cal_align_score+0xde>
mov    0x30(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%ecx
mov    -0x1c(%rbp),%edx
add    $0x1,%edx
imul   %edx,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%eax
sub    0x18(%rbp),%eax
imul   -0x4c(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x10(%rbp),%rax
imul   $0x5,-0x2c(%rbp),%ecx
imul   0x28(%rbp),%ecx
imul   0x30(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    0x28(%rbp),%r8d
mov    -0x58(%rbp),%r9d
mov    -0x44(%rbp),%r11d
mov    -0x2c(%rbp),%eax
imul   0x30(%rbp),%eax
add    %eax,%r11d
mov    -0x18(%rbp),%r10
mov    0x38(%rbp),%rax
mov    %r11d,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1030 <align_cpu@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11c0 <cpu_cal_align_score+0xb0>
jmp    1285 <cpu_cal_align_score+0x175>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11ad <cpu_cal_align_score+0x9d>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cpu_cal_align_score>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %r9d,%r13d
mov    %rdx,%r10
mov    %rdi,0x28(%rsp)
mov    0x90(%rsp),%eax
mov    0x98(%rsp),%r9d
mov    0xb0(%rsp),%edi
cltd
idiv   %edi
mov    %edx,%r11d
xor    %ebp,%ebp
test   %edx,%edx
setne  %dl
cmove  %edi,%r11d
cmp    0xa0(%rsp),%r9d
jge    12ab <cpu_cal_align_score+0x19b>
mov    0xa8(%rsp),%r8d
mov    0xb8(%rsp),%rbx
mov    %dl,%bpl
mov    %rax,%rdx
add    %ebp,%edx
lea    -0x1(%rdx),%ebp
lea    0x1(%rcx),%r14d
movslq %r9d,%rax
mov    %rax,0x10(%rsp)
movslq %r14d,%rax
mov    %rax,0x20(%rsp)
mov    %rdx,0x30(%rsp)
mov    %edx,%edx
mov    %edi,%eax
imul   %r8d,%eax
lea    (%rax,%rax,4),%edi
movl   $0x0,0xc(%rsp)
mov    %r13d,0x1c(%rsp)
mov    %rcx,0x48(%rsp)
mov    %rbp,0x40(%rsp)
mov    %rdx,0x38(%rsp)
mov    %edi,0x18(%rsp)
jmp    11eb <cpu_cal_align_score+0xdb>
nop
mov    0x10(%rsp),%r9
add    $0x1,%r9
mov    0xc(%rsp),%eax
add    0x90(%rsp),%eax
mov    %eax,0xc(%rsp)
mov    %r9,0x10(%rsp)
cmp    0xa0(%rsp),%r9d
je     12ab <cpu_cal_align_score+0x19b>
cmpl   $0x0,0x30(%rsp)
jle    11c0 <cpu_cal_align_score+0xb0>
mov    0x10(%rsp),%rax
imul   0x20(%rsp),%rax
add    0x28(%rsp),%rax
mov    %rax,0x50(%rsp)
xor    %r14d,%r14d
mov    0xc(%rsp),%eax
mov    %eax,%r12d
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    %r15,%rbp
mov    0xb0(%rsp),%r9d
cmove  %r11d,%r9d
movslq %r14d,%r14
mov    %rsi,%rbp
lea    (%rsi,%r14,4),%rsi
sub    $0x8,%rsp
mov    0x58(%rsp),%rdi
mov    %ecx,%edx
mov    %r13d,%ecx
push   %rbx
push   %r10
push   %r12
mov    %r10,%r13
mov    %r11d,%ebx
call   1030 <align_cpu@plt>
mov    0x38(%rsp),%edi
mov    0x58(%rsp),%rdx
mov    %ebx,%r11d
mov    0xd0(%rsp),%eax
mov    %rbp,%rsi
mov    0x60(%rsp),%rbp
mov    %r13,%r10
mov    0xd8(%rsp),%rbx
mov    0xc8(%rsp),%r8d
mov    0x68(%rsp),%rcx
mov    0x3c(%rsp),%r13d
add    $0x20,%rsp
add    $0x1,%r15
add    %eax,%r12d
add    %edi,%r14d
cmp    %r15,%rdx
jne    1220 <cpu_cal_align_score+0x110>
jmp    11c0 <cpu_cal_align_score+0xb0>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @cpu_cal_align_score(i8* %0, i32* %1, i32* %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, i32 %8, i32 %9, i32 %10, i32* %11) {
%13 = alloca i8*
%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 i32
%24 = alloca i32*
%25 = alloca i32
%26 = alloca i32
%27 = alloca i8*
%28 = alloca i32*
%29 = alloca i32
%30 = alloca i32
%31 = alloca i32
%32 = alloca i32
%33 = alloca i32
%34 = alloca i32
store i8* %0, i8** %13
store i32* %1, i32** %14
store i32* %2, i32** %15
store i32 %3, i32* %16
store i32 %4, i32* %17
store i32 %5, i32* %18
store i32 %6, i32* %19
store i32 %7, i32* %20
store i32 %8, i32* %21
store i32 %9, i32* %22
store i32 %10, i32* %23
store i32* %11, i32** %24
store i32 0, i32* %25
store i32 0, i32* %26
%35 = load i32, i32* %19
%36 = sdiv i32 %35, 1
store i32 %36, i32* %30
%37 = load i32, i32* %30
store i32 %37, i32* %31
store i32 0, i32* %32
%38 = load i32, i32* %30
%39 = load i32, i32* %23
%40 = srem i32 %38, %39
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %47
42: ; preds = %12
%43 = load i32, i32* %30
%44 = load i32, i32* %23
%45 = sdiv i32 %43, %44
store i32 %45, i32* %30
%46 = load i32, i32* %23
store i32 %46, i32* %33
br label %55
47: ; preds = %12
%48 = load i32, i32* %30
%49 = load i32, i32* %23
%50 = srem i32 %48, %49
store i32 %50, i32* %33
%51 = load i32, i32* %30
%52 = load i32, i32* %23
%53 = sdiv i32 %51, %52
%54 = add nsw i32 %53, 1
store i32 %54, i32* %30
br label %55
55: ; preds = %47, %42
%56 = load i32, i32* %20
store i32 %56, i32* %25
br label %57
57: ; preds = %115, %55
%58 = load i32, i32* %25
%59 = load i32, i32* %21
%60 = icmp slt i32 %58, %59
br i1 %60, label %61, label %118
61: ; preds = %57
store i32 0, i32* %26
br label %62
62: ; preds = %111, %61
%63 = load i32, i32* %26
%64 = load i32, i32* %30
%65 = icmp slt i32 %63, %64
br i1 %65, label %66, label %114
66: ; preds = %62
%67 = load i32, i32* %26
%68 = load i32, i32* %30
%69 = sub nsw i32 %68, 1
%70 = icmp eq i32 %67, %69
br i1 %70, label %71, label %73
71: ; preds = %66
%72 = load i32, i32* %33
store i32 %72, i32* %34
br label %75
73: ; preds = %66
%74 = load i32, i32* %23
store i32 %74, i32* %34
br label %75
75: ; preds = %73, %71
%76 = load i8*, i8** %13
%77 = load i32, i32* %25
%78 = load i32, i32* %16
%79 = add nsw i32 %78, 1
%80 = mul nsw i32 %77, %79
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds i8, i8* %76, i64 %81
store i8* %82, i8** %27
%83 = load i32, i32* %25
%84 = load i32, i32* %20
%85 = sub nsw i32 %83, %84
%86 = load i32, i32* %31
%87 = mul nsw i32 %85, %86
store i32 %87, i32* %29
%88 = load i32*, i32** %14
%89 = load i32, i32* %26
%90 = mul nsw i32 5, %89
%91 = load i32, i32* %22
%92 = mul nsw i32 %90, %91
%93 = load i32, i32* %23
%94 = mul nsw i32 %92, %93
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds i32, i32* %88, i64 %95
store i32* %96, i32** %28
%97 = load i8*, i8** %27
%98 = load i32*, i32** %28
%99 = load i32, i32* %16
%100 = load i32, i32* %18
%101 = load i32, i32* %22
%102 = load i32, i32* %34
%103 = load i32, i32* %29
%104 = load i32, i32* %26
%105 = load i32, i32* %23
%106 = mul nsw i32 %104, %105
%107 = add nsw i32 %103, %106
%108 = load i32*, i32** %15
%109 = load i32*, i32** %24
%110 = call i32 @align_cpu(i8* %97, i32* %98, i32 %99, i32 %100, i32 %101, i32 %102, i32 %107, i32* %108, i32* %109)
br label %111
111: ; preds = %75
%112 = load i32, i32* %26
%113 = add nsw i32 %112, 1
store i32 %113, i32* %26
br label %62
114: ; preds = %62
br label %115
115: ; preds = %114
%116 = load i32, i32* %25
%117 = add nsw i32 %116, 1
store i32 %117, i32* %25
br label %57
118: ; preds = %57
ret void
}

LLVM IR (-O2):
define void @cpu_cal_align_score(i8* %0, i32* %1, i32* %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, i32 %8, i32 %9, i32 %10, i32* %11) {
%13 = srem i32 %6, %10
%14 = icmp eq i32 %13, 0
%15 = sdiv i32 %6, %10
%16 = xor i1 %14, true
%17 = zext i1 %16 to i32
%18 = add nsw i32 %15, %17
%19 = select i1 %14, i32 %10, i32 %13
%20 = icmp slt i32 %7, %8
br i1 %20, label %21, label %58
21: ; preds = %12
%22 = icmp sgt i32 %18, 0
%23 = add nsw i32 %18, -1
%24 = add nsw i32 %3, 1
%25 = zext i32 %23 to i64
%26 = zext i32 %10 to i64
%27 = sext i32 %7 to i64
%28 = sext i32 %24 to i64
%29 = zext i32 %6 to i64
%30 = zext i32 %18 to i64
br label %31
31: ; preds = %21, %54
%32 = phi i64 [ %27, %21 ], [ %55, %54 ]
br i1 %22, label %33, label %54
33: ; preds = %31
%34 = mul nsw i64 %32, %28
%35 = getelementptr inbounds i8, i8* %0, i64 %34
%36 = sub nsw i64 %32, %27
%37 = mul i64 %36, %29
br label %38
38: ; preds = %33, %38
%39 = phi i64 [ 0, %33 ], [ %52, %38 ]
%40 = icmp eq i64 %39, %25
%41 = select i1 %40, i32 %19, i32 %10
%42 = trunc i64 %39 to i32
%43 = mul i32 %42, %10
%44 = mul i32 %43, 5
%45 = mul i32 %44, %9
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i32, i32* %1, i64 %46
%48 = mul i64 %39, %26
%49 = add i64 %48, %37
%50 = trunc i64 %49 to i32
%51 = tail call i32 @align_cpu(i8* %35, i32* %47, i32 %3, i32 %5, i32 %9, i32 %41, i32 %50, i32* %2, i32* %11)
%52 = add nuw nsw i64 %39, 1
%53 = icmp eq i64 %52, %30
br i1 %53, label %54, label %38
54: ; preds = %38, %31
%55 = add nsw i64 %32, 1
%56 = trunc i64 %55 to i32
%57 = icmp eq i32 %56, %8
br i1 %57, label %58, label %31
58: ; preds = %54, %12
ret void
}