// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x48, %rsp
movq %rdi, 0x40(%rsp)
movq %rsi, 0x38(%rsp)
movq %rdx, 0x30(%rsp)
movq %rcx, 0x28(%rsp)
cmpq $0x0, 0x40(%rsp)
jne 0x18c918
movq 0x4af6b9(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x389722(%rip), %rsi    # 0x516013
leaq 0x38dabe(%rip), %rdx    # 0x51a3b6
leaq 0x3c8d94(%rip), %rcx    # 0x555693
leaq 0x3c8b55(%rip), %r8     # 0x55545b
movl $0x1f3, %r9d            # imm = 0x1F3
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x18c91a
callq 0xec560
movsd %xmm0, 0x8(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, (%rsp)
movl $0x0, 0x1c(%rsp)
movl 0x1c(%rsp), %eax
movq 0x40(%rsp), %rcx
movl (%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jae 0x18c989
movq 0x40(%rsp), %rdi
movl 0x1c(%rsp), %esi
callq 0x18ad20
addsd (%rsp), %xmm0
movsd %xmm0, (%rsp)
movsd (%rsp), %xmm0
subsd 0x8(%rsp), %xmm0
movsd 0x3c8ab6(%rip), %xmm1   # 0x555428
ucomisd %xmm1, %xmm0
jbe 0x18c97a
jmp 0x18c989
jmp 0x18c97c
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
jmp 0x18c935
movq $0x0, 0x20(%rsp)
movq 0x20(%rsp), %rax
cmpq 0x38(%rsp), %rax
jae 0x18cabc
callq 0xec560
movsd %xmm0, 0x8(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, (%rsp)
movl $0x0, 0x18(%rsp)
movl 0x18(%rsp), %eax
movq 0x40(%rsp), %rcx
movl 0x4(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jae 0x18ca16
movq 0x40(%rsp), %rdi
movl 0x1c(%rsp), %esi
movl 0x18(%rsp), %edx
callq 0x18b0e0
addsd (%rsp), %xmm0
movsd %xmm0, (%rsp)
movsd (%rsp), %xmm0
subsd 0x8(%rsp), %xmm0
movsd 0x3c8a29(%rip), %xmm1   # 0x555428
ucomisd %xmm1, %xmm0
jbe 0x18ca07
jmp 0x18ca16
jmp 0x18ca09
movl 0x18(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x18(%rsp)
jmp 0x18c9bd
cmpq $0x0, 0x30(%rsp)
je 0x18ca2e
movq 0x30(%rsp), %rax
movl 0x18(%rsp), %edi
movq 0x28(%rsp), %rsi
callq *%rax
callq 0xec560
movsd %xmm0, 0x8(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, (%rsp)
movl $0x0, 0x14(%rsp)
movl 0x14(%rsp), %eax
movq 0x40(%rsp), %rcx
movl (%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jae 0x18caa1
movq 0x40(%rsp), %rdi
movl 0x1c(%rsp), %esi
movl 0x14(%rsp), %edx
callq 0x18ae10
addsd (%rsp), %xmm0
movsd %xmm0, (%rsp)
movsd (%rsp), %xmm0
subsd 0x8(%rsp), %xmm0
movsd 0x3c899e(%rip), %xmm1   # 0x555428
ucomisd %xmm1, %xmm0
jbe 0x18ca92
jmp 0x18caa1
jmp 0x18ca94
movl 0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14(%rsp)
jmp 0x18ca49
movl 0x14(%rsp), %eax
movl %eax, 0x1c(%rsp)
movq 0x20(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x20(%rsp)
jmp 0x18c992
addq $0x48, %rsp
retq
nopw %cs:(%rax,%rax)