Files
ioccc/2024/ferguson1/deobfuscation.html
Cody Boone Ferguson 5455784566 Truly complete 2024/ferguson1 and litmus test
The truly complete part is a reference to commit
ad622a5354. This also means that prog.c
need never be updated again, which was the entire point of that commit
that fell just short of the mark.

Fixed links in obfuscation.html.

Added litmus test to explain how I actually tested the program with all
the jumps.

Fixed typo in data file that I discovered during the above litmus test.

Fixed other files as well.

The .entry.json had a minor mod too, to better reflect what a file
actually is.

Rebuilt obfuscation.html and index.html.

Added target to Makefile which was also used during testing (this might
be explained in the obfuscation.html).
2025-08-18 08:50:37 -07:00

626 lines
22 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- START: two lines up starts content from: inc/top.default.html -->
<!-- END: this line ends content from: inc/top.default.html -->
<!-- START: this line starts content from: inc/head.default.html -->
<head>
<link rel="stylesheet" href="../../ioccc.css">
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@100..900&display=swap" rel="stylesheet">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>The International Obfuscated C Code Contest</title>
<link rel="icon" type="image/x-icon" href="../../favicon.ico">
<meta name="description" content="deobfuscation.md for 2024/ferguson1">
<meta name="keywords" content="IOCCC, 2024/ferguson1, deobfuscation.md">
</head>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- END: this line ends content from: inc/head.default.html -->
<!-- -->
<!-- This web page was formed via the tool: bin/gen-other-html.sh -->
<!-- The content of main section of this web page came from: 2024/ferguson1/deobfuscation.md -->
<!-- -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- !!! Do not modify this web page, instead modify the file: 2024/ferguson1/deobfuscation.md !!! -->
<!-- !!! Do not modify this web page, instead modify the file: 2024/ferguson1/deobfuscation.md !!! -->
<!-- !!! Do not modify this web page, instead modify the file: 2024/ferguson1/deobfuscation.md !!! -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- Markdown content was converted into HTML via the tool: bin/md2html.sh -->
<!-- START: this line starts content from: inc/body.default.html -->
<body>
<!-- END: this line ends content from: inc/body.default.html -->
<!-- START: this line starts content from: inc/topbar.default.html -->
<div class="theader">
<nav class="topbar">
<div class="container">
<div class="logo">
<a href="../../index.html" class="logo-link">
IOCCC
</a>
</div>
<div class="topbar-items">
<div class="item">
<span class="item-header">
Entries
</span>
<div class="sub-item">
<div class="outfit-font">
<a href="../../years.html" class="sub-item-link">
Winning entries
</a>
</div>
<div class="outfit-font">
<a href="../../authors.html" class="sub-item-link">
Winning authors
</a>
</div>
<div class="outfit-font">
<a href="../../location.html" class="sub-item-link">
Location of authors
</a>
</div>
<div class="outfit-font">
<a href="../../bugs.html" class="sub-item-link">
Bugs and (mis)features
</a>
</div>
<div class="outfit-font">
<a href="../../faq.html#fix_an_entry" class="sub-item-link">
Fixing entries
</a>
</div>
<div class="outfit-font">
<a href="../../faq.html#fix_author" class="sub-item-link">
Updating author info
</a>
</div>
</div>
</div>
<div class="item">
<span class="item-header">
Status
</span>
<div class="sub-item">
<div class="outfit-font">
<a href="../../news.html" class="sub-item-link">
News
</a>
</div>
<div class="outfit-font">
<a href="../../status.html" class="sub-item-link">
Contest status
</a>
</div>
<div class="outfit-font">
<a href="../../next/rules.html" class="sub-item-link">
IOCCC rules
</a>
</div>
<div class="outfit-font">
<a href="../../next/guidelines.html" class="sub-item-link">
IOCCC guidelines
</a>
</div>
<div class="outfit-font">
<a href="../../markdown.html" class="sub-item-link">
Markdown guidelines
</a>
</div>
<div class="outfit-font">
<a href="../../SECURITY.html" class="sub-item-link">
Security policy
</a>
</div>
</div>
</div>
<div class="item">
<span class="item-header">
FAQ
</span>
<div class="sub-item">
<div class="outfit-font">
<a href="../../faq.html" class="sub-item-link">
Frequently asked questions
</a>
</div>
<div class="outfit-font">
<a href="../../quick-start.html#enter" class="sub-item-link">
Enter the IOCCC
</a>
</div>
<div class="outfit-font">
<a href="../../faq.html#compiling" class="sub-item-link">
Compiling entries
</a>
</div>
<div class="outfit-font">
<a href="../../faq.html#running_entries" class="sub-item-link">
Running entries
</a>
</div>
<div class="outfit-font">
<a href="../../faq.html#help" class="sub-item-link">
How to help
</a>
</div>
</div>
</div>
<div class="item">
<span class="item-header">
About
</span>
<div class="sub-item">
<div class="outfit-font">
<a href="../../index.html" class="sub-item-link">
Home page
</a>
</div>
<div class="outfit-font">
<a href="../../social.html" class="sub-item-link">
IOCCC social media
</a>
</div>
<div class="outfit-font">
<a href="../../about.html" class="sub-item-link">
About the IOCCC
</a>
</div>
<div class="outfit-font">
<a href="../../judges.html" class="sub-item-link">
The judges
</a>
</div>
<div class="outfit-font">
<a href="../../thanks-for-help.html" class="sub-item-link">
Thanks for the help
</a>
</div>
<div class="outfit-font">
<a href="../../contact.html" class="sub-item-link">
Contact us
</a>
</div>
</div>
</div>
</div>
</div>
</nav>
<div class="header-mobile-menu">
<noscript>
<a href="../../nojs-menu.html" class="topbar-js-label">
Please Enable JavaScript
</a>
</noscript>
<button id="header-open-menu-button" class="topbar-mobile-menu">
<img
src="../../png/hamburger-icon-open.png"
alt="hamburger style menu icon - open state"
width=48
height=48>
</button>
<button id="header-close-menu-button" class="hide-content">
<img
src="../../png/hamburger-icon-closed.png"
alt="hamburger style menu icon - closed state"
width=48
height=48>
</button>
<div id="mobile-menu-panel" class="hide-content">
<div class="mobile-menu-container">
<div class="mobile-menu-wrapper">
<div class="mobile-menu-item">
Entries
</div>
<div class="mobile-submenu-wrapper">
<a class="mobile-submenu-item" href="../../years.html">
Winning entries
</a>
<a class="mobile-submenu-item" href="../../authors.html">
Winning authors
</a>
<a class="mobile-submenu-item" href="../../location.html">
Location of authors
</a>
<a class="mobile-submenu-item" href="../../bugs.html">
Bugs and (mis)features
</a>
<a class="mobile-submenu-item" href="../../faq.html#fix_an_entry">
Fixing entries
</a>
<a class="mobile-submenu-item" href="../../faq.html#fix_author">
Updating author info
</a>
<a class="mobile-submenu-item" href="../../thanks-for-help.html">
Thanks for the help
</a>
</div>
</div>
<div class="mobile-menu-wrapper">
<div class="mobile-menu-item">
Status
</div>
<div class="mobile-submenu-wrapper">
<a class="mobile-submenu-item" href="../../news.html">
News
</a>
<a class="mobile-submenu-item" href="../../status.html">
Contest status
</a>
<a class="mobile-submenu-item" href="../../next/rules.html">
IOCCC rules
</a>
<a class="mobile-submenu-item" href="../../next/guidelines.html">
IOCCC guidelines
</a>
<a class="mobile-submenu-item" href="../../markdown.html">
Markdown guidelines
</a>
<a class="mobile-submenu-item" href="../../SECURITY.html">
Security policy
</a>
</div>
</div>
<div class="mobile-menu-wrapper">
<div class="mobile-menu-item">
FAQ
</div>
<div class="mobile-submenu-wrapper">
<a class="mobile-submenu-item" href="../../faq.html">
Frequently asked questions
</a>
<a class="mobile-submenu-item" href="../../quick-start.html#enter">
Enter the IOCCC
</a>
<a class="mobile-submenu-item" href="../../faq.html#compiling">
Compiling entries
</a>
<a class="mobile-submenu-item" href="../../faq.html#running_entries">
Running entries
</a>
<a class="mobile-submenu-item" href="../../faq.html#help">
How to help
</a>
</div>
</div>
<div class="mobile-menu-wrapper">
<div class="mobile-menu-item">
About
</div>
<div class="mobile-submenu-wrapper">
<a class="mobile-submenu-item" href="../../index.html">
Home page
</a>
<a class="mobile-submenu-item" href="../../social.html">
IOCCC social media
</a>
<a class="mobile-submenu-item" href="../../about.html">
About the IOCCC
</a>
<a class="mobile-submenu-item" href="../../judges.html">
The judges
</a>
<a class="mobile-submenu-item" href="../../contact.html">
Contact us
</a>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
var headerOpenMenuButton = document.getElementById("header-open-menu-button");
var headerCloseMenuButton = document.getElementById("header-close-menu-button");
var mobileMenuPanel = document.getElementById("mobile-menu-panel");
headerOpenMenuButton.addEventListener("click", () => {
headerOpenMenuButton.classList.remove("topbar-mobile-menu");
headerOpenMenuButton.classList.add("hide-content");
headerCloseMenuButton.classList.remove("hide-content");
headerCloseMenuButton.classList.add("topbar-mobile-menu");
mobileMenuPanel.classList.remove("hide-content");
mobileMenuPanel.classList.add("topbar-mobile-panel");
});
headerCloseMenuButton.addEventListener("click", () => {
headerCloseMenuButton.classList.remove("topbar-mobile-menu");
headerCloseMenuButton.classList.add("hide-content");
mobileMenuPanel.classList.add("hide-content");
mobileMenuPanel.classList.remove("topbar-mobile-panel");
headerOpenMenuButton.classList.add("topbar-mobile-menu");
headerOpenMenuButton.classList.remove("hide-content");
});
</script>
<!-- END: this line ends content from: inc/topbar.default.html -->
<!-- START: this line starts content from: inc/header.default.html -->
<div class="header">
<a href="../../2011/zucker/index.html">
<img src="../../png/ioccc.png"
alt="IOCCC image by Matt Zucker"
width=300
height=110>
</a>
<h1>The International Obfuscated C Code Contest</h1>
<h2>deobfuscation.html for 2024/ferguson1</h2>
</div>
<!-- END: this line ends content from: inc/header.default.html -->
<!-- START: this line starts content from: inc/navbar.up2index.html -->
<div class="navbar">
<a class="Left" href="index.html">&uarr; jump to 2024/ferguson1/index.html &uarr;</a>
<a class="Right" href="https://validator.w3.org/nu/?doc=https%3A%2F%2Fwww.ioccc.org%2F2024%2Fferguson1%2Fdeobfuscation.html">&#x2713;</a>
</div>
<!-- END: this line ends content from: inc/navbar.up2index.html -->
<!-- START: this line starts content from: inc/before-content.default.html -->
<div class="content" id="content">
<!-- END: this line ends content from: inc/before-content.default.html -->
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<!-- BEFORE: 1st line of markdown file: 2024/ferguson1/deobfuscation.md -->
<p>The following hints were used for myself but also I offer them for those who
wish to more easily follow the code, though that might or might not help that
much. If a variable or other kind of symbol is missing or is not what it says
here that was by (in some cases) simply missing it or (in other cases) due to
having changed things a fair amount; this submission took a lot of work and time
to get everything in.</p>
<p>The following variables are of primary concern (some temporary ones are not
documented I think):</p>
<ul>
<li>O: how much you spend on oxen</li>
<li>R: amount spent on food (and how much you have)</li>
<li>E: amount spent on ammo (and how much you have)</li>
<li>G: amount spent on clothing (and how ‘much’ you have - a misnomer)</li>
<li>O: how much you spend on oxen (and how ‘many’ you have - a misnomer)</li>
<li>N: amount spent on miscellaneous supplies (and how ‘many’ you have - a misnomer)</li>
<li>T: how much money you have (in US dollars)</li>
<li>e: ate an ox</li>
<li>b: hp (hit points, starts out at 666, allows for survival in conditions you
can’t in the original) or stamina (kind of a combination - if you get injured
and you see the doctor and can afford it you will not keep losing hp but you
won’t gain any either). Alt code allows you to specify how many hp (default
666), if you specify also max number of turns (NB: only prog.alt.c, not
prog.alt2.c).</li>
<li>A: turn number for setting date (the first week, Monday 29 March 1847 is at
16 so to print the second week day date month and year (though it does it March
29 like the American way) you would do <code>V(A+16)</code>) (note that the date is not set
in a variable but rather for printing the date)</li>
<li>I: unused except to spell out OREGON TRAIL.</li>
<li>L: amount spent on items at fort (used as a temporary money value for
calculations at fort)</li>
<li>q: event number</li>
<li>f: flag for injury</li>
<li>M: total distance travelled</li>
<li>a: flag for illness</li>
<li>z: flag for fort option</li>
<li>K: the <code>FILE *</code> (data file)</li>
<li>y: contents of data file</li>
<li>p: used to print (one character at a time) the strings (encrypted version only)</li>
<li>r: (unsigned) answer to certain questions</li>
<li>d: son froze to death (and you ate him)</li>
<li>J: file length read (fun fact: as part of obfuscation in multiple levels, <code>J != strlen(y)</code>!). It’s reused in the V function after being set to 0.</li>
<li>l: non-zero when hunting.</li>
<li>W: flag for clearing Blue Mountains.</li>
<li>Q: got dysentery and went to doctor (I think only if you could afford the
doctor but not sure)</li>
<li>B: if non-zero, can’t afford the doctor, don’t try again (this prevents a
flood of the message each turn).</li>
<li>h: I believe this is if you were injured and could afford the doctor.</li>
<li>c: hit blizzard.</li>
<li>X: passed South Pass.</li>
<li>i: about to be strangled to death by the Flying Spaghetti Monster after
indulging in too much spaghetti.</li>
<li>g: how many limbs you’ve had to cut off (surgeon’s cut edition)</li>
<li>t: temporary array for purchasing at forts.</li>
<li>u: temporary unsigned int to iterate through array <code>t</code> (and maybe other
uses, not sure now).</li>
<li>v: non-zero means ran out of oxen so as to not flood user every turn with
certain messages. But if you buy more that could in theory happen again. Note
that some messages might be printed instead of the you have run out of oxen
message, if they’re the ones causing it, though I’m not going to say this is in
every case as there are a lot of ways for this to happen.</li>
<li><code>C</code>: alt code only, max number of turns (specified at command line, default
21).</li>
<li>any other variable I haven’t the foggiest, even if it’s not related to fog (of
which there is an event where you encounter fog) - sorry. An example here is
<code>m</code>.</li>
</ul>
<p>When an amount spent (if it happens, not necessarily going to for every
variable) spent ends up being &lt; 0 (it’s not allowed to go that low when
purchasing) it means that there is an insufficient amount (thus a variable
reuse).</p>
<p>The array:</p>
<pre><code> long *o[]={ &amp;O, &amp;R, &amp;E, &amp;G, &amp;N } /* animals, food, ammo, clothing, misc. supplies</code></pre>
<p>is used in at least one loop to not have to do checks individually. The
variables, btw, are not how many as such (well in some cases it is, although
with the number of animals it’s a ‘taken at liberty’ and based on my
interpretation of the original 1978 BASIC game) but rather
how much was spent on them. As for the ammo: $1 spent on ammo means a belt of 50.
That means another variable has to exist (that would be the <code>I</code> one) and
every time a purchase is made (at fort or initially) <code>I</code> is set to <code>E * 50</code>.</p>
<p>The functions:</p>
<ul>
<li>main(): you know what this is: or…do you?</li>
<li>k(): the function that determines if you shoot successfully.</li>
<li>x: uses <code>rand()</code> to get a pRNG number in a range.</li>
<li>V: the nasty function that decrypts (one character at a time) strings in the
data file. Or doesn’t really decrypt it per se.</li>
<li>Z: calculates address of a block in the file (used by function <code>V</code> and macro <code>S</code>).</li>
</ul>
<p>The macro:</p>
<ul>
<li>S: scanf macro.</li>
<li>w: death macro which will ‘goto hell’.</li>
</ul>
<p>If you expect me to try and describe the labels I will direct you straight to
line 22!
<!-- AFTER: last line of markdown file: 2024/ferguson1/deobfuscation.md --></p>
<!-- END: this line ends content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<!-- START: this line starts content from: inc/after-content.default.html -->
</div>
<!-- END: this line ends content from: inc/after-content.default.html -->
<!-- START: this line starts content from: inc/footer.default.html -->
<!--
Copyright © 1984-2025 by Landon Curt Noll. All Rights Reserved.
You are free to share and adapt this file under the terms of this license:
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
For more information, see:
https://creativecommons.org/licenses/by-sa/4.0/
-->
<div class="footer">
<div id="copyright"><h3>Copyright &copy; 1984-2025 by Landon Curt Noll:
<a href="https://creativecommons.org/faq/#what-does-some-rights-reserved-mean"
target="_blank"
rel="license noopener noreferrer">Some Rights Reserved</a></h3>
<p>
This work is <b>licensed by Landon Curt Noll</b> under
<b><a href="https://creativecommons.org/licenses/by-sa/4.0/?ref=chooser-v1"
target="_blank"
rel="license noopener noreferrer"
style="display:inline-block;">CC BY-SA 4.0</a></b>.
<img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;"
src="../../png/cc.png"
alt="cc inside circle symbol">
<img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;"
src="../../png/by.png"
alt="person inside circle symbol">
<img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;"
src="../../png/sa.png"
alt="arrow looping back on itself inside circle symbol"><br>
You should <b>carefully review</b> the
<b><a href="https://creativecommons.org/licenses/by-sa/4.0/legalcode.en"
target="_blank"
rel="license noopener noreferrer">CC BY-SA 4.0 LEGAL CODE</a></b>
before using the licensed material.<br>
You may wish to review the
<b><a href="../../license.html"
target="_blank"
rel="license noopener noreferrer">highlights of some of the key features and terms</a></b>
of <b>CC BY-SA 4.0</b>.<br>
</p>
</div>
<div id="coda"><h3>Coda</h3>
<p>
<a href="https://validator.w3.org/nu/?doc=https%3A%2F%2Fwww.ioccc.org%2F2024%2Fferguson1%2Fdeobfuscation.html" rel="nofollow">Nu HTML check this web page</a><br>
<a href="#top">Jump to top</a> <a href="#content">Jump to Content</a>
</p>
</div>
</div>
<!-- END: this line ends content from: inc/footer.default.html -->
<!-- START: this line starts content from: inc/bottom.default.html -->
</body>
</html>
<!-- END: this line ends content from: inc/bottom.default.html -->