Repository: mahaloz/decompilation-wiki
Pull request #27: Add switch structuring
Author: login: harpend
Created: 2025-03-25T19:18:04Z | Merged: 2025-03-28T19:59:47Z

I've placed schema based structuring into its own folder and with the new article on switch structuring. The start of the article discusses switch representations by a compiler and then structuring methods. I mainly focussed on Phoenix's methods, with some inclusion of SAILR. The omissions that may want to be added at a later date are bit test conditions and discussion of how angr reverts switch clustering.  


Diff:
diff --git a/docs/fundamentals/structuring/schema-based.md b/docs/fundamentals/structuring/schema-based/schema-based.md
similarity index 100%
rename from docs/fundamentals/structuring/schema-based.md
rename to docs/fundamentals/structuring/schema-based/schema-based.md
diff --git a/docs/fundamentals/structuring/schema-based/switch-structuring.md b/docs/fundamentals/structuring/schema-based/switch-structuring.md
new file mode 100644
index 0000000..6983242
--- /dev/null
+++ b/docs/fundamentals/structuring/schema-based/switch-structuring.md
@@ -0,0 +1,249 @@
+# Switch Structuring
+## Introduction
+One important control flow structure in C is the [Switch statement](https://learn.microsoft.com/en-us/cpp/c-language/switch-statement-c?view=msvc-170).
+In schema-based structuring algorithms the Switch statement is handled much like other structures, but requires some special attention because of the many ways a compiler can output a Switch[^3].
+Phoenix[^1] documented much of the simpler cases, found in the examples below. 
+
+
+In the simplest form, a Switch uses an indirect jump of a calculated distance from the base address of a jump table to the specific case statement. 
+Below you can find an example of a Switch statement in C, its corresponding assembly, and its Control Flow Graph (CFG).
+
+### Switch in C
+```C
+#include <stdio.h>
+#include <stdlib.h>
+
+int main() {
+  int x = rand() % 5;
+  switch (x) {
+    case 0:
+      printf("hello\n");
+      break;
+    case 1:
+      printf("hello2\n");
+      break;
+    case 2:
+      printf("hello3\n");
+      break;
+    case 3:
+      printf("hello4\n");
+      break;
+    case 4:
+      printf("hello5\n");
+      break;
+    default:
+      return 0;
+  }
+  return x;
+}
+```
+
+### Switch in Assembly
+```assembly
+0x401169:       endbr64
+0x40116d:       push    rbp
+0x40116e:       mov     rbp, rsp
+0x401171:       sub     rsp, 0x10
+0x401175:       call    0x401070 ; rand()
+0x40117a:       movsxd  rdx, eax
+0x40117d:       imul    rdx, rdx, 0x66666667
+0x401184:       shr     rdx, 0x20
+0x401188:       sar     edx, 1
+0x40118a:       mov     ecx, eax
+0x40118c:       sar     ecx, 0x1f
+0x40118f:       sub     edx, ecx
+0x401191:       mov     dword ptr [rbp - 4], edx
+0x401194:       mov     ecx, dword ptr [rbp - 4]
+0x401197:       mov     edx, ecx
+0x401199:       shl     edx, 2
+0x40119c:       add     edx, ecx
+0x40119e:       sub     eax, edx
+0x4011a0:       mov     dword ptr [rbp - 4], eax
+0x4011a3:       cmp     dword ptr [rbp - 4], 4
+0x4011a7:       ja      0x401222
+0x4011a9:       mov     eax, dword ptr [rbp - 4]
+0x4011ac:       lea     rdx, [rax*4]
+0x4011b4:       lea     rax, [rip + 0xe6d]
+0x4011bb:       mov     eax, dword ptr [rdx + rax]
+0x4011be:       cdqe
+0x4011c0:       lea     rdx, [rip + 0xe61]
+0x4011c7:       add     rax, rdx
+0x4011ca:       notrack jmp     rax
+0x401222:       mov     eax, 0
+0x401227:       jmp     0x40122c
+0x401200:       lea     rax, [rip + 0xe11] ; case 0
+0x401207:       mov     rdi, rax
+0x40120a:       call    0x401060
+0x4011cd:       lea     rax, [rip + 0xe30] ; case 1
+0x4011d4:       mov     rdi, rax
+0x4011d7:       call    0x401060
+0x4011ef:       lea     rax, [rip + 0xe1b] ; case 2
+0x4011f6:       mov     rdi, rax
+0x4011f9:       call    0x401060
+0x401211:       lea     rax, [rip + 0xe07] ; case 3
+0x401218:       mov     rdi, rax
+0x40121b:       call    0x401060
+0x4011de:       lea     rax, [rip + 0xe25] ; case 4
+0x4011e5:       mov     rdi, rax
+0x4011e8:       call    0x401060
+0x40122c:       leave
+0x40122d:       ret
+0x40120f:       jmp     0x401229
+0x4011dc:       jmp     0x401229
+0x4011fe:       jmp     0x401229
+0x401220:       jmp     0x401229
+0x4011ed:       jmp     0x401229
+0x401229:       mov     eax, dword ptr [rbp - 4]
+```
+
+### Switch CFG
+![](/static/img/switch-flow.svg)
+
+## Compiler Representations
+After compilation, a Switch can take on many forms, largely due to compiler optimizations[^3].
+
+### Jump Table
+The switch statement above loads the base offset of the jump table from memory, and then computes an indirect JMP to that address offset by the % calculation. 
+The offset is multiplied by 4 to account for the size of each address in memory (rdx = rax * 4). 
+This computation is what allows us constant time when performing a simple switch statement. 
+The indirect branch is particularly important, because it is rare to see a non-hardcoded unconditional JMP instruction, therefore anytime we see such a situation we can mark it as a potential switch.
+
+### Multiple Jump Tables
+In the situation where we have large distance between sets of numbers in our switch, the compiler may create multiple jump tables as a simple way to retain constant time in our switch statement. 
+
+Below, C code can be found that will emit multiple jump tables when compiled. 
+
+#### Multi Jump Table Switch (when compiled)
+```C
+#include <stdio.h>
+#include <stdlib.h>
+
+int main() {
+  int x = rand() % 5;
+  switch (x) {
+  case 0:
+    printf("hello\n");
+    break;
+  case 1:
+    printf("hello2\n");
+    break;
+  case 2:
+    printf("hello3\n");
+    break;
+  case 1340:
+    printf("hello4\n");
+    break;
+  case 1341:
+    printf("hello5\n");
+    break;
+  case 1342:
+    printf("hello6\n");
+    break;
+  // and so on...
+  default:
+    return 0;
+  }
+  return x;
+}
+```
+
+### Balanced Tree
+Binary Search Trees (BSTs) and Ternary Search Trees (TSTs) are used by LLVM and GCC respectively[^4] when it is not possible to implement a jump table(s)[^2]. 
+In our first figure we showed a C program containing simple and consecutive case numbers (0, 1, 2, 3, 4) this means it is easy to calculate an offset by looking up the index associated with it.
+If the case constants are not close or a constant distance apart then the compiler prefers a ST over large amounts of unused memory. 
+
+An example below shows C code that would result in an ST when compiled.
+
+### Search Tree Switch
+```C
+#include <stdio.h>
+#include <stdlib.h>
+
+int main() {
+  int x = rand() % 5;
+  switch (x) {
+    case 0:
+      printf("hello\n");
+      break;
+    case 10:
+      printf("hello2\n");
+      break;
+    case 200:
+      printf("hello3\n");
+      break;
+    case 301:
+      printf("hello4\n");
+      break;
+    case 457:
+      printf("hello5\n");
+      break;
+    default:
+      return 0;
+  }
+  return x;
+}
+```
+
+### Cascascaded Conditionals
+In a few cases the compiler may deem the best representation of the switch statement to be a set of if, else-if, and else's, in this case the techniques outlined in the phoenix paper[^1] would decompile them back to cascaded conditionals, which can result in a rather messy output from the decompiler. SAILR[^3] introduces some techniques for identifying/reverting this, and producing a more accurate output.
+
+## Structuring
+We must now _switch_ up our discussion from the different ways in which a compiler may represent a switch statement, to the ways in which we can structure them. Much of this section has been written from the influence of implementations found in the [Reko Decompiler](https://github.com/uxmal/reko/tree/master).
+
+### Standard Switch Structuring
+When structuring we visit each of the nodes in post-order and attempt to match against a set of schemas[^1][^5]. 2 of these schemas outlined in the Phoenix paper[^1] represent the 2 types of switch statement structures we can get: Switch and IncSwitch (Incomplete-Switch). If no such statements are found in a particular traversal we may identify switch candidates (covered in the next section).
+
+For us to structure a switch the following must hold:
+
+1. The switch head is the only entry.
+2. There must be one node that is exited to, or all switch cases have no successors.
+
+If these conditions are not met we queue the switch and hope other structuring occurs before we procede with its reduction.
+
+The algorithm for structuring a switch is as follows:
+
+1. Identify the switch.
+    1. Indirect jump to a jump table. 
+2. Identify the cases.
+    1. Simply find all the successors of the switch head.
+    2. The front end of the decompiler identifies jump tables relevent to the function and adds the correct successors of the graph. The entries that are added to this are done by determining the bounds that are possible to be accessed, this is obvious due to the JA instruction which defines an upper bound and the base address being loaded into the RAX register. Any gaps in the jump table should hold the same address as the JA instruction[^6].  
+3. Produce a switch statement.
+4. Relink graph.
+
+### Non-Standard Switch Structuring
+If the switch statement is not represented by a jump table It will likely be structured as cascading if/else statements. In this case we can perform a rewrite to make it more legible after we have completed structuring. To achieve this 2 steps need to be performed:
+
+1. Identify the first node in a cascade.
+
+2. Collect all subsequent nodes in a cascade.
+
+Identifying the first node is done by checking for if statements that meet a set of pattern requirements in their condition. The condition for a valid statement can be a simple `==`/`!=`; a sequence of `!=`'s separated by `&&`'s or a sequence of `==`'s separated by `&&`'s.
+We then check consecutive if structures to see if they meet this pattern, and if we can collect a sufficient number of statements we can condense it down into a switch.
+
+This however obviously wouldn't work in the case of STs, which uses > and < comparators. 
+When STs occur few decompilers seem correctly identify this, of those that do there is 2 choices: simplify, but maintain if statements (Hex-Rays) or convert to a switch statement ([angr](https://github.com/angr/angr/blob/73cff39400821e1826906e1944b332c2fda12f2c/angr/analyses/decompiler/region_simplifiers/switch_cluster_simplifier.py#L510)).
+The addition to support this involves simply continuing to traverse for == or != operators to find the leaf nodes of the STs.
+
+### Switch Candidates
+This is a term used in the Phoenix paper[^1] to describe a schema that hasn't been matched, but could be potentially a switch. They occur when a switch has extra edges into or out of it. If there are extra incoming edges to nodes other than the switch head we can simply replace the edge with a jump and for extra outgoing edges we have 2 potential choices:
+
+1. If there is an edge from one of the case nodes to the node that immediately post dominates the switch head, we choose the immediate post dominator as our successor to the switch.
+    <ol type="a">
+        <li>Immediately post dominating means the closest node n where if we reversed all edges on the graph you would have to go through n to get to the switch head.</li>
+    </ol>
+2. Else we choose the successor to be the node with the highest number of edges from case nodes, that is not a case node itself.
+
+## Code Examples
+Open-source decompilers document a few different implementations of Switch structuring. 
+Below, you can find links to code sections in open-source decompilers as well as their likely implemented algorithm.
+
+- [angr decompiler](https://github.com/angr/angr/blob/c0c83ad6bd4a6f25c4b53f540798677e44cae0ff/angr/analyses/decompiler/structuring/phoenix.py#L1080): Phoenix and SAILR
+- [Reko](https://github.com/uxmal/reko/blob/2a67676f3b3938390e1b60477b9c49129725afad/src/Decompiler/Structure/StructureAnalysis.cs#L489): Phoenix with modifications.
+
+
+[^1]: Brumley, David, et al. "Native x86 decompilation using Semantics-Preserving structural analysis and iterative Control-Flow structuring." 22nd USENIX Security Symposium (USENIX Security 13). 2013.
+[^2]: Eilam, Eldad. "Reversing: Secrets of Reverse Engineering". Wiley. 2005.
+[^3]: Basque, Zion Leonahenahe, et al. "Ahoy sailr! there is no need to dream of c: A compiler-aware structuring algorithm for binary decompilation." 33st USENIX Security Symposium (USENIX Security 24). 2024.
+[^4]: Liska, Martin: Switch lowering improvements – slideslive. https://slideslive.com/38902416/switch-lowering-improvements. 2017.
+[^5]: Cifuentes, Cristina. Reverse compilation techniques. Queensland University of Technology, Brisbane, 1994.
+[^6]: Yang, Zack: How C/C++ Compiler Generate Assembly Code For Switch Statement. https://www.zackyang.blog/article/assembly-code-generation-for-switch-statement. 2023.
diff --git a/docs/static/img/switch-flow.svg b/docs/static/img/switch-flow.svg
new file mode 100644
index 0000000..f85e7f5
--- /dev/null
+++ b/docs/static/img/switch-flow.svg
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Do not edit this file with editors other than draw.io -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg xmlns="http://www.w3.org/2000/svg" style="background: transparent; background-color: transparent; color-scheme: light dark;" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="751px" height="581px" viewBox="-0.5 -0.5 751 581" content="&lt;mxfile host=&quot;app.diagrams.net&quot; agent=&quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36&quot; version=&quot;26.1.1&quot; scale=&quot;1&quot; border=&quot;0&quot;&gt;&#10;  &lt;diagram name=&quot;Page-1&quot; id=&quot;Dlyz2CqLa-6d3qmut6gg&quot;&gt;&#10;    &lt;mxGraphModel dx=&quot;1434&quot; dy=&quot;738&quot; grid=&quot;1&quot; gridSize=&quot;10&quot; guides=&quot;1&quot; tooltips=&quot;1&quot; connect=&quot;1&quot; arrows=&quot;1&quot; fold=&quot;1&quot; page=&quot;1&quot; pageScale=&quot;1&quot; pageWidth=&quot;827&quot; pageHeight=&quot;1169&quot; math=&quot;0&quot; shadow=&quot;0&quot;&gt;&#10;      &lt;root&gt;&#10;        &lt;mxCell id=&quot;0&quot; /&gt;&#10;        &lt;mxCell id=&quot;1&quot; parent=&quot;0&quot; /&gt;&#10;        &lt;mxCell id=&quot;5Stuk5LJGEDzz4u0c-iP-3&quot; style=&quot;edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;&quot; edge=&quot;1&quot; parent=&quot;1&quot; source=&quot;5Stuk5LJGEDzz4u0c-iP-1&quot; target=&quot;5Stuk5LJGEDzz4u0c-iP-2&quot;&gt;&#10;          &lt;mxGeometry relative=&quot;1&quot; as=&quot;geometry&quot; /&gt;&#10;        &lt;/mxCell&gt;&#10;        &lt;mxCell id=&quot;5Stuk5LJGEDzz4u0c-iP-1&quot; value=&quot;Call rand()&quot; style=&quot;rounded=0;whiteSpace=wrap;html=1;&quot; vertex=&quot;1&quot; parent=&quot;1&quot;&gt;&#10;          &lt;mxGeometry x=&quot;354&quot; y=&quot;50&quot; width=&quot;120&quot; height=&quot;60&quot; as=&quot;geometry&quot; /&gt;&#10;        &lt;/mxCell&gt;&#10;        &lt;mxCell id=&quot;5Stuk5LJGEDzz4u0c-iP-5&quot; style=&quot;edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;&quot; edge=&quot;1&quot; parent=&quot;1&quot; source=&quot;5Stuk5LJGEDzz4u0c-iP-2&quot; target=&quot;5Stuk5LJGEDzz4u0c-iP-4&quot;&gt;&#10;          &lt;mxGeometry relative=&quot;1&quot; as=&quot;geometry&quot; /&gt;&#10;        &lt;/mxCell&gt;&#10;        &lt;mxCell id=&quot;5Stuk5LJGEDzz4u0c-iP-13&quot; value=&quot;Default Case&quot; style=&quot;edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];&quot; vertex=&quot;1&quot; connectable=&quot;0&quot; parent=&quot;5Stuk5LJGEDzz4u0c-iP-5&quot;&gt;&#10;          &lt;mxGeometry x=&quot;-0.0379&quot; y=&quot;-1&quot; relative=&quot;1&quot; as=&quot;geometry&quot;&gt;&#10;            &lt;mxPoint as=&quot;offset&quot; /&gt;&#10;          &lt;/mxGeometry&gt;&#10;        &lt;/mxCell&gt;&#10;        &lt;mxCell id=&quot;5Stuk5LJGEDzz4u0c-iP-10&quot; style=&quot;edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;&quot; edge=&quot;1&quot; parent=&quot;1&quot; source=&quot;5Stuk5LJGEDzz4u0c-iP-2&quot; target=&quot;5Stuk5LJGEDzz4u0c-iP-9&quot;&gt;&#10;          &lt;mxGeometry relative=&quot;1&quot; as=&quot;geometry&quot; /&gt;&#10;        &lt;/mxCell&gt;&#10;        &lt;mxCell id=&quot;5Stuk5LJGEDzz4u0c-iP-2&quot; value=&quot;dword ptr [rbp - 4] = rdx % 5&amp;lt;div&amp;gt;cmp dword ptr [rbp - 4], 4&amp;lt;/div&amp;gt;&amp;lt;div&amp;gt;ja&amp;lt;/div&amp;gt;&quot; style=&quot;rounded=0;whiteSpace=wrap;html=1;&quot; vertex=&quot;1&quot; parent=&quot;1&quot;&gt;&#10;          &lt;mxGeometry x=&quot;309&quot; y=&quot;160&quot; width=&quot;210&quot; height=&quot;60&quot; as=&quot;geometry&quot; /&gt;&#10;        &lt;/mxCell&gt;&#10;        &lt;mxCell id=&quot;5Stuk5LJGEDzz4u0c-iP-8&quot; style=&quot;edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;&quot; edge=&quot;1&quot; parent=&quot;1&quot; source=&quot;5Stuk5LJGEDzz4u0c-iP-4&quot; target=&quot;5Stuk5LJGEDzz4u0c-iP-7&quot;&gt;&#10;          &lt;mxGeometry relative=&quot;1&quot; as=&quot;geometry&quot; /&gt;&#10;        &lt;/mxCell&gt;&#10;        &lt;mxCell id=&quot;5Stuk5LJGEDzz4u0c-iP-4&quot; value=&quot;eax = 0&amp;lt;div&amp;gt;jmp&amp;lt;/div&amp;gt;&quot; style=&quot;rounded=0;whiteSpace=wrap;html=1;&quot; vertex=&quot;1&quot; parent=&quot;1&quot;&gt;&#10;          &lt;mxGeometry x=&quot;640&quot; y=&quot;160&quot; width=&quot;120&quot; height=&quot;60&quot; as=&quot;geometry&quot; /&gt;&#10;        &lt;/mxCell&gt;&#10;        &lt;mxCell id=&quot;5Stuk5LJGEDzz4u0c-iP-7&quot; value=&quot;ret eax&quot; style=&quot;rounded=0;whiteSpace=wrap;html=1;&quot; vertex=&quot;1&quot; parent=&quot;1&quot;&gt;&#10;          &lt;mxGeometry x=&quot;640&quot; y=&quot;300&quot; width=&quot;120&quot; height=&quot;60&quot; as=&quot;geometry&quot; /&gt;&#10;        &lt;/mxCell&gt;&#10;        &lt;mxCell id=&quot;5Stuk5LJGEDzz4u0c-iP-19&quot; style=&quot;edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;&quot; edge=&quot;1&quot; parent=&quot;1&quot; source=&quot;5Stuk5LJGEDzz4u0c-iP-9&quot; target=&quot;5Stuk5LJGEDzz4u0c-iP-18&quot;&gt;&#10;          &lt;mxGeometry relative=&quot;1&quot; as=&quot;geometry&quot;&gt;&#10;            &lt;Array as=&quot;points&quot;&gt;&#10;              &lt;mxPoint x=&quot;730&quot; y=&quot;380&quot; /&gt;&#10;            &lt;/Array&gt;&#10;          &lt;/mxGeometry&gt;&#10;        &lt;/mxCell&gt;&#10;        &lt;mxCell id=&quot;5Stuk5LJGEDzz4u0c-iP-20&quot; style=&quot;edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.75;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;&quot; edge=&quot;1&quot; parent=&quot;1&quot; source=&quot;5Stuk5LJGEDzz4u0c-iP-9&quot; target=&quot;5Stuk5LJGEDzz4u0c-iP-17&quot;&gt;&#10;          &lt;mxGeometry relative=&quot;1&quot; as=&quot;geometry&quot; /&gt;&#10;        &lt;/mxCell&gt;&#10;        &lt;mxCell id=&quot;5Stuk5LJGEDzz4u0c-iP-21&quot; style=&quot;edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;&quot; edge=&quot;1&quot; parent=&quot;1&quot; source=&quot;5Stuk5LJGEDzz4u0c-iP-9&quot; target=&quot;5Stuk5LJGEDzz4u0c-iP-16&quot;&gt;&#10;          &lt;mxGeometry relative=&quot;1&quot; as=&quot;geometry&quot; /&gt;&#10;        &lt;/mxCell&gt;&#10;        &lt;mxCell id=&quot;5Stuk5LJGEDzz4u0c-iP-22&quot; style=&quot;edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.25;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;&quot; edge=&quot;1&quot; parent=&quot;1&quot; source=&quot;5Stuk5LJGEDzz4u0c-iP-9&quot; target=&quot;5Stuk5LJGEDzz4u0c-iP-15&quot;&gt;&#10;          &lt;mxGeometry relative=&quot;1&quot; as=&quot;geometry&quot; /&gt;&#10;        &lt;/mxCell&gt;&#10;        &lt;mxCell id=&quot;5Stuk5LJGEDzz4u0c-iP-23&quot; style=&quot;edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;&quot; edge=&quot;1&quot; parent=&quot;1&quot; source=&quot;5Stuk5LJGEDzz4u0c-iP-9&quot; target=&quot;5Stuk5LJGEDzz4u0c-iP-14&quot;&gt;&#10;          &lt;mxGeometry relative=&quot;1&quot; as=&quot;geometry&quot;&gt;&#10;            &lt;Array as=&quot;points&quot;&gt;&#10;              &lt;mxPoint x=&quot;100&quot; y=&quot;380&quot; /&gt;&#10;            &lt;/Array&gt;&#10;          &lt;/mxGeometry&gt;&#10;        &lt;/mxCell&gt;&#10;        &lt;mxCell id=&quot;5Stuk5LJGEDzz4u0c-iP-9&quot; value=&quot;rax = dword ptr [rbp-4]&amp;lt;div&amp;gt;rdx = rax * 4&amp;lt;/div&amp;gt;&amp;lt;div&amp;gt;rax = base address&amp;lt;/div&amp;gt;&amp;lt;div&amp;gt;rax = base address + rdx&amp;lt;/div&amp;gt;&amp;lt;div&amp;gt;jmp rax&amp;lt;/div&amp;gt;&quot; style=&quot;rounded=0;whiteSpace=wrap;html=1;&quot; vertex=&quot;1&quot; parent=&quot;1&quot;&gt;&#10;          &lt;mxGeometry x=&quot;336&quot; y=&quot;300&quot; width=&quot;156&quot; height=&quot;80&quot; as=&quot;geometry&quot; /&gt;&#10;        &lt;/mxCell&gt;&#10;        &lt;mxCell id=&quot;5Stuk5LJGEDzz4u0c-iP-25&quot; style=&quot;edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0;entryY=0;entryDx=0;entryDy=0;&quot; edge=&quot;1&quot; parent=&quot;1&quot; source=&quot;5Stuk5LJGEDzz4u0c-iP-14&quot; target=&quot;5Stuk5LJGEDzz4u0c-iP-24&quot;&gt;&#10;          &lt;mxGeometry relative=&quot;1&quot; as=&quot;geometry&quot;&gt;&#10;            &lt;Array as=&quot;points&quot;&gt;&#10;              &lt;mxPoint x=&quot;100&quot; y=&quot;570&quot; /&gt;&#10;            &lt;/Array&gt;&#10;          &lt;/mxGeometry&gt;&#10;        &lt;/mxCell&gt;&#10;        &lt;mxCell id=&quot;5Stuk5LJGEDzz4u0c-iP-14&quot; value=&quot;printf(&amp;quot;hello1&amp;quot;)&quot; style=&quot;rounded=0;whiteSpace=wrap;html=1;&quot; vertex=&quot;1&quot; parent=&quot;1&quot;&gt;&#10;          &lt;mxGeometry x=&quot;40&quot; y=&quot;440&quot; width=&quot;120&quot; height=&quot;60&quot; as=&quot;geometry&quot; /&gt;&#10;        &lt;/mxCell&gt;&#10;        &lt;mxCell id=&quot;5Stuk5LJGEDzz4u0c-iP-26&quot; style=&quot;edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.25;entryY=0;entryDx=0;entryDy=0;&quot; edge=&quot;1&quot; parent=&quot;1&quot; source=&quot;5Stuk5LJGEDzz4u0c-iP-15&quot; target=&quot;5Stuk5LJGEDzz4u0c-iP-24&quot;&gt;&#10;          &lt;mxGeometry relative=&quot;1&quot; as=&quot;geometry&quot; /&gt;&#10;        &lt;/mxCell&gt;&#10;        &lt;mxCell id=&quot;5Stuk5LJGEDzz4u0c-iP-15&quot; value=&quot;printf(&amp;quot;hello2&amp;quot;)&quot; style=&quot;rounded=0;whiteSpace=wrap;html=1;&quot; vertex=&quot;1&quot; parent=&quot;1&quot;&gt;&#10;          &lt;mxGeometry x=&quot;200&quot; y=&quot;440&quot; width=&quot;120&quot; height=&quot;60&quot; as=&quot;geometry&quot; /&gt;&#10;        &lt;/mxCell&gt;&#10;        &lt;mxCell id=&quot;5Stuk5LJGEDzz4u0c-iP-27&quot; style=&quot;edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;&quot; edge=&quot;1&quot; parent=&quot;1&quot; source=&quot;5Stuk5LJGEDzz4u0c-iP-16&quot; target=&quot;5Stuk5LJGEDzz4u0c-iP-24&quot;&gt;&#10;          &lt;mxGeometry relative=&quot;1&quot; as=&quot;geometry&quot; /&gt;&#10;        &lt;/mxCell&gt;&#10;        &lt;mxCell id=&quot;5Stuk5LJGEDzz4u0c-iP-16&quot; value=&quot;printf(&amp;quot;hello3&amp;quot;)&quot; style=&quot;rounded=0;whiteSpace=wrap;html=1;&quot; vertex=&quot;1&quot; parent=&quot;1&quot;&gt;&#10;          &lt;mxGeometry x=&quot;354&quot; y=&quot;440&quot; width=&quot;120&quot; height=&quot;60&quot; as=&quot;geometry&quot; /&gt;&#10;        &lt;/mxCell&gt;&#10;        &lt;mxCell id=&quot;5Stuk5LJGEDzz4u0c-iP-28&quot; style=&quot;edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.75;entryY=0;entryDx=0;entryDy=0;&quot; edge=&quot;1&quot; parent=&quot;1&quot; source=&quot;5Stuk5LJGEDzz4u0c-iP-17&quot; target=&quot;5Stuk5LJGEDzz4u0c-iP-24&quot;&gt;&#10;          &lt;mxGeometry relative=&quot;1&quot; as=&quot;geometry&quot; /&gt;&#10;        &lt;/mxCell&gt;&#10;        &lt;mxCell id=&quot;5Stuk5LJGEDzz4u0c-iP-17&quot; value=&quot;printf(&amp;quot;hello4&amp;quot;)&quot; style=&quot;rounded=0;whiteSpace=wrap;html=1;&quot; vertex=&quot;1&quot; parent=&quot;1&quot;&gt;&#10;          &lt;mxGeometry x=&quot;510&quot; y=&quot;440&quot; width=&quot;120&quot; height=&quot;60&quot; as=&quot;geometry&quot; /&gt;&#10;        &lt;/mxCell&gt;&#10;        &lt;mxCell id=&quot;5Stuk5LJGEDzz4u0c-iP-29&quot; style=&quot;edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=1;entryY=0;entryDx=0;entryDy=0;&quot; edge=&quot;1&quot; parent=&quot;1&quot; source=&quot;5Stuk5LJGEDzz4u0c-iP-18&quot; target=&quot;5Stuk5LJGEDzz4u0c-iP-24&quot;&gt;&#10;          &lt;mxGeometry relative=&quot;1&quot; as=&quot;geometry&quot;&gt;&#10;            &lt;Array as=&quot;points&quot;&gt;&#10;              &lt;mxPoint x=&quot;730&quot; y=&quot;570&quot; /&gt;&#10;            &lt;/Array&gt;&#10;          &lt;/mxGeometry&gt;&#10;        &lt;/mxCell&gt;&#10;        &lt;mxCell id=&quot;5Stuk5LJGEDzz4u0c-iP-18&quot; value=&quot;printf(&amp;quot;hello5&amp;quot;)&quot; style=&quot;rounded=0;whiteSpace=wrap;html=1;&quot; vertex=&quot;1&quot; parent=&quot;1&quot;&gt;&#10;          &lt;mxGeometry x=&quot;670&quot; y=&quot;440&quot; width=&quot;120&quot; height=&quot;60&quot; as=&quot;geometry&quot; /&gt;&#10;        &lt;/mxCell&gt;&#10;        &lt;mxCell id=&quot;5Stuk5LJGEDzz4u0c-iP-24&quot; value=&quot;return dword ptr [rbp-4]&quot; style=&quot;rounded=0;whiteSpace=wrap;html=1;&quot; vertex=&quot;1&quot; parent=&quot;1&quot;&gt;&#10;          &lt;mxGeometry x=&quot;351&quot; y=&quot;570&quot; width=&quot;126&quot; height=&quot;60&quot; as=&quot;geometry&quot; /&gt;&#10;        &lt;/mxCell&gt;&#10;      &lt;/root&gt;&#10;    &lt;/mxGraphModel&gt;&#10;  &lt;/diagram&gt;&#10;&lt;/mxfile&gt;&#10;"><defs/><g><g data-cell-id="0"><g data-cell-id="1"><g data-cell-id="5Stuk5LJGEDzz4u0c-iP-3"><g><path d="M 374 60 L 374 103.63" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke" style="stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/><path d="M 374 108.88 L 370.5 101.88 L 374 103.63 L 377.5 101.88 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all" style="fill: light-dark(rgb(0, 0, 0), rgb(255, 255, 255)); stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/></g></g><g data-cell-id="5Stuk5LJGEDzz4u0c-iP-1"><g><rect x="314" y="0" width="120" height="60" fill="#ffffff" stroke="#000000" pointer-events="all" style="fill: light-dark(#ffffff, var(--ge-dark-color, #121212)); stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/></g><g><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 118px; height: 1px; padding-top: 30px; margin-left: 315px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; color: #000000; "><div style="display: inline-block; font-size: 12px; font-family: &quot;Helvetica&quot;; color: light-dark(#000000, #ffffff); line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">Call rand()</div></div></div></foreignObject><text x="374" y="34" fill="light-dark(#000000, #ffffff)" font-family="&quot;Helvetica&quot;" font-size="12px" text-anchor="middle">Call rand()</text></switch></g></g></g><g data-cell-id="5Stuk5LJGEDzz4u0c-iP-5"><g><path d="M 479 140 L 593.63 140" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke" style="stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/><path d="M 598.88 140 L 591.88 143.5 L 593.63 140 L 591.88 136.5 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all" style="fill: light-dark(rgb(0, 0, 0), rgb(255, 255, 255)); stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/></g><g data-cell-id="5Stuk5LJGEDzz4u0c-iP-13"><g><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 142px; margin-left: 538px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; color: #000000; background-color: #ffffff; "><div style="display: inline-block; font-size: 11px; font-family: &quot;Helvetica&quot;; color: light-dark(#000000, #ffffff); line-height: 1.2; pointer-events: all; background-color: light-dark(#ffffff, var(--ge-dark-color, #121212)); white-space: nowrap; ">Default Case</div></div></div></foreignObject><text x="538" y="145" fill="light-dark(#000000, #ffffff)" font-family="&quot;Helvetica&quot;" font-size="11px" text-anchor="middle">Default Case</text></switch></g></g></g></g><g data-cell-id="5Stuk5LJGEDzz4u0c-iP-10"><g><path d="M 374 170 L 374 243.63" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke" style="stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/><path d="M 374 248.88 L 370.5 241.88 L 374 243.63 L 377.5 241.88 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all" style="fill: light-dark(rgb(0, 0, 0), rgb(255, 255, 255)); stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/></g></g><g data-cell-id="5Stuk5LJGEDzz4u0c-iP-2"><g><rect x="269" y="110" width="210" height="60" fill="#ffffff" stroke="#000000" pointer-events="all" style="fill: light-dark(#ffffff, var(--ge-dark-color, #121212)); stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/></g><g><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 208px; height: 1px; padding-top: 140px; margin-left: 270px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; color: #000000; "><div style="display: inline-block; font-size: 12px; font-family: &quot;Helvetica&quot;; color: light-dark(#000000, #ffffff); line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">dword ptr [rbp - 4] = rdx % 5<div>cmp dword ptr [rbp - 4], 4</div><div>ja</div></div></div></div></foreignObject><text x="374" y="144" fill="light-dark(#000000, #ffffff)" font-family="&quot;Helvetica&quot;" font-size="12px" text-anchor="middle">dword ptr [rbp - 4] = rdx % 5...</text></switch></g></g></g><g data-cell-id="5Stuk5LJGEDzz4u0c-iP-8"><g><path d="M 660 170 L 660 243.63" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke" style="stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/><path d="M 660 248.88 L 656.5 241.88 L 660 243.63 L 663.5 241.88 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all" style="fill: light-dark(rgb(0, 0, 0), rgb(255, 255, 255)); stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/></g></g><g data-cell-id="5Stuk5LJGEDzz4u0c-iP-4"><g><rect x="600" y="110" width="120" height="60" fill="#ffffff" stroke="#000000" pointer-events="all" style="fill: light-dark(#ffffff, var(--ge-dark-color, #121212)); stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/></g><g><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 118px; height: 1px; padding-top: 140px; margin-left: 601px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; color: #000000; "><div style="display: inline-block; font-size: 12px; font-family: &quot;Helvetica&quot;; color: light-dark(#000000, #ffffff); line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">eax = 0<div>jmp</div></div></div></div></foreignObject><text x="660" y="144" fill="light-dark(#000000, #ffffff)" font-family="&quot;Helvetica&quot;" font-size="12px" text-anchor="middle">eax = 0...</text></switch></g></g></g><g data-cell-id="5Stuk5LJGEDzz4u0c-iP-7"><g><rect x="600" y="250" width="120" height="60" fill="#ffffff" stroke="#000000" pointer-events="all" style="fill: light-dark(#ffffff, var(--ge-dark-color, #121212)); stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/></g><g><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 118px; height: 1px; padding-top: 280px; margin-left: 601px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; color: #000000; "><div style="display: inline-block; font-size: 12px; font-family: &quot;Helvetica&quot;; color: light-dark(#000000, #ffffff); line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">ret eax</div></div></div></foreignObject><text x="660" y="284" fill="light-dark(#000000, #ffffff)" font-family="&quot;Helvetica&quot;" font-size="12px" text-anchor="middle">ret eax</text></switch></g></g></g><g data-cell-id="5Stuk5LJGEDzz4u0c-iP-19"><g><path d="M 452 330 L 690 330 L 690 383.63" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke" style="stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/><path d="M 690 388.88 L 686.5 381.88 L 690 383.63 L 693.5 381.88 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all" style="fill: light-dark(rgb(0, 0, 0), rgb(255, 255, 255)); stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/></g></g><g data-cell-id="5Stuk5LJGEDzz4u0c-iP-20"><g><path d="M 413 330 L 413 360 L 530 360 L 530 383.63" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke" style="stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/><path d="M 530 388.88 L 526.5 381.88 L 530 383.63 L 533.5 381.88 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all" style="fill: light-dark(rgb(0, 0, 0), rgb(255, 255, 255)); stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/></g></g><g data-cell-id="5Stuk5LJGEDzz4u0c-iP-21"><g><path d="M 374 330 L 374 383.63" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke" style="stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/><path d="M 374 388.88 L 370.5 381.88 L 374 383.63 L 377.5 381.88 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all" style="fill: light-dark(rgb(0, 0, 0), rgb(255, 255, 255)); stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/></g></g><g data-cell-id="5Stuk5LJGEDzz4u0c-iP-22"><g><path d="M 335 330 L 335 360 L 220 360 L 220 383.63" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke" style="stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/><path d="M 220 388.88 L 216.5 381.88 L 220 383.63 L 223.5 381.88 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all" style="fill: light-dark(rgb(0, 0, 0), rgb(255, 255, 255)); stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/></g></g><g data-cell-id="5Stuk5LJGEDzz4u0c-iP-23"><g><path d="M 296 330 L 60 330 L 60 383.63" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke" style="stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/><path d="M 60 388.88 L 56.5 381.88 L 60 383.63 L 63.5 381.88 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all" style="fill: light-dark(rgb(0, 0, 0), rgb(255, 255, 255)); stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/></g></g><g data-cell-id="5Stuk5LJGEDzz4u0c-iP-9"><g><rect x="296" y="250" width="156" height="80" fill="#ffffff" stroke="#000000" pointer-events="all" style="fill: light-dark(#ffffff, var(--ge-dark-color, #121212)); stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/></g><g><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 154px; height: 1px; padding-top: 290px; margin-left: 297px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; color: #000000; "><div style="display: inline-block; font-size: 12px; font-family: &quot;Helvetica&quot;; color: light-dark(#000000, #ffffff); line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">rax = dword ptr [rbp-4]<div>rdx = rax * 4</div><div>rax = base address</div><div>rax = base address + rdx</div><div>jmp rax</div></div></div></div></foreignObject><text x="374" y="294" fill="light-dark(#000000, #ffffff)" font-family="&quot;Helvetica&quot;" font-size="12px" text-anchor="middle">rax = dword ptr [rbp-4]...</text></switch></g></g></g><g data-cell-id="5Stuk5LJGEDzz4u0c-iP-25"><g><path d="M 60 450 L 60 520 L 304.63 520" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke" style="stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/><path d="M 309.88 520 L 302.88 523.5 L 304.63 520 L 302.88 516.5 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all" style="fill: light-dark(rgb(0, 0, 0), rgb(255, 255, 255)); stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/></g></g><g data-cell-id="5Stuk5LJGEDzz4u0c-iP-14"><g><rect x="0" y="390" width="120" height="60" fill="#ffffff" stroke="#000000" pointer-events="all" style="fill: light-dark(#ffffff, var(--ge-dark-color, #121212)); stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/></g><g><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 118px; height: 1px; padding-top: 420px; margin-left: 1px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; color: #000000; "><div style="display: inline-block; font-size: 12px; font-family: &quot;Helvetica&quot;; color: light-dark(#000000, #ffffff); line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">printf("hello1")</div></div></div></foreignObject><text x="60" y="424" fill="light-dark(#000000, #ffffff)" font-family="&quot;Helvetica&quot;" font-size="12px" text-anchor="middle">printf("hello1")</text></switch></g></g></g><g data-cell-id="5Stuk5LJGEDzz4u0c-iP-26"><g><path d="M 220 450 L 220 485 L 342.5 485 L 342.5 513.63" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke" style="stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/><path d="M 342.5 518.88 L 339 511.88 L 342.5 513.63 L 346 511.88 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all" style="fill: light-dark(rgb(0, 0, 0), rgb(255, 255, 255)); stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/></g></g><g data-cell-id="5Stuk5LJGEDzz4u0c-iP-15"><g><rect x="160" y="390" width="120" height="60" fill="#ffffff" stroke="#000000" pointer-events="all" style="fill: light-dark(#ffffff, var(--ge-dark-color, #121212)); stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/></g><g><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 118px; height: 1px; padding-top: 420px; margin-left: 161px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; color: #000000; "><div style="display: inline-block; font-size: 12px; font-family: &quot;Helvetica&quot;; color: light-dark(#000000, #ffffff); line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">printf("hello2")</div></div></div></foreignObject><text x="220" y="424" fill="light-dark(#000000, #ffffff)" font-family="&quot;Helvetica&quot;" font-size="12px" text-anchor="middle">printf("hello2")</text></switch></g></g></g><g data-cell-id="5Stuk5LJGEDzz4u0c-iP-27"><g><path d="M 374 450 L 374 513.63" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke" style="stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/><path d="M 374 518.88 L 370.5 511.88 L 374 513.63 L 377.5 511.88 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all" style="fill: light-dark(rgb(0, 0, 0), rgb(255, 255, 255)); stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/></g></g><g data-cell-id="5Stuk5LJGEDzz4u0c-iP-16"><g><rect x="314" y="390" width="120" height="60" fill="#ffffff" stroke="#000000" pointer-events="all" style="fill: light-dark(#ffffff, var(--ge-dark-color, #121212)); stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/></g><g><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 118px; height: 1px; padding-top: 420px; margin-left: 315px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; color: #000000; "><div style="display: inline-block; font-size: 12px; font-family: &quot;Helvetica&quot;; color: light-dark(#000000, #ffffff); line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">printf("hello3")</div></div></div></foreignObject><text x="374" y="424" fill="light-dark(#000000, #ffffff)" font-family="&quot;Helvetica&quot;" font-size="12px" text-anchor="middle">printf("hello3")</text></switch></g></g></g><g data-cell-id="5Stuk5LJGEDzz4u0c-iP-28"><g><path d="M 530 450 L 530 485 L 405.5 485 L 405.5 513.63" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke" style="stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/><path d="M 405.5 518.88 L 402 511.88 L 405.5 513.63 L 409 511.88 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all" style="fill: light-dark(rgb(0, 0, 0), rgb(255, 255, 255)); stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/></g></g><g data-cell-id="5Stuk5LJGEDzz4u0c-iP-17"><g><rect x="470" y="390" width="120" height="60" fill="#ffffff" stroke="#000000" pointer-events="all" style="fill: light-dark(#ffffff, var(--ge-dark-color, #121212)); stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/></g><g><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 118px; height: 1px; padding-top: 420px; margin-left: 471px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; color: #000000; "><div style="display: inline-block; font-size: 12px; font-family: &quot;Helvetica&quot;; color: light-dark(#000000, #ffffff); line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">printf("hello4")</div></div></div></foreignObject><text x="530" y="424" fill="light-dark(#000000, #ffffff)" font-family="&quot;Helvetica&quot;" font-size="12px" text-anchor="middle">printf("hello4")</text></switch></g></g></g><g data-cell-id="5Stuk5LJGEDzz4u0c-iP-29"><g><path d="M 690 450 L 690 520 L 443.37 520" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke" style="stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/><path d="M 438.12 520 L 445.12 516.5 L 443.37 520 L 445.12 523.5 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all" style="fill: light-dark(rgb(0, 0, 0), rgb(255, 255, 255)); stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/></g></g><g data-cell-id="5Stuk5LJGEDzz4u0c-iP-18"><g><rect x="630" y="390" width="120" height="60" fill="#ffffff" stroke="#000000" pointer-events="all" style="fill: light-dark(#ffffff, var(--ge-dark-color, #121212)); stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/></g><g><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 118px; height: 1px; padding-top: 420px; margin-left: 631px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; color: #000000; "><div style="display: inline-block; font-size: 12px; font-family: &quot;Helvetica&quot;; color: light-dark(#000000, #ffffff); line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">printf("hello5")</div></div></div></foreignObject><text x="690" y="424" fill="light-dark(#000000, #ffffff)" font-family="&quot;Helvetica&quot;" font-size="12px" text-anchor="middle">printf("hello5")</text></switch></g></g></g><g data-cell-id="5Stuk5LJGEDzz4u0c-iP-24"><g><rect x="311" y="520" width="126" height="60" fill="#ffffff" stroke="#000000" pointer-events="all" style="fill: light-dark(#ffffff, var(--ge-dark-color, #121212)); stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/></g><g><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 124px; height: 1px; padding-top: 550px; margin-left: 312px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; color: #000000; "><div style="display: inline-block; font-size: 12px; font-family: &quot;Helvetica&quot;; color: light-dark(#000000, #ffffff); line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">return dword ptr [rbp-4]</div></div></div></foreignObject><text x="374" y="554" fill="light-dark(#000000, #ffffff)" font-family="&quot;Helvetica&quot;" font-size="12px" text-anchor="middle">return dword ptr [rbp...</text></switch></g></g></g></g></g></g></svg>
\ No newline at end of file
diff --git a/mkdocs.yml b/mkdocs.yml
index ffb7276..4a6b17f 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -43,7 +43,9 @@ nav:
   - fundamentals/type-recovery.md
   - Control Flow Structuring:
     - fundamentals/structuring/overview.md
-    - fundamentals/structuring/schema-based.md
+    - Schema Based:
+      - fundamentals/structuring/schema-based/schema-based.md
+      - fundamentals/structuring/schema-based/switch-structuring.md
     - fundamentals/structuring/gotoless.md
     - fundamentals/structuring/loop-reduction.md
   - fundamentals/evaluation.md


Reviews:
user: login: harpend
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-28T19:41:15Z
user: login: mahaloz
state: COMMENTED
author_association: OWNER
submitted_at: 2025-03-28T19:59:33Z

Review comments:
diff_hunk: @@ -204,10 +217,12 @@ If the switch statement is not represented by a jump table It will likely be str
 
 2. Collect all subsequent nodes in a cascade.
 
-Identifying the first node is done by checking for if statements that meet a set of pattern requirements in their condition. The condition for a valid statement can be a simple ==/!=; a sequence of !='s separated by &&'s or a sequence of =='s separated by &&'s.
+Identifying the first node is done by checking for if statements that meet a set of pattern requirements in their condition. The condition for a valid statement can be a simple `==`/`!=`; a sequence of `!=`'s separated by `&&`'s or a sequence of `==`'s separated by `&&`'s.
 We then check consecutive if structures to see if they meet this pattern, and if we can collect a sufficient number of statements we can condense it down into a switch.
 
-This however obviously wouldn't work in the case of STs, which uses > and < comparators. When STs occur few decompilers seem correctly identify this, of those that do there is 2 choices: simplify, but maintain if statements (Hex-Rays) or convert to a switch statement (<a href = "https://github.com/angr/angr/blob/73cff39400821e1826906e1944b332c2fda12f2c/angr/analyses/decompiler/region_simplifiers/switch_cluster_simplifier.py#L510">angr</a>). The addition to support this involves simply continuing to traverse for == or != operators to find the leaf nodes of the STs.
+This however obviously wouldn't work in the case of STs, which uses > and < comparators. 
+When STs occur few decompilers seem correctly identify this, of those that do there is 2 choices: simplify, but maintain if statements (Hex-Rays) or convert to a switch statement ([angr](https://github.com/angr/angr/blob/73cff39400821e1826906e1944b332c2fda12f2c/angr/analyses/decompiler/region_simplifiers/switch_cluster_simplifier.py#L51)).
path: docs/fundamentals/structuring/schema-based/switch-structuring.md
user: login: harpend
body: #L510 has become #L51 in the link, meaning it no longer links to the function simplify_lowered_switches_core
created_at: 2025-03-28T19:40:03Z
author_association: CONTRIBUTOR
diff_hunk: @@ -204,10 +217,12 @@ If the switch statement is not represented by a jump table It will likely be str
 
 2. Collect all subsequent nodes in a cascade.
 
-Identifying the first node is done by checking for if statements that meet a set of pattern requirements in their condition. The condition for a valid statement can be a simple ==/!=; a sequence of !='s separated by &&'s or a sequence of =='s separated by &&'s.
+Identifying the first node is done by checking for if statements that meet a set of pattern requirements in their condition. The condition for a valid statement can be a simple `==`/`!=`; a sequence of `!=`'s separated by `&&`'s or a sequence of `==`'s separated by `&&`'s.
 We then check consecutive if structures to see if they meet this pattern, and if we can collect a sufficient number of statements we can condense it down into a switch.
 
-This however obviously wouldn't work in the case of STs, which uses > and < comparators. When STs occur few decompilers seem correctly identify this, of those that do there is 2 choices: simplify, but maintain if statements (Hex-Rays) or convert to a switch statement (<a href = "https://github.com/angr/angr/blob/73cff39400821e1826906e1944b332c2fda12f2c/angr/analyses/decompiler/region_simplifiers/switch_cluster_simplifier.py#L510">angr</a>). The addition to support this involves simply continuing to traverse for == or != operators to find the leaf nodes of the STs.
+This however obviously wouldn't work in the case of STs, which uses > and < comparators. 
+When STs occur few decompilers seem correctly identify this, of those that do there is 2 choices: simplify, but maintain if statements (Hex-Rays) or convert to a switch statement ([angr](https://github.com/angr/angr/blob/73cff39400821e1826906e1944b332c2fda12f2c/angr/analyses/decompiler/region_simplifiers/switch_cluster_simplifier.py#L51)).
path: docs/fundamentals/structuring/schema-based/switch-structuring.md
user: login: mahaloz
body: oops ty 

created_at: 2025-03-28T19:59:33Z
author_association: OWNER

PR comments:
user: login: mahaloz
created_at: 2025-03-28T19:29:23Z
body: Another banger of an addition.
I've made a few changes that don't really mess with the content, but more the wording or syntax. If you think these look good, lmk and I'll merge. 

Some notes for future PRs:
- Place each sentence on its own line. This will not show up as newlines in the final output, but it makes it easier to track diffs in the future for plaintext
- Avoid using HTML syntax whenever possible since most of your uses in this article can be replaced with Markdown syntax
- Exchange statements like `The following C code shows such an example` for `Below, C code can be found...` and then naming the example with a markdown section (see changes). 
- Avoid first-person wording, such as "I document..." 
author_association: OWNER
user: login: harpend
created_at: 2025-03-28T19:42:31Z
body: Only thing I noticed. other than that looks good to me. Thanks for the tips on wording/md.
author_association: CONTRIBUTOR