// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/extended/hmm.c
// Function: gt_hmm_init_random
void gt_hmm_init_random(GtHMM *hmm)
{
  double random_value, cumulative_prob;
  unsigned int i, j;
  gt_assert(hmm);

  /* initialize initial state probabilities in random fashion */
  cumulative_prob = 0.0;
  for (i = 0; i < hmm->num_of_states - 1; i++) {
    random_value = gt_rand_max_double(1.0 - cumulative_prob);
    gt_hmm_set_initial_state_probability(hmm, i, random_value);
    cumulative_prob += random_value;
  }
  gt_assert(cumulative_prob <= 1.0);
  gt_hmm_set_initial_state_probability(hmm, i,  1.0 - cumulative_prob);

  /* initialize transition probabilities in random fashion */
  for (i = 0; i < hmm->num_of_states; i++) {
    cumulative_prob = 0.0;
    for (j = 0; j < hmm->num_of_states - 1; j++) {
      random_value = gt_rand_max_double(1.0 - cumulative_prob);
      gt_hmm_set_transition_probability(hmm, i, j, random_value);
      cumulative_prob += random_value;
    }
    gt_assert(cumulative_prob <= 1.0);
    gt_hmm_set_transition_probability(hmm, i, j, 1.0 - cumulative_prob);
  }

  /* initialize emission probabilities in random fashion */
  for (i = 0; i < hmm->num_of_states; i++) {
    cumulative_prob = 0.0;
    for (j = 0; j < hmm->num_of_symbols - 1; j++) {
      random_value = gt_rand_max_double(1.0 - cumulative_prob);
      gt_hmm_set_emission_probability(hmm, i, j, random_value);
      cumulative_prob += random_value;
    }
    gt_assert(cumulative_prob <= 1.0);
    gt_hmm_set_emission_probability(hmm, i, j, 1.0 - cumulative_prob);
  }

  gt_assert(gt_hmm_is_valid(hmm));
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
testq %rdi, %rdi
je 0xecd40
movq %rdi, %rbx
xorl %ebp, %ebp
xorpd %xmm1, %xmm1
movl (%rbx), %eax
decl %eax
movsd 0x1f968d(%rip), %xmm0   # 0x2e6228
cmpl %eax, %ebp
jae 0xecbcc
subsd %xmm1, %xmm0
movsd %xmm1, 0x8(%rsp)
callq 0x956c8
movsd %xmm0, (%rsp)
movq %rbx, %rdi
movl %ebp, %esi
callq 0xec3a1
movsd 0x8(%rsp), %xmm1
addsd (%rsp), %xmm1
incl %ebp
jmp 0xecb8f
ucomisd %xmm1, %xmm0
jb 0xecd6e
subsd %xmm1, %xmm0
movq %rbx, %rdi
movl %ebp, %esi
callq 0xec3a1
xorl %ebp, %ebp
movl (%rbx), %eax
cmpl %eax, %ebp
jae 0xecc54
xorl %r14d, %r14d
xorpd %xmm2, %xmm2
decl %eax
movsd 0x1f962b(%rip), %xmm1   # 0x2e6228
movapd %xmm1, %xmm0
subsd %xmm2, %xmm0
cmpl %eax, %r14d
jae 0xecc39
movsd %xmm2, 0x8(%rsp)
callq 0x956c8
movsd %xmm0, (%rsp)
movq %rbx, %rdi
movl %ebp, %esi
movl %r14d, %edx
callq 0xec487
movsd 0x8(%rsp), %xmm2
addsd (%rsp), %xmm2
incl %r14d
movl (%rbx), %eax
jmp 0xecbf3
ucomisd %xmm2, %xmm1
jb 0xeccda
movq %rbx, %rdi
movl %ebp, %esi
movl %r14d, %edx
callq 0xec487
incl %ebp
jmp 0xecbe6
xorl %ebp, %ebp
cmpl %eax, %ebp
jae 0xeccc1
xorl %r14d, %r14d
xorpd %xmm2, %xmm2
movl 0x4(%rbx), %eax
decl %eax
movsd 0x1f95ba(%rip), %xmm1   # 0x2e6228
movapd %xmm1, %xmm0
subsd %xmm2, %xmm0
cmpl %eax, %r14d
jae 0xecca8
movsd %xmm2, 0x8(%rsp)
callq 0x956c8
movsd %xmm0, (%rsp)
movq %rbx, %rdi
movl %ebp, %esi
movl %r14d, %edx
callq 0xec5aa
movsd 0x8(%rsp), %xmm2
addsd (%rsp), %xmm2
incl %r14d
jmp 0xecc61
ucomisd %xmm2, %xmm1
jb 0xecd08
movq %rbx, %rdi
movl %ebp, %esi
movl %r14d, %edx
callq 0xec5aa
incl %ebp
movl (%rbx), %eax
jmp 0xecc56
movq %rbx, %rdi
callq 0xeca3c
testb %al, %al
je 0xecd9c
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movq 0x34b287(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1f8328(%rip), %rsi    # 0x2e5013
leaq 0x236671(%rip), %rdx    # 0x323363
leaq 0x236657(%rip), %rcx    # 0x323350
leaq 0x2364a3(%rip), %r8     # 0x3231a3
movl $0x11b, %r9d            # imm = 0x11B
jmp 0xecd34
movq 0x34b259(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1f82fa(%rip), %rsi    # 0x2e5013
leaq 0x236643(%rip), %rdx    # 0x323363
leaq 0x236629(%rip), %rcx    # 0x323350
leaq 0x236475(%rip), %r8     # 0x3231a3
movl $0x127, %r9d            # imm = 0x127
xorl %eax, %eax
callq 0x17a50
callq 0x17390
movq 0x34b221(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1f82c2(%rip), %rsi    # 0x2e5013
leaq 0x1fc610(%rip), %rdx    # 0x2e9368
leaq 0x2365f1(%rip), %rcx    # 0x323350
leaq 0x23643d(%rip), %r8     # 0x3231a3
movl $0x107, %r9d            # imm = 0x107
jmp 0xecd34
movq 0x34b1f3(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1f8294(%rip), %rsi    # 0x2e5013
leaq 0x2365dd(%rip), %rdx    # 0x323363
leaq 0x2365c3(%rip), %rcx    # 0x323350
leaq 0x23640f(%rip), %r8     # 0x3231a3
movl $0x110, %r9d            # imm = 0x110
jmp 0xecd34
movq 0x34b1c5(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1f8266(%rip), %rsi    # 0x2e5013
leaq 0x2365c6(%rip), %rdx    # 0x32337a
leaq 0x236595(%rip), %rcx    # 0x323350
leaq 0x2363e1(%rip), %r8     # 0x3231a3
movl $0x12b, %r9d            # imm = 0x12B
jmp 0xecd34