// File: /workspace/github_c_makefile_star2_O0/tvlabs[P]edge264/./edge264_bitstream.c
// Function: get_ae
static noinline int get_ae(Edge264Context *ctx, int ctxIdx)
{
	static const uint8_t rangeTabLPS[64 * 4] = {
		128, 176, 208, 240, 128, 167, 197, 227, 128, 158, 187, 216, 123, 150, 178, 205,
		116, 142, 169, 195, 111, 135, 160, 185, 105, 128, 152, 175, 100, 122, 144, 166,
		 95, 116, 137, 158,  90, 110, 130, 150,  85, 104, 123, 142,  81,  99, 117, 135,
		 77,  94, 111, 128,  73,  89, 105, 122,  69,  85, 100, 116,  66,  80,  95, 110,
		 62,  76,  90, 104,  59,  72,  86,  99,  56,  69,  81,  94,  53,  65,  77,  89,
		 51,  62,  73,  85,  48,  59,  69,  80,  46,  56,  66,  76,  43,  53,  63,  72,
		 41,  50,  59,  69,  39,  48,  56,  65,  37,  45,  54,  62,  35,  43,  51,  59,
		 33,  41,  48,  56,  32,  39,  46,  53,  30,  37,  43,  50,  29,  35,  41,  48,
		 27,  33,  39,  45,  26,  31,  37,  43,  24,  30,  35,  41,  23,  28,  33,  39,
		 22,  27,  32,  37,  21,  26,  30,  35,  20,  24,  29,  33,  19,  23,  27,  31,
		 18,  22,  26,  30,  17,  21,  25,  28,  16,  20,  23,  27,  15,  19,  22,  25,
		 14,  18,  21,  24,  14,  17,  20,  23,  13,  16,  19,  22,  12,  15,  18,  21,
		 12,  14,  17,  20,  11,  14,  16,  19,  11,  13,  15,  18,  10,  12,  15,  17,
		 10,  12,  14,  16,   9,  11,  13,  15,   9,  11,  12,  14,   8,  10,  12,  14,
		  8,   9,  11,  13,   7,   9,  11,  12,   7,   9,  10,  12,   7,   8,  10,  11,
		  6,   8,   9,  11,   6,   7,   9,  10,   6,   7,   8,   9,   2,   2,   2,   2,
	};
	static const uint8_t transIdx[256] = {
		  4,   5, 253, 252,   8,   9, 153, 152,  12,  13, 153, 152,  16,  17, 149, 148,
		 20,  21, 149, 148,  24,  25, 149, 148,  28,  29, 145, 144,  32,  33, 145, 144,
		 36,  37, 145, 144,  40,  41, 141, 140,  44,  45, 141, 140,  48,  49, 141, 140,
		 52,  53, 137, 136,  56,  57, 137, 136,  60,  61, 133, 132,  64,  65, 133, 132,
		 68,  69, 133, 132,  72,  73, 129, 128,  76,  77, 129, 128,  80,  81, 125, 124,
		 84,  85, 121, 120,  88,  89, 121, 120,  92,  93, 121, 120,  96,  97, 117, 116,
		100, 101, 117, 116, 104, 105, 113, 112, 108, 109, 109, 108, 112, 113, 109, 108,
		116, 117, 105, 104, 120, 121, 105, 104, 124, 125, 101, 100, 128, 129,  97,  96,
		132, 133,  97,  96, 136, 137,  93,  92, 140, 141,  89,  88, 144, 145,  89,  88,
		148, 149,  85,  84, 152, 153,  85,  84, 156, 157,  77,  76, 160, 161,  77,  76,
		164, 165,  73,  72, 168, 169,  73,  72, 172, 173,  65,  64, 176, 177,  65,  64,
		180, 181,  61,  60, 184, 185,  61,  60, 188, 189,  53,  52, 192, 193,  53,  52,
		196, 197,  49,  48, 200, 201,  45,  44, 204, 205,  45,  44, 208, 209,  37,  36,
		212, 213,  37,  36, 216, 217,  33,  32, 220, 221,  29,  28, 224, 225,  25,  24,
		228, 229,  21,  20, 232, 233,  17,  16, 236, 237,  17,  16, 240, 241,   9,   8,
		244, 245,   9,   8, 248, 249,   5,   4, 248, 249,   1,   0, 252, 253,   0,   1,
	};
	size_t state = ctx->cabac[ctxIdx];
	size_t shift = SIZE_BIT - 3 - clz(ctx->t._gb.codIRange); // [6..SIZE_BIT-3]
	size_t idx = (state & -4) + (ctx->t._gb.codIRange >> shift);
	size_t codIRangeLPS = (size_t)((uint8_t *)rangeTabLPS - 4)[idx] << (shift - 6);
	ctx->t._gb.codIRange -= codIRangeLPS;
	if (ctx->t._gb.codIOffset >= ctx->t._gb.codIRange) {
		state ^= 255;
		ctx->t._gb.codIOffset -= ctx->t._gb.codIRange;
		ctx->t._gb.codIRange = codIRangeLPS;
	}
	ctx->cabac[ctxIdx] = transIdx[state];
	int binVal = state & 1;
	if (__builtin_expect(ctx->t._gb.codIRange < 256, 0)) {
		ctx->t._gb.codIOffset = shld(get_bytes(&ctx->t._gb, SIZE_BIT / 8 - 1), ctx->t._gb.codIOffset, SIZE_BIT - 8);
		ctx->t._gb.codIRange <<= SIZE_BIT - 8;
	}
	return binVal;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x20(%rbp)
movl %esi, -0x24(%rbp)
movq -0x20(%rbp), %rax
movslq -0x24(%rbp), %rcx
movzbl 0x730(%rax,%rcx), %eax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
lzcntq %rax, %rax
movl %eax, %ecx
movl $0x3d, %eax
subl %ecx, %eax
cltq
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
andq $-0x4, %rax
movq -0x20(%rbp), %rcx
movq 0x10(%rcx), %rdx
movq -0x38(%rbp), %rcx
shrq %cl, %rdx
movq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rcx
leaq 0x81aa5(%rip), %rax     # 0xccbf0
movzbl -0x4(%rax,%rcx), %eax
movq -0x38(%rbp), %rcx
subq $0x6, %rcx
shlq %cl, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdx
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rcx
subq %rdx, %rcx
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x20(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jb 0x4b1b5
movq -0x30(%rbp), %rax
xorq $0xff, %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdx
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rcx
subq %rdx, %rcx
movq %rcx, 0x18(%rax)
movq -0x48(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x30(%rbp), %rcx
leaq 0x81b30(%rip), %rax     # 0xcccf0
movb (%rax,%rcx), %dl
movq -0x20(%rbp), %rax
movslq -0x24(%rbp), %rcx
movb %dl, 0x730(%rax,%rcx)
movq -0x30(%rbp), %rax
andq $0x1, %rax
movl %eax, -0x4c(%rbp)
movq -0x20(%rbp), %rax
cmpq $0x100, 0x10(%rax)      # imm = 0x100
setb %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x4b250
movq -0x20(%rbp), %rdi
movl $0x7, %esi
callq 0x4c850
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq %rcx, -0x8(%rbp)
movq %rax, -0x10(%rbp)
movl $0x38, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rdx
movl -0x14(%rbp), %ecx
shldq %cl, %rdx, %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rcx
shlq $0x38, %rcx
movq %rcx, 0x10(%rax)
movl -0x4c(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)