decompiled_code:
__int64 __fastcall EZ_window_Destroy(__int64 a1, unsigned int a2)
{
__int64 v2; // rbx
int v3; // eax

v2 = *(_QWORD *)(a1 + 584);
if ( v2 )
{
v3 = *(_DWORD *)(a1 + 904);
if ( v3 == 1 )
{
do
{
EZ_eventhandler_Exec(v2, a1, a2);
v2 = *(_QWORD *)(v2 + 24);
}
while ( v2 );
}
else
{
*(_DWORD *)(a1 + 904) = v3 - 1;
}
}
EZ_control_Destroy(a1, a2);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, unsigned int a2)
{
__int64 v2; // rbx
int v3; // eax

v2 = *(_QWORD *)(a1 + 584);
if ( v2 )
{
v3 = *(_DWORD *)(a1 + 904);
if ( v3 == 1 )
{
do
{
EZ_eventhandler_Exec(v2, a1, a2);
v2 = *(_QWORD *)(v2 + 24);
}
while ( v2 );
}
else
{
*(_DWORD *)(a1 + 904) = v3 - 1;
}
}
EZ_control_Destroy(a1, a2);
return 0LL;
}

original_code:
int EZ_window_Destroy(ez_control_t *self, qbool destroy_children)
{
 { int *p = (int *)((void *)0), temp = 0; ez_control_t *c = (ez_control_t *)self; if (c->event_handlers.OnDestroy) { if (c->override_counts.OnDestroy == 1) { ez_eventhandler_t *e = c->event_handlers.OnDestroy; while (e) { EZ_eventhandler_Exec(e, (ez_control_t *)self, destroy_children); e = e->next; } } else c->override_counts.OnDestroy--; } if(p) (*p) = temp; };
 EZ_control_Destroy(self, destroy_children);
 return 0;
}

canonical_original_code:
int EZ_window_Destroy(struct ez_control_s *self, enum qbool destroy_children)
{
 { int *p = (int *)((void *)0); int temp = 0; struct ez_control_s *c = (ez_control_t *)self; if (c->event_handlers.OnDestroy) { if (c->override_counts.OnDestroy == 1) { struct ez_eventhandler_s *e = c->event_handlers.OnDestroy; while (e) { EZ_eventhandler_Exec(e, (struct ez_control_s *)self, destroy_children); e = e->next; } } else c->override_counts.OnDestroy--; } if(p) (*p) = temp; };
 EZ_control_Destroy(self, destroy_children);
 return 0;
}

variable_types:
p
int *

variable_types: temp int

variable_types: struct ez_eventhandler_s { int function_type; union ez_eventhandlerfunction_u { int (*normal)(struct ez_control_s { enum ez_control_id_e { EZ_CONTROL_ID=0, EZ_BUTTON_ID=1, EZ_LABEL_ID=2, EZ_SLIDER_ID=3, EZ_SCROLLBAR_ID=4, EZ_SCROLLPANE_ID=5, EZ_WINDOW_ID=6, EZ_LISTVIEW_ID=7, EZ_LISTVIEWITEM_ID=8 } CLASS_ID; char *name; char *description; int x; int y; int prev_x; int prev_y; int absolute_x; int absolute_y; int prev_absolute_x; int prev_absolute_y; int width; int height; int prev_width; int prev_height; int virtual_x; int virtual_y; int absolute_virtual_x; int absolute_virtual_y; int virtual_width; int virtual_height; int prev_virtual_width; int prev_virtual_height; int virtual_width_min; int virtual_height_min; int width_max; int width_min; int height_max; int height_min; int bound_top; int bound_left; int bound_right; int bound_bottom; int left_edge_gap; int right_edge_gap; int top_edge_gap; int bottom_edge_gap; enum ez_anchor_e { anchor_none=expr, anchor_left=expr, anchor_right=expr, anchor_top=expr, anchor_bottom=expr } anchor_flags; int resize_handle_thickness; int draw_order; int tab_order; enum ez_control_flags_e { control_enabled=expr, control_movable=expr, control_focusable=expr, control_resize_h=expr, control_resize_v=expr, control_resizeable=expr, control_contained=expr, control_visible=expr, control_scrollable=expr, control_ignore_mouse=expr, control_anchor_viewport=expr, control_move_parent=expr, control_listen_repeat_mouse=expr, control_bg_tile_center=expr, control_bg_tile_edges=expr } ext_flags; enum ez_control_iflags_e { control_focused=expr, control_moving=expr, control_resizing_left=expr, control_resizing_right=expr, control_resizing_top=expr, control_resizing_bottom=expr, control_clicked=expr, control_mouse_over=expr, control_update_anchorgap=expr, control_hidden_by_parent=expr } int_flags; unsigned char background_color[4]; struct mpic_t { int width; int texnum; float sl; } *background; float bg_edge_size_ratio; float bg_opacity; float opacity; float overall_opacity; float x_percent; float y_percent; void *payload; struct ez_control_events_s { int (*OnMouseEvent)(struct ez_control_s *self, struct mouse_state_s { double x; double y; double x_old; double y_old; enum qbool { false=0, true=1 } buttons[9]; int button_down; int button_up; } *mouse_state); int (*OnMouseClick)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnMouseUp)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnMouseUpOutside)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnMouseDown)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnMouseHover)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnMouseEnter)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnMouseLeave)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnKeyEvent)(struct ez_control_s *self, int key, int unichar, enum qbool { false=0, true=1 } down); int (*OnKeyDown)(struct ez_control_s *self, int key, int unichar); int (*OnKeyUp)(struct ez_control_s *self, int key, int unichar); int (*OnLayoutChildren)(struct ez_control_s *self, void *ext_event_info); int (*OnDraw)(struct ez_control_s *self, void *ext_event_info); int (*OnDestroy)(struct ez_control_s *self, enum qbool { false=0, true=1 } destroy_children); int (*OnMove)(struct ez_control_s *self, void *ext_event_info); int (*OnScroll)(struct ez_control_s *self, void *ext_event_info); int (*OnParentScroll)(struct ez_control_s *self, void *ext_event_info); int (*OnResize)(struct ez_control_s *self, void *ext_event_info); int (*OnParentResize)(struct ez_control_s *self, void *ext_event_info); int (*OnGotFocus)(struct ez_control_s *self, void *ext_event_info); int (*OnLostFocus)(struct ez_control_s *self, void *ext_event_info); int (*OnVirtualResize)(struct ez_control_s *self, void *ext_event_info); int (*OnMinVirtualResize)(struct ez_control_s *self, void *ext_event_info); int (*OnFlagsChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnResizeHandleThicknessChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnEventHandlerChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnAnchorChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnVisibilityChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnOpacityChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnChildMoved)(struct ez_control_s *self, struct ez_control_s *child); int (*OnChildResize)(struct ez_control_s *self, struct ez_control_s *child); } events; struct ez_control_eventhandlers_s { struct ez_eventhandler_s *OnMouseEvent; struct ez_eventhandler_s *OnMouseClick; struct ez_eventhandler_s *OnMouseUp; struct ez_eventhandler_s *OnMouseUpOutside; struct ez_eventhandler_s *OnMouseDown; struct ez_eventhandler_s *OnMouseHover; struct ez_eventhandler_s *OnMouseEnter; struct ez_eventhandler_s *OnMouseLeave; struct ez_eventhandler_s *OnKeyEvent; struct ez_eventhandler_s *OnKeyDown; struct ez_eventhandler_s *OnKeyUp; struct ez_eventhandler_s *OnLayoutChildren; struct ez_eventhandler_s *OnDraw; struct ez_eventhandler_s *OnDestroy; struct ez_eventhandler_s *OnMove; struct ez_eventhandler_s *OnScroll; struct ez_eventhandler_s *OnParentScroll; struct ez_eventhandler_s *OnResize; struct ez_eventhandler_s *OnParentResize; struct ez_eventhandler_s *OnGotFocus; struct ez_eventhandler_s *OnLostFocus; struct ez_eventhandler_s *OnVirtualResize; struct ez_eventhandler_s *OnMinVirtualResize; struct ez_eventhandler_s *OnFlagsChanged; struct ez_eventhandler_s *OnResizeHandleThicknessChanged; struct ez_eventhandler_s *OnEventHandlerChanged; struct ez_eventhandler_s *OnAnchorChanged; struct ez_eventhandler_s *OnVisibilityChanged; struct ez_eventhandler_s *OnOpacityChanged; struct ez_eventhandler_s *OnChildMoved; struct ez_eventhandler_s *OnChildResize; } event_handlers; struct ez_control_eventcount_s { int OnMouseEvent; int OnMouseClick; int OnMouseUp; int OnMouseUpOutside; int OnMouseDown; int OnMouseHover; int OnMouseEnter; int OnMouseLeave; int OnKeyEvent; int OnKeyDown; int OnKeyUp; int OnLayoutChildren; int OnDraw; int OnDestroy; int OnMove; int OnScroll; int OnParentScroll; int OnResize; int OnParentResize; int OnGotFocus; int OnLostFocus; int OnVirtualResize; int OnMinVirtualResize; int OnFlagsChanged; int OnResizeHandleThicknessChanged; int OnEventHandlerChanged; int OnAnchorChanged; int OnVisibilityChanged; int OnOpacityChanged; int OnChildMoved; int OnChildResize; } inherit_levels; struct ez_control_eventcount_s override_counts; enum qbool { false=0, true=1 } initializing; struct ez_control_s *parent; struct ez_double_linked_list_s { int count; struct ez_dllist_node_s { struct ez_dllist_node_s *next; struct ez_dllist_node_s *previous; void *payload; } *head; struct ez_dllist_node_s *tail; } children; struct ez_tree_s { struct ez_control_s *root; enum qbool { false=0, true=1 } destroying; struct ez_dllist_node_s *focused_node; struct ez_double_linked_list_s drawlist; struct ez_double_linked_list_s tablist; struct mouse_state_s prev_mouse_state; double mouse_pressed_time[9]; } *control_tree; struct mouse_state_s prev_mouse_state; double mouse_repeat_delay; } *self, void *payload, void *ext_info); int (*mouse)(struct ez_control_s *self, void *payload, struct mouse_state_s *mouse_state); int (*key)(struct ez_control_s *self, void *payload, int key, int unichar, enum qbool { false=0, true=1 } down); int (*key_sp)(struct ez_control_s *self, void *payload, int key, int unichar); int (*destroy)(struct ez_control_s *self, void *payload, enum qbool { false=0, true=1 } destroy_children); int (*child)(struct ez_control_s *self, void *payload, struct ez_control_s *child); } function; void *payload; struct ez_eventhandler_s *next; } *

user_defined_types: struct mouse_state_s { double x; double y; double x_old; double y_old; enum qbool buttons[9]; int button_down; int button_up; }


repo: jite/jquake

decompiled_code:
__int64 __fastcall EZ_window_SetWindowAreaMinVirtualSize(__int64 a1)
{
__int64 result; // rax

if ( *(_QWORD *)(a1 + 1120) )
result = EZ_control_SetMinVirtualSize();
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
__int64 result; // rax

if ( *(_QWORD *)(a1 + 1120) )
result = EZ_control_SetMinVirtualSize();
return result;
}

original_code:
void EZ_window_SetWindowAreaMinVirtualSize(ez_window_t *window, int min_virtual_width, int min_virtual_height)
{
 if (window->window_area)
 {
  EZ_control_SetMinVirtualSize(window->window_area, min_virtual_width, min_virtual_height);
 }
}

canonical_original_code:
void EZ_window_SetWindowAreaMinVirtualSize(struct ez_window_s *window, int min_virtual_width, int min_virtual_height)
{
 if (window->window_area)
 {
  EZ_control_SetMinVirtualSize(window->window_area, min_virtual_width, min_virtual_height);
 }
}

variable_types: struct ez_window_s { struct ez_control_s { enum ez_control_id_e { EZ_CONTROL_ID=0, EZ_BUTTON_ID=1, EZ_LABEL_ID=2, EZ_SLIDER_ID=3, EZ_SCROLLBAR_ID=4, EZ_SCROLLPANE_ID=5, EZ_WINDOW_ID=6, EZ_LISTVIEW_ID=7, EZ_LISTVIEWITEM_ID=8 } CLASS_ID; char *name; char *description; int x; int y; int prev_x; int prev_y; int absolute_x; int absolute_y; int prev_absolute_x; int prev_absolute_y; int width; int height; int prev_width; int prev_height; int virtual_x; int virtual_y; int absolute_virtual_x; int absolute_virtual_y; int virtual_width; int virtual_height; int prev_virtual_width; int prev_virtual_height; int virtual_width_min; int virtual_height_min; int width_max; int width_min; int height_max; int height_min; int bound_top; int bound_left; int bound_right; int bound_bottom; int left_edge_gap; int right_edge_gap; int top_edge_gap; int bottom_edge_gap; enum ez_anchor_e { anchor_none=expr, anchor_left=expr, anchor_right=expr, anchor_top=expr, anchor_bottom=expr } anchor_flags; int resize_handle_thickness; int draw_order; int tab_order; enum ez_control_flags_e { control_enabled=expr, control_movable=expr, control_focusable=expr, control_resize_h=expr, control_resize_v=expr, control_resizeable=expr, control_contained=expr, control_visible=expr, control_scrollable=expr, control_ignore_mouse=expr, control_anchor_viewport=expr, control_move_parent=expr, control_listen_repeat_mouse=expr, control_bg_tile_center=expr, control_bg_tile_edges=expr } ext_flags; enum ez_control_iflags_e { control_focused=expr, control_moving=expr, control_resizing_left=expr, control_resizing_right=expr, control_resizing_top=expr, control_resizing_bottom=expr, control_clicked=expr, control_mouse_over=expr, control_update_anchorgap=expr, control_hidden_by_parent=expr } int_flags; unsigned char background_color[4]; struct mpic_t { int width; int texnum; float sl; } *background; float bg_edge_size_ratio; float bg_opacity; float opacity; float overall_opacity; float x_percent; float y_percent; void *payload; struct ez_control_events_s { int (*OnMouseEvent)(struct ez_control_s *self, struct mouse_state_s { double x; double y; double x_old; double y_old; enum qbool { false=0, true=1 } buttons[9]; int button_down; int button_up; } *mouse_state); int (*OnMouseClick)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnMouseUp)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnMouseUpOutside)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnMouseDown)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnMouseHover)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnMouseEnter)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnMouseLeave)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnKeyEvent)(struct ez_control_s *self, int key, int unichar, enum qbool { false=0, true=1 } down); int (*OnKeyDown)(struct ez_control_s *self, int key, int unichar); int (*OnKeyUp)(struct ez_control_s *self, int key, int unichar); int (*OnLayoutChildren)(struct ez_control_s *self, void *ext_event_info); int (*OnDraw)(struct ez_control_s *self, void *ext_event_info); int (*OnDestroy)(struct ez_control_s *self, enum qbool { false=0, true=1 } destroy_children); int (*OnMove)(struct ez_control_s *self, void *ext_event_info); int (*OnScroll)(struct ez_control_s *self, void *ext_event_info); int (*OnParentScroll)(struct ez_control_s *self, void *ext_event_info); int (*OnResize)(struct ez_control_s *self, void *ext_event_info); int (*OnParentResize)(struct ez_control_s *self, void *ext_event_info); int (*OnGotFocus)(struct ez_control_s *self, void *ext_event_info); int (*OnLostFocus)(struct ez_control_s *self, void *ext_event_info); int (*OnVirtualResize)(struct ez_control_s *self, void *ext_event_info); int (*OnMinVirtualResize)(struct ez_control_s *self, void *ext_event_info); int (*OnFlagsChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnResizeHandleThicknessChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnEventHandlerChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnAnchorChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnVisibilityChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnOpacityChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnChildMoved)(struct ez_control_s *self, struct ez_control_s *child); int (*OnChildResize)(struct ez_control_s *self, struct ez_control_s *child); } events; struct ez_control_eventhandlers_s { struct ez_eventhandler_s { int function_type; union ez_eventhandlerfunction_u { int (*normal)(struct ez_control_s *self, void *payload, void *ext_info); int (*mouse)(struct ez_control_s *self, void *payload, struct mouse_state_s *mouse_state); int (*key)(struct ez_control_s *self, void *payload, int key, int unichar, enum qbool { false=0, true=1 } down); int (*key_sp)(struct ez_control_s *self, void *payload, int key, int unichar); int (*destroy)(struct ez_control_s *self, void *payload, enum qbool { false=0, true=1 } destroy_children); int (*child)(struct ez_control_s *self, void *payload, struct ez_control_s *child); } function; void *payload; struct ez_eventhandler_s *next; } *OnMouseEvent; struct ez_eventhandler_s *OnMouseClick; struct ez_eventhandler_s *OnMouseUp; struct ez_eventhandler_s *OnMouseUpOutside; struct ez_eventhandler_s *OnMouseDown; struct ez_eventhandler_s *OnMouseHover; struct ez_eventhandler_s *OnMouseEnter; struct ez_eventhandler_s *OnMouseLeave; struct ez_eventhandler_s *OnKeyEvent; struct ez_eventhandler_s *OnKeyDown; struct ez_eventhandler_s *OnKeyUp; struct ez_eventhandler_s *OnLayoutChildren; struct ez_eventhandler_s *OnDraw; struct ez_eventhandler_s *OnDestroy; struct ez_eventhandler_s *OnMove; struct ez_eventhandler_s *OnScroll; struct ez_eventhandler_s *OnParentScroll; struct ez_eventhandler_s *OnResize; struct ez_eventhandler_s *OnParentResize; struct ez_eventhandler_s *OnGotFocus; struct ez_eventhandler_s *OnLostFocus; struct ez_eventhandler_s *OnVirtualResize; struct ez_eventhandler_s *OnMinVirtualResize; struct ez_eventhandler_s *OnFlagsChanged; struct ez_eventhandler_s *OnResizeHandleThicknessChanged; struct ez_eventhandler_s *OnEventHandlerChanged; struct ez_eventhandler_s *OnAnchorChanged; struct ez_eventhandler_s *OnVisibilityChanged; struct ez_eventhandler_s *OnOpacityChanged; struct ez_eventhandler_s *OnChildMoved; struct ez_eventhandler_s *OnChildResize; } event_handlers; struct ez_control_eventcount_s { int OnMouseEvent; int OnMouseClick; int OnMouseUp; int OnMouseUpOutside; int OnMouseDown; int OnMouseHover; int OnMouseEnter; int OnMouseLeave; int OnKeyEvent; int OnKeyDown; int OnKeyUp; int OnLayoutChildren; int OnDraw; int OnDestroy; int OnMove; int OnScroll; int OnParentScroll; int OnResize; int OnParentResize; int OnGotFocus; int OnLostFocus; int OnVirtualResize; int OnMinVirtualResize; int OnFlagsChanged; int OnResizeHandleThicknessChanged; int OnEventHandlerChanged; int OnAnchorChanged; int OnVisibilityChanged; int OnOpacityChanged; int OnChildMoved; int OnChildResize; } inherit_levels; struct ez_control_eventcount_s override_counts; enum qbool { false=0, true=1 } initializing; struct ez_control_s *parent; struct ez_double_linked_list_s { int count; struct ez_dllist_node_s { struct ez_dllist_node_s *next; struct ez_dllist_node_s *previous; void *payload; } *head; struct ez_dllist_node_s *tail; } children; struct ez_tree_s { struct ez_control_s *root; enum qbool { false=0, true=1 } destroying; struct ez_dllist_node_s *focused_node; struct ez_double_linked_list_s drawlist; struct ez_double_linked_list_s tablist; struct mouse_state_s prev_mouse_state; double mouse_pressed_time[9]; } *control_tree; struct mouse_state_s prev_mouse_state; double mouse_repeat_delay; } super; struct ez_scrollpane_s { struct ez_control_s super; struct ez_scrollpane_events_s { int (*OnTargetChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnTargetResize)(struct ez_control_s *self, void *ext_event_info); int (*OnTargetScroll)(struct ez_control_s *self, void *ext_event_info); int (*OnScrollbarThicknessChanged)(struct ez_control_s *self, void *ext_event_info); } events; struct ez_scrollpane_eventhandlers_s { struct ez_eventhandler_s *OnTargetChanged; struct ez_eventhandler_s *OnTargetResize; struct ez_eventhandler_s *OnTargetScroll; struct ez_eventhandler_s *OnScrollbarThicknessChanged; } event_handlers; struct ez_scrollpane_eventcount_s { int OnTargetChanged; int OnScrollbarThicknessChanged; } inherit_levels; struct ez_scrollpane_eventcount_s override_counts; struct ez_control_s *target; struct ez_control_s *prev_target; struct ez_scrollbar_s { struct ez_control_s super; struct ez_scrollbar_events_s { int (*OnTargetChanged)(struct ez_control_s *self, void *ext_event_info); } events; struct ez_scrollbar_eventhandlers_s { struct ez_eventhandler_s *OnTargetChanged; } event_handlers; struct ez_scrollbar_eventcount_s { int OnTargetChanged; } inherit_levels; struct ez_scrollbar_eventcount_s override_counts; struct ez_button_s { struct ez_control_s super; struct ez_button_events_s { int (*OnAction)(struct ez_control_s *self, void *ext_event_info); int (*OnTextAlignmentChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnToggled)(struct ez_control_s *self, void *ext_event_info); } events; struct ez_button_eventhandlers_s { struct ez_eventhandler_s *OnAction; struct ez_eventhandler_s *OnTextAlignmentChanged; struct ez_eventhandler_s *OnToggled; } event_handlers; struct ez_button_eventcount_s { int OnAction; int OnTextAlignmentChanged; int OnToggled; } inherit_levels; struct ez_button_eventcount_s override_counts; struct ez_label_s { struct ez_control_s super; struct ez_label_events_s { int (*OnTextChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnCaretMoved)(struct ez_control_s *self, void *ext_event_info); int (*OnTextScaleChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnTextFlagsChanged)(struct ez_control_s *self, void *ext_event_info); } events; struct ez_label_eventhandlers_s { struct ez_eventhandler_s *OnTextChanged; struct ez_eventhandler_s *OnCaretMoved; struct ez_eventhandler_s *OnTextScaleChanged; struct ez_eventhandler_s *OnTextFlagsChanged; } event_handlers; struct ez_label_eventcount_s { int OnTextChanged; int OnCaretMoved; int OnTextScaleChanged; int OnTextFlagsChanged; } inherit_levels; struct ez_label_eventcount_s override_counts; char *text; int text_length; enum ez_label_flags_e { label_largefont=expr, label_autosize=expr, label_autoellipsis=expr, label_wraptext=expr, label_selectable=expr, label_readonly=expr } ext_flags; enum ez_label_iflags_e { label_selecting=expr } int_flags; struct ez_label_textpos_s { int index; int row; int col; } wordwraps[512]; struct clrinfo_s { int c; int i; } color; float scale; int scaled_char_size; int select_start; int select_end; struct ez_label_textpos_s caret_pos; int num_rows; int num_cols; } *text_label; struct mpic_t *focused_image; struct mpic_t *normal_image; struct mpic_t *hover_image; struct mpic_t *pressed_image; struct mpic_t *toggled_hover_image; unsigned char color_focused[4]; unsigned char color_normal[4]; unsigned char color_hover[4]; unsigned char color_pressed[4]; unsigned char color_toggled_hover[4]; enum ez_button_iflags_e { button_toggled=expr } int_flags; enum ez_button_flags_e { button_use_images=expr, button_is_toggleable=expr } ext_flags; int padding_top; int padding_left; int padding_right; int padding_bottom; enum ez_textalign_e { top_left=0, top_center=1, top_right=2, middle_left=3, middle_center=4, middle_right=5, bottom_left=6, bottom_center=7, bottom_right=8 } text_alignment; struct clrinfo_s focused_text_color; struct clrinfo_s normal_text_color; struct clrinfo_s hover_text_color; struct clrinfo_s pressed_text_color; int override_count; int inheritance_level; } *back; struct ez_button_s *slider; struct ez_button_s *forward; enum ez_orientation_s { vertical=0, horizontal=1 } orientation; int scroll_area; int slider_minsize; int scroll_delta_x; int scroll_delta_y; struct ez_control_s *target; enum ez_scrollbar_flags_e { target_parent=expr } ext_flags; enum ez_scrollbar_iflags_e { sliding=expr, scrolling=expr } int_flags; } *v_scrollbar; struct ez_scrollbar_s *h_scrollbar; int scrollbar_thickness; enum ez_scrollpane_flags_e { always_v_scrollbar=expr, always_h_scrollbar=expr } ext_flags; enum ez_scrollpane_iflags_e { show_v_scrollbar=expr, show_h_scrollbar=expr, resizing_target=expr } int_flags; } *scrollpane; struct ez_control_s *window_area; struct ez_control_s *titlebar; struct ez_button_s *close_button; } *

return_type: void

user_defined_types: struct ez_window_s { struct ez_control_s super; struct ez_scrollpane_s *scrollpane; struct ez_control_s *window_area; struct ez_control_s *titlebar; struct ez_button_s *close_button; }

