// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/extended/hmm.c
// Function: gt_hmm_emit
void gt_hmm_emit(GtHMM *hmm, GtUword num_of_emissions,
              void (*proc_emission)(unsigned int symbol, void *data),
              void *data)
{
  GtUword i;
  unsigned int state, symbol, next_state;
  double random_value, cumulative_prob;
  gt_assert(hmm);

  /* determine initial state */
  random_value = gt_rand_0_to_1();
  cumulative_prob = 0.0;
  for (state = 0; state < hmm->num_of_states - 1; state++) {
    cumulative_prob += gt_hmm_get_initial_state_probability(hmm, state);
    if (cumulative_prob - random_value > DBL_EPSILON)
      break;
  }

  /* emit loop */
  for (i = 0; i < num_of_emissions; i++) {
    /* emit character */
    random_value = gt_rand_0_to_1();
    cumulative_prob = 0.0;
    for (symbol = 0; symbol < hmm->num_of_symbols - 1; symbol++) {
      cumulative_prob += gt_hmm_get_emission_probability(hmm, state, symbol);
      if (cumulative_prob - random_value > DBL_EPSILON)
        break;
    }
    if (proc_emission != NULL)
      proc_emission(symbol, data);
    /* go to next state */
    random_value = gt_rand_0_to_1();
    cumulative_prob = 0.0;
    for (next_state = 0; next_state < hmm->num_of_states - 1; next_state++) {
      cumulative_prob += gt_hmm_get_transition_probability(hmm,
                                                           state, next_state);
      if (cumulative_prob - random_value > DBL_EPSILON)
        break;
    }
    state = next_state;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, 0x10(%rsp)
testq %rdi, %rdi
je 0xed812
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
xorpd %xmm0, %xmm0
movsd %xmm0, (%rsp)
xorl %ebp, %ebp
callq 0x9576b
movsd %xmm0, 0x8(%rsp)
movl (%r12), %eax
decl %eax
cmpl %eax, %ebp
jae 0xed730
movq %r12, %rdi
movl %ebp, %esi
callq 0xec6ee
movsd (%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rsp)
movapd %xmm1, %xmm0
subsd 0x8(%rsp), %xmm0
ucomisd 0x235a46(%rip), %xmm0   # 0x323170
ja 0xed730
incl %ebp
jmp 0xed6f6
xorl %ebx, %ebx
cmpq %r15, %rbx
je 0xed803
xorpd %xmm0, %xmm0
movsd %xmm0, (%rsp)
xorl %r13d, %r13d
callq 0x9576b
movsd %xmm0, 0x8(%rsp)
movl 0x4(%r12), %eax
decl %eax
cmpl %eax, %r13d
jae 0xed792
movq %r12, %rdi
movl %ebp, %esi
movl %r13d, %edx
callq 0xec95e
movsd (%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rsp)
movapd %xmm1, %xmm0
subsd 0x8(%rsp), %xmm0
ucomisd 0x2359e5(%rip), %xmm0   # 0x323170
ja 0xed792
incl %r13d
jmp 0xed752
testq %r14, %r14
je 0xed7a2
movl %r13d, %edi
movq 0x10(%rsp), %rsi
callq *%r14
xorpd %xmm0, %xmm0
movsd %xmm0, (%rsp)
xorl %r13d, %r13d
callq 0x9576b
movsd %xmm0, 0x8(%rsp)
movl (%r12), %eax
decl %eax
cmpl %eax, %r13d
jae 0xed7f8
movq %r12, %rdi
movl %ebp, %esi
movl %r13d, %edx
callq 0xec77b
movsd (%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rsp)
movapd %xmm1, %xmm0
subsd 0x8(%rsp), %xmm0
ucomisd 0x23597f(%rip), %xmm0   # 0x323170
ja 0xed7f8
incl %r13d
jmp 0xed7b9
incq %rbx
movl %r13d, %ebp
jmp 0xed732
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x34a74f(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1f77f0(%rip), %rsi    # 0x2e5013
leaq 0x1fbb3e(%rip), %rdx    # 0x2e9368
leaq 0x235bcf(%rip), %rcx    # 0x323400
leaq 0x23596b(%rip), %r8     # 0x3231a3
movl $0x1f3, %r9d            # imm = 0x1F3
xorl %eax, %eax
callq 0x17a50
callq 0x17390