// File: /workspace/github_c_makefile_star2_O1/akumrao[P]videoAnalyzer/x264.c
// Function: main
int main( int argc, char **argv )
{
    x264_t *h;
    x264_param_t param;
    x264_picture_t *pic;

    FILE    *fyuv;
    FILE    *fh26l;
    FILE    *fout = stdout;

    char    *p;

    int     i_frame, i_frame_total;
    int64_t i_start, i_end;
    int64_t i_file;

    int     b_decompress = 0;

#ifdef _MSC_VER
    _setmode(_fileno(stdin), _O_BINARY);    /* thanks to Marcos Morais <morais at dee.ufcg.edu.br> */
    _setmode(_fileno(stdout), _O_BINARY);
#endif

    x264_param_default( &param );
    param.f_fps = 25.0;

    /* Parse command line options */
    opterr = 0; // no error message
    for( ;; )
    {
        int long_options_index;
        static struct option long_options[] =
        {
            { "help",    no_argument,       NULL, 'h' },
            { "bitrate", required_argument, NULL, 'b' },
            { "bframe",  required_argument, NULL, 'B' },
            { "iframe",  required_argument, NULL, 'i' },
            { "idrframe",  required_argument, NULL, 'I' },
            { "nf",      no_argument,       NULL, 'n' },
            { "cabac",   no_argument,       NULL, 'c' },
            { "qp",      required_argument, NULL, 'q' },
            { "ref",     required_argument, NULL, 'r' },
            { "no-asm",  no_argument,       NULL, 'C' },
            { "sar",     required_argument, NULL, 's' },
            { "output",  required_argument, NULL, 'o' },
            {0, 0, 0, 0}
        };

        int c;

        c = getopt_long( argc, argv, "hi:b:r:cxB:m:q:no:s:",
                         long_options, &long_options_index);

        if( c == -1 )
        {
            break;
        }

        switch( c )
        {
            case 0:
                break;
            case 'h':
                help();
                return 0;
            case 'b':
                param.i_bitrate = atol( optarg );
                break;
            case 'B':
                param.i_bframe = atol( optarg );
                break;
            case 'i':
                param.i_iframe = atol( optarg );
                break;
            case 'I':
                param.i_idrframe = atol( optarg );
                break;
            case 'n':
                param.b_deblocking_filter = 0;
                break;
            case 'q':
                param.i_qp_constant = atoi( optarg );
                break;
            case 'r':
                param.i_frame_reference = atoi( optarg );
                break;
            case 'c':
                param.b_cabac = 1;
                break;
            case 'm':
                param.i_me = atoi( optarg );
                break;
            case 'x':
                b_decompress = 1;
                break;
            case 'C':
                param.cpu = 0;
                break;
            case'o':
                if( ( fout = fopen( optarg, "wb" ) ) == NULL )
                {
                    fprintf( stderr, "cannot open output file `%s'\n", optarg );
                    return -1;
                }
                break;
            case 's':
            {
                char *p = strchr( optarg, ':' );
                if( p )
                {
                    param.vui.i_sar_width = atoi( optarg );
                    param.vui.i_sar_height = atoi( p + 1 );
                }
                break;
            }
            default:
                fprintf( stderr, "unknown option (%c)\n", optopt );
                return -1;
        }
    }

    /* Control-C handler */
    signal( SIGINT, SigIntHandler );

    if( b_decompress )
    {
        x264_nal_t nal;
        int i_data;
        int b_eof;

        if( optind > argc - 1 )
        {
            help();
            return -1;
        }

        if( !strcmp( argv[optind], "-" ) )
        {
            fh26l = stdin;
            optind++;
        }
        else if( ( fh26l = fopen( argv[optind++], "rb" ) ) == NULL )
        {
            fprintf( stderr, "could not open h26l file '%s'\n", argv[optind - 1] );
            return -1;
        }

        //param.cpu = 0;
        if( ( h = x264_decoder_open( &param ) ) == NULL )
        {
            fprintf( stderr, "x264_decoder_open failed\n" );
            return -1;
        }

        i_start = x264_mdate();
        b_eof = 0;
        i_frame = 0;
        i_data  = 0;
        nal.p_payload = (uint8_t*)x264_malloc( DATA_MAX );

        while( !i_ctrl_c )
        {
            uint8_t *p, *p_next, *end;
            int i_size;
            /* fill buffer */
            if( i_data < DATA_MAX && !b_eof )
            {
                int i_read = fread( &data[i_data], 1, DATA_MAX - i_data, fh26l );
                if( i_read <= 0 )
                {
                    b_eof = 1;
                }
                else
                {
                    i_data += i_read;
                }
            }

            if( i_data < 3 )
            {
                break;
            }

            end = &data[i_data];

            /* extract one nal */
            p = &data[0];
            while( p < end - 3 )
            {
                if( p[0] == 0x00 && p[1] == 0x00 && p[2] == 0x01 )
                {
                    break;
                }
                p++;
            }

            if( p >= end - 3 )
            {
                fprintf( stderr, "garbage (i_data = %d)\n", i_data );
                i_data = 0;
                continue;
            }

            p_next = p + 3;
            while( p_next < end - 3 )
            {
                if( p_next[0] == 0x00 && p_next[1] == 0x00 && p_next[2] == 0x01 )
                {
                    break;
                }
                p_next++;
            }

            if( p_next == end - 3 && i_data < DATA_MAX )
            {
                p_next = end;
            }

            /* decode this nal */
            i_size = p_next - p - 3;
            if( i_size <= 0 )
            {
                if( b_eof )
                {
                    break;
                }
                fprintf( stderr, "nal too large (FIXME) ?\n" );
                i_data = 0;
                continue;
            }

            x264_nal_decode( &nal, p +3, i_size );

            /* decode the content of the nal */
            x264_decoder_decode( h, &pic, &nal );

            if( pic != NULL )
            {
                int i;

                i_frame++;

                for( i = 0; i < pic->i_plane;i++ )
                {
                    int i_line;
                    int i_div;

                    i_div = i==0 ? 1 : 2;
                    for( i_line = 0; i_line < pic->i_height/i_div; i_line++ )
                    {
                        fwrite( pic->plane[i]+i_line*pic->i_stride[i], 1, pic->i_width/i_div, fout );
                        dumpByte( pic->plane[i]+i_line*pic->i_stride[i], pic->i_width/i_div, 1    );
                        
                    }
                }
            }

            memmove( &data[0], p_next, end - p_next );
            i_data -= p_next - &data[0];
        }

        i_end = x264_mdate();
        free( nal.p_payload );
        fprintf( stderr, "\n" );

        x264_decoder_close( h );

        fclose( fh26l );
        if( fout != stdout )
        {
            fclose( fout );
        }
        if( i_frame > 0 )
        {
            double fps = (double)i_frame * (double)1000000 /
                         (double)( i_end - i_start );
            fprintf( stderr, "decoded %d frames %ffps\n", i_frame, fps );
        }
    }
    else
    {
        if( optind > argc - 2 )
        {
            help();
            return -1;
        }

        /* init params */
        if( !strcmp( argv[optind], "-" ) )
        {
            fyuv = stdin;
            optind++;
        }
        else if( ( fyuv = fopen( argv[optind++], "rb" ) ) == NULL )
        {
            fprintf( stderr, "could not open yuv input file '%s'\n", argv[optind - 1] );
            return -1;
        }

        param.i_width           = strtol( argv[optind++], &p, 0 );
        param.i_height          = strtol( p+1, &p, 0 );

        i_frame_total = 0;
        if( !fseek( fyuv, 0, SEEK_END ) )
        {
            int64_t i_size = ftell( fyuv );
            fseek( fyuv, 0, SEEK_SET );
            i_frame_total = i_size / ( param.i_width * param.i_height * 3 / 2 );
        }

        if( ( h = x264_encoder_open( &param ) ) == NULL )
        {
            fprintf( stderr, "x264_encoder_open failed\n" );
            return -1;
        }

        pic = x264_picture_new( h );

        i_start = x264_mdate();
        for( i_frame = 0, i_file = 0; i_ctrl_c == 0 ; i_frame++ )
        {
            int         i_nal;
            x264_nal_t  *nal;

            int         i;

           /* i420  =   y = w*h
                      u = w*h/4
                      v = w*h/4  
            */
            
            //fillByte(pic->plane[0],  param.i_width , param.i_height);
            ///* read a frame
            if( fread( pic->plane[0], 1, param.i_width * param.i_height, fyuv ) <= 0 ||
                fread( pic->plane[1], 1, param.i_width * param.i_height / 4, fyuv ) <= 0 ||
                fread( pic->plane[2], 1, param.i_width * param.i_height / 4, fyuv ) <= 0 )
            {
                break;
            }
            
           // if(i_frame == 16 ) break; //arvind
            
            if( x264_encoder_encode( h, &nal, &i_nal, pic ) < 0 )
            {
                fprintf( stderr, "x264_encoder_encode failed\n" );
            }

            for( i = 0; i < i_nal; i++ )
            {
                int i_size;
                int i_data;

                i_data = DATA_MAX;
                if( ( i_size = x264_nal_encode( data, &i_data, 1, &nal[i] ) ) > 0 )
                {
                    i_file += fwrite( data, 1, i_size, fout );
                }
                else if( i_size < 0 )
                {
                    fprintf( stderr,
                             "need to increase buffer size (size=%d)\n", -i_size );
                }
            }
        }
        i_end = x264_mdate();
        x264_picture_delete( pic );
        x264_encoder_close( h );
        fprintf( stderr, "\n" );

        fclose( fyuv );
        if( fout != stdout )
        {
            fclose( fout );
        }

        if( i_frame > 0 )
        {
            double fps = (double)i_frame * (double)1000000 /
                         (double)( i_end - i_start );

            fprintf( stderr, "encoded %d frames %ffps %lld kb/s\n", i_frame, fps, i_file * 8 * 25 / i_frame / 1000 );
        }
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rsi, %r13
movl %edi, %r14d
movq 0x2edd8(%rip), %rax     # 0x31fa0
movq (%rax), %rbx
leaq -0xa4(%rbp), %r12
movq %r12, %rdi
callq 0x2460
movl $0x41c80000, 0x14(%r12) # imm = 0x41C80000
movq 0x2edf6(%rip), %rax     # 0x31fe0
movl $0x0, (%rax)
xorl %r12d, %r12d
movl $0x0, -0x38(%rbp)
movl %r14d, %edi
movq %r13, %rsi
leaq 0x1de9a(%rip), %rdx     # 0x210a1
leaq 0x2ef02(%rip), %rcx     # 0x32110
leaq -0xe0(%rbp), %r8
callq 0x21e0
cmpl $0x42, %eax
jle 0x324e
leal -0x62(%rax), %ecx
cmpl $0x16, %ecx
ja 0x327b
leaq 0x1ddd6(%rip), %rdx     # 0x21004
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
movq 0x2ed72(%rip), %rax     # 0x31fb0
movq (%rax), %rdi
callq 0x2120
movl %eax, -0x6c(%rbp)
jmp 0x33b4
cmpl $-0x1, %eax
je 0x32a7
testl %eax, %eax
je 0x33b4
cmpl $0x42, %eax
jne 0x33c2
movq 0x2ed45(%rip), %rax     # 0x31fb0
movq (%rax), %rdi
callq 0x2120
movl %eax, -0x80(%rbp)
jmp 0x33b4
cmpl $0x43, %eax
je 0x33aa
cmpl $0x49, %eax
jne 0x33c2
movq 0x2ed1c(%rip), %rax     # 0x31fb0
movq (%rax), %rdi
callq 0x2120
movl %eax, -0x88(%rbp)
jmp 0x33b4
movl $0x2, %r15d
jmp 0x33b7
xorl %r15d, %r15d
movl $0x1, %r12d
jmp 0x33b7
movl $0x1, -0x78(%rbp)
jmp 0x33b4
movq 0x2ecdd(%rip), %rax     # 0x31fb0
movq (%rax), %rdi
callq 0x21a0
movl %eax, -0x68(%rbp)
jmp 0x33b4
movq 0x2ecc6(%rip), %rax     # 0x31fb0
movq (%rax), %rdi
callq 0x21a0
movl %eax, -0x8c(%rbp)
jmp 0x33b4
movl $0x0, -0x7c(%rbp)
jmp 0x33b4
movq 0x2eca0(%rip), %rax     # 0x31fb0
movq (%rax), %rdi
callq 0x2120
movl %eax, -0x84(%rbp)
jmp 0x33b4
movq %r12, -0x40(%rbp)
movq %r13, -0x48(%rbp)
movq 0x2ec7e(%rip), %rax     # 0x31fb0
movq (%rax), %r12
movq %r12, %rdi
movl $0x3a, %esi
callq 0x2050
xorl %r15d, %r15d
testq %rax, %rax
je 0x336c
movq %rax, %r13
movq %r12, %rdi
callq 0x21a0
movl %eax, -0x94(%rbp)
incq %r13
movq %r13, %rdi
callq 0x21a0
movl %eax, -0x98(%rbp)
movq -0x48(%rbp), %r13
movq -0x40(%rbp), %r12
jmp 0x33b7
movq 0x2ec33(%rip), %rax     # 0x31fb0
movq (%rax), %rdi
leaq 0x1dd2f(%rip), %rsi     # 0x210b6
callq 0x20f0
testq %rax, %rax
je 0x33e4
movq %rax, %rbx
jmp 0x33b4
movq 0x2ec13(%rip), %rax     # 0x31fb0
movq (%rax), %rdi
callq 0x21a0
movl %eax, -0x70(%rbp)
jmp 0x33b4
movl $0x0, -0xa4(%rbp)
xorl %r15d, %r15d
testl %r15d, %r15d
je 0x31fa
jmp 0x33fa
callq 0x225c
movl $0xffffffff, -0x38(%rbp) # imm = 0xFFFFFFFF
jmp 0x33dc
callq 0x2238
movl $0x0, -0x38(%rbp)
movl $0x1, %r15d
jmp 0x33b7
callq 0x2210
movl $0xffffffff, -0x38(%rbp) # imm = 0xFFFFFFFF
movl $0x1, %r15d
xorl %ebx, %ebx
jmp 0x33b7
cmpl $0x2, %r15d
jne 0x3473
leaq 0x723(%rip), %rsi       # 0x3b2a
movl $0x2, %edi
callq 0x2100
movq 0x2ebc0(%rip), %r15     # 0x31fd8
testl %r12d, %r12d
je 0x347b
movslq (%r15), %r12
cmpl %r14d, %r12d
jge 0x3ad8
movq (%r13,%r12,8), %r14
leaq 0x1dcb7(%rip), %rsi     # 0x210ec
movq %r14, %rdi
callq 0x2160
testl %eax, %eax
je 0x34d5
incl %r12d
movl %r12d, (%r15)
leaq 0x1dc9c(%rip), %rsi     # 0x210ee
movq %r14, %rdi
callq 0x20f0
movq %rax, %r12
testq %rax, %rax
jne 0x34e8
movq %r13, %rdi
callq 0x22a7
jmp 0x3ae4
movl -0x38(%rbp), %eax
jmp 0x3ac6
movslq (%r15), %r12
addl $-0x2, %r14d
cmpl %r14d, %r12d
jg 0x3b04
movq (%r13,%r12,8), %r14
leaq 0x1dc55(%rip), %rsi     # 0x210ec
movq %r14, %rdi
callq 0x2160
testl %eax, %eax
je 0x3821
incl %r12d
movl %r12d, (%r15)
leaq 0x1dc3a(%rip), %rsi     # 0x210ee
movq %r14, %rdi
callq 0x20f0
movq %rax, %r14
testq %rax, %rax
jne 0x3831
movq %r13, %rdi
callq 0x2355
jmp 0x3b10
movq 0x2eae4(%rip), %rax     # 0x31fc0
movq (%rax), %rax
incl %r12d
movl %r12d, (%r15)
movq %rax, %r12
leaq -0xa4(%rbp), %rdi
callq 0xb90c
movq %rax, -0x58(%rbp)
testq %rax, %rax
je 0x3adf
callq 0x9ee8
movq %rax, -0xb0(%rbp)
movl $0x2dc6c0, %edi         # imm = 0x2DC6C0
callq 0x4849
leaq -0xe0(%rbp), %rcx
movq %rax, 0x10(%rcx)
leaq 0x2ed97(%rip), %rax     # 0x322c0
negl %eax
movq %rax, -0x60(%rbp)
xorl %r13d, %r13d
xorl %edi, %edi
movl $0x0, -0x4c(%rbp)
movq %r12, -0xc0(%rbp)
cmpb $0x0, 0x30b437(%rip)    # 0x30e980
jne 0x37b7
cmpl $0x2dc6bf, %r13d        # imm = 0x2DC6BF
jg 0x3594
testl %edi, %edi
jne 0x3594
movslq %r13d, %rdi
leaq 0x2ed5a(%rip), %rax     # 0x322c0
addq %rax, %rdi
movl $0x2dc6c0, %edx         # imm = 0x2DC6C0
subl %r13d, %edx
movl $0x1, %esi
movq %r12, %rcx
callq 0x2190
xorl %edi, %edi
testl %eax, %eax
setle %dil
movl $0x0, %ecx
cmovlel %ecx, %eax
addl %r13d, %eax
movl %eax, %r13d
movl %r13d, %r15d
cmpl $0x2, %r13d
jg 0x35a8
movb $0x1, %r14b
movl %r15d, %r13d
jmp 0x3791
leaq 0x2ed11(%rip), %rax     # 0x322c0
leaq (%r15,%rax), %rcx
addq $-0x3, %rcx
cmpq %rax, %rcx
seta %dl
jbe 0x35f8
leaq 0x2ecfa(%rip), %rax     # 0x322c0
leaq (%rax,%r15), %r13
movl $0x3, %eax
leaq 0x2eceb(%rip), %rsi     # 0x322c1
cmpb $0x0, -0x1(%rsi)
jne 0x35e7
cmpb $0x0, (%rsi)
jne 0x35e7
cmpb $0x1, 0x1(%rsi)
je 0x3624
cmpq %rcx, %rsi
setb %dl
incq %rsi
incq %rax
cmpq %rax, %r15
jne 0x35d6
movq 0x2e9d1(%rip), %rax     # 0x31fd0
movl %edi, %r13d
movq (%rax), %rdi
xorl %r14d, %r14d
leaq 0x1db1b(%rip), %rsi     # 0x2112a
movl %r15d, %edx
xorl %eax, %eax
callq 0x2180
movl %r13d, %edi
xorl %r13d, %r13d
jmp 0x3791
testb $0x1, %dl
je 0x35f8
addq $0x2, %rsi
movq %rsi, %rdx
cmpq %rcx, %rsi
jae 0x3654
movq %rsi, %rdx
cmpb $0x0, (%rdx)
jne 0x3649
cmpb $0x0, 0x1(%rdx)
jne 0x3649
cmpb $0x1, 0x2(%rdx)
je 0x3654
incq %rdx
cmpq %rcx, %rdx
jb 0x3638
movq %rcx, %rdx
cmpq %rcx, %rdx
movq %rdx, %r8
cmoveq %r13, %r8
cmpl $0x2dc6c0, %r15d        # imm = 0x2DC6C0
cmovgeq %rdx, %r8
movq -0x60(%rbp), %rcx
movq %r8, -0x48(%rbp)
leaq (%rcx,%r8), %rdx
subq %rax, %rdx
testl %edx, %edx
jle 0x379c
movl %edi, -0x40(%rbp)
leaq -0xe0(%rbp), %r14
movq %r14, %rdi
callq 0xb864
movq -0x58(%rbp), %rdi
leaq -0x30(%rbp), %rsi
movq %r14, %rdx
callq 0xbb24
cmpq $0x0, -0x30(%rbp)
je 0x3761
incl -0x4c(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jle 0x3761
movq %r13, -0xb8(%rbp)
xorl %r13d, %r13d
cmpq $0x1, %r13
movl $0x2, %r14d
sbbl $0x0, %r14d
movq -0x30(%rbp), %rcx
movl 0x4(%rcx), %eax
cltd
idivl %r14d
testl %eax, %eax
jle 0x3746
xorl %r12d, %r12d
movslq 0xc(%rcx,%r13,4), %rdi
movslq %r12d, %r12
imulq %r12, %rdi
addq 0x20(%rcx,%r13,8), %rdi
movl (%rcx), %eax
cltd
idivl %r14d
movslq %eax, %rdx
movl $0x1, %esi
movq %rbx, %rcx
callq 0x21f0
movq -0x30(%rbp), %rax
movslq 0xc(%rax,%r13,4), %rdi
imulq %r12, %rdi
addq 0x20(%rax,%r13,8), %rdi
movl (%rax), %eax
cltd
idivl %r14d
movl %eax, %esi
movl $0x1, %edx
callq 0x4dc1
incl %r12d
movq -0x30(%rbp), %rcx
movl 0x4(%rcx), %eax
cltd
idivl %r14d
cmpl %eax, %r12d
jl 0x36e8
incq %r13
movq -0x30(%rbp), %rax
movslq 0x8(%rax), %rax
cmpq %rax, %r13
jl 0x36c8
movq -0xb8(%rbp), %r13
movq -0x48(%rbp), %r12
subq %r12, %r13
leaq 0x2eb51(%rip), %r14     # 0x322c0
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x21c0
leal (%r14,%r15), %r13d
subl %r12d, %r13d
xorl %r14d, %r14d
movl -0x40(%rbp), %edi
movq -0xc0(%rbp), %r12
testb %r14b, %r14b
je 0x3542
jmp 0x37b7
testl %edi, %edi
jne 0x359d
movl %edi, %r14d
callq 0x22d7
movl %r14d, %edi
xorl %r14d, %r14d
jmp 0x361c
callq 0x9ee8
movq %rax, %r14
movq -0xd0(%rbp), %rdi
callq 0x2110
movq 0x2e7fe(%rip), %rax     # 0x31fd0
movq (%rax), %rsi
movl $0xa, %edi
callq 0x2130
movq -0x58(%rbp), %rdi
callq 0xdbd2
movq %r12, %rdi
callq 0x20b0
movq 0x2e7a9(%rip), %rax     # 0x31fa0
cmpq (%rax), %rbx
je 0x3804
movq %rbx, %rdi
callq 0x20b0
movb $0x1, %bl
movl -0x4c(%rbp), %edi
testl %edi, %edi
jg 0x3af0
movl -0x38(%rbp), %eax
testb %bl, %bl
jne 0x3ac4
jmp 0x3ac6
movq 0x2e798(%rip), %rax     # 0x31fc0
movq (%rax), %r14
incl %r12d
movl %r12d, (%r15)
movslq (%r15), %rax
leal 0x1(%rax), %ecx
movl %ecx, (%r15)
movq (%r13,%rax,8), %rdi
leaq -0xe0(%rbp), %r15
movq %r15, %rsi
xorl %edx, %edx
callq 0x2170
movl %eax, -0xa0(%rbp)
movq (%r15), %rdi
incq %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x2170
movl %eax, -0x9c(%rbp)
movq %r14, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x20c0
testl %eax, %eax
movq %r14, %r15
jne 0x3896
movq %r15, %rdi
callq 0x2030
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x20c0
leaq -0xa4(%rbp), %rdi
callq 0x1480c
testq %rax, %rax
je 0x3b0b
movq %rax, %r13
movq %rax, %rdi
callq 0x46e4
movq %rax, -0x30(%rbp)
callq 0x9ee8
movq %rax, %r14
cmpb $0x0, 0x30b0b7(%rip)    # 0x30e980
movq %r15, -0x40(%rbp)
movq %r13, -0x60(%rbp)
je 0x38de
xorl %r12d, %r12d
xorl %r15d, %r15d
jmp 0x3a74
movq %r14, -0x58(%rbp)
movq $0x0, -0x38(%rbp)
leaq 0x2e9cf(%rip), %r12     # 0x322c0
movq $0x0, -0x48(%rbp)
movq %r12, %r14
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rdi
movslq -0xa0(%rbp), %rax
movslq -0x9c(%rbp), %rdx
imulq %rax, %rdx
movl $0x1, %esi
movq %r15, %rcx
callq 0x2190
testq %rax, %rax
je 0x3a2c
movq -0x30(%rbp), %rax
movq 0x28(%rax), %rdi
movl -0x9c(%rbp), %eax
imull -0xa0(%rbp), %eax
leal 0x3(%rax), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
sarl $0x2, %ecx
movslq %ecx, %rdx
movl $0x1, %esi
movq %r15, %rcx
callq 0x2190
testq %rax, %rax
je 0x3a2c
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rdi
movl -0x9c(%rbp), %eax
imull -0xa0(%rbp), %eax
leal 0x3(%rax), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
sarl $0x2, %ecx
movslq %ecx, %rdx
movl $0x1, %esi
movq %r15, %rcx
callq 0x2190
testq %rax, %rax
je 0x3a2c
movq -0x30(%rbp), %rcx
movq %r13, %rdi
leaq -0xc8(%rbp), %rsi
leaq -0x50(%rbp), %rdx
callq 0x14f2b
testl %eax, %eax
js 0x3a5a
movb $0x1, %al
cmpl $0x0, -0x50(%rbp)
jle 0x3a2e
xorl %r13d, %r13d
xorl %r15d, %r15d
movq %r14, %r12
movl $0x2dc6c0, -0x64(%rbp)  # imm = 0x2DC6C0
movq -0xc8(%rbp), %rcx
addq %r13, %rcx
movq %r12, %rdi
leaq -0x64(%rbp), %rsi
movl $0x1, %edx
callq 0x14b9d
testl %eax, %eax
jle 0x3a0c
movl %eax, %edx
movl $0x1, %esi
movq %r12, %rdi
movq %rbx, %rcx
callq 0x21f0
addq %rax, -0x48(%rbp)
jmp 0x3a0e
js 0x3a23
incq %r15
movslq -0x50(%rbp), %rax
addq $0x18, %r13
cmpq %rax, %r15
movq %r14, %r12
jl 0x39ce
jmp 0x3a4e
movl %eax, %edi
callq 0x23a7
jmp 0x3a0e
xorl %eax, %eax
movq %r14, %r12
testb %al, %al
je 0x3a64
movq -0x38(%rbp), %rax
incl %eax
movq %rax, -0x38(%rbp)
cmpb $0x1, 0x30af3a(%rip)    # 0x30e980
jne 0x38f9
jmp 0x3a64
movq -0x40(%rbp), %r15
movq -0x60(%rbp), %r13
movb $0x1, %al
jmp 0x3a31
callq 0x2385
jmp 0x39bd
imulq $0xc8, -0x48(%rbp), %r15
movq -0x58(%rbp), %r14
movq -0x38(%rbp), %r12
callq 0x9ee8
movq %rax, %r13
movq -0x30(%rbp), %rdi
callq 0x47f4
movq -0x60(%rbp), %rdi
callq 0x2c12
movq 0x2e53b(%rip), %rax     # 0x31fd0
movq (%rax), %rsi
movl $0xa, %edi
callq 0x2130
movq -0x40(%rbp), %rdi
callq 0x20b0
movq 0x2e4ee(%rip), %rax     # 0x31fa0
cmpq (%rax), %rbx
je 0x3abf
movq %rbx, %rdi
callq 0x20b0
testl %r12d, %r12d
jne 0x3b17
xorl %eax, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2283
jmp 0x3ae4
callq 0x2333
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %ebx, %ebx
jmp 0x3814
movq %r14, %rsi
movq -0xb0(%rbp), %rdx
callq 0x22f9
jmp 0x3811
callq 0x243c
jmp 0x3b10
callq 0x241a
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x3ac6
movl %r12d, %edi
movq %r13, %rsi
movq %r14, %rdx
movq %r15, %rcx
callq 0x23c9
jmp 0x3ac4