// File: fiveseven-lambda[P]michaelis-menten/a.cpp
// Function: main
int main(){
	display = XOpenDisplay(NULL);
	if(display == NULL){
		fputs("error: cannot connect to X server\n", stderr);
		return -1;
	}
	int screen = XDefaultScreen(display);
	Window root = XRootWindow(display, screen);
	width = XDisplayWidth(display, screen);
	height = XDisplayHeight(display, screen);
	unsigned long black = XBlackPixel(display, screen), white = XWhitePixel(display, screen);

	window = XCreateSimpleWindow(display, root, 0, 0, width, height, 1, black, white);

	int depth = XDefaultDepth(display, screen);
	buffer = XCreatePixmap(display, window, width, height, depth);

	XGCValues gcValues;
	gcValues.foreground = black;
	winBlackGC = XCreateGC(display, window, GCForeground, &gcValues);
	bufBlackGC = XCreateGC(display, buffer, GCForeground, &gcValues);
	gcValues.foreground = white;
	winWhiteGC = XCreateGC(display, window, GCForeground, &gcValues);
	bufWhiteGC = XCreateGC(display, buffer, GCForeground, &gcValues);

	constexpr long set_mask = ExposureMask | StructureNotifyMask | KeyPressMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask;
	constexpr long run_mask = StructureNotifyMask | KeyPressMask;

	XSelectInput(display, window, set_mask);
	XMapWindow(display, window);

set:
	for(;;){
		XEvent event;
		XNextEvent(display, &event);
		switch(event.type){
			case Expose:
				XCopyArea(
					display, buffer, window, winBlackGC,
					event.xexpose.x, event.xexpose.y, event.xexpose.width, event.xexpose.height, event.xexpose.x, event.xexpose.y
				);
				continue;
			case ConfigureNotify:
				width = event.xconfigure.width;
				height = event.xconfigure.height;
				XFreePixmap(display, buffer);
				buffer = XCreatePixmap(display, window, width, height, depth);
				break;
			case DestroyNotify:
				XFreeGC(display, winBlackGC);
				XFreeGC(display, winWhiteGC);
				XFreeGC(display, bufBlackGC);
				XFreeGC(display, bufWhiteGC);
				XFreePixmap(display, buffer);
				XCloseDisplay(display);
				return 0;
			case ButtonPress:
				switch(event.xbutton.button){
					case Button1:
						object::node::find(Vector<short>(event.xbutton.x, event.xbutton.y));
						if(object::node::focused == object::node::nodes.size()){
							object::edge::find(Vector<short>(event.xbutton.x, event.xbutton.y));
							if(object::edge::focused < object::edge::edges.size()){
								object::edge::drawing::from = -1;
								object::edge::drawing::from_edge = object::edge::focused;
								object::edge::drawing::points.push_back(XPoint(event.xbutton.x, event.xbutton.y));
							}
						}else{
							object::edge::drawing::from = object::node::focused;
							object::edge::drawing::points.push_back(XPoint(event.xbutton.x, event.xbutton.y));
						}
						break;
					case Button3:
						object::node::find(Vector<short>(event.xbutton.x, event.xbutton.y));
						if(object::node::focused == object::node::nodes.size()){
							object::node::nodes.push_back(object::node::Node(
								.001,
								Vector<double>(
									static_cast<double>(event.xbutton.x) / width,
									static_cast<double>(event.xbutton.y) / height
								)
							));
							object::node::origin.x = object::node::origin.y = 0;
						}else{
							Arc arc = object::node::nodes[object::node::focused].arc();
							object::node::origin.x = arc.x - event.xbutton.x;
							object::node::origin.y = arc.y - event.xbutton.y;
						}
						object::node::moving = true;
						break;
					case Button4:
						if(object::node::focused < object::node::nodes.size()){
							object::node::nodes[object::node::focused].am += .0001;
						}else if(object::edge::focused < object::edge::edges.size()){
							object::edge::edges[object::edge::focused].k += .0001;
						}
						break;
					case Button5:
						if(object::node::focused < object::node::nodes.size()){
							object::node::nodes[object::node::focused].am -= .0001;
							if(object::node::nodes[object::node::focused].am < 0){
								object::node::nodes[object::node::focused].am = 0;
							}
						}else if(object::edge::focused < object::edge::edges.size()){
							object::edge::edges[object::edge::focused].k -= .0001;
							if(object::edge::edges[object::edge::focused].k < 0){
								object::edge::edges[object::edge::focused].k = 0;
							}
						}
				}
				break;
			case ButtonRelease:
				if(object::node::moving){
					object::node::moving = false;
				}else if(!object::edge::drawing::points.empty()){
					object::node::find(Vector<short>(event.xbutton.x, event.xbutton.y));
					if(object::node::focused == object::node::nodes.size()){
						object::edge::find(Vector<short>(event.xbutton.x, event.xbutton.y));
						if(object::edge::focused < object::edge::edges.size()){
							if(object::edge::drawing::from != -1){
								object::edge::edges[object::edge::focused].from.push_back(object::edge::drawing::from);
							}
						}
					}else{
						if(object::edge::drawing::from == -1){
							object::edge::edges[object::edge::drawing::from_edge].to.push_back(object::node::focused);
						}else if(object::edge::drawing::from != object::node::focused){
							std::size_t i = std::distance(
								object::edge::drawing::len.begin(),
								std::lower_bound(object::edge::drawing::len.begin(), object::edge::drawing::len.end(),
								object::edge::drawing::len.back() / 2)
							);
							Vector<double> line =
								object::node::nodes[object::node::focused].p - object::node::nodes[object::edge::drawing::from].p;
							line *= .2;
							Vector<double> mid(
								static_cast<double>(object::edge::drawing::points[i].x) / width,
								static_cast<double>(object::edge::drawing::points[i].y) / height
							);
							object::edge::focused = object::edge::edges.size();
							object::edge::edges.push_back(
								object::edge::Edge(
									object::edge::drawing::from, object::node::focused, .001, mid, mid - line, mid + line
								)
							);
							object::node::focused = object::node::nodes.size();
						}
					}
					object::edge::drawing::points.clear();
					object::edge::drawing::len.clear();
				}
				break;
			case MotionNotify:
				if(object::node::moving){
					object::node::nodes[object::node::focused].p = Vector<double>(
						static_cast<double>(object::node::origin.x + event.xmotion.x) / width,
						static_cast<double>(object::node::origin.y + event.xmotion.y) / height
					);
				}else if(!object::edge::drawing::points.empty()){
					double x = object::edge::drawing::points.back().x;
					double y = object::edge::drawing::points.back().y;
					object::edge::drawing::points.push_back(XPoint{static_cast<short>(event.xmotion.x), static_cast<short>(event.xmotion.y)});
					double prev = object::edge::drawing::len.empty() ? 0 : object::edge::drawing::len.back();
					object::edge::drawing::len.push_back(prev + hypot(x - event.xmotion.x, y - event.xmotion.y));
				}
				break;
			case KeyPress:
				switch(XLookupKeysym(&event.xkey, 0)){
					case XK_Return:
						XSelectInput(display, window, run_mask);
						goto run;
				}
			default:
				continue;
		}
		object::draw_all();
	}
run:
	for(object::node::Node &i : object::node::nodes) i.am_set = i.am;
	for(;;){
		if(XPending(display)){
			XEvent event;
			XNextEvent(display, &event);
			switch(event.type){
				case DestroyNotify:
					XFreeGC(display, winBlackGC);
					XFreeGC(display, winWhiteGC);
					XFreeGC(display, bufBlackGC);
					XFreeGC(display, bufWhiteGC);
					XFreePixmap(display, buffer);
					return 0;
				case ConfigureNotify:
					width = event.xconfigure.width;
					height = event.xconfigure.height;
					break;
				case KeyPress:
					switch(XLookupKeysym(&event.xkey, 0)){
						case XK_Return:
							for(object::node::Node &i : object::node::nodes) i.am = i.am_set;
							XSelectInput(display, window, set_mask);
							XCopyArea(display, buffer, window, winBlackGC, 0, 0, width, height, 0, 0);
							object::draw_all();
							XFlush(display);
							goto set;
					}
			}
		}else{
			for(object::edge::Edge &i : object::edge::edges){
				double tmp = i.k / object::scale;
				for(std::size_t j : i.from) tmp *= object::node::nodes[j].am * object::scale;
				for(std::size_t j : i.from) object::node::nodes[j].am -= tmp;
				for(std::size_t j : i.to) object::node::nodes[j].am += tmp;
			}
			for(std::size_t i = 0; i < object::node::nodes.size(); ++i){
				printf("%f%c", object::node::nodes[i].am, ",\n"[i == object::node::nodes.size() - 1]);
			}
			object::draw_all();
			XFlush(display);
			usleep(1000);
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x618, %rsp            # imm = 0x618
movl $0x0, -0xc(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0x2210
movq %rax, 0xc5b5(%rip)      # 0x10198
cmpq $0x0, 0xc5ad(%rip)      # 0x10198
jne 0x3c0f
movq 0xc3ec(%rip), %rax      # 0xffe0
movq (%rax), %rsi
leaq 0x74a2(%rip), %rdi      # 0xb0a0
callq 0x21e0
movl $0xffffffff, -0xc(%rbp) # imm = 0xFFFFFFFF
jmp 0x50ef
movq 0xc582(%rip), %rdi      # 0x10198
callq 0x2130
movl %eax, -0x10(%rbp)
movq 0xc573(%rip), %rdi      # 0x10198
movl -0x10(%rbp), %esi
callq 0x2270
movq %rax, -0x18(%rbp)
movq 0xc560(%rip), %rdi      # 0x10198
movl -0x10(%rbp), %esi
callq 0x2280
movl %eax, 0xc56a(%rip)      # 0x101b0
movq 0xc54b(%rip), %rdi      # 0x10198
movl -0x10(%rbp), %esi
callq 0x2040
movl %eax, 0xc559(%rip)      # 0x101b4
movq 0xc536(%rip), %rdi      # 0x10198
movl -0x10(%rbp), %esi
callq 0x2260
movq %rax, -0x20(%rbp)
movq 0xc523(%rip), %rdi      # 0x10198
movl -0x10(%rbp), %esi
callq 0x2200
movq %rax, -0x28(%rbp)
movq 0xc510(%rip), %rdi      # 0x10198
movq -0x18(%rbp), %rsi
movl 0xc51d(%rip), %r8d      # 0x101b0
movl 0xc51a(%rip), %r9d      # 0x101b4
movq -0x20(%rbp), %r10
movq -0x28(%rbp), %rax
xorl %ecx, %ecx
movl %ecx, %edx
movl $0x1, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x2090
movq %rax, 0xc4dd(%rip)      # 0x101a0
movq 0xc4ce(%rip), %rdi      # 0x10198
movl -0x10(%rbp), %esi
callq 0x2070
movl %eax, -0x2c(%rbp)
movq 0xc4bc(%rip), %rdi      # 0x10198
movq 0xc4bd(%rip), %rsi      # 0x101a0
movl 0xc4c7(%rip), %edx      # 0x101b0
movl 0xc4c5(%rip), %ecx      # 0x101b4
movl -0x2c(%rbp), %r8d
callq 0x2050
movq %rax, 0xc4a9(%rip)      # 0x101a8
movq -0x20(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq 0xc487(%rip), %rdi      # 0x10198
movq 0xc488(%rip), %rsi      # 0x101a0
movl $0x4, %edx
leaq -0xb0(%rbp), %rcx
callq 0x20f0
movq %rax, 0xc488(%rip)      # 0x101b8
movq 0xc461(%rip), %rdi      # 0x10198
movq 0xc46a(%rip), %rsi      # 0x101a8
movl $0x4, %edx
leaq -0xb0(%rbp), %rcx
callq 0x20f0
movq %rax, 0xc472(%rip)      # 0x101c8
movq -0x28(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq 0xc430(%rip), %rdi      # 0x10198
movq 0xc431(%rip), %rsi      # 0x101a0
movl $0x4, %edx
leaq -0xb0(%rbp), %rcx
callq 0x20f0
movq %rax, 0xc439(%rip)      # 0x101c0
movq 0xc40a(%rip), %rdi      # 0x10198
movq 0xc413(%rip), %rsi      # 0x101a8
movl $0x4, %edx
leaq -0xb0(%rbp), %rcx
callq 0x20f0
movq %rax, 0xc423(%rip)      # 0x101d0
movq $0x2804d, -0xb8(%rbp) # imm = 0x2804D
movq $0x20001, -0xc0(%rbp) # imm = 0x20001
movq 0xc3ce(%rip), %rdi      # 0x10198
movq 0xc3cf(%rip), %rsi      # 0x101a0
movl $0x2804d, %edx          # imm = 0x2804D
callq 0x2140
movq 0xc3b6(%rip), %rdi      # 0x10198
movq 0xc3b7(%rip), %rsi      # 0x101a0
callq 0x21d0
jmp 0x3df0
movq 0xc3a1(%rip), %rdi      # 0x10198
leaq -0x180(%rbp), %rsi
callq 0x2230
movl -0x180(%rbp), %eax
addl $-0x2, %eax
movl %eax, %ecx
movq %rcx, -0x520(%rbp)
subl $0x14, %eax
ja 0x4ae1
movq -0x520(%rbp), %rax
leaq 0x720c(%rip), %rcx      # 0xb038
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0xc35c(%rip), %rdi      # 0x10198
movq 0xc365(%rip), %rsi      # 0x101a8
movq 0xc356(%rip), %rdx      # 0x101a0
movq 0xc367(%rip), %rcx      # 0x101b8
movl -0x158(%rbp), %r8d
movl -0x154(%rbp), %r9d
movl -0x150(%rbp), %ebx
movl -0x14c(%rbp), %r11d
movl -0x158(%rbp), %r10d
movl -0x154(%rbp), %eax
movl %ebx, (%rsp)
movl %r11d, 0x8(%rsp)
movl %r10d, 0x10(%rsp)
movl %eax, 0x18(%rsp)
callq 0x20c0
jmp 0x3df0
movl -0x148(%rbp), %eax
movl %eax, 0xc310(%rip)      # 0x101b0
movl -0x144(%rbp), %eax
movl %eax, 0xc308(%rip)      # 0x101b4
movq 0xc2e5(%rip), %rdi      # 0x10198
movq 0xc2ee(%rip), %rsi      # 0x101a8
callq 0x22b0
movq 0xc2d2(%rip), %rdi      # 0x10198
movq 0xc2d3(%rip), %rsi      # 0x101a0
movl 0xc2dd(%rip), %edx      # 0x101b0
movl 0xc2db(%rip), %ecx      # 0x101b4
movl -0x2c(%rbp), %r8d
callq 0x2050
movq %rax, 0xc2bf(%rip)      # 0x101a8
jmp 0x4ae6
movq 0xc2a3(%rip), %rdi      # 0x10198
movq 0xc2bc(%rip), %rsi      # 0x101b8
callq 0x2120
movq 0xc290(%rip), %rdi      # 0x10198
movq 0xc2b1(%rip), %rsi      # 0x101c0
callq 0x2120
movq 0xc27d(%rip), %rdi      # 0x10198
movq 0xc2a6(%rip), %rsi      # 0x101c8
callq 0x2120
movq 0xc26a(%rip), %rdi      # 0x10198
movq 0xc29b(%rip), %rsi      # 0x101d0
callq 0x2120
movq 0xc257(%rip), %rdi      # 0x10198
movq 0xc260(%rip), %rsi      # 0x101a8
callq 0x22b0
movq 0xc244(%rip), %rdi      # 0x10198
callq 0x22d0
movl $0x0, -0xc(%rbp)
jmp 0x50ef
movl -0x12c(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x528(%rbp)
subl $0x4, %eax
ja 0x4424
movq -0x528(%rbp), %rax
leaq 0x70ff(%rip), %rcx      # 0xb08c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl -0x140(%rbp), %eax
movw %ax, -0x186(%rbp)
movl -0x13c(%rbp), %eax
movw %ax, -0x188(%rbp)
leaq -0x184(%rbp), %rdi
leaq -0x186(%rbp), %rsi
leaq -0x188(%rbp), %rdx
callq 0x5af0
leaq -0x184(%rbp), %rdi
callq 0x2d10
movq 0xc213(%rip), %rax      # 0x101f0
movq %rax, -0x530(%rbp)
leaq 0xc1ed(%rip), %rdi      # 0x101d8
callq 0x5590
movq %rax, %rcx
movq -0x530(%rbp), %rax
cmpq %rcx, %rax
jne 0x40b4
movl -0x140(%rbp), %eax
movw %ax, -0x18e(%rbp)
movl -0x13c(%rbp), %eax
movw %ax, -0x190(%rbp)
leaq -0x18c(%rbp), %rdi
leaq -0x18e(%rbp), %rsi
leaq -0x190(%rbp), %rdx
callq 0x5af0
leaq -0x18c(%rbp), %rdi
callq 0x2e50
movq 0xc1ce(%rip), %rax      # 0x10218
movq %rax, -0x538(%rbp)
leaq 0xc1a8(%rip), %rdi      # 0x10200
callq 0x5670
movq %rax, %rcx
movq -0x538(%rbp), %rax
cmpq %rcx, %rax
jae 0x40b2
movq $-0x1, 0xc1a9(%rip) # 0x10220
movq 0xc19a(%rip), %rax      # 0x10218
movq %rax, 0xc1a3(%rip)      # 0x10228
movl -0x140(%rbp), %eax
movw %ax, -0x194(%rbp)
movl -0x13c(%rbp), %eax
movw %ax, -0x192(%rbp)
leaq 0xc18a(%rip), %rdi      # 0x10230
leaq -0x194(%rbp), %rsi
callq 0x5b20
jmp 0x40ef
movq 0xc135(%rip), %rax      # 0x101f0
movq %rax, 0xc15e(%rip)      # 0x10220
movl -0x140(%rbp), %eax
movw %ax, -0x198(%rbp)
movl -0x13c(%rbp), %eax
movw %ax, -0x196(%rbp)
leaq 0xc14d(%rip), %rdi      # 0x10230
leaq -0x198(%rbp), %rsi
callq 0x5b20
jmp 0x4424
movl -0x140(%rbp), %eax
movw %ax, -0x19e(%rbp)
movl -0x13c(%rbp), %eax
movw %ax, -0x1a0(%rbp)
leaq -0x19c(%rbp), %rdi
leaq -0x19e(%rbp), %rsi
leaq -0x1a0(%rbp), %rdx
callq 0x5af0
leaq -0x19c(%rbp), %rdi
callq 0x2d10
movq 0xc0b5(%rip), %rax      # 0x101f0
movq %rax, -0x540(%rbp)
leaq 0xc08f(%rip), %rdi      # 0x101d8
callq 0x5590
movq %rax, %rcx
movq -0x540(%rbp), %rax
cmpq %rcx, %rax
jne 0x4204
movsd 0x6ebf(%rip), %xmm0     # 0xb028
movsd %xmm0, -0x1c8(%rbp)
cvtsi2sdl -0x140(%rbp), %xmm0
cvtsi2sdl 0xc02f(%rip), %xmm1 # 0x101b0
divsd %xmm1, %xmm0
movsd %xmm0, -0x1e0(%rbp)
cvtsi2sdl -0x13c(%rbp), %xmm0
cvtsi2sdl 0xc017(%rip), %xmm1 # 0x101b4
divsd %xmm1, %xmm0
movsd %xmm0, -0x1e8(%rbp)
leaq -0x1d8(%rbp), %rdi
leaq -0x1e0(%rbp), %rsi
leaq -0x1e8(%rbp), %rdx
callq 0x5b80
leaq -0x1c0(%rbp), %rdi
leaq -0x1c8(%rbp), %rsi
leaq -0x1d8(%rbp), %rdx
callq 0x5bb0
leaq 0xbff4(%rip), %rdi      # 0x101d8
leaq -0x1c0(%rbp), %rsi
callq 0x5b50
movw $0x0, 0xc003(%rip)      # 0x101fc
movw $0x0, 0xbff8(%rip)      # 0x101fa
jmp 0x425a
movq 0xbfe5(%rip), %rsi      # 0x101f0
leaq 0xbfc6(%rip), %rdi      # 0x101d8
callq 0x55c0
movq %rax, %rdi
callq 0x55e0
movl %eax, %ecx
movl %ecx, -0x1ee(%rbp)
shrq $0x20, %rax
movw %ax, -0x1ea(%rbp)
movswl -0x1ee(%rbp), %eax
subl -0x140(%rbp), %eax
movw %ax, 0xbfb4(%rip)       # 0x101fa
movswl -0x1ec(%rbp), %eax
subl -0x13c(%rbp), %eax
movw %ax, 0xbfa2(%rip)       # 0x101fc
movb $0x1, 0xbf97(%rip)      # 0x101f8
jmp 0x4424
movq 0xbf83(%rip), %rax      # 0x101f0
movq %rax, -0x548(%rbp)
leaq 0xbf5d(%rip), %rdi      # 0x101d8
callq 0x5590
movq %rax, %rcx
movq -0x548(%rbp), %rax
cmpq %rcx, %rax
jae 0x42b4
movq 0xbf5a(%rip), %rsi      # 0x101f0
leaq 0xbf3b(%rip), %rdi      # 0x101d8
callq 0x55c0
movsd 0x6d86(%rip), %xmm0     # 0xb030
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
jmp 0x4304
movq 0xbf5d(%rip), %rax      # 0x10218
movq %rax, -0x550(%rbp)
leaq 0xbf37(%rip), %rdi      # 0x10200
callq 0x5670
movq %rax, %rcx
movq -0x550(%rbp), %rax
cmpq %rcx, %rax
jae 0x4302
movq 0xbf34(%rip), %rsi      # 0x10218
leaq 0xbf15(%rip), %rdi      # 0x10200
callq 0x56a0
movsd 0x6d38(%rip), %xmm0     # 0xb030
addsd 0x30(%rax), %xmm0
movsd %xmm0, 0x30(%rax)
jmp 0x4304
jmp 0x4424
movq 0xbee0(%rip), %rax      # 0x101f0
movq %rax, -0x558(%rbp)
leaq 0xbeba(%rip), %rdi      # 0x101d8
callq 0x5590
movq %rax, %rcx
movq -0x558(%rbp), %rax
cmpq %rcx, %rax
jae 0x4394
movq 0xbeb7(%rip), %rsi      # 0x101f0
leaq 0xbe98(%rip), %rdi      # 0x101d8
callq 0x55c0
movsd (%rax), %xmm0
movsd 0x6cdf(%rip), %xmm1     # 0xb030
subsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movq 0xbe90(%rip), %rsi      # 0x101f0
leaq 0xbe71(%rip), %rdi      # 0x101d8
callq 0x55c0
xorps %xmm0, %xmm0
ucomisd (%rax), %xmm0
jbe 0x438f
movq 0xbe74(%rip), %rsi      # 0x101f0
leaq 0xbe55(%rip), %rdi      # 0x101d8
callq 0x55c0
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
jmp 0x4422
movq 0xbe7d(%rip), %rax      # 0x10218
movq %rax, -0x560(%rbp)
leaq 0xbe57(%rip), %rdi      # 0x10200
callq 0x5670
movq %rax, %rcx
movq -0x560(%rbp), %rax
cmpq %rcx, %rax
jae 0x4420
movq 0xbe54(%rip), %rsi      # 0x10218
leaq 0xbe35(%rip), %rdi      # 0x10200
callq 0x56a0
movsd 0x30(%rax), %xmm0
movsd 0x6c53(%rip), %xmm1     # 0xb030
subsd %xmm1, %xmm0
movsd %xmm0, 0x30(%rax)
movq 0xbe2b(%rip), %rsi      # 0x10218
leaq 0xbe0c(%rip), %rdi      # 0x10200
callq 0x56a0
xorps %xmm0, %xmm0
ucomisd 0x30(%rax), %xmm0
jbe 0x441e
movq 0xbe0e(%rip), %rsi      # 0x10218
leaq 0xbdef(%rip), %rdi      # 0x10200
callq 0x56a0
xorps %xmm0, %xmm0
movsd %xmm0, 0x30(%rax)
jmp 0x4420
jmp 0x4422
jmp 0x4424
jmp 0x4ae6
testb $0x1, 0xbdc8(%rip)      # 0x101f8
je 0x443e
movb $0x0, 0xbdbf(%rip)      # 0x101f8
jmp 0x48d8
leaq 0xbdeb(%rip), %rdi      # 0x10230
callq 0x5ab0
testb $0x1, %al
jne 0x48d6
movl -0x140(%rbp), %eax
movw %ax, -0x1f4(%rbp)
movl -0x13c(%rbp), %eax
movw %ax, -0x1f6(%rbp)
leaq -0x1f2(%rbp), %rdi
leaq -0x1f4(%rbp), %rsi
leaq -0x1f6(%rbp), %rdx
callq 0x5af0
leaq -0x1f2(%rbp), %rdi
callq 0x2d10
movq 0xbd57(%rip), %rax      # 0x101f0
movq %rax, -0x568(%rbp)
leaq 0xbd31(%rip), %rdi      # 0x101d8
callq 0x5590
movq %rax, %rcx
movq -0x568(%rbp), %rax
cmpq %rcx, %rax
jne 0x455b
movl -0x140(%rbp), %eax
movw %ax, -0x1fc(%rbp)
movl -0x13c(%rbp), %eax
movw %ax, -0x1fe(%rbp)
leaq -0x1fa(%rbp), %rdi
leaq -0x1fc(%rbp), %rsi
leaq -0x1fe(%rbp), %rdx
callq 0x5af0
leaq -0x1fa(%rbp), %rdi
callq 0x2e50
movq 0xbd12(%rip), %rax      # 0x10218
movq %rax, -0x570(%rbp)
leaq 0xbcec(%rip), %rdi      # 0x10200
callq 0x5670
movq %rax, %rcx
movq -0x570(%rbp), %rax
cmpq %rcx, %rax
jae 0x4556
cmpq $-0x1, 0xbcf0(%rip)     # 0x10220
je 0x4554
movq 0xbcdf(%rip), %rsi      # 0x10218
leaq 0xbcc0(%rip), %rdi      # 0x10200
callq 0x56a0
movq %rax, %rdi
leaq 0xbcd1(%rip), %rsi      # 0x10220
callq 0x5bf0
jmp 0x4556
jmp 0x48be
cmpq $-0x1, 0xbcbd(%rip)     # 0x10220
jne 0x4590
movq 0xbcbc(%rip), %rsi      # 0x10228
leaq 0xbc8d(%rip), %rdi      # 0x10200
callq 0x56a0
movq %rax, %rdi
addq $0x18, %rdi
leaq 0xbc6a(%rip), %rsi      # 0x101f0
callq 0x5bf0
jmp 0x48bc
movq 0xbc89(%rip), %rax      # 0x10220
cmpq 0xbc52(%rip), %rax      # 0x101f0
je 0x48ba
leaq 0xbc9d(%rip), %rdi      # 0x10248
movq %rdi, -0x5b0(%rbp)
callq 0x5ca0
movq -0x5b0(%rbp), %rdi
movq %rax, -0x210(%rbp)
callq 0x5ca0
movq -0x5b0(%rbp), %rdi
movq %rax, -0x220(%rbp)
callq 0x5d20
movq -0x5b0(%rbp), %rdi
movq %rax, -0x228(%rbp)
callq 0x5d50
movsd (%rax), %xmm0
movsd 0x6a24(%rip), %xmm1     # 0xb020
mulsd %xmm1, %xmm0
movsd %xmm0, -0x230(%rbp)
movq -0x220(%rbp), %rdi
movq -0x228(%rbp), %rsi
leaq -0x230(%rbp), %rdx
callq 0x5cd0
movq %rax, -0x218(%rbp)
movq -0x210(%rbp), %rdi
movq -0x218(%rbp), %rsi
callq 0x5c60
movq %rax, -0x208(%rbp)
movq 0xbba6(%rip), %rsi      # 0x101f0
leaq 0xbb87(%rip), %rdi      # 0x101d8
movq %rdi, -0x5a8(%rbp)
callq 0x55c0
movq -0x5a8(%rbp), %rdi
movups 0x10(%rax), %xmm0
movaps %xmm0, -0x250(%rbp)
movq 0xbbaa(%rip), %rsi      # 0x10220
callq 0x55c0
movq %rax, %rdi
addq $0x10, %rdi
movsd -0x250(%rbp), %xmm0
movsd -0x248(%rbp), %xmm1
callq 0x5d90
movsd %xmm0, -0x240(%rbp)
movsd %xmm1, -0x238(%rbp)
movabsq $0x3fc999999999999a, %rax # imm = 0x3FC999999999999A
movq %rax, -0x258(%rbp)
leaq -0x240(%rbp), %rdi
movq %rdi, -0x598(%rbp)
leaq -0x258(%rbp), %rsi
callq 0x52e0
movq -0x208(%rbp), %rsi
leaq 0xbb50(%rip), %rdi      # 0x10230
movq %rdi, -0x5a0(%rbp)
callq 0x5320
movq -0x5a0(%rbp), %rdi
movswl (%rax), %eax
cvtsi2sd %eax, %xmm0
cvtsi2sdl 0xbaae(%rip), %xmm1 # 0x101b0
divsd %xmm1, %xmm0
movsd %xmm0, -0x270(%rbp)
movq -0x208(%rbp), %rsi
callq 0x5320
movswl 0x2(%rax), %eax
cvtsi2sd %eax, %xmm0
cvtsi2sdl 0xba8a(%rip), %xmm1 # 0x101b4
divsd %xmm1, %xmm0
movsd %xmm0, -0x278(%rbp)
leaq -0x268(%rbp), %rdi
leaq -0x270(%rbp), %rsi
leaq -0x278(%rbp), %rdx
callq 0x5b80
leaq 0xbaa9(%rip), %rdi      # 0x10200
movq %rdi, -0x580(%rbp)
callq 0x5670
movq -0x598(%rbp), %rdi
movq %rax, 0xbaa7(%rip)      # 0x10218
movq 0xbaa8(%rip), %rax      # 0x10220
movq %rax, -0x590(%rbp)
movq 0xba6a(%rip), %rax      # 0x101f0
movq %rax, -0x588(%rbp)
movups -0x268(%rbp), %xmm0
movaps %xmm0, -0x2f0(%rbp)
movups -0x268(%rbp), %xmm0
movaps %xmm0, -0x310(%rbp)
movsd -0x310(%rbp), %xmm0
movsd -0x308(%rbp), %xmm1
callq 0x5d90
movq -0x598(%rbp), %rdi
movsd %xmm0, -0x300(%rbp)
movsd %xmm1, -0x2f8(%rbp)
movups -0x268(%rbp), %xmm0
movaps %xmm0, -0x330(%rbp)
movsd -0x330(%rbp), %xmm0
movsd -0x328(%rbp), %xmm1
callq 0x5230
movq -0x590(%rbp), %rsi
movq -0x588(%rbp), %rdx
movsd %xmm0, -0x320(%rbp)
movsd %xmm1, -0x318(%rbp)
movsd -0x2f0(%rbp), %xmm1
movsd -0x2e8(%rbp), %xmm2
movsd -0x300(%rbp), %xmm3
movsd -0x2f8(%rbp), %xmm4
movsd -0x320(%rbp), %xmm5
movsd -0x318(%rbp), %xmm6
leaq -0x2e0(%rbp), %rdi
movq %rdi, -0x578(%rbp)
movsd 0x67cc(%rip), %xmm0     # 0xb028
callq 0x5e00
movq -0x580(%rbp), %rdi
movq -0x578(%rbp), %rsi
callq 0x5dd0
jmp 0x4876
leaq -0x2e0(%rbp), %rdi
callq 0x5f40
leaq 0xb94f(%rip), %rdi      # 0x101d8
callq 0x5590
movq %rax, 0xb95b(%rip)      # 0x101f0
jmp 0x48ba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x338(%rbp)
movl %eax, -0x33c(%rbp)
leaq -0x2e0(%rbp), %rdi
callq 0x5f40
jmp 0x50fc
jmp 0x48bc
jmp 0x48be
leaq 0xb96b(%rip), %rdi      # 0x10230
callq 0x5f70
leaq 0xb977(%rip), %rdi      # 0x10248
callq 0x5f90
jmp 0x48d8
jmp 0x4ae6
testb $0x1, 0xb914(%rip)      # 0x101f8
je 0x497c
movswl 0xb909(%rip), %eax      # 0x101fa
addl -0x140(%rbp), %eax
cvtsi2sd %eax, %xmm0
cvtsi2sdl 0xb8ad(%rip), %xmm1 # 0x101b0
divsd %xmm1, %xmm0
movsd %xmm0, -0x358(%rbp)
movswl 0xb8e6(%rip), %eax      # 0x101fc
addl -0x13c(%rbp), %eax
cvtsi2sd %eax, %xmm0
cvtsi2sdl 0xb88c(%rip), %xmm1 # 0x101b4
divsd %xmm1, %xmm0
movsd %xmm0, -0x360(%rbp)
leaq -0x350(%rbp), %rdi
leaq -0x358(%rbp), %rsi
leaq -0x360(%rbp), %rdx
callq 0x5b80
movq 0xb89b(%rip), %rsi      # 0x101f0
leaq 0xb87c(%rip), %rdi      # 0x101d8
callq 0x55c0
movq -0x350(%rbp), %rcx
movq %rcx, 0x10(%rax)
movq -0x348(%rbp), %rcx
movq %rcx, 0x18(%rax)
jmp 0x4aab
leaq 0xb8ad(%rip), %rdi      # 0x10230
callq 0x5ab0
testb $0x1, %al
jne 0x4aa9
leaq 0xb899(%rip), %rdi      # 0x10230
movq %rdi, -0x5b8(%rbp)
callq 0x5fb0
movq -0x5b8(%rbp), %rdi
movswl (%rax), %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x368(%rbp)
callq 0x5fb0
movswl 0x2(%rax), %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x370(%rbp)
movl -0x140(%rbp), %eax
movw %ax, -0x374(%rbp)
movl -0x13c(%rbp), %eax
movw %ax, -0x372(%rbp)
leaq 0xb841(%rip), %rdi      # 0x10230
leaq -0x374(%rbp), %rsi
callq 0x5b20
leaq 0xb846(%rip), %rdi      # 0x10248
callq 0x5ff0
testb $0x1, %al
jne 0x4a0d
jmp 0x4a1a
xorps %xmm0, %xmm0
movsd %xmm0, -0x5c0(%rbp)
jmp 0x4a32
leaq 0xb827(%rip), %rdi      # 0x10248
callq 0x5d50
movsd (%rax), %xmm0
movsd %xmm0, -0x5c0(%rbp)
movsd -0x5c0(%rbp), %xmm0
movsd %xmm0, -0x380(%rbp)
movsd -0x380(%rbp), %xmm0
movsd %xmm0, -0x5c8(%rbp)
movsd -0x368(%rbp), %xmm0
cvtsi2sdl -0x140(%rbp), %xmm1
subsd %xmm1, %xmm0
movsd -0x370(%rbp), %xmm1
cvtsi2sdl -0x13c(%rbp), %xmm2
subsd %xmm2, %xmm1
callq 0x2080
movaps %xmm0, %xmm1
movsd -0x5c8(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x388(%rbp)
leaq 0xb7ab(%rip), %rdi      # 0x10248
leaq -0x388(%rbp), %rsi
callq 0x6030
jmp 0x4aab
jmp 0x4ae6
leaq -0x180(%rbp), %rdi
xorl %esi, %esi
callq 0x21f0
subq $0xff0d, %rax           # imm = 0xFF0D
jne 0x4adf
jmp 0x4ac5
movq 0xb6cc(%rip), %rdi      # 0x10198
movq 0xb6cd(%rip), %rsi      # 0x101a0
movl $0x20001, %edx          # imm = 0x20001
callq 0x2140
jmp 0x4af0
jmp 0x4ae1
jmp 0x3df0
callq 0x32b0
jmp 0x3df0
leaq 0xb6e1(%rip), %rax      # 0x101d8
movq %rax, -0x390(%rbp)
leaq 0xb6d3(%rip), %rdi      # 0x101d8
callq 0x58b0
movq %rax, -0x398(%rbp)
leaq 0xb6c0(%rip), %rdi      # 0x101d8
callq 0x58e0
movq %rax, -0x3a0(%rbp)
leaq -0x398(%rbp), %rdi
leaq -0x3a0(%rbp), %rsi
callq 0x5910
xorb $-0x1, %al
testb $0x1, %al
jne 0x4b3f
jmp 0x4b77
leaq -0x398(%rbp), %rdi
callq 0x5950
movq %rax, -0x3a8(%rbp)
movq -0x3a8(%rbp), %rax
movsd (%rax), %xmm0
movq -0x3a8(%rbp), %rax
movsd %xmm0, 0x8(%rax)
leaq -0x398(%rbp), %rdi
callq 0x5a50
jmp 0x4b24
jmp 0x4b79
movq 0xb618(%rip), %rdi      # 0x10198
callq 0x21a0
cmpl $0x0, %eax
je 0x4d81
movq 0xb603(%rip), %rdi      # 0x10198
leaq -0x468(%rbp), %rsi
callq 0x2230
movl -0x468(%rbp), %eax
movl %eax, -0x5cc(%rbp)
subl $0x2, %eax
je 0x4c5d
jmp 0x4bb8
movl -0x5cc(%rbp), %eax
subl $0x11, %eax
je 0x4bd5
jmp 0x4bc5
movl -0x5cc(%rbp), %eax
subl $0x16, %eax
je 0x4c40
jmp 0x4d7c
movq 0xb5bc(%rip), %rdi      # 0x10198
movq 0xb5d5(%rip), %rsi      # 0x101b8
callq 0x2120
movq 0xb5a9(%rip), %rdi      # 0x10198
movq 0xb5ca(%rip), %rsi      # 0x101c0
callq 0x2120
movq 0xb596(%rip), %rdi      # 0x10198
movq 0xb5bf(%rip), %rsi      # 0x101c8
callq 0x2120
movq 0xb583(%rip), %rdi      # 0x10198
movq 0xb5b4(%rip), %rsi      # 0x101d0
callq 0x2120
movq 0xb570(%rip), %rdi      # 0x10198
movq 0xb579(%rip), %rsi      # 0x101a8
callq 0x22b0
movl $0x0, -0xc(%rbp)
jmp 0x50ef
movl -0x430(%rbp), %eax
movl %eax, 0xb564(%rip)      # 0x101b0
movl -0x42c(%rbp), %eax
movl %eax, 0xb55c(%rip)      # 0x101b4
jmp 0x4d7c
leaq -0x468(%rbp), %rdi
xorl %esi, %esi
callq 0x21f0
subq $0xff0d, %rax           # imm = 0xFF0D
jne 0x4d7a
jmp 0x4c79
leaq 0xb558(%rip), %rax      # 0x101d8
movq %rax, -0x470(%rbp)
leaq 0xb54a(%rip), %rdi      # 0x101d8
callq 0x58b0
movq %rax, -0x478(%rbp)
leaq 0xb537(%rip), %rdi      # 0x101d8
callq 0x58e0
movq %rax, -0x480(%rbp)
leaq -0x478(%rbp), %rdi
leaq -0x480(%rbp), %rsi
callq 0x5910
xorb $-0x1, %al
testb $0x1, %al
jne 0x4cc8
jmp 0x4d00
leaq -0x478(%rbp), %rdi
callq 0x5950
movq %rax, -0x488(%rbp)
movq -0x488(%rbp), %rax
movsd 0x8(%rax), %xmm0
movq -0x488(%rbp), %rax
movsd %xmm0, (%rax)
leaq -0x478(%rbp), %rdi
callq 0x5a50
jmp 0x4cad
movq 0xb491(%rip), %rdi      # 0x10198
movq 0xb492(%rip), %rsi      # 0x101a0
movl $0x2804d, %edx          # imm = 0x2804D
callq 0x2140
movq 0xb479(%rip), %rdi      # 0x10198
movq 0xb482(%rip), %rsi      # 0x101a8
movq 0xb473(%rip), %rdx      # 0x101a0
movq 0xb484(%rip), %rcx      # 0x101b8
movl 0xb475(%rip), %r10d     # 0x101b0
movl 0xb473(%rip), %eax      # 0x101b4
xorl %r9d, %r9d
movl %r9d, %r8d
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
movl $0x0, 0x10(%rsp)
movl $0x0, 0x18(%rsp)
callq 0x20c0
callq 0x32b0
movq 0xb428(%rip), %rdi      # 0x10198
callq 0x2240
jmp 0x3dee
jmp 0x4d7c
jmp 0x50ea
leaq 0xb478(%rip), %rax      # 0x10200
movq %rax, -0x490(%rbp)
leaq 0xb46a(%rip), %rdi      # 0x10200
callq 0x56c0
movq %rax, -0x498(%rbp)
leaq 0xb457(%rip), %rdi      # 0x10200
callq 0x56f0
movq %rax, -0x4a0(%rbp)
leaq -0x498(%rbp), %rdi
leaq -0x4a0(%rbp), %rsi
callq 0x5720
xorb $-0x1, %al
testb $0x1, %al
jne 0x4dd3
jmp 0x500b
leaq -0x498(%rbp), %rdi
callq 0x5760
movq %rax, -0x4a8(%rbp)
movq -0x4a8(%rbp), %rax
movsd 0x30(%rax), %xmm0
divsd 0xb386(%rip), %xmm0     # 0x10180
movsd %xmm0, -0x4b0(%rbp)
movq -0x4a8(%rbp), %rax
movq %rax, -0x4b8(%rbp)
movq -0x4b8(%rbp), %rdi
callq 0x5780
movq %rax, -0x4c0(%rbp)
movq -0x4b8(%rbp), %rdi
callq 0x57b0
movq %rax, -0x4c8(%rbp)
leaq -0x4c0(%rbp), %rdi
leaq -0x4c8(%rbp), %rsi
callq 0x57e0
xorb $-0x1, %al
testb $0x1, %al
jne 0x4e51
jmp 0x4ea4
leaq -0x4c0(%rbp), %rdi
callq 0x5820
movq (%rax), %rax
movq %rax, -0x4d0(%rbp)
movq -0x4d0(%rbp), %rsi
leaq 0xb363(%rip), %rdi      # 0x101d8
callq 0x55c0
movsd (%rax), %xmm0
mulsd 0xb2fa(%rip), %xmm0     # 0x10180
mulsd -0x4b0(%rbp), %xmm0
movsd %xmm0, -0x4b0(%rbp)
leaq -0x4c0(%rbp), %rdi
callq 0x5870
jmp 0x4e36
movq -0x4a8(%rbp), %rax
movq %rax, -0x4d8(%rbp)
movq -0x4d8(%rbp), %rdi
callq 0x5780
movq %rax, -0x4e0(%rbp)
movq -0x4d8(%rbp), %rdi
callq 0x57b0
movq %rax, -0x4e8(%rbp)
leaq -0x4e0(%rbp), %rdi
leaq -0x4e8(%rbp), %rsi
callq 0x57e0
xorb $-0x1, %al
testb $0x1, %al
jne 0x4ef3
jmp 0x4f4e
leaq -0x4e0(%rbp), %rdi
callq 0x5820
movq (%rax), %rax
movq %rax, -0x4f0(%rbp)
movsd -0x4b0(%rbp), %xmm0
movsd %xmm0, -0x5d8(%rbp)
movq -0x4f0(%rbp), %rsi
leaq 0xb2b1(%rip), %rdi      # 0x101d8
callq 0x55c0
movsd -0x5d8(%rbp), %xmm1
movsd (%rax), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, (%rax)
leaq -0x4e0(%rbp), %rdi
callq 0x5870
jmp 0x4ed8
movq -0x4a8(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x4f8(%rbp)
movq -0x4f8(%rbp), %rdi
callq 0x5780
movq %rax, -0x500(%rbp)
movq -0x4f8(%rbp), %rdi
callq 0x57b0
movq %rax, -0x508(%rbp)
leaq -0x500(%rbp), %rdi
leaq -0x508(%rbp), %rsi
callq 0x57e0
xorb $-0x1, %al
testb $0x1, %al
jne 0x4fa1
jmp 0x4ff8
leaq -0x500(%rbp), %rdi
callq 0x5820
movq (%rax), %rax
movq %rax, -0x510(%rbp)
movsd -0x4b0(%rbp), %xmm0
movsd %xmm0, -0x5e0(%rbp)
movq -0x510(%rbp), %rsi
leaq 0xb203(%rip), %rdi      # 0x101d8
callq 0x55c0
movsd -0x5e0(%rbp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
leaq -0x500(%rbp), %rdi
callq 0x5870
jmp 0x4f86
jmp 0x4ffa
leaq -0x498(%rbp), %rdi
callq 0x5890
jmp 0x4db5
movq $0x0, -0x518(%rbp)
movq -0x518(%rbp), %rax
movq %rax, -0x5e8(%rbp)
leaq 0xb1ad(%rip), %rdi      # 0x101d8
callq 0x5590
movq %rax, %rcx
movq -0x5e8(%rbp), %rax
cmpq %rcx, %rax
jae 0x50cf
movq -0x518(%rbp), %rsi
leaq 0xb187(%rip), %rdi      # 0x101d8
callq 0x55c0
movsd (%rax), %xmm0
movsd %xmm0, -0x5f8(%rbp)
movq -0x518(%rbp), %rax
movq %rax, -0x5f0(%rbp)
leaq 0xb161(%rip), %rdi      # 0x101d8
callq 0x5590
movsd -0x5f8(%rbp), %xmm0
movq %rax, %rcx
movq -0x5f0(%rbp), %rax
subq $0x1, %rcx
cmpq %rcx, %rax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, %ecx
leaq 0x6022(%rip), %rax      # 0xb0c8
movsbl (%rax,%rcx), %esi
leaq 0x6012(%rip), %rdi      # 0xb0c3
movb $0x1, %al
callq 0x2030
movq -0x518(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x518(%rbp)
jmp 0x5016
callq 0x32b0
movq 0xb0bd(%rip), %rdi      # 0x10198
callq 0x2240
movl $0x3e8, %edi            # imm = 0x3E8
callq 0x2220
jmp 0x4b79
movl -0xc(%rbp), %eax
addq $0x618, %rsp            # imm = 0x618
popq %rbx
popq %rbp
retq
movq -0x338(%rbp), %rdi
callq 0x22a0
nopl (%rax,%rax)