// File: DoubleString[P]RtConverter/src/Rtklib/rtcm3e.cpp
// Function: bamboo::gen_msm_index(bamboo::rtcm_t*, int, int*, int*, int*, unsigned char*, unsigned char*, unsigned char*)
static void gen_msm_index(rtcm_t *rtcm, int sys, int *nsat, int *nsig,
                          int *ncell, unsigned char *sat_ind,
                          unsigned char *sig_ind, unsigned char *cell_ind)
{
    int i,j,sat,sig,cell,f;
    
    *nsat=*nsig=*ncell=0;
    
    /* generate satellite and signal index */
    for (i=0;i<rtcm->obs.n;i++) {
        if (!(sat=to_satid(sys,rtcm->obs.data[i].sat))) continue;
        
        for (j=0;j<NFREQ+NEXOBS;j++) {
            if (!(sig=to_sigid(sys,rtcm->obs.data[i].code[j],&f))) continue;
            
            sat_ind[sat-1]=sig_ind[sig-1]=1;
        }
    }
    for (i=0;i<64;i++) {
        if (sat_ind[i]) sat_ind[i]=++(*nsat);
    }
    for (i=0;i<32;i++) {
        if (sig_ind[i]) sig_ind[i]=++(*nsig);
    }
    /* generate cell index */
    for (i=0;i<rtcm->obs.n;i++) {
        if (!(sat=to_satid(sys,rtcm->obs.data[i].sat))) continue;
        
        for (j=0;j<NFREQ+NEXOBS;j++) {
            if (!(sig=to_sigid(sys,rtcm->obs.data[i].code[j],&f))) continue;
            
            cell=sig_ind[sig-1]-1+(sat_ind[sat-1]-1)*(*nsig);
            cell_ind[cell]=1;
        }
    }
    for (i=0;i<*nsat*(*nsig);i++) {
        if (cell_ind[i]&&*ncell<64) cell_ind[i]=++(*ncell);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x28(%rbp), %rax
movl $0x0, (%rax)
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
movq -0x18(%rbp), %rax
movl $0x0, (%rax)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x30(%rcx), %eax
jge 0x89511
movl -0xc(%rbp), %edi
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x34(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movzbl 0x10(%rax), %esi
callq 0x89f50
movl %eax, -0x3c(%rbp)
cmpl $0x0, %eax
jne 0x89495
jmp 0x89503
movl $0x0, -0x38(%rbp)
cmpl $0x3, -0x38(%rbp)
jge 0x89501
movl -0xc(%rbp), %edi
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x34(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movslq -0x38(%rbp), %rcx
leaq -0x48(%rbp), %rdx
movzbl 0x18(%rax,%rcx), %esi
callq 0x89fb0
movl %eax, -0x40(%rbp)
cmpl $0x0, %eax
jne 0x894d4
jmp 0x894f6
movq 0x10(%rbp), %rax
movl -0x40(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movb $0x1, (%rax,%rcx)
movq -0x30(%rbp), %rax
movl -0x3c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movb $0x1, (%rax,%rcx)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x8949c
jmp 0x89503
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x8945c
movl $0x0, -0x34(%rbp)
cmpl $0x40, -0x34(%rbp)
jge 0x89551
movq -0x30(%rbp), %rax
movslq -0x34(%rbp), %rcx
cmpb $0x0, (%rax,%rcx)
je 0x89544
movq -0x18(%rbp), %rcx
movl (%rcx), %eax
addl $0x1, %eax
movl %eax, (%rcx)
movb %al, %dl
movq -0x30(%rbp), %rax
movslq -0x34(%rbp), %rcx
movb %dl, (%rax,%rcx)
jmp 0x89546
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x89518
movl $0x0, -0x34(%rbp)
cmpl $0x20, -0x34(%rbp)
jge 0x89591
movq 0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
cmpb $0x0, (%rax,%rcx)
je 0x89584
movq -0x20(%rbp), %rcx
movl (%rcx), %eax
addl $0x1, %eax
movl %eax, (%rcx)
movb %al, %dl
movq 0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movb %dl, (%rax,%rcx)
jmp 0x89586
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x89558
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x30(%rcx), %eax
jge 0x89675
movl -0xc(%rbp), %edi
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x34(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movzbl 0x10(%rax), %esi
callq 0x89f50
movl %eax, -0x3c(%rbp)
cmpl $0x0, %eax
jne 0x895d4
jmp 0x89667
movl $0x0, -0x38(%rbp)
cmpl $0x3, -0x38(%rbp)
jge 0x89665
movl -0xc(%rbp), %edi
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x34(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movslq -0x38(%rbp), %rcx
leaq -0x48(%rbp), %rdx
movzbl 0x18(%rax,%rcx), %esi
callq 0x89fb0
movl %eax, -0x40(%rbp)
cmpl $0x0, %eax
jne 0x89617
jmp 0x89657
movq 0x10(%rbp), %rax
movl -0x40(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
subl $0x1, %eax
movq -0x30(%rbp), %rcx
movl -0x3c(%rbp), %edx
subl $0x1, %edx
movslq %edx, %rdx
movzbl (%rcx,%rdx), %ecx
subl $0x1, %ecx
movq -0x20(%rbp), %rdx
imull (%rdx), %ecx
addl %ecx, %eax
movl %eax, -0x44(%rbp)
movq 0x18(%rbp), %rax
movslq -0x44(%rbp), %rcx
movb $0x1, (%rax,%rcx)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x895db
jmp 0x89667
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x89598
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x18(%rbp), %rcx
movl (%rcx), %ecx
movq -0x20(%rbp), %rdx
imull (%rdx), %ecx
cmpl %ecx, %eax
jge 0x896cc
movq 0x18(%rbp), %rax
movslq -0x34(%rbp), %rcx
cmpb $0x0, (%rax,%rcx)
je 0x896bf
movq -0x28(%rbp), %rax
cmpl $0x40, (%rax)
jge 0x896bf
movq -0x28(%rbp), %rcx
movl (%rcx), %eax
addl $0x1, %eax
movl %eax, (%rcx)
movb %al, %dl
movq 0x18(%rbp), %rax
movslq -0x34(%rbp), %rcx
movb %dl, (%rax,%rcx)
jmp 0x896c1
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x8967c
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)