// File: /workspace/github_c_makefile_star2_O1/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 %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x36e8(%rip), %rax      # 0x7388
movq %rax, 0x8(%rsi)
movb $0x0, 0x10(%rsi)
movl $0x1, %esi
callq 0x2c8b
movl %eax, %r15d
andl $0x1, %eax
shll $0x8, %eax
movl $0xfffffeff, %ecx       # imm = 0xFFFFFEFF
andl (%rbx), %ecx
orl %eax, %ecx
movw %cx, (%rbx)
movq %r14, %rdi
movl $0x1, %esi
callq 0x2c8b
testb $0x1, %r15b
jne 0x3d88
movl 0x14(%rbx), %ecx
andl $0x1, %eax
andl $-0x2, %ecx
orl %eax, %ecx
movw %cx, 0x14(%rbx)
movq %r14, %rdi
movl $0x1, %esi
callq 0x2c8b
movl 0x14(%rbx), %ecx
andl $0x1, %eax
andl $-0x3, %ecx
leal (%rcx,%rax,2), %eax
movw %ax, 0x14(%rbx)
movq %r14, %rdi
movl $0x1, %esi
callq 0x2c8b
movl 0x14(%rbx), %ecx
andl $0x1, %eax
andl $-0x5, %ecx
leal (%rcx,%rax,4), %eax
movw %ax, 0x14(%rbx)
movq %r14, %rdi
movl $0x1, %esi
callq 0x2c8b
movl 0x14(%rbx), %ecx
andl $0x1, %eax
andl $-0x9, %ecx
leal (%rcx,%rax,8), %eax
movw %ax, 0x14(%rbx)
movq %r14, %rdi
movl $0x1, %esi
callq 0x2c8b
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 0x3e38
andb $-0x20, 0x14(%rbx)
jmp 0x3f8f
testl %eax, %eax
je 0x3e68
leaq 0x3612(%rip), %rax      # 0x73a9
movq %rax, 0x8(%rbx)
movb $0x2, 0x10(%rbx)
orb $0x1, 0x14(%rbx)
movq %r14, %rdi
movl $0x4, %esi
callq 0x2c8b
movb 0x14(%rbx), %cl
addb %al, %al
addb $0x4, %al
andb $0x3e, %al
andb $-0x3f, %cl
orb %al, %cl
movb %cl, 0x14(%rbx)
movq %r14, %rdi
movl $0x1, %esi
callq 0x2c8b
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 0x3e00
movq %r14, %rdi
movl $0x1, %esi
callq 0x2c8b
movb 0x14(%rbx), %cl
shlb $0x7, %al
andb $0x7f, %cl
orb %al, %cl
movb %cl, 0x14(%rbx)
movzbl 0x14(%rbx), %esi
movl %esi, %ecx
andb $-0x40, %cl
xorl %eax, %eax
negb %cl
jo 0x3e1c
shrl %esi
andl $0x1f, %esi
movq %r14, %rdi
callq 0x2d24
movl %eax, 0x18(%rbx)
movzbl 0x14(%rbx), %esi
cmpl $0x40, %esi
jae 0x3eec
movl $0x0, 0x1c(%rbx)
jmp 0x3f8f
leaq 0x3558(%rip), %rax      # 0x7397
movq %rax, 0x8(%rbx)
movb $0x1, 0x10(%rbx)
testw %dx, %dx
jne 0x3f01
andl $0xfc0f, %ecx           # imm = 0xFC0F
movw %cx, 0x14(%rbx)
movl $0x0, 0x18(%rbx)
xorl %eax, %eax
jmp 0x3f42
leaq 0x354d(%rip), %rax      # 0x73bc
movq %rax, 0x8(%rbx)
movb $0x3, 0x10(%rbx)
andb $-0x2, 0x14(%rbx)
movq %r14, %rdi
movl $0x4, %esi
callq 0x2c8b
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 0x2d24
movl %eax, 0x18(%rbx)
movl 0x14(%rbx), %esi
shrl %esi
andl $0x1f, %esi
movq %r14, %rdi
callq 0x2d24
movl %eax, 0x1c(%rbx)
movl 0x14(%rbx), %esi
shrl %esi
andl $0x1f, %esi
movq %r14, %rdi
callq 0x2d24
movl %eax, 0x20(%rbx)
movl 0x14(%rbx), %esi
shrl %esi
andl $0x1f, %esi
movq %r14, %rdi
callq 0x2d24
movl %eax, 0x24(%rbx)
jmp 0x3f8f
shrl %esi
andl $0x1f, %esi
movq %r14, %rdi
callq 0x2d24
movl %eax, 0x1c(%rbx)
jmp 0x3f8f
movq %r14, %rdi
movl $0x5, %esi
callq 0x2c8b
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 0x2d24
movl %eax, 0x18(%rbx)
movl 0x14(%rbx), %esi
shrl $0x5, %esi
andl $0x1f, %esi
movq %r14, %rdi
callq 0x2d24
movl %eax, 0x1c(%rbx)
testb $0x8, 0x14(%rbx)
je 0x3f5d
movzwl (%rbx), %esi
andl $0xf, %esi
movq %r14, %rdi
callq 0x2c8b
movw %ax, 0x20(%rbx)
testb $0x4, 0x14(%rbx)
je 0x3f75
movzwl (%rbx), %esi
andl $0xf, %esi
movq %r14, %rdi
callq 0x2c8b
movw %ax, 0x22(%rbx)
testb $0x2, 0x14(%rbx)
je 0x3f8f
movl (%rbx), %esi
shrl $0x4, %esi
andl $0xf, %esi
movq %r14, %rdi
callq 0x2c8b
movw %ax, 0x24(%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq