// File: DoubleString[P]RtConverter/src/Rtklib/rcvraw.cpp
// Function: bamboo::init_raw(bamboo::raw_t*, int)
extern int init_raw(raw_t *raw, int format)
{
    const double lam_glo[NFREQ]={CLIGHT/FREQ1_GLO,CLIGHT/FREQ2_GLO};
    gtime_t time0={0};
    obsd_t data0={{0}};
    eph_t  eph0 ={0,-1,-1};
    alm_t  alm0 ={0,-1};
    geph_t geph0={0,-1};
    seph_t seph0={0};
    sbsmsg_t sbsmsg0={0};
    lexmsg_t lexmsg0={0};
    int i,j,sys,ret=1;
    
    trace(3,"init_raw: format=%d\n",format);
    
    raw->time=time0;
    raw->ephsat=0;
    raw->sbsmsg=sbsmsg0;
    raw->msgtype[0]='\0';
    for (i=0;i<MAXRTKSAT;i++) {
        for (j=0;j<380;j++) raw->subfrm[i][j]=0;
        for (j=0;j<NFREQ+NEXOBS;j++) {
            raw->tobs [i][j]=time0;
            raw->lockt[i][j]=0.0;
            raw->halfc[i][j]=0;
        }
        raw->icpp[i]=raw->off[i]=raw->prCA[i]=raw->dpCA[i]=0.0;
    }
    for (i=0;i<MAXOBS;i++) raw->freqn[i]=0;
    raw->lexmsg=lexmsg0;
    raw->icpc=0.0;
    raw->nbyte=raw->len=0;
    raw->iod=raw->flag=raw->tbase=raw->outtype=0;
    raw->tod=-1;
    for (i=0;i<MAXRAWLEN;i++) raw->buff[i]=0;
    raw->opt[0]='\0';
    raw->format=-1;
    
    raw->obs.data =NULL;
    raw->obuf.data=NULL;
    raw->nav.eph  =NULL;
    raw->nav.alm  =NULL;
    raw->nav.geph =NULL;
    raw->nav.seph =NULL;
    raw->half_cyc =NULL;
    raw->rcv_data =NULL;
    
    if (!(raw->obs.data =(obsd_t *)malloc(sizeof(obsd_t)*MAXOBS))||
        !(raw->obuf.data=(obsd_t *)malloc(sizeof(obsd_t)*MAXOBS))||
        !(raw->nav.eph  =(eph_t  *)malloc(sizeof(eph_t )*MAXRTKSAT))||
        !(raw->nav.alm  =(alm_t  *)malloc(sizeof(alm_t )*MAXRTKSAT))||
        !(raw->nav.geph =(geph_t *)malloc(sizeof(geph_t)*NSATGLO))||
        !(raw->nav.seph =(seph_t *)malloc(sizeof(seph_t)*NSATSBS*2))) {
        free_raw(raw);
        return 0;
    }
    raw->obs.n =0;
    raw->obuf.n=0;
    raw->nav.n =MAXRTKSAT;
    raw->nav.na=MAXRTKSAT;
    raw->nav.ng=NSATGLO;
    raw->nav.ns=NSATSBS*2;
    for (i=0;i<MAXOBS   ;i++) raw->obs.data [i]=data0;
    for (i=0;i<MAXOBS   ;i++) raw->obuf.data[i]=data0;
    for (i=0;i<MAXRTKSAT   ;i++) raw->nav.eph  [i]=eph0;
    for (i=0;i<MAXRTKSAT   ;i++) raw->nav.alm  [i]=alm0;
    for (i=0;i<NSATGLO  ;i++) raw->nav.geph [i]=geph0;
    for (i=0;i<NSATSBS*2;i++) raw->nav.seph [i]=seph0;
    for (i=0;i<MAXRTKSAT;i++) for (j=0;j<NFREQ;j++) {
        if (!(sys=satsys(i+1,NULL))) continue;
        raw->nav.lam[i][j]=sys==SYS_GLO?lam_glo[j]:lam_carr[j];
    }
    raw->sta.name[0]=raw->sta.marker[0]='\0';
    raw->sta.antdes[0]=raw->sta.antsno[0]='\0';
    raw->sta.rectype[0]=raw->sta.recver[0]=raw->sta.recsno[0]='\0';
    raw->sta.antsetup=raw->sta.itrf=raw->sta.deltype=0;
    for (i=0;i<3;i++) {
        raw->sta.pos[i]=raw->sta.del[i]=0.0;
    }
    raw->sta.hgt=0.0;
    
    /* initialize receiver dependent data */
    raw->format=format;
    switch (format) {
      //  case STRFMT_CMR : ret=init_cmr (raw); break;
        case STRFMT_RT17: ret=init_rt17(raw); break;
    }
    if (!ret) {
        free_raw(raw);
        return 0;
    }
    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x480, %rsp            # imm = 0x480
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq 0x58fb7(%rip), %rax     # 0xbf0d0
movq %rax, -0x30(%rbp)
movq 0x58fb4(%rip), %rax     # 0xbf0d8
movq %rax, -0x28(%rbp)
movq 0x58fb1(%rip), %rax     # 0xbf0e0
movq %rax, -0x20(%rbp)
leaq -0x40(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x93d0
leaq -0xa0(%rbp), %rdi
xorl %esi, %esi
movl $0x60, %edx
callq 0x93d0
leaq -0x1c0(%rbp), %rdi
xorl %esi, %esi
movl $0x120, %edx            # imm = 0x120
callq 0x93d0
movl $0xffffffff, -0x1bc(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x1b8(%rbp) # imm = 0xFFFFFFFF
leaq -0x230(%rbp), %rdi
xorl %esi, %esi
movl $0x70, %edx
callq 0x93d0
movl $0xffffffff, -0x22c(%rbp) # imm = 0xFFFFFFFF
leaq -0x2c8(%rbp), %rdi
xorl %esi, %esi
movl $0x98, %edx
callq 0x93d0
movl $0xffffffff, -0x2c4(%rbp) # imm = 0xFFFFFFFF
leaq -0x350(%rbp), %rdi
xorl %esi, %esi
movl $0x88, %edx
callq 0x93d0
leaq -0x37c(%rbp), %rdi
xorl %esi, %esi
movl $0x2c, %edx
callq 0x93d0
leaq -0x464(%rbp), %rdi
xorl %esi, %esi
movl $0xe8, %edx
callq 0x93d0
movl $0x1, -0x474(%rbp)
movl -0x14(%rbp), %edx
movl $0x3, %edi
leaq 0x5910c(%rip), %rsi     # 0xbf315
movb $0x0, %al
callq 0x8b980
movq -0x10(%rbp), %rax
movq -0x40(%rbp), %rcx
movq %rcx, (%rax)
movq -0x38(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x70e40(%rax)
movq -0x10(%rbp), %rdi
addq $0x70e44, %rdi          # imm = 0x70E44
leaq -0x37c(%rbp), %rsi
movl $0x2c, %edx
callq 0x9610
movq -0x10(%rbp), %rax
movb $0x0, 0x70e70(%rax)
movl $0x0, -0x468(%rbp)
cmpl $0x9b, -0x468(%rbp)
jge 0x663d7
movl $0x0, -0x46c(%rbp)
cmpl $0x17c, -0x46c(%rbp)    # imm = 0x17C
jge 0x662bf
movq -0x10(%rbp), %rax
addq $0x70f70, %rax          # imm = 0x70F70
movslq -0x468(%rbp), %rcx
imulq $0x17c, %rcx, %rcx      # imm = 0x17C
addq %rcx, %rax
movslq -0x46c(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movl -0x46c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x46c(%rbp)
jmp 0x6627c
movl $0x0, -0x46c(%rbp)
cmpl $0x3, -0x46c(%rbp)
jge 0x66367
movq -0x10(%rbp), %rax
addq $0x10, %rax
movslq -0x468(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movslq -0x46c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq -0x40(%rbp), %rcx
movq %rcx, (%rax)
movq -0x38(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
addq $0x7f670, %rax          # imm = 0x7F670
movslq -0x468(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq -0x46c(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq -0x10(%rbp), %rax
addq $0x81860, %rax          # imm = 0x81860
movslq -0x468(%rbp), %rcx
imulq $0x3, %rcx, %rcx
addq %rcx, %rax
movslq -0x46c(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movl -0x46c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x46c(%rbp)
jmp 0x662c9
movq -0x10(%rbp), %rax
movslq -0x468(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, 0x81388(%rax,%rcx,8)
movq -0x10(%rbp), %rax
movslq -0x468(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, 0x80eb0(%rax,%rcx,8)
movq -0x10(%rbp), %rax
movslq -0x468(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, 0x809d0(%rax,%rcx,8)
movq -0x10(%rbp), %rax
movslq -0x468(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, 0x804f8(%rax,%rcx,8)
movl -0x468(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x468(%rbp)
jmp 0x66262
movl $0x0, -0x468(%rbp)
cmpl $0x40, -0x468(%rbp)
jge 0x6640e
movq -0x10(%rbp), %rax
movslq -0x468(%rbp), %rcx
movb $0x0, 0x81a31(%rax,%rcx)
movl -0x468(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x468(%rbp)
jmp 0x663e1
movq -0x10(%rbp), %rdi
addq $0x7f584, %rdi          # imm = 0x7F584
leaq -0x464(%rbp), %rsi
movl $0xe8, %edx
callq 0x9610
movq -0x10(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x80ea8(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x81a78(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x81a74(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x81a8c(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x81a84(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x81a88(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x81a7c(%rax)
movq -0x10(%rbp), %rax
movl $0xffffffff, 0x81a80(%rax) # imm = 0xFFFFFFFF
movl $0x0, -0x468(%rbp)
cmpl $0x1000, -0x468(%rbp)   # imm = 0x1000
jge 0x664d5
movq -0x10(%rbp), %rax
movslq -0x468(%rbp), %rcx
movb $0x0, 0x81a90(%rax,%rcx)
movl -0x468(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x468(%rbp)
jmp 0x664a5
movq -0x10(%rbp), %rax
movb $0x0, 0x82a90(%rax)
movq -0x10(%rbp), %rax
movl $0xffffffff, 0x82b98(%rax) # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rax
movq $0x0, 0x1d28(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x1d38(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x1d80(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x1da8(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x1d88(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x1d90(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x82b90(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x82ba0(%rax)
movl $0x1800, %edi           # imm = 0x1800
callq 0x99e0
movq -0x10(%rbp), %rcx
movq %rax, 0x1d28(%rcx)
cmpq $0x0, %rax
je 0x6660c
movl $0x1800, %edi           # imm = 0x1800
callq 0x99e0
movq -0x10(%rbp), %rcx
movq %rax, 0x1d38(%rcx)
cmpq $0x0, %rax
je 0x6660c
movl $0xae60, %edi           # imm = 0xAE60
callq 0x99e0
movq -0x10(%rbp), %rcx
movq %rax, 0x1d80(%rcx)
cmpq $0x0, %rax
je 0x6660c
movl $0x43d0, %edi           # imm = 0x43D0
callq 0x99e0
movq -0x10(%rbp), %rcx
movq %rax, 0x1da8(%rcx)
cmpq $0x0, %rax
je 0x6660c
movl $0x1008, %edi           # imm = 0x1008
callq 0x99e0
movq -0x10(%rbp), %rcx
movq %rax, 0x1d88(%rcx)
cmpq $0x0, %rax
je 0x6660c
movl $0x1870, %edi           # imm = 0x1870
callq 0x99e0
movq -0x10(%rbp), %rcx
movq %rax, 0x1d90(%rcx)
cmpq $0x0, %rax
jne 0x66621
movq -0x10(%rbp), %rdi
callq 0x66a70
movl $0x0, -0x4(%rbp)
jmp 0x66a5f
movq -0x10(%rbp), %rax
movl $0x0, 0x1d20(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x1d30(%rax)
movq -0x10(%rbp), %rax
movl $0x9b, 0x1d40(%rax)
movq -0x10(%rbp), %rax
movl $0x9b, 0x1d68(%rax)
movq -0x10(%rbp), %rax
movl $0x1b, 0x1d48(%rax)
movq -0x10(%rbp), %rax
movl $0x2e, 0x1d50(%rax)
movl $0x0, -0x468(%rbp)
cmpl $0x40, -0x468(%rbp)
jge 0x666c3
movq -0x10(%rbp), %rax
movq 0x1d28(%rax), %rdi
movslq -0x468(%rbp), %rax
imulq $0x60, %rax, %rax
addq %rax, %rdi
leaq -0xa0(%rbp), %rsi
movl $0x60, %edx
callq 0x9610
movl -0x468(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x468(%rbp)
jmp 0x6667f
movl $0x0, -0x468(%rbp)
cmpl $0x40, -0x468(%rbp)
jge 0x66711
movq -0x10(%rbp), %rax
movq 0x1d38(%rax), %rdi
movslq -0x468(%rbp), %rax
imulq $0x60, %rax, %rax
addq %rax, %rdi
leaq -0xa0(%rbp), %rsi
movl $0x60, %edx
callq 0x9610
movl -0x468(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x468(%rbp)
jmp 0x666cd
movl $0x0, -0x468(%rbp)
cmpl $0x9b, -0x468(%rbp)
jge 0x66765
movq -0x10(%rbp), %rax
movq 0x1d80(%rax), %rdi
movslq -0x468(%rbp), %rax
imulq $0x120, %rax, %rax      # imm = 0x120
addq %rax, %rdi
leaq -0x1c0(%rbp), %rsi
movl $0x120, %edx            # imm = 0x120
callq 0x9610
movl -0x468(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x468(%rbp)
jmp 0x6671b
movl $0x0, -0x468(%rbp)
cmpl $0x9b, -0x468(%rbp)
jge 0x667b6
movq -0x10(%rbp), %rax
movq 0x1da8(%rax), %rdi
movslq -0x468(%rbp), %rax
imulq $0x70, %rax, %rax
addq %rax, %rdi
leaq -0x230(%rbp), %rsi
movl $0x70, %edx
callq 0x9610
movl -0x468(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x468(%rbp)
jmp 0x6676f
movl $0x0, -0x468(%rbp)
cmpl $0x1b, -0x468(%rbp)
jge 0x66807
movq -0x10(%rbp), %rax
movq 0x1d88(%rax), %rdi
movslq -0x468(%rbp), %rax
imulq $0x98, %rax, %rax
addq %rax, %rdi
leaq -0x2c8(%rbp), %rsi
movl $0x98, %edx
callq 0x9610
movl -0x468(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x468(%rbp)
jmp 0x667c0
movl $0x0, -0x468(%rbp)
cmpl $0x2e, -0x468(%rbp)
jge 0x66858
movq -0x10(%rbp), %rax
movq 0x1d90(%rax), %rdi
movslq -0x468(%rbp), %rax
imulq $0x88, %rax, %rax
addq %rax, %rdi
leaq -0x350(%rbp), %rsi
movl $0x88, %edx
callq 0x9610
movl -0x468(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x468(%rbp)
jmp 0x66811
movl $0x0, -0x468(%rbp)
cmpl $0x9b, -0x468(%rbp)
jge 0x6693f
movl $0x0, -0x46c(%rbp)
cmpl $0x3, -0x46c(%rbp)
jge 0x66929
movl -0x468(%rbp), %edi
addl $0x1, %edi
xorl %eax, %eax
movl %eax, %esi
callq 0x8b3b0
movl %eax, -0x470(%rbp)
cmpl $0x0, %eax
jne 0x668a8
jmp 0x66915
cmpl $0x4, -0x470(%rbp)
jne 0x668c8
movslq -0x46c(%rbp), %rax
movsd -0x30(%rbp,%rax,8), %xmm0
movsd %xmm0, -0x480(%rbp)
jmp 0x668e3
movslq -0x46c(%rbp), %rcx
leaq 0x5c6ba(%rip), %rax     # 0xc2f90
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x480(%rbp)
movsd -0x480(%rbp), %xmm0
movq -0x10(%rbp), %rax
addq $0x1d40, %rax           # imm = 0x1D40
addq $0x298, %rax            # imm = 0x298
movslq -0x468(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq -0x46c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x46c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x46c(%rbp)
jmp 0x6687c
jmp 0x6692b
movl -0x468(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x468(%rbp)
jmp 0x66862
movq -0x10(%rbp), %rax
movb $0x0, 0x70c78(%rax)
movq -0x10(%rbp), %rax
movb $0x0, 0x70c38(%rax)
movq -0x10(%rbp), %rax
movb $0x0, 0x70cf8(%rax)
movq -0x10(%rbp), %rax
movb $0x0, 0x70cb8(%rax)
movq -0x10(%rbp), %rax
movb $0x0, 0x70db8(%rax)
movq -0x10(%rbp), %rax
movb $0x0, 0x70d78(%rax)
movq -0x10(%rbp), %rax
movb $0x0, 0x70d38(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x70e00(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x70dfc(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x70df8(%rax)
movl $0x0, -0x468(%rbp)
cmpl $0x3, -0x468(%rbp)
jge 0x66a08
movq -0x10(%rbp), %rax
movslq -0x468(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, 0x70e20(%rax,%rcx,8)
movq -0x10(%rbp), %rax
movslq -0x468(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, 0x70e08(%rax,%rcx,8)
movl -0x468(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x468(%rbp)
jmp 0x669c0
movq -0x10(%rbp), %rax
movq $0x0, 0x70e38(%rax)
movl -0x14(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x82b98(%rax)
movl -0x14(%rbp), %eax
subl $0xc, %eax
jne 0x66a3d
jmp 0x66a2e
movq -0x10(%rbp), %rdi
callq 0x67eb0
movl %eax, -0x474(%rbp)
cmpl $0x0, -0x474(%rbp)
jne 0x66a58
movq -0x10(%rbp), %rdi
callq 0x66a70
movl $0x0, -0x4(%rbp)
jmp 0x66a5f
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x480, %rsp            # imm = 0x480
popq %rbp
retq
nopl (%rax,%rax)