// File: joncampbell123[P]floppytools/kryoflux1.cpp
// Function: main
int main(int argc,char **argv) {
    if (argc < 2) {
        fprintf(stderr,"%s <raw>\n",argv[0]);
        return 1;
    }

    FILE *fp = fopen(argv[1],"rb");
    if (fp == NULL) return 1;

    struct kryoflux_event ev;
    struct kryoflux_stream_info si;

    while (kryoflux_read(ev,fp)) {
        fprintf(stderr,"flux=%lu(0x%lx) oob=%u ooblen=%zu offset=%lu\n",
                ev.flux_interval,ev.flux_interval,ev.oob_code,ev.msg.size(),ev.offset);

        if (ev.msg.size() != 0 && ev.oob_code == 4) {
            fprintf(stderr,"  oobmsg='");
            fwrite(&ev.msg[0],ev.msg.size(),1,stderr);
            fprintf(stderr,"'\n");

            kryoflux_update_stream_info(si,ev.msg);
            fprintf(stderr,"Updated stream info: name='%s' sck=%.19f ick=%.19f\n",
                si.name.c_str(),si.sck,si.ick);
        }
    }

    fclose(fp);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x2, -0x8(%rbp)
jge 0x237a
movq 0x5c8a(%rip), %rax      # 0x7fe0
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rdx
leaq 0x2c9d(%rip), %rsi      # 0x5004
movb $0x0, %al
callq 0x21b0
movl $0x1, -0x4(%rbp)
jmp 0x259a
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x2c85(%rip), %rsi      # 0x500e
callq 0x2160
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x23a5
movl $0x1, -0x4(%rbp)
jmp 0x259a
leaq -0x40(%rbp), %rdi
callq 0x25b0
leaq -0x70(%rbp), %rdi
callq 0x3530
jmp 0x23b9
jmp 0x23bb
movq -0x18(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0x2940
movb %al, -0x7d(%rbp)
jmp 0x23cd
movb -0x7d(%rbp), %al
testb $0x1, %al
jne 0x23d9
jmp 0x2569
movq 0x5c00(%rip), %rax      # 0x7fe0
movq (%rax), %rax
movq %rax, -0x98(%rbp)
movl -0x40(%rbp), %eax
movl %eax, -0x8c(%rbp)
movl -0x40(%rbp), %eax
movl %eax, -0x88(%rbp)
movzbl -0x3b(%rbp), %eax
movl %eax, -0x84(%rbp)
leaq -0x40(%rbp), %rdi
addq $0x10, %rdi
callq 0x25d0
movq -0x98(%rbp), %rdi
movl -0x8c(%rbp), %edx
movl -0x88(%rbp), %ecx
movl -0x84(%rbp), %r8d
movq %rax, %r9
movq -0x38(%rbp), %rax
leaq 0x2bd6(%rip), %rsi      # 0x5011
movq %rax, (%rsp)
movb $0x0, %al
callq 0x21b0
leaq -0x40(%rbp), %rdi
addq $0x10, %rdi
callq 0x25d0
cmpq $0x0, %rax
je 0x2564
movzbl -0x3b(%rbp), %eax
cmpl $0x4, %eax
jne 0x2564
movq 0x5b6f(%rip), %rax      # 0x7fe0
movq %rax, -0xa0(%rbp)
movq (%rax), %rdi
leaq 0x2bbd(%rip), %rsi      # 0x503f
xorl %eax, %eax
movl %eax, -0xb4(%rbp)
callq 0x21b0
movl -0xb4(%rbp), %eax
leaq -0x30(%rbp), %rdi
movq %rdi, -0xb0(%rbp)
movl %eax, %esi
callq 0x25f0
movq -0xb0(%rbp), %rdi
movq %rax, -0xa8(%rbp)
callq 0x25d0
movq -0xa8(%rbp), %rdi
movq %rax, %rsi
movq -0xa0(%rbp), %rax
movq (%rax), %rcx
movl $0x1, %edx
callq 0x2220
jmp 0x24da
movq 0x5aff(%rip), %rax      # 0x7fe0
movq (%rax), %rdi
leaq 0x2b5f(%rip), %rsi      # 0x504a
xorl %eax, %eax
callq 0x21b0
leaq -0x30(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x3750
jmp 0x2501
movq 0x5ad8(%rip), %rax      # 0x7fe0
movq (%rax), %rax
movq %rax, -0xc0(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x20a0
movq -0xc0(%rbp), %rdi
movq %rax, %rdx
movsd -0x50(%rbp), %xmm0
movsd -0x48(%rbp), %xmm1
leaq 0x2b17(%rip), %rsi      # 0x504d
movb $0x2, %al
callq 0x21b0
jmp 0x2564
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x258f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x2610
jmp 0x258f
jmp 0x23bb
movq -0x18(%rbp), %rdi
callq 0x2130
jmp 0x2574
movl $0x0, -0x4(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x2610
leaq -0x40(%rbp), %rdi
callq 0x2630
jmp 0x259a
leaq -0x40(%rbp), %rdi
callq 0x2630
jmp 0x25a6
movl -0x4(%rbp), %eax
addq $0xd0, %rsp
popq %rbp
retq
movq -0x78(%rbp), %rdi
callq 0x2200
nop