// File: /workspace/github_c_makefile_star2_O2/joncampbell123[P]swfhax/swf.c
// Function: swf_reader_read_SHAPE_record
int swf_reader_read_SHAPE_record(swf_reader *swf,swf_SHAPE_reading *r) {
	unsigned int tmp;

	r->ShapeRecord_str = "EndShapeRecord";
	r->ShapeRecord_type = swf_shrec_EndShapeRecord;
	r->ShapeRecordTypeFlag = swf_reader_read_UB(swf,1);
	if (r->ShapeRecordTypeFlag == 0) {
		r->shrec.style.StyleChangeRecord.StateNewStyles = swf_reader_read_UB(swf,1);
		r->shrec.style.StyleChangeRecord.StateLineStyle = swf_reader_read_UB(swf,1);
		r->shrec.style.StyleChangeRecord.StateFillStyle1 = swf_reader_read_UB(swf,1);
		r->shrec.style.StyleChangeRecord.StateFillStyle0 = swf_reader_read_UB(swf,1);
		r->shrec.style.StyleChangeRecord.StateMoveTo = swf_reader_read_UB(swf,1);
		/* EndShapeRecord TypeFlag == 0, followed by 5 bits of 0 */
		if (r->shrec.style.StyleChangeRecord.StateNewStyles == 0 &&
			r->shrec.style.StyleChangeRecord.StateLineStyle == 0 &&
			r->shrec.style.StyleChangeRecord.StateFillStyle1 == 0 &&
			r->shrec.style.StyleChangeRecord.StateFillStyle0 == 0 &&
			r->shrec.style.StyleChangeRecord.StateMoveTo == 0) {
			r->shrec.style.EndShapeRecord.EndOfShape = 0;
			return 0;
		}

		/* StyleChangeRecord TypeFlag == 0, 5 bits at least 1 is nonzero */
		r->ShapeRecord_str = "StyleChangeRecord";
		r->ShapeRecord_type = swf_shrec_StyleChangeRecord;
		if (r->shrec.style.StyleChangeRecord.StateMoveTo) {
			r->shrec.style.StyleChangeRecord.MoveBits = swf_reader_read_UB(swf,5);
			r->shrec.style.StyleChangeRecord.MoveDeltaX = swf_reader_read_SB(swf,r->shrec.style.StyleChangeRecord.MoveBits);
			r->shrec.style.StyleChangeRecord.MoveDeltaY = swf_reader_read_SB(swf,r->shrec.style.StyleChangeRecord.MoveBits);
		}
		else {
			r->shrec.style.StyleChangeRecord.MoveBits = 0;
			r->shrec.style.StyleChangeRecord.MoveDeltaX = 0;
			r->shrec.style.StyleChangeRecord.MoveDeltaY = 0;
		}
		if (r->shrec.style.StyleChangeRecord.StateFillStyle0)
			r->shrec.style.StyleChangeRecord.FillStyle0 = swf_reader_read_UB(swf,r->NumFillBits);
		if (r->shrec.style.StyleChangeRecord.StateFillStyle1)
			r->shrec.style.StyleChangeRecord.FillStyle1 = swf_reader_read_UB(swf,r->NumFillBits);
		if (r->shrec.style.StyleChangeRecord.StateLineStyle)
			r->shrec.style.StyleChangeRecord.LineStyle = swf_reader_read_UB(swf,r->NumLineBits);
	}
	else {
		tmp = swf_reader_read_UB(swf,1);
		if (tmp) { /* StraightEdgeRecord TypeFlag == 1, StraightFlag == 1, 5 bits */
			r->ShapeRecord_str = "StraightEdgeRecord";
			r->ShapeRecord_type = swf_shrec_StraightEdgeRecord;
			r->shrec.edge.StraightEdgeRecord.StraightFlag = 1;
			r->shrec.edge.StraightEdgeRecord.NumBits = swf_reader_read_UB(swf,4) + 2;
			r->shrec.edge.StraightEdgeRecord.GeneralLineFlag = swf_reader_read_UB(swf,1);
			if (r->shrec.edge.StraightEdgeRecord.GeneralLineFlag == 0)
				r->shrec.edge.StraightEdgeRecord.VertLineFlag = swf_reader_read_UB(swf,1);
			if (r->shrec.edge.StraightEdgeRecord.GeneralLineFlag || r->shrec.edge.StraightEdgeRecord.VertLineFlag == 0)
				r->shrec.edge.StraightEdgeRecord.DeltaX = swf_reader_read_SB(swf,r->shrec.edge.StraightEdgeRecord.NumBits);
			else
				r->shrec.edge.StraightEdgeRecord.DeltaX = 0;
			if (r->shrec.edge.StraightEdgeRecord.GeneralLineFlag || r->shrec.edge.StraightEdgeRecord.VertLineFlag == 1)
				r->shrec.edge.StraightEdgeRecord.DeltaY = swf_reader_read_SB(swf,r->shrec.edge.StraightEdgeRecord.NumBits);
			else
				r->shrec.edge.StraightEdgeRecord.DeltaY = 0;
		}
		else {
			r->ShapeRecord_str = "CurvedEdgeRecord";
			r->ShapeRecord_type = swf_shrec_CurvedEdgeRecord;
			r->shrec.edge.CurvedEdgeRecord.StraightFlag = 0;
			r->shrec.edge.CurvedEdgeRecord.NumBits = swf_reader_read_UB(swf,4) + 2;
			r->shrec.edge.CurvedEdgeRecord.ControlDeltaX = swf_reader_read_SB(swf,r->shrec.edge.CurvedEdgeRecord.NumBits);
			r->shrec.edge.CurvedEdgeRecord.ControlDeltaY = swf_reader_read_SB(swf,r->shrec.edge.CurvedEdgeRecord.NumBits);
			r->shrec.edge.CurvedEdgeRecord.AnchorDeltaX = swf_reader_read_SB(swf,r->shrec.edge.CurvedEdgeRecord.NumBits);
			r->shrec.edge.CurvedEdgeRecord.AnchorDeltaY = swf_reader_read_SB(swf,r->shrec.edge.CurvedEdgeRecord.NumBits);
		}
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x2f60(%rip), %rax      # 0x6388
movq %rax, 0x8(%rsi)
movb $0x0, 0x10(%rsi)
pushq $0x1
popq %r15
movl %r15d, %esi
callq 0x2694
movl %eax, %r12d
andl $0x1, %eax
shll $0x8, %eax
movl $0xfffffeff, %ecx       # imm = 0xFFFFFEFF
andl (%rbx), %ecx
orl %eax, %ecx
movw %cx, (%rbx)
movq %r14, %rdi
movl %r15d, %esi
callq 0x2694
testb $0x1, %r12b
jne 0x350a
movl 0x14(%rbx), %ecx
andl $0x1, %eax
andl $-0x2, %ecx
orl %eax, %ecx
movw %cx, 0x14(%rbx)
movq %r14, %rdi
movl %r15d, %esi
callq 0x2694
movl 0x14(%rbx), %ecx
andl $0x1, %eax
andl $-0x3, %ecx
leal (%rcx,%rax,2), %eax
movw %ax, 0x14(%rbx)
movq %r14, %rdi
movl %r15d, %esi
callq 0x2694
movl 0x14(%rbx), %ecx
andl $0x1, %eax
andl $-0x5, %ecx
leal (%rcx,%rax,4), %eax
movw %ax, 0x14(%rbx)
movq %r14, %rdi
movl %r15d, %esi
callq 0x2694
movl 0x14(%rbx), %ecx
andl $0x1, %eax
andl $-0x9, %ecx
leal (%rcx,%rax,8), %eax
movw %ax, 0x14(%rbx)
movq %r14, %rdi
movl %r15d, %esi
callq 0x2694
movzwl 0x14(%rbx), %ecx
movl %eax, %edx
shll $0x4, %edx
andl $0x10, %edx
movl %ecx, %esi
andl $-0x11, %esi
orl %edx, %esi
movw %si, 0x14(%rbx)
testb $0xf, %cl
sete %sil
testb $0x1, %al
sete %al
andb %sil, %al
cmpb $0x1, %al
jne 0x3591
andb $-0x20, %cl
movb %cl, 0x14(%rbx)
jmp 0x3711
testl %eax, %eax
je 0x35be
leaq 0x2e90(%rip), %rax      # 0x63a9
movq %rax, 0x8(%rbx)
movb $0x2, 0x10(%rbx)
orb $0x1, 0x14(%rbx)
pushq $0x4
popq %rsi
movq %r14, %rdi
callq 0x2694
movb 0x14(%rbx), %cl
addb %al, %al
addb $0x4, %al
andb $0x3e, %al
andb $-0x3f, %cl
orb %al, %cl
movb %cl, 0x14(%rbx)
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x2694
movb 0x14(%rbx), %cl
movl %eax, %edx
shlb $0x6, %dl
andb $0x40, %dl
andb $-0x41, %cl
orb %dl, %cl
movb %cl, 0x14(%rbx)
testb $0x1, %al
jne 0x357c
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x2694
movb 0x14(%rbx), %cl
shlb $0x7, %al
andb $0x7f, %cl
orb %al, %cl
movb %cl, 0x14(%rbx)
movl %ecx, %eax
andb $-0x40, %al
negb %al
jno 0x3640
andl $0x0, 0x18(%rbx)
jmp 0x3664
leaq 0x2dff(%rip), %rax      # 0x6397
movq %rax, 0x8(%rbx)
movb $0x1, 0x10(%rbx)
testw %dx, %dx
jne 0x367c
andl $0xfc0f, %ecx           # imm = 0xFC0F
movw %cx, 0x14(%rbx)
andl $0x0, 0x18(%rbx)
xorl %eax, %eax
jmp 0x36bf
leaq 0x2df7(%rip), %rax      # 0x63bc
movq %rax, 0x8(%rbx)
movb $0x3, 0x10(%rbx)
andb $-0x2, 0x14(%rbx)
pushq $0x4
popq %rsi
movq %r14, %rdi
callq 0x2694
movb 0x14(%rbx), %cl
addb %al, %al
addb $0x4, %al
movl %eax, %edx
andb $0x3e, %dl
andb $-0x3f, %cl
orb %dl, %cl
movb %cl, 0x14(%rbx)
shrb %al
andb $0x1f, %al
movzbl %al, %esi
movq %r14, %rdi
callq 0x2712
movl %eax, 0x18(%rbx)
movl 0x14(%rbx), %esi
shrl %esi
andl $0x1f, %esi
movq %r14, %rdi
callq 0x2712
movl %eax, 0x1c(%rbx)
movl 0x14(%rbx), %esi
shrl %esi
andl $0x1f, %esi
movq %r14, %rdi
callq 0x2712
movl %eax, 0x20(%rbx)
movl 0x14(%rbx), %esi
shrl %esi
andl $0x1f, %esi
movq %r14, %rdi
callq 0x2712
movl %eax, 0x24(%rbx)
jmp 0x3711
shrb %cl
andb $0x1f, %cl
movzbl %cl, %esi
movq %r14, %rdi
callq 0x2712
movb 0x14(%rbx), %cl
movl %eax, 0x18(%rbx)
cmpb $0x40, %cl
jae 0x3664
andl $0x0, 0x1c(%rbx)
jmp 0x3711
shrb %cl
andb $0x1f, %cl
movzbl %cl, %esi
movq %r14, %rdi
callq 0x2712
movl %eax, 0x1c(%rbx)
jmp 0x3711
pushq $0x5
popq %rsi
movq %r14, %rdi
callq 0x2694
andl $0x1f, %eax
movl %eax, %ecx
shll $0x5, %ecx
movl $0xfffffc1f, %edx       # imm = 0xFFFFFC1F
andl 0x14(%rbx), %edx
orl %ecx, %edx
movw %dx, 0x14(%rbx)
movq %r14, %rdi
movl %eax, %esi
callq 0x2712
movl %eax, 0x18(%rbx)
movl 0x14(%rbx), %esi
shrl $0x5, %esi
andl $0x1f, %esi
movq %r14, %rdi
callq 0x2712
movzwl 0x14(%rbx), %ecx
movl %eax, 0x1c(%rbx)
testb $0x8, %cl
je 0x36dd
movzwl (%rbx), %esi
andl $0xf, %esi
movq %r14, %rdi
callq 0x2694
movw %ax, 0x20(%rbx)
movzwl 0x14(%rbx), %ecx
testb $0x4, %cl
je 0x36f8
movzwl (%rbx), %esi
andl $0xf, %esi
movq %r14, %rdi
callq 0x2694
movw %ax, 0x22(%rbx)
movzwl 0x14(%rbx), %ecx
testb $0x2, %cl
je 0x3711
movl (%rbx), %esi
shrl $0x4, %esi
andl $0xf, %esi
movq %r14, %rdi
callq 0x2694
movw %ax, 0x24(%rbx)
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq