// File: /workspace/github_c_makefile_star2_O3/arkanis[P]process-map/map.c
// Function: main
int main(int argc, char** argv) {
	if (argc != 2) {
		fprintf(stderr, "usage: %s pid\n", argv[0]);
		return 0;
	}
	
	FILE* cmdLineFile = fopen(TextFormat("/proc/%s/cmdline", argv[1]), "rb");
	if (cmdLineFile == NULL) {
		fprintf(stderr, "Couldn't find process %s\n", argv[1]);
		return 0;
	}
	char* cmdLine = NULL;
	fscanf(cmdLineFile, "%m[^\n]", &cmdLine);
	fclose(cmdLineFile);
	
	int screenWidth = 800, screenHeight = 600;
	SetConfigFlags(FLAG_VSYNC_HINT | FLAG_WINDOW_RESIZABLE);
	InitWindow(screenWidth, screenHeight, TextFormat("Memory map of process %s: %s", argv[1], cmdLine));
	
	Font uiFont      = LoadFontEx("NotoSans-Regular.ttf", 16, NULL, 0);
	Font mapLabelSdfFont = LoadSdfFont("NotoSans-Regular.ttf");
	Shader sdfFontShader = LoadShader(NULL, "sdf-text.fs");
	
	GuiSetFont(uiFont);
	
	AddrRange* ranges = NULL;
	size_t rangeCount = 0;
	LoadAddrRanges(argv[1], &ranges, &rangeCount);
	size_t hilbertCurveOrder = 0;
	Texture2D mapTexture = PlotAddrRanges(ranges, rangeCount, mapLabelSdfFont, &hilbertCurveOrder);
	PlotRangeElfSymbols(ranges, rangeCount, hilbertCurveOrder, mapLabelSdfFont);
	
	Shader mapShader = LoadShader(NULL, "range-map2.fs");
	int selectedColorLoc = GetShaderLocation(mapShader, "selectedColor");
	Shader symbolMapShader = LoadShader(NULL, "symbol-map.fs");
	
	TaskTraces traces = LoadTaskTraces(argv[1]);
	
	Camera2D camera = (Camera2D){
		.target = (Vector2){ mapTexture.width / 2, mapTexture.height / 2 },
		.offset = (Vector2){ screenWidth / 2, screenHeight / 2 },
		.zoom = 1.0
	};
	
	bool wasWindowFocused = true, isPanning = false;
	Vector2 prevMousePos = { 0 };
	while ( !WindowShouldClose() ) {
		if ( IsWindowResized() ) {
			screenWidth = GetScreenWidth();
			screenHeight = GetScreenHeight();
		}
		
		// Reduce FPS when window isn't focused
		if ( IsWindowFocused() && !wasWindowFocused ) {
			wasWindowFocused = true;
			SetTargetFPS(0);
		} else if ( !IsWindowFocused() && wasWindowFocused ) {
			wasWindowFocused = false;
			SetTargetFPS(30);
		}
		
		// Mouse panning
		if ( IsMouseButtonPressed(MOUSE_LEFT_BUTTON) ) {
			isPanning = true;
			prevMousePos = GetMousePosition();
		} else if ( isPanning && IsMouseButtonReleased(MOUSE_LEFT_BUTTON) ) {
			isPanning = false;
		} else if ( isPanning ) {
			float dx = prevMousePos.x - GetMouseX(), dy = prevMousePos.y - GetMouseY();
			camera.target.x += dx / camera.zoom;
			camera.target.y += dy / camera.zoom;
			prevMousePos = GetMousePosition();
		}
		
		// Mousewheel zooming (world space position remains the same directly at the mouse pointer)
		const float factor = powf(0.9, -GetMouseWheelMove());  // 0.9^1 = 0.9, 0.9^-1 = 1/0.9
		Vector2 mousePosWs = GetScreenToWorld2D(GetMousePosition(), camera);
		float oldScale = camera.zoom, newScale = camera.zoom * factor;
		camera.target.x = mousePosWs.x + (camera.target.x - mousePosWs.x) * (oldScale / newScale);
		camera.target.y = mousePosWs.y + (camera.target.y - mousePosWs.y) * (oldScale / newScale);
		camera.zoom = newScale;
		
		// Handle keyboard input
		if (IsKeyPressed(KEY_R)) {
			mapShader = LoadShader(NULL, "range-map2.fs");
			symbolMapShader = LoadShader(NULL, "symbol-map.fs");
		}
		
		// Picking
		AddrRange* selectedRange = NULL;
		Color      selectedRangeColor = BLACK;
		if ( CheckCollisionPointRec(mousePosWs, (Rectangle){ .x = 0, .y = 0, .width = mapTexture.width, .height = mapTexture.height }) ) {
			uint64_t page = HilberCurvePosToDist(hilbertCurveOrder, mousePosWs.x, mousePosWs.y);
			for (size_t i = 0; i < rangeCount; i++) {
				if (page >= ranges[i].startPage && page < ranges[i].endPage) {
					selectedRange = &ranges[i];
					selectedRangeColor = selectedRange->color;
					break;
				}
			}
		}
		
		UpdateTaskTraces(&traces, ranges, rangeCount, hilbertCurveOrder);
		
		
		// Prepare view culling
		Vector2 viewTopLeft = GetScreenToWorld2D((Vector2){ 0, 0 }, camera);
		Vector2 viewBottomRight = GetScreenToWorld2D((Vector2){ screenWidth, screenHeight }, camera);
		Rectangle viewBoundingBox = (Rectangle){ .x = viewTopLeft.x, .y = viewTopLeft.y, .width = viewBottomRight.x - viewTopLeft.x, .height = viewBottomRight.y - viewTopLeft.y };
		
		BeginDrawing();
			ClearBackground(WHITE);
			
			BeginMode2D(camera);
				// Draw map legend
				int lx = -220, ly = 0;
				DrawRectangle(lx, ly, 16, 16, (Color){ 184, 224, 198, 255 });
				BeginShaderMode(sdfFontShader);
					DrawTextEx(mapLabelSdfFont, "File backed memory map",          (Vector2){ -200, ly }, 14, 0, BLACK); ly += 14;
					DrawTextEx(mapLabelSdfFont, "(different color for each name)", (Vector2){ -200, ly }, 14, 0, BLACK); ly += 14 + 6;
				EndShaderMode();
				DrawRectangle(lx, ly, 16, 16, (Color){ 229, 229, 229, 255 });
				BeginShaderMode(sdfFontShader);
					DrawTextEx(mapLabelSdfFont, "Anonymous memory map",            (Vector2){ -200, ly }, 14, 0, BLACK); ly += 14 + 6;
				EndShaderMode();
				DrawRectangle(lx, ly, 16, 16, (Color){ 250, 250, 250, 255 });
				BeginShaderMode(sdfFontShader);
					DrawTextEx(mapLabelSdfFont, "Unused address space",            (Vector2){ -200, ly }, 14, 0, BLACK); ly += 14 + 6;
					DrawTextEx(mapLabelSdfFont, "(not displayed to scale)",        (Vector2){ -200, ly }, 14, 0, BLACK); ly += (14 + 6) * 2;
				EndShaderMode();
				DrawRectangle(lx, ly, 16, 16, (Color){ 229, 229, 229, 255 });
				BeginShaderMode(sdfFontShader);
					DrawTextEx(mapLabelSdfFont, "1 MiByte to scale",               (Vector2){ -200, ly }, 14, 0, BLACK); ly += 14 + 6;
				EndShaderMode();
				DrawRectangle(lx - (64-16), ly, 64, 64, (Color){ 229, 229, 229, 255 });
				BeginShaderMode(sdfFontShader);
					DrawTextEx(mapLabelSdfFont, "16 MiByte to scale",              (Vector2){ -200, ly }, 14, 0, BLACK); ly += 14 + 6;
				EndShaderMode();
				
				// Draw map and highlight selected range
				BeginShaderMode(mapShader);
					Vector4 selectedColor = ColorNormalize(selectedRangeColor);
					SetShaderValue(mapShader, selectedColorLoc, &selectedColor, UNIFORM_VEC4);
					DrawTexture(mapTexture, 0, 0, BLANK);
				EndShaderMode();
				
				if (selectedRange && selectedRange->label.boundingBox.width < viewBoundingBox.width * mmapLabelMaxWindowFraction) {
					BeginShaderMode(sdfFontShader);
						DrawTextEx(mapLabelSdfFont, selectedRange->label.text, (Vector2){ selectedRange->label.boundingBox.x, selectedRange->label.boundingBox.y }, selectedRange->label.fontSize, 0, BLACK);
					EndShaderMode();
				}
				
				// Draw range lables, their symbol maps and the symbol lables if necessary
				for (size_t i = 0; i < rangeCount; i++) {
					AddrRange* range = &ranges[i];
					if ( CheckCollisionRecs(range->boundingBox, viewBoundingBox) ) {
						if (range->boundingBox.width < viewBoundingBox.width * mmapLabelMaxWindowFraction) {
							BeginShaderMode(sdfFontShader);
								DrawTextEx(mapLabelSdfFont, range->label.text, (Vector2){ range->label.boundingBox.x, range->label.boundingBox.y }, range->label.fontSize, 0, (Color){ 0, 0, 0, 128 });
							EndShaderMode();
						}
						
						if (range->boundingBox.width > viewBoundingBox.width * mmapDetailsMinWindowFraction) {
							BeginShaderMode(symbolMapShader);
								DrawTexturePro(range->symbolMap, (Rectangle){ 0, 0, range->symbolMap.width, range->symbolMap.height }, range->boundingBox, (Vector2){ 0, 0 }, 0, (Color){0, 0, 0, 32});
							EndShaderMode();
							
							BeginShaderMode(sdfFontShader);
								for (size_t s = 0; s < range->symbolCount; s++) {
									Label* label = &range->symbolLabels[s];
									if ( CheckCollisionRecs(label->boundingBox, viewBoundingBox) && label->boundingBox.height * camera.zoom > 2 )
										DrawTextEx(mapLabelSdfFont, label->text, (Vector2){ label->boundingBox.x, label->boundingBox.y }, label->fontSize, 0, (Color){ 0, 0, 0, 128 });
								}
							EndShaderMode();
						}
					}
				}
				
				rlglDraw();
				glUseProgram(traces.particleShader.id);
					// Have to set the model view projection matrix manually because raylib has not matrix uniform type
					Matrix mvp = MatrixMultiply(GetMatrixModelview(), GetMatrixProjection());
					glUniformMatrix4fv(traces.particleShader.locs[LOC_MATRIX_MVP], 1, false, MatrixToFloat(mvp));
					glUniform1ui(traces.shaderCurrentTimeLocation, traces.currentTime);
					
					for (size_t t = 0; t < traces.taskCount; t++) {
						if (traces.focusedTaskIndex == -1 || (ssize_t)t == traces.focusedTaskIndex) {
							Color transparentColor = traces.tasks[t].color;
							transparentColor.a = 64;
							Vector4 color = ColorNormalize(transparentColor);
							SetShaderValue(traces.particleShader, traces.shaderColorLocation, &color, UNIFORM_VEC4);
							glBindVertexArray(traces.tasks[t].particleVAO);
								glDrawArrays(GL_POINTS, 0, particleCount);
							glBindVertexArray(0);
						}
					}
				glUseProgram(0);
			EndMode2D();
			
			DrawRectangle(0, 0, screenWidth, 20, RAYWHITE);
			if (selectedRange) {
				const char* sizeUnit = NULL;
				double size = HumanReadableByteSize(selectedRange->endAddr - selectedRange->startAddr, &sizeUnit);
				DrawTextEx(uiFont, TextFormat("Size: %.2lf %s", size, sizeUnit), (Vector2){ 5, 3 }, uiFont.baseSize, 0, BLACK);
				DrawTextEx(uiFont, TextFormat("Address 0x%016lx - 0x%016lx", selectedRange->startAddr, selectedRange->endAddr), (Vector2){ 120, 3 }, uiFont.baseSize, 0, BLACK);
				
				if ( ! selectedRange->isGap ) {
					DrawTextEx(uiFont, selectedRange->perms,    (Vector2){ 410, 3 }, uiFont.baseSize, 0, BLACK);
					DrawTextEx(uiFont, selectedRange->filePath, (Vector2){ 450, 3 }, uiFont.baseSize, 0, BLACK);
				}
			}
			
			GuiEnable();
			Rectangle tasksPanel = (Rectangle){ screenWidth - 200, 20, 200, screenHeight };
			GuiPanel(tasksPanel);
			float x = 5, y = 5;
			for (ssize_t t = 0; t < (ssize_t)traces.taskCount; t++) {
				if (traces.focusedTaskIndex == -1 || t == traces.focusedTaskIndex) {
					GuiEnable();
					DrawCircle(tasksPanel.x + x + 3, tasksPanel.y + y + 16/2, 3, traces.tasks[t].color);
				} else {
					GuiDisable();
					DrawCircle(tasksPanel.x + x + 3, tasksPanel.y + y + 16/2, 3, LIGHTGRAY);
				}
				const char* text = TextFormat("Task %d%s", traces.tasks[t].pid, traces.tasks[t].dead ? " (dead)" : "");
				if ( GuiLabelButton((Rectangle){ tasksPanel.x + x + 10, tasksPanel.y + y, 200 - 2*5, 16 }, text) ) {
					if (t == traces.focusedTaskIndex)
						traces.focusedTaskIndex = -1;
					else
						traces.focusedTaskIndex = t;
				}
				GuiLabel((Rectangle){ tasksPanel.x + x + 10, tasksPanel.y + y + 16, 200 - 2*5, 16 }, traces.tasks[t].name);
				
				y += 20 + 16;
			}
			
		EndDrawing();
	}
	
	UnloadTaskTraces(&traces);
	UnloadShader(mapShader);
	UnloadTexture(mapTexture);
	UnloadAddrRanges(&ranges, &rangeCount);
	UnloadShader(sdfFontShader);
	UnloadFont(mapLabelSdfFont);
	UnloadShader(symbolMapShader);
	UnloadFont(uiFont);
	CloseWindow();
	free(cmdLine);
	
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2a8, %rsp            # imm = 0x2A8
movq %rsi, %r12
cmpl $0x2, %edi
jne 0x13c97
movq 0x8(%r12), %rsi
addq $0x8, %r12
leaq 0x52aff(%rip), %rdi     # 0x653e7
xorl %eax, %eax
callq 0x4dfb7
leaq 0x52adf(%rip), %rsi     # 0x653d5
movq %rax, %rdi
callq 0x61d0
testq %rax, %rax
je 0x13ca4
movq %rax, %rbx
leaq 0x218(%rsp), %r14
movq $0x0, (%r14)
leaq 0x52ca8(%rip), %rsi     # 0x655c8
movq %rax, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x60e0
movq %rbx, %rdi
callq 0x6620
movl $0x44, %edi
callq 0x2b0ed
movq (%r12), %rsi
movq (%r14), %rdx
leaq 0x52ac5(%rip), %rdi     # 0x65412
xorl %eax, %eax
callq 0x4dfb7
movl $0x320, %edi            # imm = 0x320
movl $0x258, %esi            # imm = 0x258
movq %rax, %rdx
callq 0x270f3
leaq 0x52ac2(%rip), %rbx     # 0x6542f
leaq 0xf8(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
movl $0x10, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x4a3ac
leaq 0x68(%rsp), %rdi
movq %rbx, %rsi
callq 0x13cb1
leaq 0x52aa6(%rip), %rsi     # 0x65444
xorl %edi, %edi
callq 0x223d0
movl %eax, 0x5c(%rsp)
movq %rdx, 0x98(%rsp)
movl (%r15), %ebx
movq 0x4(%r15), %r14
movl 0xc(%r15), %ebp
movups 0x10(%r15), %xmm0
movaps %xmm0, 0x130(%rsp)
movups 0x20(%r15), %xmm0
movaps %xmm0, 0x140(%rsp)
testl %ebp, %ebp
je 0x12a63
cmpb $0x1, 0x91870(%rip)     # 0xa4255
jne 0x12a19
leaq 0x108(%rsp), %rax
movl %ebx, 0x9186b(%rip)     # 0xa4260
movq %r14, 0x91868(%rip)     # 0xa4264
movl %ebp, 0x9186a(%rip)     # 0xa426c
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movaps %xmm0, 0x91860(%rip)    # 0xa4270
movaps %xmm1, 0x91869(%rip)    # 0xa4280
jmp 0x12a5d
callq 0x6a3c
movl %ebx, 0x9183c(%rip)     # 0xa4260
movq %r14, 0x91839(%rip)     # 0xa4264
movl %ebp, 0x9183b(%rip)     # 0xa426c
movaps 0x130(%rsp), %xmm0
movaps 0x140(%rsp), %xmm1
movaps %xmm0, 0x91828(%rip)    # 0xa4270
movaps %xmm1, 0x91831(%rip)    # 0xa4280
cmpb $0x0, 0x917ff(%rip)     # 0xa4255
jne 0x12a5d
callq 0x6a3c
movl %ebx, 0x9186d(%rip)     # 0xa42d0
xorl %ebx, %ebx
leaq 0xc8(%rsp), %r15
movq %rbx, (%r15)
leaq 0xb8(%rsp), %r13
movq %rbx, (%r13)
movq (%r12), %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x13dc2
leaq 0x128(%rsp), %rbp
movq %rbx, (%rbp)
movq (%r15), %r15
movq (%r13), %r13
movups 0x68(%rsp), %xmm0
movups 0x78(%rsp), %xmm1
movups 0x88(%rsp), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
leaq 0x168(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rbp, %rcx
callq 0x13fdb
movq (%rbp), %rdx
movups 0x68(%rsp), %xmm0
movups 0x78(%rsp), %xmm1
movups 0x88(%rsp), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %r15, %rdi
movq %r13, %rsi
callq 0x145d7
leaq 0x52943(%rip), %rsi     # 0x65450
xorl %edi, %edi
callq 0x223d0
movq %rdx, %rsi
leaq 0x52940(%rip), %rdx     # 0x6545e
movl %eax, 0x58(%rsp)
movl %eax, %edi
movq %rsi, 0xe0(%rsp)
callq 0x22a0d
movl %eax, 0xf0(%rsp)
leaq 0x5292d(%rip), %rsi     # 0x6546c
xorl %edi, %edi
callq 0x223d0
movl %eax, 0x60(%rsp)
movq %rdx, 0xe8(%rsp)
movq (%r12), %rsi
leaq 0x130(%rsp), %rdi
callq 0x14aed
movsd 0x52695(%rip), %xmm0    # 0x65200
movq 0x4(%rbx), %xmm1
movdqa %xmm1, %xmm2
psrld $0x1f, %xmm2
paddd %xmm1, %xmm2
psrad $0x1, %xmm2
cvtdq2ps %xmm2, %xmm1
movlhps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
movups %xmm0, 0xa0(%rsp)
movsd 0x525a8(%rip), %xmm0    # 0x65140
movsd %xmm0, 0xb0(%rsp)
callq 0x27c20
testb %al, %al
je 0x12c97
movl 0x5c(%rsp), %ebx
leaq 0x130(%rsp), %rdi
callq 0x151e9
movl 0x58(%rsp), %edi
movq 0xe0(%rsp), %rsi
callq 0x22967
movl 0x178(%rsp), %eax
movl %eax, 0x10(%rsp)
movups 0x168(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x3f8de
leaq 0xc8(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0x152b3
movl %ebx, %edi
movq 0x98(%rsp), %rsi
callq 0x22967
movups 0x68(%rsp), %xmm0
movups 0x78(%rsp), %xmm1
movups 0x88(%rsp), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0x4de70
movl 0x60(%rsp), %edi
movq 0xe8(%rsp), %rsi
callq 0x22967
movups 0xf8(%rsp), %xmm0
movups 0x108(%rsp), %xmm1
movups 0x118(%rsp), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0x4de70
callq 0x27bb9
movq 0x218(%rsp), %rdi
callq 0x62e0
xorl %eax, %eax
addq $0x2a8, %rsp            # imm = 0x2A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorps %xmm0, %xmm0
movaps %xmm0, 0x220(%rsp)
movb $0x1, %al
movl %eax, 0x38(%rsp)
movl $0x258, 0xc4(%rsp) # imm = 0x258
movl $0x320, %r14d           # imm = 0x320
movl $0x0, 0x3c(%rsp)
callq 0x27cb6
testb %al, %al
je 0x12cde
callq 0x28343
movl %eax, %r14d
callq 0x2834a
movl %eax, 0xc4(%rsp)
callq 0x27cab
testb %al, %al
je 0x12cee
testb $0x1, 0x38(%rsp)
je 0x12d0d
callq 0x27cab
testb %al, %al
jne 0x12d1a
testb $0x1, 0x38(%rsp)
je 0x12d1a
movl $0x1e, %edi
movl $0x0, 0x38(%rsp)
jmp 0x12d15
movb $0x1, %al
movl %eax, 0x38(%rsp)
xorl %edi, %edi
callq 0x2afbf
xorl %edi, %edi
callq 0x2bccc
testb %al, %al
je 0x12d3a
movb $0x1, %al
movl %eax, 0x3c(%rsp)
callq 0x26136
movaps %xmm0, 0x220(%rsp)
jmp 0x12da7
testb $0x1, 0x3c(%rsp)
je 0x12d9f
movl $0x0, 0x3c(%rsp)
xorl %edi, %edi
callq 0x2bd0b
testb %al, %al
jne 0x12da7
callq 0x2bd6d
movl %eax, %ebp
callq 0x2bd8a
movd %ebp, %xmm0
movd %eax, %xmm1
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
cvtdq2ps %xmm0, %xmm0
movaps 0x220(%rsp), %xmm1
subps %xmm0, %xmm1
movss 0xb4(%rsp), %xmm0
unpcklps %xmm0, %xmm0            # xmm0 = xmm0[0,0,1,1]
divps %xmm0, %xmm1
movsd 0xa8(%rsp), %xmm0
addps %xmm1, %xmm0
movlps %xmm0, 0xa8(%rsp)
jmp 0x12d25
movl $0x0, 0x3c(%rsp)
callq 0x26155
movaps %xmm0, %xmm1
xorps 0x522fa(%rip), %xmm1    # 0x650b0
movss 0x522a6(%rip), %xmm0    # 0x65064
callq 0x6040
movss %xmm0, 0x40(%rsp)
callq 0x26136
movq 0xb0(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0xa0(%rsp), %xmm1
movups %xmm1, (%rsp)
callq 0x2ac62
movss 0xb4(%rsp), %xmm2
movss 0x40(%rsp), %xmm1
mulss %xmm2, %xmm1
divss %xmm1, %xmm2
movaps %xmm1, %xmm3
movsd 0xa8(%rsp), %xmm1
subps %xmm0, %xmm1
unpcklps %xmm2, %xmm2            # xmm2 = xmm2[0,0,1,1]
mulps %xmm1, %xmm2
movaps %xmm0, 0x40(%rsp)
addps %xmm0, %xmm2
movlps %xmm2, 0xa8(%rsp)
movss %xmm3, 0xb4(%rsp)
movl $0x52, %edi
callq 0x2b9b9
testb %al, %al
je 0x12e73
xorl %edi, %edi
leaq 0x52608(%rip), %rsi     # 0x65450
callq 0x223d0
movl %eax, 0x58(%rsp)
movq %rdx, 0xe0(%rsp)
xorl %edi, %edi
leaq 0x5260a(%rip), %rsi     # 0x6546c
callq 0x223d0
movl %eax, 0x60(%rsp)
movq %rdx, 0xe8(%rsp)
movsd 0x16c(%rsp), %xmm0
cvtdq2ps %xmm0, %xmm2
xorps %xmm1, %xmm1
movaps 0x40(%rsp), %xmm0
callq 0x320c1
testb %al, %al
je 0x12ef0
movaps 0x40(%rsp), %xmm0
cvttss2si %xmm0, %esi
movq 0x128(%rsp), %rbp
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
cvttss2si %xmm0, %edx
movq %rbp, %rdi
callq 0x14ea9
movq 0xb8(%rsp), %rdx
movl $0xff000000, %r12d      # imm = 0xFF000000
movq 0xc8(%rsp), %rsi
testq %rdx, %rdx
je 0x12f10
movq %rsi, %r15
movq %rdx, %rcx
cmpq 0x30(%r15), %rax
jb 0x12ee2
cmpq 0x38(%r15), %rax
jb 0x13c8e
addq $0xa0, %r15
decq %rcx
jne 0x12ed2
jmp 0x12f12
movq 0xc8(%rsp), %rsi
movq 0xb8(%rsp), %rdx
movl $0xff000000, %r12d      # imm = 0xFF000000
movq 0x128(%rsp), %rbp
jmp 0x12f12
xorl %edx, %edx
xorl %r15d, %r15d
leaq 0x130(%rsp), %rdi
movq %rbp, %rcx
callq 0x14f28
movq 0xb0(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0xa0(%rsp), %xmm0
movups %xmm0, (%rsp)
xorps %xmm0, %xmm0
callq 0x2ac62
movq %r14, 0x210(%rsp)
xorps %xmm1, %xmm1
cvtsi2ss %r14d, %xmm1
movaps %xmm0, 0xd0(%rsp)
xorps %xmm2, %xmm2
cvtsi2ssl 0xc4(%rsp), %xmm2
movq 0xb0(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0xa0(%rsp), %xmm0
movups %xmm0, (%rsp)
movaps %xmm2, 0x230(%rsp)
unpcklps %xmm2, %xmm1            # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movaps %xmm1, %xmm0
callq 0x2ac62
subps 0xd0(%rsp), %xmm0
movaps %xmm0, 0x40(%rsp)
callq 0x287cf
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x2877a
movq 0xb0(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0xa0(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x28d59
movl $0xffffff24, %edi       # imm = 0xFFFFFF24
xorl %esi, %esi
movl $0x10, %edx
movl $0x10, %ecx
movl $0xffc6e0b8, %r8d       # imm = 0xFFC6E0B8
callq 0x2e4dc
movl 0x5c(%rsp), %ebp
movl %ebp, %edi
movq 0x98(%rsp), %rbx
movq %rbx, %rsi
callq 0x229a3
movups 0x68(%rsp), %xmm0
movups 0x78(%rsp), %xmm1
movups 0x88(%rsp), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
xorps %xmm2, %xmm2
leaq 0x5244e(%rip), %rdi     # 0x6547a
movss 0x52034(%rip), %xmm0    # 0x65068
movss 0x52030(%rip), %xmm1    # 0x6506c
movl $0xff000000, %esi       # imm = 0xFF000000
callq 0x4e092
movups 0x68(%rsp), %xmm0
movups 0x78(%rsp), %xmm1
movups 0x88(%rsp), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
xorps %xmm2, %xmm2
leaq 0x52421(%rip), %rdi     # 0x65491
movsd 0x52198(%rip), %xmm0    # 0x65210
movss 0x51fec(%rip), %xmm1    # 0x6506c
movl $0xff000000, %esi       # imm = 0xFF000000
callq 0x4e092
callq 0x229d3
movl $0xffffff24, %edi       # imm = 0xFFFFFF24
movl $0x22, %esi
movl $0x10, %edx
movl $0x10, %ecx
movl $0xffe5e5e5, %r8d       # imm = 0xFFE5E5E5
callq 0x2e4dc
movl %ebp, %edi
movq %rbx, %rsi
callq 0x229a3
movups 0x68(%rsp), %xmm0
movups 0x78(%rsp), %xmm1
movups 0x88(%rsp), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
xorps %xmm2, %xmm2
leaq 0x523cf(%rip), %rdi     # 0x654b1
movsd 0x52136(%rip), %xmm0    # 0x65220
movss 0x51f7a(%rip), %xmm1    # 0x6506c
movl $0xff000000, %esi       # imm = 0xFF000000
callq 0x4e092
callq 0x229d3
movl $0xffffff24, %edi       # imm = 0xFFFFFF24
movl $0x36, %esi
movl $0x10, %edx
movl $0x10, %ecx
movl $0xfffafafa, %r8d       # imm = 0xFFFAFAFA
callq 0x2e4dc
movl %ebp, %edi
movq %rbx, %rsi
callq 0x229a3
movups 0x68(%rsp), %xmm0
movups 0x78(%rsp), %xmm1
movups 0x88(%rsp), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
xorps %xmm2, %xmm2
leaq 0x52372(%rip), %rdi     # 0x654c6
movsd 0x520d4(%rip), %xmm0    # 0x65230
movss 0x51f08(%rip), %xmm1    # 0x6506c
movl $0xff000000, %esi       # imm = 0xFF000000
callq 0x4e092
movups 0x68(%rsp), %xmm0
movups 0x78(%rsp), %xmm1
movups 0x88(%rsp), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
xorps %xmm2, %xmm2
leaq 0x52343(%rip), %rdi     # 0x654db
movsd 0x520a0(%rip), %xmm0    # 0x65240
movss 0x51ec4(%rip), %xmm1    # 0x6506c
movl $0xff000000, %esi       # imm = 0xFF000000
callq 0x4e092
callq 0x229d3
movl $0xffffff24, %edi       # imm = 0xFFFFFF24
movl $0x72, %esi
movl $0x10, %edx
movl $0x10, %ecx
movl $0xffe5e5e5, %r8d       # imm = 0xFFE5E5E5
callq 0x2e4dc
movl %ebp, %edi
movq %rbx, %rsi
callq 0x229a3
movups 0x68(%rsp), %xmm0
movups 0x78(%rsp), %xmm1
movups 0x88(%rsp), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
xorps %xmm2, %xmm2
leaq 0x522ea(%rip), %rdi     # 0x654f4
movsd 0x5203e(%rip), %xmm0    # 0x65250
movss 0x51e52(%rip), %xmm1    # 0x6506c
movl $0xff000000, %esi       # imm = 0xFF000000
callq 0x4e092
callq 0x229d3
movl $0xfffffef4, %edi       # imm = 0xFFFFFEF4
movl $0x86, %esi
movl $0x40, %edx
movl $0x40, %ecx
movl $0xffe5e5e5, %r8d       # imm = 0xFFE5E5E5
callq 0x2e4dc
movl %ebp, %edi
movq %rbx, %rsi
callq 0x229a3
movups 0x68(%rsp), %xmm0
movups 0x78(%rsp), %xmm1
movups 0x88(%rsp), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
xorps %xmm2, %xmm2
leaq 0x5228a(%rip), %rdi     # 0x65506
movsd 0x51fdc(%rip), %xmm0    # 0x65260
movss 0x51de0(%rip), %xmm1    # 0x6506c
movl $0xff000000, %esi       # imm = 0xFF000000
callq 0x4e092
callq 0x229d3
movl 0x58(%rsp), %ebx
movl %ebx, %edi
movq 0xe0(%rsp), %r14
movq %r14, %rsi
callq 0x229a3
movl %r12d, %edi
callq 0x4115c
movlhps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
movups %xmm0, 0x250(%rsp)
movl %ebx, %edi
movq %r14, %rsi
movl 0xf0(%rsp), %edx
leaq 0x250(%rsp), %rcx
movl $0x3, %r8d
callq 0x22ab7
movl 0x178(%rsp), %eax
movl %eax, 0x10(%rsp)
movups 0x168(%rsp), %xmm0
movups %xmm0, (%rsp)
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x3fb7e
callq 0x229d3
testq %r15, %r15
je 0x13374
movaps 0x40(%rsp), %xmm0
mulss 0x51d54(%rip), %xmm0    # 0x65070
ucomiss 0x6c(%r15), %xmm0
jbe 0x13374
movl %ebp, %edi
movq 0x98(%rsp), %rsi
callq 0x229a3
movq 0x58(%r15), %rdi
movsd 0x64(%r15), %xmm0
movss 0x60(%r15), %xmm1
movups 0x68(%rsp), %xmm2
movups 0x78(%rsp), %xmm3
movups 0x88(%rsp), %xmm4
movups %xmm4, 0x20(%rsp)
movups %xmm3, 0x10(%rsp)
movups %xmm2, (%rsp)
xorps %xmm2, %xmm2
movl $0xff000000, %esi       # imm = 0xFF000000
callq 0x4e092
callq 0x229d3
movq %r15, 0x208(%rsp)
cmpq $0x0, 0xb8(%rsp)
je 0x1358b
movaps 0x40(%rsp), %xmm0
movaps %xmm0, %xmm1
mulss 0x51cd5(%rip), %xmm1    # 0x65070
movss %xmm1, 0x64(%rsp)
mulss 0x51ccb(%rip), %xmm0    # 0x65074
movss %xmm0, 0xf4(%rsp)
xorl %ebx, %ebx
movq 0xc8(%rsp), %r15
leaq (%rbx,%rbx,4), %r14
shlq $0x5, %r14
movsd 0x44(%r15,%r14), %xmm0
movsd 0x4c(%r15,%r14), %xmm1
movaps 0xd0(%rsp), %xmm2
movaps 0x40(%rsp), %xmm3
callq 0x321cf
testb %al, %al
je 0x1357a
addq %r14, %r15
movss 0x4c(%r15), %xmm0
movss 0x64(%rsp), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x13457
movl %ebp, %edi
movq 0x98(%rsp), %rsi
callq 0x229a3
movq 0x58(%r15), %rdi
movsd 0x64(%r15), %xmm0
movss 0x60(%r15), %xmm1
movups 0x68(%rsp), %xmm2
movups 0x78(%rsp), %xmm3
movups 0x88(%rsp), %xmm4
movups %xmm4, 0x20(%rsp)
movups %xmm3, 0x10(%rsp)
movups %xmm2, (%rsp)
xorps %xmm2, %xmm2
movl $0x80000000, %esi       # imm = 0x80000000
callq 0x4e092
callq 0x229d3
movss 0x4c(%r15), %xmm0
ucomiss 0xf4(%rsp), %xmm0
jbe 0x1357a
movl 0x60(%rsp), %edi
movq 0xe8(%rsp), %rsi
callq 0x229a3
movsd 0x7c(%r15), %xmm0
cvtdq2ps %xmm0, %xmm1
movsd 0x44(%r15), %xmm2
movsd 0x4c(%r15), %xmm3
movl 0x88(%r15), %eax
movl %eax, 0x10(%rsp)
movups 0x78(%r15), %xmm0
movups %xmm0, (%rsp)
xorps %xmm0, %xmm0
xorps %xmm4, %xmm4
xorps %xmm5, %xmm5
movl $0x20000000, %edi       # imm = 0x20000000
callq 0x3fbea
callq 0x229d3
movl %ebp, %edi
movq 0x98(%rsp), %rsi
callq 0x229a3
cmpq $0x0, 0x90(%r15)
je 0x13575
movl $0x18, %r14d
xorl %r12d, %r12d
movq 0x98(%r15), %r13
movsd -0xc(%r13,%r14), %xmm0
movsd -0x4(%r13,%r14), %xmm1
movaps 0xd0(%rsp), %xmm2
movaps 0x40(%rsp), %xmm3
callq 0x321cf
testb %al, %al
je 0x13561
movss (%r13,%r14), %xmm0
mulss 0xb4(%rsp), %xmm0
ucomiss 0x51b09(%rip), %xmm0    # 0x65028
jbe 0x13561
movq -0x18(%r13,%r14), %rdi
movsd -0xc(%r13,%r14), %xmm0
movss -0x10(%r13,%r14), %xmm1
movups 0x68(%rsp), %xmm2
movups 0x78(%rsp), %xmm3
movups 0x88(%rsp), %xmm4
movups %xmm4, 0x20(%rsp)
movups %xmm3, 0x10(%rsp)
movups %xmm2, (%rsp)
xorps %xmm2, %xmm2
movl $0x80000000, %esi       # imm = 0x80000000
callq 0x4e092
incq %r12
addq $0x20, %r14
cmpq 0x90(%r15), %r12
jb 0x134dd
callq 0x229d3
incq %rbx
cmpq 0xb8(%rsp), %rbx
jb 0x133b4
callq 0x1f3b5
movl 0x148(%rsp), %edi
movl %edi, 0x40(%rsp)
leaq 0x925fe(%rip), %rax     # 0xa5ba0
callq *(%rax)
leaq 0x1c0(%rsp), %rdi
callq 0x22c66
leaq 0x180(%rsp), %rdi
callq 0x22c06
movaps 0x1c0(%rsp), %xmm3
movaps 0x1d0(%rsp), %xmm2
movaps 0x1e0(%rsp), %xmm4
movss 0x194(%rsp), %xmm0
movhps 0x184(%rsp), %xmm0      # xmm0 = xmm0[0,1],mem[0,1]
movss 0x1a4(%rsp), %xmm1
movss 0x1b4(%rsp), %xmm5
movlhps %xmm1, %xmm5            # xmm5 = xmm5[0],xmm1[0]
shufps $0x22, %xmm5, %xmm0     # xmm0 = xmm0[2,0],xmm5[2,0]
movss 0x1a0(%rsp), %xmm1
movss 0x1b0(%rsp), %xmm5
movlhps %xmm1, %xmm5            # xmm5 = xmm5[0],xmm1[0]
movss 0x190(%rsp), %xmm1
shufps $0x0, %xmm2, %xmm2      # xmm2 = xmm2[0,0,0,0]
mulps %xmm0, %xmm2
shufps $0x0, %xmm3, %xmm3      # xmm3 = xmm3[0,0,0,0]
unpcklpd 0x180(%rsp), %xmm1      # xmm1 = xmm1[0],mem[0]
shufps $0x22, %xmm5, %xmm1     # xmm1 = xmm1[2,0],xmm5[2,0]
mulps %xmm1, %xmm3
addps %xmm2, %xmm3
movss 0x1a8(%rsp), %xmm2
movss 0x1b8(%rsp), %xmm5
movlhps %xmm2, %xmm5            # xmm5 = xmm5[0],xmm2[0]
movss 0x198(%rsp), %xmm2
shufps $0x0, %xmm4, %xmm4      # xmm4 = xmm4[0,0,0,0]
movhps 0x188(%rsp), %xmm2      # xmm2 = xmm2[0,1],mem[0,1]
shufps $0x22, %xmm5, %xmm2     # xmm2 = xmm2[2,0],xmm5[2,0]
mulps %xmm2, %xmm4
addps %xmm3, %xmm4
movss 0x1ac(%rsp), %xmm3
movss 0x1bc(%rsp), %xmm5
movlhps %xmm3, %xmm5            # xmm5 = xmm5[0],xmm3[0]
movss 0x19c(%rsp), %xmm3
movhps 0x18c(%rsp), %xmm3      # xmm3 = xmm3[0,1],mem[0,1]
shufps $0x22, %xmm5, %xmm3     # xmm3 = xmm3[2,0],xmm5[2,0]
movaps 0x1f0(%rsp), %xmm5
shufps $0x0, %xmm5, %xmm5      # xmm5 = xmm5[0,0,0,0]
mulps %xmm3, %xmm5
addps %xmm4, %xmm5
movups 0x1c4(%rsp), %xmm4
movq 0x150(%rsp), %rax
movq %rax, 0xd0(%rsp)
movl 0x18(%rax), %edi
movaps %xmm5, 0x260(%rsp)
movups 0x1d4(%rsp), %xmm5
shufps $0x0, %xmm5, %xmm5      # xmm5 = xmm5[0,0,0,0]
mulps %xmm0, %xmm5
shufps $0x0, %xmm4, %xmm4      # xmm4 = xmm4[0,0,0,0]
mulps %xmm1, %xmm4
addps %xmm5, %xmm4
movups 0x1e4(%rsp), %xmm5
shufps $0x0, %xmm5, %xmm5      # xmm5 = xmm5[0,0,0,0]
mulps %xmm2, %xmm5
addps %xmm4, %xmm5
movss 0x1f4(%rsp), %xmm4
shufps $0x0, %xmm4, %xmm4      # xmm4 = xmm4[0,0,0,0]
mulps %xmm3, %xmm4
addps %xmm5, %xmm4
movups 0x1c8(%rsp), %xmm5
movaps %xmm4, 0x270(%rsp)
movups 0x1d8(%rsp), %xmm4
shufps $0x0, %xmm4, %xmm4      # xmm4 = xmm4[0,0,0,0]
mulps %xmm0, %xmm4
shufps $0x0, %xmm5, %xmm5      # xmm5 = xmm5[0,0,0,0]
mulps %xmm1, %xmm5
addps %xmm4, %xmm5
movups 0x1e8(%rsp), %xmm4
shufps $0x0, %xmm4, %xmm4      # xmm4 = xmm4[0,0,0,0]
mulps %xmm2, %xmm4
addps %xmm5, %xmm4
movss 0x1f8(%rsp), %xmm5
shufps $0x0, %xmm5, %xmm5      # xmm5 = xmm5[0,0,0,0]
mulps %xmm3, %xmm5
addps %xmm4, %xmm5
movaps %xmm5, 0x280(%rsp)
movups 0x1dc(%rsp), %xmm4
shufps $0x0, %xmm4, %xmm4      # xmm4 = xmm4[0,0,0,0]
mulps %xmm0, %xmm4
movups 0x1cc(%rsp), %xmm0
shufps $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0]
mulps %xmm1, %xmm0
addps %xmm4, %xmm0
movups 0x1ec(%rsp), %xmm1
shufps $0x0, %xmm1, %xmm1      # xmm1 = xmm1[0,0,0,0]
mulps %xmm2, %xmm1
addps %xmm0, %xmm1
movss 0x1fc(%rsp), %xmm0
shufps $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0]
mulps %xmm3, %xmm0
addps %xmm1, %xmm0
movaps %xmm0, 0x290(%rsp)
leaq 0x92598(%rip), %rax     # 0xa5d50
movq (%rax), %rax
movl $0x1, %esi
xorl %edx, %edx
leaq 0x260(%rsp), %rcx
callq *%rax
movl 0x15c(%rsp), %edi
movl 0x160(%rsp), %esi
leaq 0x960d7(%rip), %rax     # 0xa98b8
callq *(%rax)
movq 0x138(%rsp), %rbx
testq %rbx, %rbx
je 0x138a0
movq 0x130(%rsp), %r14
movq 0x140(%rsp), %r12
movl 0x158(%rsp), %r15d
addq $0x14, %r14
xorl %r13d, %r13d
cmpq $-0x1, %r12
setne %al
cmpq %r13, %r12
setne %cl
testb %cl, %al
jne 0x13890
movzbl -0x2(%r14), %eax
shll $0x10, %eax
movzwl -0x4(%r14), %ecx
leal (%rcx,%rax), %edi
addl $0x40000000, %edi       # imm = 0x40000000
callq 0x4115c
movlhps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
movups %xmm0, 0x240(%rsp)
movl 0x40(%rsp), %edi
movq 0xd0(%rsp), %rsi
movl %r15d, %edx
leaq 0x240(%rsp), %rcx
movl $0x3, %r8d
callq 0x22ab7
movl (%r14), %edi
leaq 0x9247a(%rip), %rbp     # 0xa5cf0
callq *(%rbp)
xorl %edi, %edi
xorl %esi, %esi
movl $0x7d0, %edx            # imm = 0x7D0
leaq 0x924d7(%rip), %rax     # 0xa5d60
callq *(%rax)
xorl %edi, %edi
callq *(%rbp)
incq %r13
addq $0x20, %r14
cmpq %r13, %rbx
jne 0x13813
xorl %edi, %edi
leaq 0x922f7(%rip), %rax     # 0xa5ba0
callq *(%rax)
callq 0x29382
xorl %edi, %edi
xorl %esi, %esi
movq 0x210(%rsp), %r14
movl %r14d, %edx
movl $0x14, %ecx
movl $0xfff5f5f5, %r8d       # imm = 0xFFF5F5F5
callq 0x2e4dc
movq 0x208(%rsp), %r12
testq %r12, %r12
je 0x13ada
movq 0x8(%r12), %rax
subq (%r12), %rax
movq %rax, %xmm1
punpckldq 0x5197a(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x51982(%rip), %xmm1    # 0x65280
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
movapd %xmm0, 0x40(%rsp)
callq 0x6660
divsd 0x51a63(%rip), %xmm0    # 0x65380
callq 0x6710
cvttsd2si %xmm0, %rax
movq %rax, %rcx
subsd 0x51a56(%rip), %xmm0    # 0x65388
cvttsd2si %xmm0, %rdx
sarq $0x3f, %rcx
andq %rcx, %rdx
orq %rax, %rdx
cmpq $0x8, %rdx
movl $0x8, %eax
cmovaeq %rax, %rdx
movl %edx, %eax
leaq 0x8eb49(%rip), %rcx     # 0xa24a0
movq (%rcx,%rax,8), %r15
addl %edx, %edx
leal (%rdx,%rdx,4), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
callq 0x6430
movapd 0x40(%rsp), %xmm1
divsd %xmm0, %xmm1
leaq 0x51b9c(%rip), %rdi     # 0x65519
movapd %xmm1, %xmm0
movq %r15, %rsi
movb $0x1, %al
callq 0x4dfb7
xorps %xmm1, %xmm1
cvtsi2ssl 0xf8(%rsp), %xmm1
movups 0xf8(%rsp), %xmm0
movups 0x108(%rsp), %xmm2
movups 0x118(%rsp), %xmm3
movups %xmm3, 0x20(%rsp)
movups %xmm2, 0x10(%rsp)
movups %xmm0, (%rsp)
xorps %xmm2, %xmm2
movq %rax, %rdi
movsd 0x518c5(%rip), %xmm0    # 0x65290
movl $0xff000000, %esi       # imm = 0xFF000000
callq 0x4e092
movq (%r12), %rsi
movq 0x8(%r12), %rdx
leaq 0x51b43(%rip), %rdi     # 0x65528
xorl %eax, %eax
callq 0x4dfb7
xorps %xmm1, %xmm1
cvtsi2ssl 0xf8(%rsp), %xmm1
movups 0xf8(%rsp), %xmm0
movups 0x108(%rsp), %xmm2
movups 0x118(%rsp), %xmm3
movups %xmm3, 0x20(%rsp)
movups %xmm2, 0x10(%rsp)
movups %xmm0, (%rsp)
xorps %xmm2, %xmm2
movq %rax, %rdi
movsd 0x51874(%rip), %xmm0    # 0x652a0
movl $0xff000000, %esi       # imm = 0xFF000000
callq 0x4e092
cmpb $0x0, 0x10(%r12)
jne 0x13ada
movq 0x18(%r12), %rdi
xorps %xmm1, %xmm1
cvtsi2ssl 0xf8(%rsp), %xmm1
movups 0xf8(%rsp), %xmm0
movups 0x108(%rsp), %xmm2
movups 0x118(%rsp), %xmm3
movups %xmm3, 0x20(%rsp)
movups %xmm2, 0x10(%rsp)
movups %xmm0, (%rsp)
xorps %xmm2, %xmm2
movsd 0x5182c(%rip), %xmm0    # 0x652b0
movl $0xff000000, %esi       # imm = 0xFF000000
callq 0x4e092
movq 0x20(%r12), %rdi
xorps %xmm1, %xmm1
cvtsi2ssl 0xf8(%rsp), %xmm1
movups 0xf8(%rsp), %xmm0
movups 0x108(%rsp), %xmm2
movups 0x118(%rsp), %xmm3
movups %xmm3, 0x20(%rsp)
movups %xmm2, 0x10(%rsp)
movups %xmm0, (%rsp)
xorps %xmm2, %xmm2
movsd 0x517f0(%rip), %xmm0    # 0x652c0
movl $0xff000000, %esi       # imm = 0xFF000000
callq 0x4e092
leal -0xc8(%r14), %ebp
movaps 0x517e8(%rip), %xmm0    # 0x652d0
cvtsi2ss %ebp, %xmm0
movl $0x0, 0x9075a(%rip)     # 0xa4250
movaps 0x517e3(%rip), %xmm1    # 0x652e0
unpcklps 0x230(%rsp), %xmm1      # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
callq 0x7b3f
testq %rbx, %rbx
jle 0x13c73
xorps %xmm2, %xmm2
cvtsi2ss %ebp, %xmm2
movss 0x51556(%rip), %xmm1    # 0x65078
addss %xmm1, %xmm2
movaps %xmm2, %xmm0
addss 0x5154b(%rip), %xmm0    # 0x6507c
cvttss2si %xmm0, %ebp
movq 0x130(%rsp), %r12
movq 0x140(%rsp), %r15
addss 0x514c3(%rip), %xmm2    # 0x65010
movaps %xmm2, 0xd0(%rsp)
xorl %r13d, %r13d
cmpq $-0x1, %r15
setne %al
cmpq %r15, %r13
setne %cl
movss %xmm1, 0x64(%rsp)
movaps %xmm1, %xmm0
addss 0x514ae(%rip), %xmm0    # 0x65024
movaps %xmm0, 0x40(%rsp)
addss 0x514fd(%rip), %xmm0    # 0x65080
testb %cl, %al
jne 0x13b98
movl $0x0, 0x906bf(%rip)     # 0xa4250
movl 0x10(%r12), %edx
jmp 0x13ba7
movl $0x3, 0x906ae(%rip)     # 0xa4250
movl $0xffc8c8c8, %edx       # imm = 0xFFC8C8C8
cvttss2si %xmm0, %esi
movl %ebp, %edi
movss 0x514c7(%rip), %xmm0    # 0x6507c
callq 0x2ca9e
cmpb $0x0, 0x1c(%r12)
movl (%r12), %esi
leaq 0x5a559(%rip), %rdx     # 0x6e124
leaq 0x5197c(%rip), %rax     # 0x6554e
cmovneq %rax, %rdx
leaq 0x51967(%rip), %rdi     # 0x65544
xorl %eax, %eax
callq 0x4dfb7
movaps 0x40(%rsp), %xmm0
movaps 0xd0(%rsp), %xmm1
movlhps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
shufps $0xe2, %xmm1, %xmm0     # xmm0 = xmm0[2,0],xmm1[2,3]
movsd 0x516f0(%rip), %xmm1    # 0x652f0
movq %rax, %rdi
callq 0xa912
cmpq %r15, %r13
movq %r13, %rcx
movq $-0x1, %rdx
cmoveq %rdx, %rcx
testb %al, %al
cmovneq %rcx, %r15
movaps 0x40(%rsp), %xmm0
addss 0x51458(%rip), %xmm0    # 0x65084
movq 0x8(%r12), %rdi
movaps 0xd0(%rsp), %xmm1
movlhps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
shufps $0xe2, %xmm1, %xmm0     # xmm0 = xmm0[2,0],xmm1[2,3]
movsd 0x516a8(%rip), %xmm1    # 0x652f0
callq 0x8278
movss 0x64(%rsp), %xmm1
addss 0x5142d(%rip), %xmm1    # 0x65088
incq %r13
addq $0x20, %r12
cmpq %r13, %rbx
jne 0x13b58
movq %r15, 0x140(%rsp)
callq 0x28919
callq 0x27c20
testb %al, %al
movl 0x5c(%rsp), %ebx
je 0x12cc1
jmp 0x12bb2
movl 0x40(%r15), %r12d
jmp 0x12f15
movq %r12, %rdi
callq 0x6840
jmp 0x12c83
movq %r12, %rdi
callq 0x685e
jmp 0x12c83