user_defined_types: struct ez_control_s { enum ez_control_id_e CLASS_ID; char *name; char *description; int x; int y; int prev_x; int prev_y; int absolute_x; int absolute_y; int prev_absolute_x; int prev_absolute_y; int width; int height; int prev_width; int prev_height; int virtual_x; int virtual_y; int absolute_virtual_x; int absolute_virtual_y; int virtual_width; int virtual_height; int prev_virtual_width; int prev_virtual_height; int virtual_width_min; int virtual_height_min; int width_max; int width_min; int height_max; int height_min; int bound_top; int bound_left; int bound_right; int bound_bottom; int left_edge_gap; int right_edge_gap; int top_edge_gap; int bottom_edge_gap; enum ez_anchor_e anchor_flags; int resize_handle_thickness; int draw_order; int tab_order; enum ez_control_flags_e ext_flags; enum ez_control_iflags_e int_flags; unsigned char background_color[4]; struct mpic_t *background; float bg_edge_size_ratio; float bg_opacity; float opacity; float overall_opacity; float x_percent; float y_percent; void *payload; struct ez_control_events_s events; struct ez_control_eventhandlers_s event_handlers; struct ez_control_eventcount_s inherit_levels; struct ez_control_eventcount_s override_counts; enum qbool initializing; struct ez_control_s *parent; struct ez_double_linked_list_s children; struct ez_tree_s *control_tree; struct mouse_state_s prev_mouse_state; double mouse_repeat_delay; }

user_defined_types: struct ez_control_events_s { int (*OnMouseEvent)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnMouseClick)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnMouseUp)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnMouseUpOutside)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnMouseDown)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnMouseHover)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnMouseEnter)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnMouseLeave)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnKeyEvent)(struct ez_control_s *self, int key, int unichar, enum qbool down); int (*OnKeyDown)(struct ez_control_s *self, int key, int unichar); int (*OnKeyUp)(struct ez_control_s *self, int key, int unichar); int (*OnLayoutChildren)(struct ez_control_s *self, void *ext_event_info); int (*OnDraw)(struct ez_control_s *self, void *ext_event_info); int (*OnDestroy)(struct ez_control_s *self, enum qbool destroy_children); int (*OnMove)(struct ez_control_s *self, void *ext_event_info); int (*OnScroll)(struct ez_control_s *self, void *ext_event_info); int (*OnParentScroll)(struct ez_control_s *self, void *ext_event_info); int (*OnResize)(struct ez_control_s *self, void *ext_event_info); int (*OnParentResize)(struct ez_control_s *self, void *ext_event_info); int (*OnGotFocus)(struct ez_control_s *self, void *ext_event_info); int (*OnLostFocus)(struct ez_control_s *self, void *ext_event_info); int (*OnVirtualResize)(struct ez_control_s *self, void *ext_event_info); int (*OnMinVirtualResize)(struct ez_control_s *self, void *ext_event_info); int (*OnFlagsChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnResizeHandleThicknessChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnEventHandlerChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnAnchorChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnVisibilityChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnOpacityChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnChildMoved)(struct ez_control_s *self, struct ez_control_s *child); int (*OnChildResize)(struct ez_control_s *self, struct ez_control_s *child); }

user_defined_types: struct ez_control_eventhandlers_s { struct ez_eventhandler_s *OnMouseEvent; struct ez_eventhandler_s *OnMouseClick; struct ez_eventhandler_s *OnMouseUp; struct ez_eventhandler_s *OnMouseUpOutside; struct ez_eventhandler_s *OnMouseDown; struct ez_eventhandler_s *OnMouseHover; struct ez_eventhandler_s *OnMouseEnter; struct ez_eventhandler_s *OnMouseLeave; struct ez_eventhandler_s *OnKeyEvent; struct ez_eventhandler_s *OnKeyDown; struct ez_eventhandler_s *OnKeyUp; struct ez_eventhandler_s *OnLayoutChildren; struct ez_eventhandler_s *OnDraw; struct ez_eventhandler_s *OnDestroy; struct ez_eventhandler_s *OnMove; struct ez_eventhandler_s *OnScroll; struct ez_eventhandler_s *OnParentScroll; struct ez_eventhandler_s *OnResize; struct ez_eventhandler_s *OnParentResize; struct ez_eventhandler_s *OnGotFocus; struct ez_eventhandler_s *OnLostFocus; struct ez_eventhandler_s *OnVirtualResize; struct ez_eventhandler_s *OnMinVirtualResize; struct ez_eventhandler_s *OnFlagsChanged; struct ez_eventhandler_s *OnResizeHandleThicknessChanged; struct ez_eventhandler_s *OnEventHandlerChanged; struct ez_eventhandler_s *OnAnchorChanged; struct ez_eventhandler_s *OnVisibilityChanged; struct ez_eventhandler_s *OnOpacityChanged; struct ez_eventhandler_s *OnChildMoved; struct ez_eventhandler_s *OnChildResize; }

user_defined_types: struct ez_double_linked_list_s { int count; struct ez_dllist_node_s *head; struct ez_dllist_node_s *tail; }

user_defined_types: struct ez_scrollpane_s { struct ez_control_s super; struct ez_scrollpane_events_s events; struct ez_scrollpane_eventhandlers_s event_handlers; struct ez_scrollpane_eventcount_s inherit_levels; struct ez_scrollpane_eventcount_s override_counts; struct ez_control_s *target; struct ez_control_s *prev_target; struct ez_scrollbar_s *v_scrollbar; struct ez_scrollbar_s *h_scrollbar; int scrollbar_thickness; enum ez_scrollpane_flags_e ext_flags; enum ez_scrollpane_iflags_e int_flags; }

user_defined_types: struct ez_tree_s { struct ez_control_s *root; enum qbool destroying; struct ez_dllist_node_s *focused_node; struct ez_double_linked_list_s drawlist; struct ez_double_linked_list_s tablist; struct mouse_state_s prev_mouse_state; double mouse_pressed_time[9]; }

user_defined_types: struct ez_eventhandler_s { int function_type; union ez_eventhandlerfunction_u function; void *payload; struct ez_eventhandler_s *next; }

user_defined_types: struct ez_scrollbar_s { struct ez_control_s super; struct ez_scrollbar_events_s events; struct ez_scrollbar_eventhandlers_s event_handlers; struct ez_scrollbar_eventcount_s inherit_levels; struct ez_scrollbar_eventcount_s override_counts; struct ez_button_s *back; struct ez_button_s *slider; struct ez_button_s *forward; enum ez_orientation_s orientation; int scroll_area; int slider_minsize; int scroll_delta_x; int scroll_delta_y; struct ez_control_s *target; enum ez_scrollbar_flags_e ext_flags; enum ez_scrollbar_iflags_e int_flags; }

user_defined_types: union ez_eventhandlerfunction_u { int (*normal)(struct ez_control_s *self, void *payload, void *ext_info); int (*mouse)(struct ez_control_s *self, void *payload, struct mouse_state_s *mouse_state); int (*key)(struct ez_control_s *self, void *payload, int key, int unichar, enum qbool down); int (*key_sp)(struct ez_control_s *self, void *payload, int key, int unichar); int (*destroy)(struct ez_control_s *self, void *payload, enum qbool destroy_children); int (*child)(struct ez_control_s *self, void *payload, struct ez_control_s *child); }

user_defined_types: struct ez_button_s { struct ez_control_s super; struct ez_button_events_s events; struct ez_button_eventhandlers_s event_handlers; struct ez_button_eventcount_s inherit_levels; struct ez_button_eventcount_s override_counts; struct ez_label_s *text_label; struct mpic_t *focused_image; struct mpic_t *normal_image; struct mpic_t *hover_image; struct mpic_t *pressed_image; struct mpic_t *toggled_hover_image; unsigned char color_focused[4]; unsigned char color_normal[4]; unsigned char color_hover[4]; unsigned char color_pressed[4]; unsigned char color_toggled_hover[4]; enum ez_button_iflags_e int_flags; enum ez_button_flags_e ext_flags; int padding_top; int padding_left; int padding_right; int padding_bottom; enum ez_textalign_e text_alignment; struct clrinfo_s focused_text_color; struct clrinfo_s normal_text_color; struct clrinfo_s hover_text_color; struct clrinfo_s pressed_text_color; int override_count; int inheritance_level; }

user_defined_types: struct ez_label_s { struct ez_control_s super; struct ez_label_events_s events; struct ez_label_eventhandlers_s event_handlers; struct ez_label_eventcount_s inherit_levels; struct ez_label_eventcount_s override_counts; char *text; int text_length; enum ez_label_flags_e ext_flags; enum ez_label_iflags_e int_flags; struct ez_label_textpos_s wordwraps[512]; struct clrinfo_s color; float scale; int scaled_char_size; int select_start; int select_end; struct ez_label_textpos_s caret_pos; int num_rows; int num_cols; }


decompiled_code:
__int64 __fastcall EZ_window_AddChild(__int64 a1, __int64 a2)
{
if ( !*(_QWORD *)(*(_QWORD *)(a1 + 1112) + 1192LL) )
Sys_Error("EZ_window_AddChild(): Window scrollpane has a NULL target.\n");
EZ_control_AddChild(*(_QWORD *)(a1 + 1120), a2);
return EZ_control_SetDrawOrder(a2, (unsigned int)(*(_DWORD *)(*(_QWORD *)(a1 + 1120) + 168LL) + 1), 1LL);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2)
{
if ( !*(_QWORD *)(*(_QWORD *)(a1 + 1112) + 1192LL) )
Sys_Error("EZ_window_AddChild(): Window scrollpane has a NULL target.\n");
EZ_control_AddChild(*(_QWORD *)(a1 + 1120), a2);
return EZ_control_SetDrawOrder(a2, (unsigned int)(*(_DWORD *)(*(_QWORD *)(a1 + 1120) + 168LL) + 1), 1LL);
}

original_code:
void EZ_window_AddChild(ez_window_t *window, ez_control_t *child)
{
 if (!window->scrollpane->target)
 {
  Sys_Error("EZ_window_AddChild(): Window scrollpane has a NULL target.\n");
 }
 EZ_control_AddChild(window->window_area, child);
 EZ_control_SetDrawOrder(child, window->window_area->draw_order + 1, true);
}

canonical_original_code:
void EZ_window_AddChild(struct ez_window_s *window, struct ez_control_s *child)
{
 if (!window->scrollpane->target)
 {
  Sys_Error("EZ_window_AddChild(): Window scrollpane has a NULL target.\n");
 }
 EZ_control_AddChild(window->window_area, child);
 EZ_control_SetDrawOrder(child, window->window_area->draw_order + 1, true);
}

variable_types:
child
struct ez_control_s *

user_defined_types: enum ez_control_id_e { EZ_CONTROL_ID=0, EZ_BUTTON_ID=1, EZ_LABEL_ID=2, EZ_SLIDER_ID=3, EZ_SCROLLBAR_ID=4, EZ_SCROLLPANE_ID=5, EZ_WINDOW_ID=6, EZ_LISTVIEW_ID=7, EZ_LISTVIEWITEM_ID=8 }

user_defined_types: enum ez_anchor_e { anchor_none=expr, anchor_left=expr, anchor_right=expr, anchor_top=expr, anchor_bottom=expr }

user_defined_types: enum ez_control_flags_e { control_enabled=expr, control_movable=expr, control_focusable=expr, control_resize_h=expr, control_resize_v=expr, control_resizeable=expr, control_contained=expr, control_visible=expr, control_scrollable=expr, control_ignore_mouse=expr, control_anchor_viewport=expr, control_move_parent=expr, control_listen_repeat_mouse=expr, control_bg_tile_center=expr, control_bg_tile_edges=expr }

user_defined_types: enum ez_control_iflags_e { control_focused=expr, control_moving=expr, control_resizing_left=expr, control_resizing_right=expr, control_resizing_top=expr, control_resizing_bottom=expr, control_clicked=expr, control_mouse_over=expr, control_update_anchorgap=expr, control_hidden_by_parent=expr }

user_defined_types: struct ez_control_eventcount_s { int OnMouseEvent; int OnMouseClick; int OnMouseUp; int OnMouseUpOutside; int OnMouseDown; int OnMouseHover; int OnMouseEnter; int OnMouseLeave; int OnKeyEvent; int OnKeyDown; int OnKeyUp; int OnLayoutChildren; int OnDraw; int OnDestroy; int OnMove; int OnScroll; int OnParentScroll; int OnResize; int OnParentResize; int OnGotFocus; int OnLostFocus; int OnVirtualResize; int OnMinVirtualResize; int OnFlagsChanged; int OnResizeHandleThicknessChanged; int OnEventHandlerChanged; int OnAnchorChanged; int OnVisibilityChanged; int OnOpacityChanged; int OnChildMoved; int OnChildResize; }

user_defined_types: struct mpic_t { int width; int texnum; float sl; }

user_defined_types: struct ez_scrollpane_events_s { int (*OnTargetChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnTargetResize)(struct ez_control_s *self, void *ext_event_info); int (*OnTargetScroll)(struct ez_control_s *self, void *ext_event_info); int (*OnScrollbarThicknessChanged)(struct ez_control_s *self, void *ext_event_info); }

user_defined_types: struct ez_scrollpane_eventhandlers_s { struct ez_eventhandler_s *OnTargetChanged; struct ez_eventhandler_s *OnTargetResize; struct ez_eventhandler_s *OnTargetScroll; struct ez_eventhandler_s *OnScrollbarThicknessChanged; }

user_defined_types: struct ez_scrollpane_eventcount_s { int OnTargetChanged; int OnScrollbarThicknessChanged; }

user_defined_types: enum ez_scrollpane_flags_e { always_v_scrollbar=expr, always_h_scrollbar=expr }

user_defined_types: enum ez_scrollpane_iflags_e { show_v_scrollbar=expr, show_h_scrollbar=expr, resizing_target=expr }

user_defined_types: struct ez_dllist_node_s { struct ez_dllist_node_s *next; struct ez_dllist_node_s *previous; void *payload; }

user_defined_types: struct ez_scrollbar_events_s { int (*OnTargetChanged)(struct ez_control_s *self, void *ext_event_info); }

user_defined_types: struct ez_scrollbar_eventhandlers_s { struct ez_eventhandler_s *OnTargetChanged; }

user_defined_types: struct ez_scrollbar_eventcount_s { int OnTargetChanged; }

user_defined_types: enum ez_orientation_s { vertical=0, horizontal=1 }

user_defined_types: enum ez_scrollbar_flags_e { target_parent=expr }

user_defined_types: enum ez_scrollbar_iflags_e { sliding=expr, scrolling=expr }

user_defined_types: struct ez_button_events_s { int (*OnAction)(struct ez_control_s *self, void *ext_event_info); int (*OnTextAlignmentChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnToggled)(struct ez_control_s *self, void *ext_event_info); }

user_defined_types: struct ez_button_eventhandlers_s { struct ez_eventhandler_s *OnAction; struct ez_eventhandler_s *OnTextAlignmentChanged; struct ez_eventhandler_s *OnToggled; }

user_defined_types: struct ez_button_eventcount_s { int OnAction; int OnTextAlignmentChanged; int OnToggled; }

user_defined_types: enum ez_button_iflags_e { button_toggled=expr }

user_defined_types: enum ez_button_flags_e { button_use_images=expr, button_is_toggleable=expr }

user_defined_types: enum ez_textalign_e { top_left=0, top_center=1, top_right=2, middle_left=3, middle_center=4, middle_right=5, bottom_left=6, bottom_center=7, bottom_right=8 }

user_defined_types: struct ez_label_events_s { int (*OnTextChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnCaretMoved)(struct ez_control_s *self, void *ext_event_info); int (*OnTextScaleChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnTextFlagsChanged)(struct ez_control_s *self, void *ext_event_info); }

user_defined_types: struct ez_label_eventhandlers_s { struct ez_eventhandler_s *OnTextChanged; struct ez_eventhandler_s *OnCaretMoved; struct ez_eventhandler_s *OnTextScaleChanged; struct ez_eventhandler_s *OnTextFlagsChanged; }

user_defined_types: struct ez_label_eventcount_s { int OnTextChanged; int OnCaretMoved; int OnTextScaleChanged; int OnTextFlagsChanged; }

user_defined_types: enum ez_label_flags_e { label_largefont=expr, label_autosize=expr, label_autoellipsis=expr, label_wraptext=expr, label_selectable=expr, label_readonly=expr }

user_defined_types: enum ez_label_iflags_e { label_selecting=expr }

user_defined_types: struct ez_label_textpos_s { int index; int row; int col; }


decompiled_code:
__int64 __fastcall SList_Switch(unsigned int a1, unsigned int a2)
{
__int64 v2; // rbp
__int64 v3; // rbx
__m128i v4; // xmm0
__int64 result; // rax

if ( a1 > 0x1FF )
{
result = Sys_Error("SList_Switch: Bad index %d", a1);
if ( a2 <= 0x1FF )
goto LABEL_3;
LABEL_5:
result = Sys_Error("SList_Switch: Bad index %d", a2);
goto LABEL_3;
}
if ( a2 > 0x1FF )
goto LABEL_5;
LABEL_3:
v2 = (int)a1;
v3 = (int)a2;
v4 = _mm_load_si128((const __m128i *)&slist[v2]);
slist[v2] = (__int128)_mm_load_si128((const __m128i *)&slist[v3]);
slist[v3] = (__int128)v4;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned int a1, unsigned int a2)
{
__int64 v2; // rbp
__int64 v3; // rbx
__m128i v4; // xmm0
__int64 result; // rax

if ( a1 > 0x1FF )
{
result = Sys_Error("SList_Switch: Bad index %d", a1);
if ( a2 <= 0x1FF )
goto LABEL_3;
LABEL_5:
result = Sys_Error("SList_Switch: Bad index %d", a2);
goto LABEL_3;
}
if ( a2 > 0x1FF )
goto LABEL_5;
LABEL_3:
v2 = (int)a1;
v3 = (int)a2;
v4 = _mm_load_si128((const __m128i *)&slist[v2]);
slist[v2] = (__int128)_mm_load_si128((const __m128i *)&slist[v3]);
slist[v3] = (__int128)v4;
return result;
}

original_code:
void SList_Switch (int a, int b) {
 server_entry_t temp;
 if (a >= 512 || a < 0)
  Sys_Error("SList_Switch: Bad index %d", a);
 if (b >= 512 || b < 0)
  Sys_Error("SList_Switch: Bad index %d", b);
 memcpy(&temp, &slist[a], sizeof(temp));
 memcpy(&slist[a], &slist[b], sizeof(temp));
 memcpy(&slist[b], &temp, sizeof(temp));
}

canonical_original_code:
void SList_Switch(int a, int b) {
 struct server_entry_t temp;
 if (a >= 512 || a < 0)
  Sys_Error("SList_Switch: Bad index %d", a);
 if (b >= 512 || b < 0)
  Sys_Error("SList_Switch: Bad index %d", b);
 memcpy(&temp, &slist[a], sizeof(temp));
 memcpy(&slist[a], &slist[b], sizeof(temp));
 memcpy(&slist[b], &temp, sizeof(temp));
}

variable_types: a int

variable_types: b int

variable_types: struct server_entry_t { char *server; char *description; }


decompiled_code:
__int64 SList_Init()
{
__int64 result; // rax

result = 0LL;
memset(&slist, 0, 0x2000uLL);
return result;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 result; // rax

result = 0LL;
memset(&slist, 0, 0x2000uLL);
return result;
}

original_code:
void SList_Init(void) {
 memset(&slist, 0, sizeof(slist));
}

canonical_original_code:
void SList_Init() {
 memset(&slist, 0, sizeof(slist));
}


decompiled_code:
__int64 __fastcall SList_Set(unsigned int a1, __int64 a2, __int64 a3)
{
__int64 v4; // rbx
void *v5; // rdi
void *v6; // rdi
__int64 v7; // rbx
__int64 result; // rax

v4 = (int)a1;
if ( a1 > 0x1FF )
Sys_Error("SList_Switch: Bad index %d", a1);
v5 = *(void **)&slist[a1];
if ( v5 )
{
free(v5);
*(_QWORD *)&slist[v4] = 0LL;
}
v6 = (void *)*((_QWORD *)&slist[v4] + 1);
if ( v6 )
{
free(v6);
*((_QWORD *)&slist[v4] + 1) = 0LL;
}
v7 = v4;
*(_QWORD *)&slist[v7] = Q_strdup(a2);
result = Q_strdup(a3);
*((_QWORD *)&slist[v7] + 1) = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int a1, __int64 a2, __int64 a3)
{
__int64 v4; // rbx
void *v5; // rdi
void *v6; // rdi
__int64 v7; // rbx
__int64 result; // rax

v4 = (int)a1;
if ( a1 > 0x1FF )
Sys_Error("SList_Switch: Bad index %d", a1);
v5 = *(void **)&slist[a1];
if ( v5 )
{
free(v5);
*(_QWORD *)&slist[v4] = 0LL;
}
v6 = (void *)*((_QWORD *)&slist[v4] + 1);
if ( v6 )
{
free(v6);
*((_QWORD *)&slist[v4] + 1) = 0LL;
}
v7 = v4;
*(_QWORD *)&slist[v7] = Q_strdup(a2);
result = Q_strdup(a3);
*((_QWORD *)&slist[v7] + 1) = result;
return result;
}

original_code:
void SList_Set (int i, char *addr, char *desc) {
 if (i >= 512 || i < 0)
  Sys_Error("SList_Switch: Bad index %d", i);
 if (slist[i].server)
  if(slist[i].server) { free(slist[i].server); slist[i].server = ((void *)0); };
 if (slist[i].description)
  if(slist[i].description) { free(slist[i].description); slist[i].description = ((void *)0); };
 slist[i].server = Q_strdup (addr);
 slist[i].description = Q_strdup (desc);
}

canonical_original_code:
void SList_Set(int i, char *addr, char *desc) {
 if (i >= 512 || i < 0)
  Sys_Error("SList_Switch: Bad index %d", i);
 if (slist[i].server)
  if(slist[i].server) { free(slist[i].server); slist[i].server = ((void *)0); };
 if (slist[i].description)
  if(slist[i].description) { free(slist[i].description); slist[i].description = ((void *)0); };
 slist[i].server = Q_strdup (addr);
 slist[i].description = Q_strdup (desc);
}

variable_types: i int

variable_types:
addr
char *

variable_types:
desc
char *


decompiled_code:
__int64 __fastcall SList_Reset_NoFree(unsigned int a1)
{
__int64 v1; // rbx
__int64 result; // rax

if ( a1 > 0x1FF )
result = Sys_Error("SList_Switch: Bad index %d", a1);
v1 = (int)a1;
*(_QWORD *)&slist[v1] = 0LL;
*((_QWORD *)&slist[v1] + 1) = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int a1)
{
__int64 v1; // rbx
__int64 result; // rax

if ( a1 > 0x1FF )
result = Sys_Error("SList_Switch: Bad index %d", a1);
v1 = (int)a1;
*(_QWORD *)&slist[v1] = 0LL;
*((_QWORD *)&slist[v1] + 1) = 0LL;
return result;
}

original_code:
void SList_Reset_NoFree (int i) {
 if (i >= 512 || i < 0)
  Sys_Error("SList_Switch: Bad index %d", i);
 slist[i].description = slist[i].server = ((void *)0);
}

canonical_original_code:
void SList_Reset_NoFree(int i) {
 if (i >= 512 || i < 0)
  Sys_Error("SList_Switch: Bad index %d", i);
 slist[i].description = slist[i].server = ((void *)0);
}


decompiled_code:
__int64 SList_Length()
{
__int64 result; // rax

for ( result = 0LL; result != 512; ++result )
{
if ( !*(_QWORD *)&slist[result] )
return (unsigned int)result;
}
return 512LL;
}

canonical_decompiled_code:
__int64 func5()
{
__int64 result; // rax

for ( result = 0LL; result != 512; ++result )
{
if ( !*(_QWORD *)&slist[result] )
return (unsigned int)result;
}
return 512LL;
}

original_code:
int SList_Length (void) {
 int count;
 for (count = 0; count < 512 && slist[count].server; count++)
  ;
 return count;
}

canonical_original_code:
int SList_Length() {
 int count;
 for (count = 0; count < 512 && slist[count].server; count++)
  ;
 return count;
}

variable_types: count int

return_type: int


decompiled_code:
__int64 __fastcall UI_Print3(__int64 a1, __int64 a2, unsigned __int8 *a3, __int64 a4, __int64 a5, int a6)
{
unsigned __int8 *v6; // r12
unsigned int v7; // ebp
unsigned __int8 v8; // dl
__int64 v9; // rdi
__int64 result; // rax

v6 = a3;
v7 = a1;
if ( !a6 )
return Draw_ColoredString3(a1, a2, a3, a4, a5, 0LL);
v8 = *a3;
if ( v8 )
{
do
{
v9 = v7;
++v6;
v7 += 8;
result = UI_DrawCharacter(v9, (unsigned int)a2, v8 | 0x80u);
v8 = *v6;
}
while ( *v6 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2, unsigned __int8 *a3, __int64 a4, __int64 a5, int a6)
{
unsigned __int8 *v6; // r12
unsigned int v7; // ebp
unsigned __int8 v8; // dl
__int64 v9; // rdi
__int64 result; // rax

v6 = a3;
v7 = a1;
if ( !a6 )
return Draw_ColoredString3(a1, a2, a3, a4, a5, 0LL);
v8 = *a3;
if ( v8 )
{
do
{
v9 = v7;
++v6;
v7 += 8;
result = func0(v9, (unsigned int)a2, v8 | 0x80u);
v8 = *v6;
}
while ( *v6 );
}
return result;
}

original_code:
void UI_Print3 (int cx, int cy, const char *str, clrinfo_t *clr, int clr_cnt, int red)
{
 if (red)
 {
  while (*str)
  {
   UI_DrawCharacter (cx, cy, (*str) | (red ? 128 : 0));
   str++;
   cx += 8;
  }
 }
 else
 {
  Draw_ColoredString3 (cx, cy, str, clr, clr_cnt, red);
 }
}

canonical_original_code:
void UI_Print3(int cx, int cy, char *str, struct clrinfo_s *clr, int clr_cnt, int red)
{
 if (red)
 {
  while (*str)
  {
   UI_DrawCharacter (cx, cy, (*str) | (red ? 128 : 0));
   str++;
   cx += 8;
  }
 }
 else
 {
  Draw_ColoredString3 (cx, cy, str, clr, clr_cnt, red);
 }
}

variable_types: cx int

variable_types: cy int

variable_types:
str
char *

variable_types:
clr
struct clrinfo_s { int c; int i; } *

variable_types: red int


decompiled_code:
__int64 __fastcall UI_Print_Center3(int a1, unsigned int a2, int a3, char *a4, __int64 a5, unsigned int a6, int a7)
{
int v11; // eax

v11 = strlen(a4);
return UI_Print3((unsigned int)(a1 + (a3 - 8 * v11) / 2), a2, (unsigned __int8 *)a4, a5, a6, a7);
}

canonical_decompiled_code:
__int64 __fastcall func6(int a1, unsigned int a2, int a3, char *a4, __int64 a5, unsigned int a6, int a7)
{
int v11; // eax

v11 = strlen(a4);
return func4((unsigned int)(a1 + (a3 - 8 * v11) / 2), a2, (unsigned __int8 *)a4, a5, a6, a7);
}

original_code:
void UI_Print_Center3 (int cx, int cy, int w, char *str, clrinfo_t *clr, int clr_cnt, int red)
{
 int text_length = strlen(str);
 UI_Print3(cx + (w - 8 * text_length) / 2, cy, str, clr, clr_cnt, red);
}

canonical_original_code:
void UI_Print_Center3(int cx, int cy, int w, char *str, struct clrinfo_s *clr, int clr_cnt, int red)
{
 int text_length = strlen(str);
 UI_Print3(cx + (w - 8 * text_length) / 2, cy, str, clr, clr_cnt, red);
}

variable_types: w int


decompiled_code:
// attributes: thunk
__int64 UI_DrawColoredAlphaBox()
{
return Draw_AlphaFillRGB();
}

canonical_decompiled_code:
__int64 func9()
{
return Draw_AlphaFillRGB();
}

original_code:
void UI_DrawColoredAlphaBox(int x, int y, int w, int h, color_t color)
{
 Draw_AlphaFillRGB(x, y, w, h, color);
}

canonical_original_code:
void UI_DrawColoredAlphaBox(int x, int y, int w, int h, int color)
{
 Draw_AlphaFillRGB(x, y, w, h, color);
}

variable_types: x int

variable_types: y int

variable_types: h int

variable_types: color int


decompiled_code:
__int64 __fastcall UI_DrawGrayBox(unsigned int a1, unsigned int a2, unsigned int a3, unsigned int a4)
{
unsigned int v6; // ebx
int v7; // xmm1_4
float v8; // xmm0_4
unsigned int v9; // eax
double v11; // xmm3_8
float v12; // xmm0_4
float v13; // [rsp+0h] [rbp-2Ch]

v6 = HIDWORD(menu_marked_bgcolor[8]);
if ( *(float *)&menu_marked_fade[4] == 0.0 )
{
v7 = LC0;
}
else
{
v13 = *(float *)&menu_marked_fade[4];
v11 = Sys_DoubleTime();
v12 = (sin(v13 * v11) + 1.0) * 0.5;
v8 = v12 * 0.5 + 0.5;
if ( v8 < 0.0 )
{
v8 = 0.0;
goto LABEL_4;
}
v7 = LC0;
if ( v8 <= 1.0 )
goto LABEL_4;
}
v8 = *(float *)&v7;
LABEL_4:
v9 = RGBA_TO_COLOR(
(unsigned __int8)(int)(float)(v8 * (float)(unsigned __int8)v6),
(unsigned __int8)(int)(float)((float)BYTE1(v6) * v8),
(unsigned __int8)(int)(float)((float)BYTE2(v6) * v8),
HIBYTE(v6));
return UI_DrawColoredAlphaBox(a1, a2, a3, a4, v9);
}

canonical_decompiled_code:
__int64 __fastcall func10(unsigned int a1, unsigned int a2, unsigned int a3, unsigned int a4)
{
unsigned int v6; // ebx
int v7; // xmm1_4
float v8; // xmm0_4
unsigned int v9; // eax
double v11; // xmm3_8
float v12; // xmm0_4
float v13; // [rsp+0h] [rbp-2Ch]

v6 = HIDWORD(menu_marked_bgcolor[8]);
if ( *(float *)&menu_marked_fade[4] == 0.0 )
{
v7 = LC0;
}
else
{
v13 = *(float *)&menu_marked_fade[4];
v11 = Sys_DoubleTime();
v12 = (sin(v13 * v11) + 1.0) * 0.5;
v8 = v12 * 0.5 + 0.5;
if ( v8 < 0.0 )
{
v8 = 0.0;
goto LABEL_4;
}
v7 = LC0;
if ( v8 <= 1.0 )
goto LABEL_4;
}
v8 = *(float *)&v7;
LABEL_4:
v9 = RGBA_TO_COLOR(
(unsigned __int8)(int)(float)(v8 * (float)(unsigned __int8)v6),
(unsigned __int8)(int)(float)((float)BYTE1(v6) * v8),
(unsigned __int8)(int)(float)((float)BYTE2(v6) * v8),
HIBYTE(v6));
return func9(a1, a2, a3, a4, v9);
}

original_code:
void UI_DrawGrayBox(int x, int y, int w, int h)
{
 byte c[4];
 float fade = 1;
 memcpy(c, menu_marked_bgcolor.color, sizeof(byte) * 4);
 if (menu_marked_fade.value)
 {
  fade = 0.5 * (1.0 + sin(menu_marked_fade.value * Sys_DoubleTime()));
  fade = 0.5 + (1.0 - 0.5) * fade ;
  fade = ((0) >= (1) ? (0) : (fade) < (0) ? (0) : (fade) > (1) ? (1) : (fade));
 }
 UI_DrawColoredAlphaBox(x, y, w, h, RGBA_TO_COLOR((fade * c[0]), (fade * c[1]), (fade * c[2]), c[3]));
}

canonical_original_code:
void UI_DrawGrayBox(int x, int y, int w, int h)
{
 unsigned char c[4];
 float fade = 1;
 memcpy(c, menu_marked_bgcolor.color, sizeof(byte) * 4);
 if (menu_marked_fade.value)
 {
  fade = 0.5 * (1.0 + sin(menu_marked_fade.value * Sys_DoubleTime()));
  fade = 0.5 + (1.0 - 0.5) * fade ;
  fade = ((0) >= (1) ? (0) : (fade) < (0) ? (0) : (fade) > (1) ? (1) : (fade));
 }
 UI_DrawColoredAlphaBox(x, y, w, h, RGBA_TO_COLOR((fade * c[0]), (fade * c[1]), (fade * c[2]), c[3]));
}

variable_types:
c
unsigned char [4]

variable_types: fade float


original_code:
qbool UI_PrintTextBlock(int x, int y, int w, int h, const char* text, qbool red)
{
 int letters_per_line = w / 8;
 int lines = h / 8;
 int linelen = 0;
 int linecount = 0;
 char buf[1024];
 const char *start = text, *end, *wordend;
 while (*start && linecount < lines)
 {
  wordend = start;
  end = wordend;
  linelen = 0;
  while (linelen < letters_per_line && *wordend)
  {
   end = wordend;
   do
   {
    wordend++;
    linelen++;
   }
   while (*wordend && *wordend != ' ' && *wordend != '\n');
   if(linelen >= letters_per_line)
   {
    do
    {
     wordend--;
     linelen--;
    }
    while(*wordend && *wordend != ' ' && linelen > 0);
    end = (linelen == 0) ? (end + letters_per_line - 1) : wordend;
    break;
   }
   if (*wordend == '\n')
   {
    end = wordend;
    break;
   }
  }
  if (!*wordend && linelen < letters_per_line)
  {
   end = wordend;
  }
  while (*end && *end == ' ')
  {
   end++;
  }
  if(*start && *start == '\n')
  {
   start++;
  }
  strlcpy(buf, start, end - start + 1);
  UI_Print(x, y + (linecount * 8), buf, red);
  linecount++;
  start = end;
 }
 return !(*start);
}

canonical_original_code:
enum qbool UI_PrintTextBlock(int x, int y, int w, int h, char *text, enum qbool red)
{
 int letters_per_line = w / 8;
 int lines = h / 8;
 int linelen = 0;
 int linecount = 0;
 char buf[1024];
 char *start = text; char *end; char *wordend;
 while (*start && linecount < lines)
 {
  wordend = start;
  end = wordend;
  linelen = 0;
  while (linelen < letters_per_line && *wordend)
  {
   end = wordend;
   do
   {
    wordend++;
    linelen++;
   }
   while (*wordend && *wordend != ' ' && *wordend != '\n');
   if(linelen >= letters_per_line)
   {
    do
    {
     wordend--;
     linelen--;
    }
    while(*wordend && *wordend != ' ' && linelen > 0);
    end = (linelen == 0) ? (end + letters_per_line - 1) : wordend;
    break;
   }
   if (*wordend == '\n')
   {
    end = wordend;
    break;
   }
  }
  if (!*wordend && linelen < letters_per_line)
  {
   end = wordend;
  }
  while (*end && *end == ' ')
  {
   end++;
  }
  if(*start && *start == '\n')
  {
   start++;
  }
  strlcpy(buf, start, end - start + 1);
  UI_Print(x, y + (linecount * 8), buf, red);
  linecount++;
  start = end;
 }
 return !(*start);
}

variable_types:
text
char *

variable_types:
red
enum qbool { false=0, true=1 }

variable_types: lines int

variable_types: linelen int

variable_types: linecount int

variable_types:
buf
char [1024]

variable_types:
start
char *

variable_types:
end
char *

variable_types:
wordend
char *

return_type: enum qbool { false=0, true=1 }


decompiled_code:
// attributes: thunk
__int64 UI_DrawCharacter()
{
return Draw_Character();
}

canonical_decompiled_code:
__int64 func0()
{
return Draw_Character();
}

original_code:
void UI_DrawCharacter (int cx, int line, int num)
{
 Draw_Character ( cx, line, num);
}

canonical_original_code:
void UI_DrawCharacter(int cx, int line, int num)
{
 Draw_Character ( cx, line, num);
}

variable_types: cx int

variable_types: line int

variable_types: num int


decompiled_code:
__int64 __fastcall UI_Print(__int64 a1, __int64 a2, unsigned __int8 *a3, int a4)
{
unsigned __int8 *v4; // r12
unsigned int v5; // ebp
unsigned __int8 v6; // dl
__int64 v7; // rdi
__int64 result; // rax

v4 = a3;
v5 = a1;
if ( !a4 )
return Draw_ColoredString(a1, a2, a3, 0LL);
v6 = *a3;
if ( v6 )
{
do
{
v7 = v5;
++v4;
v5 += 8;
result = UI_DrawCharacter(v7, (unsigned int)a2, v6 | 0x80u);
v6 = *v4;
}
while ( *v4 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, unsigned __int8 *a3, int a4)
{
unsigned __int8 *v4; // r12
unsigned int v5; // ebp
unsigned __int8 v6; // dl
__int64 v7; // rdi
__int64 result; // rax

v4 = a3;
v5 = a1;
if ( !a4 )
return Draw_ColoredString(a1, a2, a3, 0LL);
v6 = *a3;
if ( v6 )
{
do
{
v7 = v5;
++v4;
v5 += 8;
result = func0(v7, (unsigned int)a2, v6 | 0x80u);
v6 = *v4;
}
while ( *v4 );
}
return result;
}

original_code:
void UI_Print (int cx, int cy, const char *str, int red)
{
 if (red)
 {
  while (*str)
  {
   UI_DrawCharacter (cx, cy, (*str) | (red ? 128 : 0));
   str++;
   cx += 8;
  }
 }
 else
 {
  Draw_ColoredString (cx, cy, str, red);
 }
}

canonical_original_code:
void UI_Print(int cx, int cy, char *str, int red)
{
 if (red)
 {
  while (*str)
  {
   UI_DrawCharacter (cx, cy, (*str) | (red ? 128 : 0));
   str++;
   cx += 8;
  }
 }
 else
 {
  Draw_ColoredString (cx, cy, str, red);
 }
}

variable_types: cy int

variable_types:
str
char *

variable_types: red int


decompiled_code:
__int64 __fastcall UI_DrawSlider(int a1, unsigned int a2, float a3)
{
float v4; // xmm0_4
int v5; // er13
unsigned int v6; // ebp
__int64 v7; // rdi

v4 = 0.0;
v5 = a1;
if ( a3 >= 0.0 )
v4 = fminf(1.0, a3);
v6 = a1;
UI_DrawCharacter((unsigned int)(a1 - 8), a2, 128LL);
do
{
v7 = v6;
v6 += 8;
UI_DrawCharacter(v7, a2, 129LL);
}
while ( v6 != v5 + 96 );
UI_DrawCharacter(v6, a2, 130LL);
UI_DrawCharacter((unsigned int)(int)(float)((float)(v4 * 88.0) + (float)v5), a2, 131LL);
return (unsigned int)(v5 + 104);
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1, unsigned int a2, float a3)
{
float v4; // xmm0_4
int v5; // er13
unsigned int v6; // ebp
__int64 v7; // rdi

v4 = 0.0;
v5 = a1;
if ( a3 >= 0.0 )
v4 = fminf(1.0, a3);
v6 = a1;
func0((unsigned int)(a1 - 8), a2, 128LL);
do
{
v7 = v6;
v6 += 8;
func0(v7, a2, 129LL);
}
while ( v6 != v5 + 96 );
func0(v6, a2, 130LL);
func0((unsigned int)(int)(float)((float)(v4 * 88.0) + (float)v5), a2, 131LL);
return (unsigned int)(v5 + 104);
}

original_code:
int UI_DrawSlider (int x, int y, float range) {
 int i;
 range = ((0) >= (1) ? (0) : (range) < (0) ? (0) : (range) > (1) ? (1) : (range));
 UI_DrawCharacter (x-8, y, 128);
 for (i=0 ; i<12 ; i++)
  UI_DrawCharacter (x + i*8, y, 129);
 UI_DrawCharacter (x+i*8, y, 130);
 UI_DrawCharacter (x + (12 -1)*8 * range, y, 131);
 return x+(i+1)*8;
}

canonical_original_code:
int UI_DrawSlider(int x, int y, float range) {
 int i;
 range = ((0) >= (1) ? (0) : (range) < (0) ? (0) : (range) > (1) ? (1) : (range));
 UI_DrawCharacter (x-8, y, 128);
 for (i=0 ; i<12 ; i++)
  UI_DrawCharacter (x + i*8, y, 129);
 UI_DrawCharacter (x+i*8, y, 130);
 UI_DrawCharacter (x + (12 -1)*8 * range, y, 131);
 return x+(i+1)*8;
}

variable_types: x int

variable_types: y int

variable_types: range float

variable_types: i int


decompiled_code:
__int64 UI_SliderWidth()
{
return 104LL;
}

canonical_decompiled_code:
__int64 func3()
{
return 104LL;
}

original_code: int UI_SliderWidth(void) { return (12 +1)*8; }

canonical_original_code: int UI_SliderWidth() { return (12 +1)*8; }


decompiled_code:
__int64 __fastcall UI_Print_Center(int a1, unsigned int a2, int a3, char *a4, int a5)
{
int v8; // eax

v8 = strlen(a4);
return UI_Print((unsigned int)(a1 + (a3 - 8 * v8) / 2), a2, (unsigned __int8 *)a4, a5);
}

canonical_decompiled_code:
__int64 __fastcall func5(int a1, unsigned int a2, int a3, char *a4, int a5)
{
int v8; // eax

v8 = strlen(a4);
return func1((unsigned int)(a1 + (a3 - 8 * v8) / 2), a2, (unsigned __int8 *)a4, a5);
}

original_code:
void UI_Print_Center (int cx, int cy, int w, const char *str, int red)
{
 int text_length = strlen(str);
 UI_Print(cx + (w - 8 * text_length) / 2, cy, str, red);
}

canonical_original_code:
void UI_Print_Center(int cx, int cy, int w, char *str, int red)
{
 int text_length = strlen(str);
 UI_Print(cx + (w - 8 * text_length) / 2, cy, str, red);
}

variable_types: w int


decompiled_code:
__int64 __fastcall UI_DrawBox(__int64 a1, __int64 a2, int a3, int a4)
{
int v6; // ecx
int v7; // edx
__int64 v8; // rcx

v6 = a4 + 7;
if ( a4 >= 0 )
v6 = a4;
v7 = a3 + 7;
v8 = (unsigned int)((v6 >> 3) - 1);
if ( a3 >= 0 )
v7 = a3;
return Draw_TextBox(a1, a2, (unsigned int)((v7 >> 3) - 1), v8);
}

original_code:
void UI_DrawBox(int x, int y, int w, int h)
{
 Draw_TextBox(x, y, w / 8 - 1, h / 8 - 1);
}

variable_types: h int


decompiled_code:
void __noreturn Host_Error(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-4D0h] BYREF
char s[1024]; // [rsp+20h] [rbp-4B8h] BYREF

if ( inerror_2 )
Sys_Error("Host_Error: recursively entered");
va_start(arg, format);
inerror_2 = 1;
vsnprintf(s, 0x400uLL, format, arg);
Com_Printf("\n===========================\n");
Com_Printf("Host_Error: %s\n", s);
Com_Printf("===========================\n\n");
CL_Disconnect();
if ( !host_initialized )
Sys_Error("Host_Error: %s", s);
inerror_2 = 0;
Host_Abort();
}

canonical_decompiled_code:
void __noreturn func5(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-4D0h] BYREF
char s[1024]; // [rsp+20h] [rbp-4B8h] BYREF

if ( inerror_2 )
Sys_Error("Host_Error: recursively entered");
va_start(arg, format);
inerror_2 = 1;
vsnprintf(s, 0x400uLL, format, arg);
Com_Printf("\n===========================\n");
Com_Printf("Host_Error: %s\n", s);
Com_Printf("===========================\n\n");
CL_Disconnect();
if ( !host_initialized )
Sys_Error("Host_Error: %s", s);
inerror_2 = 0;
func3();
}

original_code:
void Host_Error (char *error, ...)
{
 va_list argptr;
 char string[1024];
 static qbool inerror = false;
 if (inerror)
  Sys_Error ("Host_Error: recursively entered");
 inerror = true;
 __builtin_va_start(argptr,error);
 vsnprintf (string, sizeof(string), error, argptr);
 __builtin_va_end(argptr);
 Com_Printf ("\n===========================\n");
 Com_Printf ("Host_Error: %s\n",string);
 Com_Printf ("===========================\n\n");
 CL_Disconnect ();
 if (!host_initialized)
  Sys_Error ("Host_Error: %s", string);
 inerror = false;
 Host_Abort ();
}

canonical_original_code:
void Host_Error(char *error, ...)
{
 __builtin_va_list argptr;
 char string[1024];
 static enum qbool inerror = false;
 if (inerror)
  Sys_Error ("Host_Error: recursively entered");
 inerror = true;
 __builtin_va_start(argptr,error);
 vsnprintf (string, sizeof(string), error, argptr);
 __builtin_va_end(argptr);
 Com_Printf ("\n===========================\n");
 Com_Printf ("Host_Error: %s\n",string);
 Com_Printf ("===========================\n\n");
 CL_Disconnect ();
 if (!host_initialized)
  Sys_Error ("Host_Error: %s", string);
 inerror = false;
 Host_Abort ();
}

variable_types:
error
char *

variable_types:
string
char [1024]

variable_types:
inerror
enum qbool { false=0, true=1 }


decompiled_code:
char Startup_Place()
{
const char *v0; // rsi
bool v1; // zf
char result; // al
__int64 v3; // rax
__int64 v4; // rax

v0 = (const char *)cl_startupdemo[1];
if ( *v0 )
{
v3 = va("playdemo %s\n", v0);
result = Cbuf_AddText(v3);
key_dest = 6;
}
else if ( !strcmp(*((const char **)&cl_onload + 1), "menu") )
{
result = Cbuf_AddText("togglemenu\n");
}
else if ( !strcmp(*((const char **)&cl_onload + 1), "browser") )
{
result = Cbuf_AddText("menu_slist\n");
}
else
{
v1 = strcmp(*((const char **)&cl_onload + 1), "console") == 0;
result = !v1;
if ( !v1 )
{
v4 = va("%s\n", *((const char **)&cl_onload + 1));
result = Cbuf_AddText(v4);
}
}
return result;
}

canonical_decompiled_code:
char func10()
{
const char *v0; // rsi
bool v1; // zf
char result; // al
__int64 v3; // rax
__int64 v4; // rax

v0 = (const char *)cl_startupdemo[1];
if ( *v0 )
{
v3 = va("playdemo %s\n", v0);
result = Cbuf_AddText(v3);
key_dest = 6;
}
else if ( !strcmp(*((const char **)&cl_onload + 1), "menu") )
{
result = Cbuf_AddText("togglemenu\n");
}
else if ( !strcmp(*((const char **)&cl_onload + 1), "browser") )
{
result = Cbuf_AddText("menu_slist\n");
}
else
{
v1 = strcmp(*((const char **)&cl_onload + 1), "console") == 0;
result = !v1;
if ( !v1 )
{
v4 = va("%s\n", *((const char **)&cl_onload + 1));
result = Cbuf_AddText(v4);
}
}
return result;
}

original_code:
void Startup_Place(void)
{
    extern cvar_t cl_onload;
 extern cvar_t cl_startupdemo;
 if (cl_startupdemo.string[0]) {
  Cbuf_AddText(va("playdemo %s\n", cl_startupdemo.string));
  key_dest = key_startupdemo;
 }
 else
 {
  if (!strcmp(cl_onload.string, "menu"))
   Cbuf_AddText("togglemenu\n");
  else if (!strcmp(cl_onload.string, "browser"))
   Cbuf_AddText("menu_slist\n");
  else if (!strcmp(cl_onload.string, "console"))
   ;
  else Cbuf_AddText(va("%s\n", cl_onload.string));
 }
}

canonical_original_code:
void Startup_Place()
{
    extern struct cvar_s cl_onload;
 extern struct cvar_s cl_startupdemo;
 if (cl_startupdemo.string[0]) {
  Cbuf_AddText(va("playdemo %s\n", cl_startupdemo.string));
  key_dest = key_startupdemo;
 }
 else
 {
  if (!strcmp(cl_onload.string, "menu"))
   Cbuf_AddText("togglemenu\n");
  else if (!strcmp(cl_onload.string, "browser"))
   Cbuf_AddText("menu_slist\n");
  else if (!strcmp(cl_onload.string, "console"))
   ;
  else Cbuf_AddText(va("%s\n", cl_onload.string));
 }
}

variable_types: struct cvar_s { char *name; char *string; int flags; void (*OnChange)(struct cvar_s *var, char *value, enum qbool { false=0, true=1 } *cancel); float value; float maxrulesetvalue; float minrulesetvalue; char *defaultvalue; char *latchedString; int integer; unsigned char color[4]; enum qbool { false=0, true=1 } modified; enum qbool { false=0, true=1 } teamplay; struct cvar_group_s { char name[65]; int count; struct cvar_s *head; struct cvar_group_s *next; } *group; struct cvar_s *next_in_group; struct cvar_s *hash_next; struct cvar_s *next; }

user_defined_types: struct cvar_s { char *name; char *string; int flags; void (*OnChange)(struct cvar_s *var, char *value, enum qbool *cancel); float value; float maxrulesetvalue; float minrulesetvalue; char *defaultvalue; char *latchedString; int integer; unsigned char color[4]; enum qbool modified; enum qbool teamplay; struct cvar_group_s *group; struct cvar_s *next_in_group; struct cvar_s *hash_next; struct cvar_s *next; }


decompiled_code:
int Host_Shutdown()
{
if ( isdown_0 )
return puts("recursive shutdown");
isdown_0 = 1;
S_StopAllSounds(1LL);
S_Update(&vec3_origin, &vec3_origin, &vec3_origin);
CL_Shutdown();
NET_Shutdown();
Con_Shutdown();
return TCL_Shutdown();
}

canonical_decompiled_code:
int func12()
{
if ( isdown_0 )
return puts("recursive shutdown");
isdown_0 = 1;
S_StopAllSounds(1LL);
S_Update(&vec3_origin, &vec3_origin, &vec3_origin);
CL_Shutdown();
NET_Shutdown();
Con_Shutdown();
return TCL_Shutdown();
}

original_code:
void Host_Shutdown (void)
{
 static qbool isdown = false;
 if (isdown) {
  printf ("recursive shutdown\n");
  return;
 }
 isdown = true;
 S_StopAllSounds (true);
 S_Update (vec3_origin, vec3_origin, vec3_origin, vec3_origin);
 CL_Shutdown ();
 NET_Shutdown ();
 Con_Shutdown();
 TCL_Shutdown ();
}

canonical_original_code:
void Host_Shutdown()
{
 static enum qbool isdown = false;
 if (isdown) {
  printf ("recursive shutdown\n");
  return;
 }
 isdown = true;
 S_StopAllSounds (true);
 S_Update (vec3_origin, vec3_origin, vec3_origin, vec3_origin);
 CL_Shutdown ();
 NET_Shutdown ();
 Con_Shutdown();
 TCL_Shutdown ();
}

variable_types:
isdown
enum qbool { false=0, true=1 }


decompiled_code:
char *__fastcall XSD_DetectType_OnStartElement(char *a1, const char *a2)
{
char *result; // rax

if ( !*a1 )
result = strcpy(a1, a2);
return result;
}

canonical_decompiled_code:
char *__fastcall func0(char *a1, const char *a2)
{
char *result; // rax

if ( !*a1 )
result = strcpy(a1, a2);
return result;
}

original_code:
static void XSD_DetectType_OnStartElement(void *userData, const XML_Char *name, const XML_Char **atts)
{
    char *type = (char *) userData;
    if (type[0] == 0)
        strcpy(type, name);
}

canonical_original_code:
static void XSD_DetectType_OnStartElement(void *userData, char *name, char **atts)
{
    char *type = (char *) userData;
    if (type[0] == 0)
        strcpy(type, name);
}

variable_types:
userData
void *

variable_types:
name
char *

variable_types:
atts
char **

variable_types:
type
char *


decompiled_code:
char *__fastcall XSD_AddText(void *ptr, void *src, int a3)
{
size_t v3; // rbx
size_t v4; // r14
char *v5; // r12
size_t v6; // rax

v3 = a3;
if ( ptr )
{
v4 = strlen((const char *)ptr) + a3 + 1;
v5 = (char *)Q_malloc(v4);
strlcpy(v5, ptr, v4);
v6 = strlen(v5);
memcpy(&v5[v6], src, v3);
v5[strlen((const char *)ptr) + v3] = 0;
free(ptr);
}
else
{
v5 = (char *)Q_malloc(a3 + 1);
memcpy(v5, src, v3);
v5[v3] = 0;
}
return v5;
}

canonical_decompiled_code:
char *__fastcall func2(void *ptr, void *src, int a3)
{
size_t v3; // rbx
size_t v4; // r14
char *v5; // r12
size_t v6; // rax

v3 = a3;
if ( ptr )
{
v4 = strlen((const char *)ptr) + a3 + 1;
v5 = (char *)Q_malloc(v4);
strlcpy(v5, ptr, v4);
v6 = strlen(v5);
memcpy(&v5[v6], src, v3);
v5[strlen((const char *)ptr) + v3] = 0;
free(ptr);
}
else
{
v5 = (char *)Q_malloc(a3 + 1);
memcpy(v5, src, v3);
v5[v3] = 0;
}
return v5;
}

original_code:
char *XSD_AddText(char *dst, const char *src, int src_len)
{
    char *buf;
 size_t len;
    if (dst == ((void *)0))
    {
        buf = (char *) Q_malloc(src_len + 1);
        memcpy(buf, src, src_len);
        buf[src_len] = 0;
    }
    else
    {
  len = 1 + src_len + strlen(dst);
        buf = (char *) Q_malloc(len);
        strlcpy (buf, dst, len);
        memcpy(buf+strlen(buf), src, src_len);
        buf[src_len+strlen(dst)] = 0;
        if(dst) { free(dst); dst = ((void *)0); };
    }
    return buf;
}

canonical_original_code:
char *XSD_AddText(char *dst, char *src, int src_len)
{
    char *buf;
 unsigned long len;
    if (dst == ((void *)0))
    {
        buf = (char *) Q_malloc(src_len + 1);
        memcpy(buf, src, src_len);
        buf[src_len] = 0;
    }
    else
    {
  len = 1 + src_len + strlen(dst);
        buf = (char *) Q_malloc(len);
        strlcpy (buf, dst, len);
        memcpy(buf+strlen(buf), src, src_len);
        buf[src_len+strlen(dst)] = 0;
        if(dst) { free(dst); dst = ((void *)0); };
    }
    return buf;
}

variable_types:
dst
char *

variable_types:
src
char *

variable_types:
buf
char *

variable_types:
len
unsigned long

return_type: char *


decompiled_code:
_BOOL8 __fastcall XSD_IsIn(char *s1, char *s2)
{
_BOOL4 v2; // er13
size_t v3; // rbx

v2 = 0;
v3 = strlen(s2);
if ( strlen(s1) >= v3 && !strncmp(s1, s2, v3) )
v2 = s1[v3] == 47 || s1[v3] == 0;
return v2;
}

canonical_decompiled_code:
_BOOL8 __fastcall func5(char *s1, char *s2)
{
_BOOL4 v2; // er13
size_t v3; // rbx

v2 = 0;
v3 = strlen(s2);
if ( strlen(s1) >= v3 && !strncmp(s1, s2, v3) )
v2 = s1[v3] == 47 || s1[v3] == 0;
return v2;
}

original_code:
int XSD_IsIn(char *path, char *subPath)
{
    size_t sublen = strlen(subPath);
    if (strlen(path) < sublen)
        return 0;
    if (!strncmp(path, subPath, sublen) &&
        (path[sublen] == 0 || path[sublen] == '/'))
    {
        return 1;
    }
    return 0;
}

canonical_original_code:
int XSD_IsIn(char *path, char *subPath)
{
    unsigned long sublen = strlen(subPath);
    if (strlen(path) < sublen)
        return 0;
    if (!strncmp(path, subPath, sublen) &&
        (path[sublen] == 0 || path[sublen] == '/'))
    {
        return 1;
    }
    return 0;
}

variable_types:
path
char *

variable_types:
subPath
char *

variable_types:
sublen
unsigned long


decompiled_code:
void __fastcall XSD_FreeDocument(const char **a1)
{
const char *v2; // rdi
const char *v3; // rbp
__int64 v4; // rbx

v2 = xsd_mappings;
if ( xsd_mappings )
{
v3 = *a1;
v4 = 0LL;
while ( strcmp(v2, v3) )
{
++v4;
v2 = (&xsd_mappings)[4 * v4];
if ( !v2 )
return;
}
((void (__fastcall *)(const char **))(&xsd_mappings)[4 * (int)v4 + 2])(a1);
}
}

canonical_decompiled_code:
void __fastcall func11(const char **a1)
{
const char *v2; // rdi
const char *v3; // rbp
__int64 v4; // rbx

v2 = xsd_mappings;
if ( xsd_mappings )
{
v3 = *a1;
v4 = 0LL;
while ( strcmp(v2, v3) )
{
++v4;
v2 = (&xsd_mappings)[4 * v4];
if ( !v2 )
return;
}
((void (__fastcall *)(const char **))(&xsd_mappings)[4 * (int)v4 + 2])(a1);
}
}

original_code:
void XSD_FreeDocument(xml_t *document)
{
    int i = 0;
    while (xsd_mappings[i].document_type != ((void *)0))
    {
        if (!strcmp(xsd_mappings[i].document_type, document->document_type))
        {
            xsd_mappings[i].free_function(document);
            return;
        }
        i++;
    }
}

canonical_original_code:
void XSD_FreeDocument(struct xml_s *document)
{
    int i = 0;
    while (xsd_mappings[i].document_type != ((void *)0))
    {
        if (!strcmp(xsd_mappings[i].document_type, document->document_type))
        {
            xsd_mappings[i].free_function(document);
            return;
        }
        i++;
    }
}

variable_types:
document
struct xml_s { char *document_type; } *

variable_types: i int


decompiled_code:
__int64 __fastcall XSD_XslConvert(const char **a1)
{
const char *v2; // rdi
const char *v3; // rbp
__int64 v4; // rbx
char *v5; // rax
__int64 result; // rax

v2 = xsd_mappings;
if ( !xsd_mappings )
goto LABEL_7;
v3 = *a1;
v4 = 0LL;
while ( strcmp(v2, v3) )
{
++v4;
v2 = (&xsd_mappings)[4 * v4];
if ( !v2 )
goto LABEL_7;
}
v5 = (&xsd_mappings)[4 * (int)v4 + 3];
if ( v5 )
result = ((__int64 (__fastcall *)(const char **))v5)(a1);
else
LABEL_7:
result = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(const char **a1)
{
const char *v2; // rdi
const char *v3; // rbp
__int64 v4; // rbx
char *v5; // rax
__int64 result; // rax

v2 = xsd_mappings;
if ( !xsd_mappings )
goto LABEL_7;
v3 = *a1;
v4 = 0LL;
while ( strcmp(v2, v3) )
{
++v4;
v2 = (&xsd_mappings)[4 * v4];
if ( !v2 )
goto LABEL_7;
}
v5 = (&xsd_mappings)[4 * (int)v4 + 3];
if ( v5 )
result = ((__int64 (__fastcall *)(const char **))v5)(a1);
else
LABEL_7:
result = 0LL;
return result;
}

original_code:
xml_document_t * XSD_XslConvert(xml_t *doc)
{
    int i = 0;
    while (xsd_mappings[i].document_type != ((void *)0))
    {
        if (!strcmp(xsd_mappings[i].document_type, doc->document_type))
        {
            if (xsd_mappings[i].convert_function)
                return (xml_document_t *)xsd_mappings[i].convert_function(doc);
            else
                return ((void *)0);
        }
        i++;
    }
    return ((void *)0);
}

canonical_original_code:
struct xml_document_s *XSD_XslConvert(struct xml_s *doc)
{
    int i = 0;
    while (xsd_mappings[i].document_type != ((void *)0))
    {
        if (!strcmp(xsd_mappings[i].document_type, doc->document_type))
        {
            if (xsd_mappings[i].convert_function)
                return (struct xml_document_s *)xsd_mappings[i].convert_function(doc);
            else
                return ((void *)0);
        }
        i++;
    }
    return ((void *)0);
}

variable_types:
doc
struct xml_s { char *document_type; } *

return_type: struct xml_document_s { char *document_type; char *title; char *date; struct xml_document_author_s { enum document_tag_type_t { tag_text=0, tag_section=1, tag_p=2, tag_list=3, tag_dict=4, tag_hr=5, tag_h=6, tag_pre=7, tag_em=8, tag_a=9, tag_img=10, tag_color=11, tag_br=12, tag_sp=13, tag_li=14, tag_di=15 } type; struct xml_document_author_s *next; char *name; char *email; char *im; } *authors; struct document_tag_s { enum document_tag_type_t { tag_text=0, tag_section=1, tag_p=2, tag_list=3, tag_dict=4, tag_hr=5, tag_h=6, tag_pre=7, tag_em=8, tag_a=9, tag_img=10, tag_color=11, tag_br=12, tag_sp=13, tag_li=14, tag_di=15 } type; struct document_tag_s *next; } *content; } *

user_defined_types: struct xml_document_s { char *document_type; char *title; char *date; struct xml_document_author_s *authors; struct document_tag_s *content; }

user_defined_types: struct xml_document_author_s { enum document_tag_type_t type; struct xml_document_author_s *next; char *name; char *email; char *im; }

user_defined_types: struct document_tag_s { enum document_tag_type_t type; struct document_tag_s *next; }


decompiled_code:
const char **__fastcall XSD_LoadDocumentWithXsl(__int64 a1)
{
const char **result; // rax
const char **v2; // r12
__int64 v3; // rbx

result = (const char **)XSD_LoadDocument(a1);
v2 = result;
if ( result )
{
if ( strcmp(*result, "document") )
{
v3 = XSD_XslConvert(result);
XSD_FreeDocument(v2);
result = (const char **)v3;
}
}
return result;
}

canonical_decompiled_code:
const char **__fastcall func13(__int64 a1)
{
const char **result; // rax
const char **v2; // r12
__int64 v3; // rbx

result = (const char **)func10(a1);
v2 = result;
if ( result )
{
if ( strcmp(*result, "document") )
{
v3 = func12(result);
func11(v2);
result = (const char **)v3;
}
}
return result;
}

original_code:
xml_document_t * XSD_LoadDocumentWithXsl(char *filename)
{
    xml_t *doc;
    xml_document_t *document;
    doc = XSD_LoadDocument(filename);
    if (doc == ((void *)0))
        return ((void *)0);
    if (!strcmp(doc->document_type, "document"))
        return (xml_document_t *) doc;
    document = XSD_XslConvert(doc);
    XSD_FreeDocument(doc);
    return document;
}

canonical_original_code:
struct xml_document_s *XSD_LoadDocumentWithXsl(char *filename)
{
    struct xml_s *doc;
    struct xml_document_s *document;
    doc = XSD_LoadDocument(filename);
    if (doc == ((void *)0))
        return ((void *)0);
    if (!strcmp(doc->document_type, "document"))
        return (struct xml_document_s *) doc;
    document = XSD_XslConvert(doc);
    XSD_FreeDocument(doc);
    return document;
}

variable_types:
filename
char *

variable_types: struct xml_document_s { char *document_type; char *title; char *date; struct xml_document_author_s { enum document_tag_type_t { tag_text=0, tag_section=1, tag_p=2, tag_list=3, tag_dict=4, tag_hr=5, tag_h=6, tag_pre=7, tag_em=8, tag_a=9, tag_img=10, tag_color=11, tag_br=12, tag_sp=13, tag_li=14, tag_di=15 } type; struct xml_document_author_s *next; char *name; char *email; char *im; } *authors; struct document_tag_s { enum document_tag_type_t { tag_text=0, tag_section=1, tag_p=2, tag_list=3, tag_dict=4, tag_hr=5, tag_h=6, tag_pre=7, tag_em=8, tag_a=9, tag_img=10, tag_color=11, tag_br=12, tag_sp=13, tag_li=14, tag_di=15 } type; struct document_tag_s *next; } *content; } *


decompiled_code:
const char *__fastcall XSD_GetAttribute(const char **a1, const char *a2)
{
const char **v2; // rbx
const char *v3; // rdi

v2 = a1;
v3 = *a1;
if ( v3 )
{
while ( strcmp(v3, a2) )
{
v3 = v2[2];
v2 += 2;
if ( !v3 )
return v3;
}
v3 = v2[1];
}
return v3;
}

canonical_decompiled_code:
const char *__fastcall func1(const char **a1, const char *a2)
{
const char **v2; // rbx
const char *v3; // rdi

v2 = a1;
v3 = *a1;
if ( v3 )
{
while ( strcmp(v3, a2) )
{
v3 = v2[2];
v2 += 2;
if ( !v3 )
return v3;
}
v3 = v2[1];
}
return v3;
}

original_code:
const char *XSD_GetAttribute(const char **atts, const char *name)
{
    while (*atts)
    {
        if (!strcmp(*atts, name))
            return *(atts+1);
        atts += 2;
    }
    return ((void *)0);
}

canonical_original_code:
char *XSD_GetAttribute(char **atts, char *name)
{
    while (*atts)
    {
        if (!strcmp(*atts, name))
            return *(atts+1);
        atts += 2;
    }
    return ((void *)0);
}


decompiled_code:
unsigned __int64 __fastcall XSD_IsSpace(unsigned __int8 a1)
{
unsigned __int64 result; // rax

result = 0LL;
if ( a1 <= 0x20u )
result = (0x100002600uLL >> a1) & 1;
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func3(unsigned __int8 a1)
{
unsigned __int64 result; // rax

result = 0LL;
if ( a1 <= 0x20u )
result = (0x100002600uLL >> a1) & 1;
return result;
}

original_code:
int XSD_IsSpace(char c)
{
    if (c == ' ' || c == '\t' || c == '\n' || c == '\r')
        return 1;
    return 0;
}

variable_types: c char


decompiled_code:
__int64 __fastcall XSD_StripSpaces(void *ptr)
{
unsigned int v2; // ebx
size_t v3; // rax
_BYTE *v4; // rbp
size_t v5; // rax
__int64 v6; // rdx
unsigned __int64 v7; // rsi
int v8; // er13
size_t v9; // rax
unsigned __int8 v10; // di
int v11; // er13
size_t v12; // rax
int v13; // esi
__int64 v14; // rdx
_BYTE *v15; // rdx
__int64 v16; // r13

if ( !ptr )
return 0LL;
v2 = 0;
v3 = strlen((const char *)ptr);
v4 = (_BYTE *)Q_malloc(v3 + 1);
v5 = strlen((const char *)ptr);
LODWORD(v6) = 0;
v7 = v5;
while ( v2 < v7 )
{
v10 = *((_BYTE *)ptr + v2);
if ( (unsigned int)XSD_IsSpace(v10) )
{
if ( (_DWORD)v6 )
{
if ( !(unsigned int)XSD_IsSpace(v4[(unsigned int)(v6 - 1)]) )
{
v4[v6] = 32;
v8 = v6 + 1;
v9 = strlen((const char *)ptr);
LODWORD(v6) = v8;
v7 = v9;
}
}
}
else
{
v4[v6] = v10;
v11 = v6 + 1;
v12 = strlen((const char *)ptr);
LODWORD(v6) = v11;
v7 = v12;
}
++v2;
}
while ( 1 )
{
if ( !(_DWORD)v6 )
{
v15 = v4;
goto LABEL_14;
}
v13 = v6 - 1;
if ( !(unsigned int)XSD_IsSpace(v4[(unsigned int)(v6 - 1)]) )
break;
LODWORD(v6) = v13;
}
v15 = &v4[v14];
LABEL_14:
*v15 = 0;
v16 = Q_strdup(v4);
if ( v4 )
free(v4);
free(ptr);
return v16;
}

canonical_decompiled_code:
__int64 __fastcall func4(void *ptr)
{
unsigned int v2; // ebx
size_t v3; // rax
_BYTE *v4; // rbp
size_t v5; // rax
__int64 v6; // rdx
unsigned __int64 v7; // rsi
int v8; // er13
size_t v9; // rax
unsigned __int8 v10; // di
int v11; // er13
size_t v12; // rax
int v13; // esi
__int64 v14; // rdx
_BYTE *v15; // rdx
__int64 v16; // r13

if ( !ptr )
return 0LL;
v2 = 0;
v3 = strlen((const char *)ptr);
v4 = (_BYTE *)Q_malloc(v3 + 1);
v5 = strlen((const char *)ptr);
LODWORD(v6) = 0;
v7 = v5;
while ( v2 < v7 )
{
v10 = *((_BYTE *)ptr + v2);
if ( (unsigned int)func3(v10) )
{
if ( (_DWORD)v6 )
{
if ( !(unsigned int)func3(v4[(unsigned int)(v6 - 1)]) )
{
v4[v6] = 32;
v8 = v6 + 1;
v9 = strlen((const char *)ptr);
LODWORD(v6) = v8;
v7 = v9;
}
}
}
else
{
v4[v6] = v10;
v11 = v6 + 1;
v12 = strlen((const char *)ptr);
LODWORD(v6) = v11;
v7 = v12;
}
++v2;
}
while ( 1 )
{
if ( !(_DWORD)v6 )
{
v15 = v4;
goto LABEL_14;
}
v13 = v6 - 1;
if ( !(unsigned int)func3(v4[(unsigned int)(v6 - 1)]) )
break;
LODWORD(v6) = v13;
}
v15 = &v4[v14];
LABEL_14:
*v15 = 0;
v16 = Q_strdup(v4);
if ( v4 )
free(v4);
free(ptr);
return v16;
}

original_code:
char *XSD_StripSpaces (char *str)
{
    char *buf, *ret;
    unsigned int p = 0, q = 0;
    if (str == ((void *)0))
        return str;
    buf = (char *) Q_malloc(strlen(str)+1);
    for (p=0; p < strlen(str); p++)
    {
        if (XSD_IsSpace(str[p]))
        {
            if (q == 0 || XSD_IsSpace(buf[q-1]))
                ;
            else
                buf[q++] = ' ';
        }
        else
            buf[q++] = str[p];
    }
    while (q > 0 && XSD_IsSpace(buf[q-1]))
        q--;
    buf[q] = 0;
    ret = (char *) Q_strdup(buf);
    if(buf) { free(buf); buf = ((void *)0); };
    if(str) { free(str); str = ((void *)0); };
    return ret;
}

canonical_original_code:
char *XSD_StripSpaces(char *str)
{
    char *buf; char *ret;
    unsigned int p = 0; unsigned int q = 0;
    if (str == ((void *)0))
        return str;
    buf = (char *) Q_malloc(strlen(str)+1);
    for (p=0; p < strlen(str); p++)
    {
        if (XSD_IsSpace(str[p]))
        {
            if (q == 0 || XSD_IsSpace(buf[q-1]))
                ;
            else
                buf[q++] = ' ';
        }
        else
            buf[q++] = str[p];
    }
    while (q > 0 && XSD_IsSpace(buf[q-1]))
        q--;
    buf[q] = 0;
    ret = (char *) Q_strdup(buf);
    if(buf) { free(buf); buf = ((void *)0); };
    if(str) { free(str); str = ((void *)0); };
    return ret;
}

variable_types:
str
char *

variable_types:
ret
char *

variable_types:
p
unsigned int

variable_types:
q
unsigned int


decompiled_code:
__int64 SNDDMA_GetDMAPos_OSS_Legacy()
{
unsigned int v0; // er12
const char *v1; // rbp
__int64 v2; // rcx
char v4[8]; // [rsp+4h] [rbp-24h] BYREF
unsigned int v5; // [rsp+Ch] [rbp-1Ch]

v0 = 0;
if ( shm )
{
v1 = (const char *)Cvar_String("s_oss_device");
if ( ioctl(audio_fd, 0x800C5012uLL, v4) == -1 )
{
perror(v1);
Com_Printf("Uh, sound dead.\n");
close(audio_fd);
}
else
{
v2 = shm;
*(_DWORD *)(shm + 20LL) = v5 / *(_DWORD *)(shm + 4LL);
v0 = *(_DWORD *)(v2 + 20);
}
}
return v0;
}

canonical_decompiled_code:
__int64 func0()
{
unsigned int v0; // er12
const char *v1; // rbp
__int64 v2; // rcx
char v4[8]; // [rsp+4h] [rbp-24h] BYREF
unsigned int v5; // [rsp+Ch] [rbp-1Ch]

v0 = 0;
if ( shm )
{
v1 = (const char *)Cvar_String("s_oss_device");
if ( ioctl(audio_fd, 0x800C5012uLL, v4) == -1 )
{
perror(v1);
Com_Printf("Uh, sound dead.\n");
close(audio_fd);
}
else
{
v2 = shm;
*(_DWORD *)(shm + 20LL) = v5 / *(_DWORD *)(shm + 4LL);
v0 = *(_DWORD *)(v2 + 20);
}
}
return v0;
}

original_code:
int SNDDMA_GetDMAPos_OSS_Legacy(void)
{
 struct count_info count;
 char *snd_dev = ((void *)0);
 if (!shm)
  return 0;
 snd_dev = Cvar_String("s_oss_device");
 if (ioctl(audio_fd, (((2U) << (((0 +8)+8)+14)) | ((('P')) << (0 +8)) | (((18)) << 0) | ((((sizeof(count_info)))) << ((0 +8)+8))), &count) == -1) {
  perror(snd_dev);
  Com_Printf("Uh, sound dead.\n");
  close(audio_fd);
  return 0;
 }
 shm->samplepos = count.ptr / shm->format.width;
 return shm->samplepos;
}

canonical_original_code:
int SNDDMA_GetDMAPos_OSS_Legacy()
{
 struct count_info count;
 char *snd_dev = ((void *)0);
 if (!shm)
  return 0;
 snd_dev = Cvar_String("s_oss_device");
 if (ioctl(audio_fd, (((2U) << (((0 +8)+8)+14)) | ((('P')) << (0 +8)) | (((18)) << 0) | ((((sizeof(count_info)))) << ((0 +8)+8))), &count) == -1) {
  perror(snd_dev);
  Com_Printf("Uh, sound dead.\n");
  close(audio_fd);
  return 0;
 }
 shm->samplepos = count.ptr / shm->format.width;
 return shm->samplepos;
}

variable_types: struct count_info { int bytes; int blocks; int ptr; }


decompiled_code:
int SNDDMA_Shutdown_OSS_Legacy()
{
int result; // eax
int v1; // ebp
int v2[3]; // [rsp+Ch] [rbp-Ch] BYREF

result = shm;
v2[0] = 0;
if ( *(_QWORD *)(shm + 24LL) )
result = munmap(*(void **)(shm + 24LL), *(int *)(shm + 32LL));
v1 = audio_fd;
if ( audio_fd )
{
ioctl(audio_fd, 0x40045010uLL, v2);
ioctl(v1, 0x5000uLL, 0LL);
result = close(v1);
}
audio_fd = -1;
return result;
}

canonical_decompiled_code:
int func1()
{
int result; // eax
int v1; // ebp
int v2[3]; // [rsp+Ch] [rbp-Ch] BYREF

result = shm;
v2[0] = 0;
if ( *(_QWORD *)(shm + 24LL) )
result = munmap(*(void **)(shm + 24LL), *(int *)(shm + 32LL));
v1 = audio_fd;
if ( audio_fd )
{
ioctl(audio_fd, 0x40045010uLL, v2);
ioctl(v1, 0x5000uLL, 0LL);
result = close(v1);
}
audio_fd = -1;
return result;
}

variable_types: tmp int