// File: /workspace/github_c_makefile_star2_O0/akumrao[P]videoAnalyzer/encoder/set.c
// Function: x264_sps_init(x264_sps_t*, int, x264_param_t*)
void x264_sps_init(x264_sps_t *sps, int i_id, x264_param_t *param) {LOG_CALL;
    sps->i_id = i_id;
    sps->i_profile_idc = PROFILE_EXTENTED;
    sps->i_level_idc = 21; /* FIXME ? */
    sps->b_constraint_set0 = 0;
    sps->b_constraint_set1 = 0;
    sps->b_constraint_set2 = 0;

    sps->i_log2_max_frame_num = 8;
    sps->i_poc_type = 0;
    if (sps->i_poc_type == 0)
    {
        sps->i_log2_max_poc_lsb = 8;
    }
    else if (sps->i_poc_type == 1)
    {
        int i;

        /* FIXME */
        sps->b_delta_pic_order_always_zero = 1;
        sps->i_offset_for_non_ref_pic = 0;
        sps->i_offset_for_top_to_bottom_field = 0;
        sps->i_num_ref_frames_in_poc_cycle = 0;

        for (i = 0; i < sps->i_num_ref_frames_in_poc_cycle; i++)
        {
            sps->i_offset_for_ref_frame[i] = 0;
        }
    }

    sps->i_num_ref_frames = param->i_frame_reference + 1; /* +1 for 2 ref in B */
    sps->b_gaps_in_frame_num_value_allowed = 0;
    sps->i_mb_width = (param->i_width + 15) / 16;
    sps->i_mb_height = (param->i_height + 15) / 16;
    sps->b_frame_mbs_only = 1;
    sps->b_mb_adaptive_frame_field = 0;
    sps->b_direct8x8_inference = 0;
    if (sps->b_frame_mbs_only == 0)
    {
        sps->b_direct8x8_inference = 1;
    }

    if (param->i_width % 16 != 0 || param->i_height % 16 != 0)
    {
        sps->b_crop = 1;
        sps->crop.i_left = 0;
        sps->crop.i_right = (16 - param->i_width % 16) / 2;
        sps->crop.i_top = 0;
        sps->crop.i_bottom = (16 - param->i_height % 16) / 2;
    }
    else
    {
        sps->b_crop = 0;
        sps->crop.i_left = 0;
        sps->crop.i_right = 0;
        sps->crop.i_top = 0;
        sps->crop.i_bottom = 0;
    }

    if (param->vui.i_sar_width > 0 && param->vui.i_sar_height > 0)
    {
        int w = param->vui.i_sar_width;
        int h = param->vui.i_sar_height;
        int a = w, b = h;

        while (b != 0)
        {
            int t = a;

            a = b;
            b = t % b;
        }

        w /= a;
        h /= a;
        while (w > 65535 || h > 65535)
        {
            w /= 2;
            h /= 2;
        }

        if (w == 0 || h == 0)
        {
            fprintf(stderr, "x264: cannot create valid sample aspect ratio\n");
            sps->b_vui = 0;
        }
        else if (w == h)
        {
            fprintf(stderr, "x264: no need for a SAR\n");
            sps->b_vui = 0;
        }
        else
        {
            fprintf(stderr, "x264: using SAR=%d/%d\n", w, h);
            sps->b_vui = 1;
            sps->vui.i_sar_width = w;
            sps->vui.i_sar_height = h;
        }
    }
    else
    {
        sps->b_vui = 0;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
leaq 0x5ec6(%rip), %rdi      # 0x28eb0
leaq 0xd687(%rip), %rsi      # 0x30678
leaq 0xd68e(%rip), %rdx      # 0x30686
movb $0x0, %al
callq 0x4d20
movl -0xc(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, (%rax)
movq -0x8(%rbp), %rax
movl $0x58, 0x4(%rax)
movq -0x8(%rbp), %rax
movl $0x15, 0x8(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0xc(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x10(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x14(%rax)
movq -0x8(%rbp), %rax
movl $0x8, 0x18(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x1c(%rax)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x1c(%rax)
jne 0x2306c
movq -0x8(%rbp), %rax
movl $0x8, 0x20(%rax)
jmp 0x230d4
movq -0x8(%rbp), %rax
cmpl $0x1, 0x1c(%rax)
jne 0x230d2
movq -0x8(%rbp), %rax
movl $0x1, 0x24(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x28(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x2c(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x30(%rax)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x30(%rcx), %eax
jge 0x230d0
movq -0x8(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movl $0x0, 0x34(%rax,%rcx,4)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x230a9
jmp 0x230d2
jmp 0x230d4
movq -0x18(%rbp), %rax
movl 0x18(%rax), %ecx
addl $0x1, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x434(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x438(%rax)
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
addl $0xf, %eax
movl $0x10, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x43c(%rax)
movq -0x18(%rbp), %rax
movl 0x8(%rax), %eax
addl $0xf, %eax
movl $0x10, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x440(%rax)
movq -0x8(%rbp), %rax
movl $0x1, 0x444(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x448(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x44c(%rax)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x444(%rax)
jne 0x23177
movq -0x8(%rbp), %rax
movl $0x1, 0x44c(%rax)
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
movl $0x10, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x231a3
movq -0x18(%rbp), %rax
movl 0x8(%rax), %eax
movl $0x10, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
je 0x23223
movq -0x8(%rbp), %rax
movl $0x1, 0x450(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x454(%rax)
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
movl $0x10, %ecx
cltd
idivl %ecx
movl $0x10, %eax
subl %edx, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x458(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x45c(%rax)
movq -0x18(%rbp), %rax
movl 0x8(%rax), %eax
movl $0x10, %ecx
cltd
idivl %ecx
movl $0x10, %eax
subl %edx, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x460(%rax)
jmp 0x23269
movq -0x8(%rbp), %rax
movl $0x0, 0x450(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x454(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x458(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x45c(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x460(%rax)
movq -0x18(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jle 0x233cb
movq -0x18(%rbp), %rax
cmpl $0x0, 0xc(%rax)
jle 0x233cb
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x24(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x232c3
movl -0x28(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x30(%rbp), %eax
cltd
idivl -0x2c(%rbp)
movl %edx, -0x2c(%rbp)
jmp 0x232a5
movl -0x28(%rbp), %ecx
movl -0x20(%rbp), %eax
cltd
idivl %ecx
movl %eax, -0x20(%rbp)
movl -0x28(%rbp), %ecx
movl -0x24(%rbp), %eax
cltd
idivl %ecx
movl %eax, -0x24(%rbp)
movb $0x1, %al
cmpl $0xffff, -0x20(%rbp)    # imm = 0xFFFF
movb %al, -0x31(%rbp)
jg 0x232f6
cmpl $0xffff, -0x24(%rbp)    # imm = 0xFFFF
setg %al
movb %al, -0x31(%rbp)
movb -0x31(%rbp), %al
testb $0x1, %al
jne 0x232ff
jmp 0x2331d
movl -0x20(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x20(%rbp)
movl -0x24(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x24(%rbp)
jmp 0x232db
cmpl $0x0, -0x20(%rbp)
je 0x23329
cmpl $0x0, -0x24(%rbp)
jne 0x23351
movq 0x12ca0(%rip), %rax     # 0x35fd0
movq (%rax), %rdi
leaq 0xd35a(%rip), %rsi      # 0x30694
movb $0x0, %al
callq 0x2160
movq -0x8(%rbp), %rax
movl $0x0, 0x464(%rax)
jmp 0x233c9
movl -0x20(%rbp), %eax
cmpl -0x24(%rbp), %eax
jne 0x23381
movq 0x12c70(%rip), %rax     # 0x35fd0
movq (%rax), %rdi
leaq 0xd359(%rip), %rsi      # 0x306c3
movb $0x0, %al
callq 0x2160
movq -0x8(%rbp), %rax
movl $0x0, 0x464(%rax)
jmp 0x233c7
movq 0x12c48(%rip), %rax     # 0x35fd0
movq (%rax), %rdi
movl -0x20(%rbp), %edx
movl -0x24(%rbp), %ecx
leaq 0xd344(%rip), %rsi      # 0x306dc
movb $0x0, %al
callq 0x2160
movq -0x8(%rbp), %rax
movl $0x1, 0x464(%rax)
movl -0x20(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x468(%rax)
movl -0x24(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x46c(%rax)
jmp 0x233c9
jmp 0x233d9
movq -0x8(%rbp), %rax
movl $0x0, 0x464(%rax)
addq $0x40, %rsp
popq %rbp
retq
nop