// File: /workspace/github_c_makefile_star2_O0/akumrao[P]videoAnalyzer/decoder/set.c
// Function: x264_pps_read(bs_s*, x264_pps_t*)
int x264_pps_read(bs_t *s, x264_pps_t pps_array[256]) {LOG_CALL;
    x264_pps_t *pps;
    int id;
    int i;

    id = bs_read_ue(s,"id");
    if (bs_eof(s) || id >= 256)
    {
        fprintf(stderr, "id invalid\n");
        return -1;
    }
    pps = &pps_array[id];
    pps->i_id = id;
    pps->i_sps_id = bs_read_ue(s,"i_sps_id");
    if (pps->i_sps_id >= 32)
    {
        goto error;
    }
    pps->b_cabac = bs_read1(s, "b_cabac");
    pps->b_pic_order = bs_read1(s, "b_pic_order");
    pps->i_num_slice_groups = bs_read_ue(s,"i_num_slice_groups") + 1;
    if (pps->i_num_slice_groups > 1)
    {
        fprintf(stderr, "FMO unsupported\n ");

        pps->i_slice_group_map_type = bs_read_ue(s,"i_slice_group_map_type");
        if (pps->i_slice_group_map_type == 0)
        {
            for (i = 0; i < pps->i_num_slice_groups; i++)
            {
                pps->i_run_length[i] = bs_read_ue(s,"i_run_length");
            }
        } else if (pps->i_slice_group_map_type == 2)
        {
            for (i = 0; i < pps->i_num_slice_groups; i++)
            {
                pps->i_top_left[i] = bs_read_ue(s,"i_top_left");
                pps->i_bottom_right[i] = bs_read_ue(s,"i_bottom_right");
            }
        } else if (pps->i_slice_group_map_type == 3 ||
                pps->i_slice_group_map_type == 4 ||
                pps->i_slice_group_map_type == 5)
        {
            pps->b_slice_group_change_direction = bs_read1(s, "b_slice_group_change_direction");
            pps->i_slice_group_change_rate = bs_read_ue(s,"i_slice_group_change_rate") + 1;
        } else if (pps->i_slice_group_map_type == 6)
        {
            pps->i_pic_size_in_map_units = bs_read_ue(s,"i_pic_size_in_map_units") + 1;
            for (i = 0; i < pps->i_pic_size_in_map_units; i++)
            {
                /*  FIXME */
                /* pps->i_slice_group_id = bs_read( s, ceil( log2( pps->i_pic_size_in_map_units +1 ) ) ); */
            }
        }
    }
    pps->i_num_ref_idx_l0_active = bs_read_ue(s,"i_num_ref_idx_l0_active") + 1;
    pps->i_num_ref_idx_l1_active = bs_read_ue(s,"i_num_ref_idx_l1_active") + 1;
    pps->b_weighted_pred = bs_read1(s, "b_weighted_pred");
    pps->b_weighted_bipred = bs_read(s, 2,"b_weighted_bipred");

    pps->i_pic_init_qp = bs_read_se(s,"i_pic_init_qp") + 26;
    pps->i_pic_init_qs = bs_read_se(s,"i_pic_init_qs") + 26;

    pps->i_chroma_qp_index_offset = bs_read_se(s,"i_chroma_qp_index_offset");

    pps->b_deblocking_filter_control = bs_read1(s, "b_deblocking_filter_control");
    pps->b_constrained_intra_pred = bs_read1(s, "b_constrained_intra_pred");
    pps->b_redundant_pic_cnt = bs_read1(s, "b_redundant_pic_cnt");

    if (bs_eof(s))
    {
        /* no rbsp trailing */
        fprintf(stderr, "incomplete PPS\n");
        goto error;
    }
    fprintf(stderr, "x264_sps_read: pps:0x%x sps:0x%x %s slice_groups=%d ref0:%d ref1:%d QP:%d QS:%d QC=%d DFC:%d CIP:%d RPC:%d\n",
            pps->i_id, pps->i_sps_id,
            pps->b_cabac ? "CABAC" : "CAVLC",
            pps->i_num_slice_groups,
            pps->i_num_ref_idx_l0_active,
            pps->i_num_ref_idx_l1_active,
            pps->i_pic_init_qp, pps->i_pic_init_qs, pps->i_chroma_qp_index_offset,
            pps->b_deblocking_filter_control,
            pps->b_constrained_intra_pred,
            pps->b_redundant_pic_cnt);

    return id;
error:
    pps->i_id = -1;
    return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdi, -0x38(%rbp)
movq %rsi, -0x40(%rbp)
leaq 0x1454d(%rip), %rdi     # 0x28eb0
leaq 0x17597(%rip), %rsi     # 0x2bf01
leaq 0x177b6(%rip), %rdx     # 0x2c127
movb $0x0, %al
callq 0x4d20
movq -0x38(%rbp), %rdi
leaq 0x16b8b(%rip), %rsi     # 0x2b50e
callq 0x147c0
movl %eax, -0x4c(%rbp)
movq -0x38(%rbp), %rdi
callq 0x14870
cmpl $0x0, %eax
jne 0x149a2
cmpl $0x100, -0x4c(%rbp)     # imm = 0x100
jl 0x149c6
movq 0x21627(%rip), %rax     # 0x35fd0
movq (%rax), %rdi
leaq 0x17782(%rip), %rsi     # 0x2c135
movb $0x0, %al
callq 0x2160
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
jmp 0x14e56
movq -0x40(%rbp), %rax
movslq -0x4c(%rbp), %rcx
imulq $0x104c, %rcx, %rcx     # imm = 0x104C
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movl -0x4c(%rbp), %ecx
movq -0x48(%rbp), %rax
movl %ecx, (%rax)
movq -0x38(%rbp), %rdi
leaq 0x17751(%rip), %rsi     # 0x2c141
callq 0x147c0
movl %eax, %ecx
movq -0x48(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x48(%rbp), %rax
cmpl $0x20, 0x4(%rax)
jl 0x14a0d
jmp 0x14e45
movq -0x38(%rbp), %rdi
leaq 0x17732(%rip), %rsi     # 0x2c14a
callq 0x146b0
movl %eax, %ecx
movq -0x48(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x38(%rbp), %rdi
leaq 0x17721(%rip), %rsi     # 0x2c152
callq 0x146b0
movl %eax, %ecx
movq -0x48(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x38(%rbp), %rdi
leaq 0x17714(%rip), %rsi     # 0x2c15e
callq 0x147c0
movl %eax, %ecx
addl $0x1, %ecx
movq -0x48(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x48(%rbp), %rax
cmpl $0x1, 0x10(%rax)
jle 0x14c05
movq 0x21560(%rip), %rax     # 0x35fd0
movq (%rax), %rdi
leaq 0x176f7(%rip), %rsi     # 0x2c171
movb $0x0, %al
callq 0x2160
movq -0x38(%rbp), %rdi
leaq 0x176f7(%rip), %rsi     # 0x2c183
callq 0x147c0
movl %eax, %ecx
movq -0x48(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x48(%rbp), %rax
cmpl $0x0, 0x14(%rax)
jne 0x14ae5
movl $0x0, -0x50(%rbp)
movl -0x50(%rbp), %eax
movq -0x48(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jge 0x14ae0
movq -0x38(%rbp), %rdi
leaq 0x176d8(%rip), %rsi     # 0x2c19a
callq 0x147c0
movl %eax, %edx
movq -0x48(%rbp), %rax
movslq -0x50(%rbp), %rcx
movl %edx, 0x18(%rax,%rcx,4)
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x14aab
jmp 0x14c03
movq -0x48(%rbp), %rax
cmpl $0x2, 0x14(%rax)
jne 0x14b54
movl $0x0, -0x50(%rbp)
movl -0x50(%rbp), %eax
movq -0x48(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jge 0x14b4f
movq -0x38(%rbp), %rdi
leaq 0x1769a(%rip), %rsi     # 0x2c1a7
callq 0x147c0
movl %eax, %edx
movq -0x48(%rbp), %rax
movslq -0x50(%rbp), %rcx
movl %edx, 0x418(%rax,%rcx,4)
movq -0x38(%rbp), %rdi
leaq 0x17684(%rip), %rsi     # 0x2c1b2
callq 0x147c0
movl %eax, %edx
movq -0x48(%rbp), %rax
movslq -0x50(%rbp), %rcx
movl %edx, 0x818(%rax,%rcx,4)
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x14af6
jmp 0x14c01
movq -0x48(%rbp), %rax
cmpl $0x3, 0x14(%rax)
je 0x14b72
movq -0x48(%rbp), %rax
cmpl $0x4, 0x14(%rax)
je 0x14b72
movq -0x48(%rbp), %rax
cmpl $0x5, 0x14(%rax)
jne 0x14baf
movq -0x38(%rbp), %rdi
leaq 0x17644(%rip), %rsi     # 0x2c1c1
callq 0x146b0
movl %eax, %ecx
movq -0x48(%rbp), %rax
movl %ecx, 0xc18(%rax)
movq -0x38(%rbp), %rdi
leaq 0x17647(%rip), %rsi     # 0x2c1e0
callq 0x147c0
movl %eax, %ecx
addl $0x1, %ecx
movq -0x48(%rbp), %rax
movl %ecx, 0xc1c(%rax)
jmp 0x14bff
movq -0x48(%rbp), %rax
cmpl $0x6, 0x14(%rax)
jne 0x14bfd
movq -0x38(%rbp), %rdi
leaq 0x17636(%rip), %rsi     # 0x2c1fa
callq 0x147c0
movl %eax, %ecx
addl $0x1, %ecx
movq -0x48(%rbp), %rax
movl %ecx, 0xc20(%rax)
movl $0x0, -0x50(%rbp)
movl -0x50(%rbp), %eax
movq -0x48(%rbp), %rcx
cmpl 0xc20(%rcx), %eax
jge 0x14bfb
jmp 0x14bf0
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x14bdf
jmp 0x14bfd
jmp 0x14bff
jmp 0x14c01
jmp 0x14c03
jmp 0x14c05
movq -0x38(%rbp), %rdi
leaq 0x1697a(%rip), %rsi     # 0x2b58a
callq 0x147c0
movl %eax, %ecx
addl $0x1, %ecx
movq -0x48(%rbp), %rax
movl %ecx, 0x1024(%rax)
movq -0x38(%rbp), %rdi
leaq 0x16973(%rip), %rsi     # 0x2b5a2
callq 0x147c0
movl %eax, %ecx
addl $0x1, %ecx
movq -0x48(%rbp), %rax
movl %ecx, 0x1028(%rax)
movq -0x38(%rbp), %rdi
leaq 0x175c4(%rip), %rsi     # 0x2c212
callq 0x146b0
movl %eax, %ecx
movq -0x48(%rbp), %rax
movl %ecx, 0x102c(%rax)
movq -0x38(%rbp), %rdi
movl $0x2, %esi
leaq 0x175b3(%rip), %rdx     # 0x2c222
callq 0x14560
movl %eax, %ecx
movq -0x48(%rbp), %rax
movl %ecx, 0x1030(%rax)
movq -0x38(%rbp), %rdi
leaq 0x175a9(%rip), %rsi     # 0x2c234
callq 0x148c0
movl %eax, %ecx
addl $0x1a, %ecx
movq -0x48(%rbp), %rax
movl %ecx, 0x1034(%rax)
movq -0x38(%rbp), %rdi
leaq 0x17598(%rip), %rsi     # 0x2c242
callq 0x148c0
movl %eax, %ecx
addl $0x1a, %ecx
movq -0x48(%rbp), %rax
movl %ecx, 0x1038(%rax)
movq -0x38(%rbp), %rdi
leaq 0x17587(%rip), %rsi     # 0x2c250
callq 0x148c0
movl %eax, %ecx
movq -0x48(%rbp), %rax
movl %ecx, 0x103c(%rax)
movq -0x38(%rbp), %rdi
leaq 0x17584(%rip), %rsi     # 0x2c269
callq 0x146b0
movl %eax, %ecx
movq -0x48(%rbp), %rax
movl %ecx, 0x1040(%rax)
movq -0x38(%rbp), %rdi
leaq 0x17584(%rip), %rsi     # 0x2c285
callq 0x146b0
movl %eax, %ecx
movq -0x48(%rbp), %rax
movl %ecx, 0x1044(%rax)
movq -0x38(%rbp), %rdi
leaq 0x17581(%rip), %rsi     # 0x2c29e
callq 0x146b0
movl %eax, %ecx
movq -0x48(%rbp), %rax
movl %ecx, 0x1048(%rax)
movq -0x38(%rbp), %rdi
callq 0x14870
cmpl $0x0, %eax
je 0x14d59
movq 0x2128d(%rip), %rax     # 0x35fd0
movq (%rax), %rdi
leaq 0x17565(%rip), %rsi     # 0x2c2b2
movb $0x0, %al
callq 0x2160
jmp 0x14e45
movq 0x21270(%rip), %rax     # 0x35fd0
movq (%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x48(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x58(%rbp)
movq -0x48(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x54(%rbp)
movq -0x48(%rbp), %rax
cmpl $0x0, 0x8(%rax)
je 0x14d91
leaq 0x175a3(%rip), %rax     # 0x2c32e
movq %rax, -0x68(%rbp)
jmp 0x14d9e
leaq 0x1759c(%rip), %rax     # 0x2c334
movq %rax, -0x68(%rbp)
jmp 0x14d9e
movl -0x54(%rbp), %ecx
movl -0x58(%rbp), %edx
movq -0x60(%rbp), %rdi
movq -0x68(%rbp), %r8
movq -0x48(%rbp), %rax
movl 0x10(%rax), %r9d
movq -0x48(%rbp), %rax
movl 0x1024(%rax), %r13d
movq -0x48(%rbp), %rax
movl 0x1028(%rax), %r12d
movq -0x48(%rbp), %rax
movl 0x1034(%rax), %r15d
movq -0x48(%rbp), %rax
movl 0x1038(%rax), %r14d
movq -0x48(%rbp), %rax
movl 0x103c(%rax), %ebx
movq -0x48(%rbp), %rax
movl 0x1040(%rax), %r11d
movq -0x48(%rbp), %rax
movl 0x1044(%rax), %r10d
movq -0x48(%rbp), %rax
movl 0x1048(%rax), %eax
leaq 0x174b1(%rip), %rsi     # 0x2c2c2
movl %r13d, (%rsp)
movl %r12d, 0x8(%rsp)
movl %r15d, 0x10(%rsp)
movl %r14d, 0x18(%rsp)
movl %ebx, 0x20(%rsp)
movl %r11d, 0x28(%rsp)
movl %r10d, 0x30(%rsp)
movl %eax, 0x38(%rsp)
movb $0x0, %al
callq 0x2160
movl -0x4c(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x14e56
movq -0x48(%rbp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
movl -0x2c(%rbp), %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax,%rax)