// File: /workspace/github_c_makefile_star2_O0/videolan[P]bitstream/examples/rtp_check_seqnum.c
// Function: main
int main(int i_argc, char **ppsz_argv)
{
    int i_packet_size = DEFAULT_PACKET_SIZE;

    if (ppsz_argv[1] != NULL &&
        (!strcmp(ppsz_argv[1], "-h") || !strcmp(ppsz_argv[1], "--help")))
        usage(ppsz_argv[0]);

    if (ppsz_argv[1] != NULL)
        i_packet_size = atoi(ppsz_argv[1]);
    if (i_packet_size > 65535 || i_packet_size < RTP_HEADER_SIZE)
        usage(ppsz_argv[0]);

    uint8_t p_buffer[i_packet_size];
    uint16_t i_seqnum = 0;

    for ( ; ; ) {
        ssize_t toto;
        if ((toto=read(STDIN_FILENO, p_buffer, i_packet_size)) != i_packet_size) {
            fprintf(stderr, "couldn't read %zd\n", toto);
            exit(EXIT_FAILURE);
        }

        if (!rtp_check_hdr(p_buffer)) {
            fprintf(stderr, "invalid RTP header\n");
            continue;
        }

        uint16_t i_new_seqnum = rtp_get_seqnum(p_buffer);
        if (i_new_seqnum != i_seqnum)
            fprintf(stderr, "received packet %hu while expecting %hu\n",
                    i_new_seqnum, i_seqnum);
        i_seqnum = (i_new_seqnum + 1) % 65536;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x530, -0x14(%rbp)     # imm = 0x530
movq -0x10(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x11e6
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0xe4d(%rip), %rsi       # 0x2004
callq 0x1040
cmpl $0x0, %eax
je 0x11da
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0xe37(%rip), %rsi       # 0x2007
callq 0x1040
cmpl $0x0, %eax
jne 0x11e6
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x1310
movq -0x10(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x1201
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x1060
movl %eax, -0x14(%rbp)
cmpl $0xffff, -0x14(%rbp)    # imm = 0xFFFF
jg 0x1210
cmpl $0xc, -0x14(%rbp)
jge 0x121c
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x1310
movl -0x14(%rbp), %eax
movq %rsp, %rcx
movq %rcx, -0x20(%rbp)
movq %rax, %rdx
addq $0xf, %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x48(%rbp)
movq %rcx, %rsp
movq %rax, -0x28(%rbp)
movw $0x0, -0x2a(%rbp)
movq -0x48(%rbp), %rsi
movslq -0x14(%rbp), %rdx
xorl %edi, %edi
callq 0x1030
movq %rax, -0x38(%rbp)
movslq -0x14(%rbp), %rcx
cmpq %rcx, %rax
je 0x128a
movq 0x2d8d(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
movq -0x38(%rbp), %rdx
leaq 0xd95(%rip), %rsi       # 0x200e
movb $0x0, %al
callq 0x1050
movl $0x1, %edi
callq 0x1070
movq -0x48(%rbp), %rdi
callq 0x1350
testb $0x1, %al
jne 0x12b1
movq 0x2d5a(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0xd79(%rip), %rsi       # 0x2021
movb $0x0, %al
callq 0x1050
jmp 0x1248
movq -0x48(%rbp), %rdi
callq 0x1370
movw %ax, -0x3a(%rbp)
movzwl -0x3a(%rbp), %eax
movzwl -0x2a(%rbp), %ecx
cmpl %ecx, %eax
je 0x12ea
movq 0x2d27(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
movzwl -0x3a(%rbp), %edx
movzwl -0x2a(%rbp), %ecx
leaq 0xd52(%rip), %rsi       # 0x2035
movb $0x0, %al
callq 0x1050
movzwl -0x3a(%rbp), %eax
addl $0x1, %eax
movl $0x10000, %ecx          # imm = 0x10000
cltd
idivl %ecx
movw %dx, %ax
movw %ax, -0x2a(%rbp)
jmp 0x1248
nopw %cs:(%rax,%rax)