#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int main(int argv, char *argc[]) {
  int xor_base = -1;
  FILE *inf;
  FILE *ouf;
  char a, b;
  int i, j;
  char outfile[1024];
  int inbracket = 0, quoted = 0;
  unsigned long count;
  if (argv < 3) {
    fprintf(stderr, "\nUsage: encode <XOR_VAL> "
                    "<file>\n\n");
    fprintf(stderr, "    This program will:\n");
    fprintf(stderr, "    - take as input a source code file <file>,\n");
    fprintf(stderr, "    - search for literal strings inclosed by _(), "
                    "like '_(string)',\n");
    fprintf(stderr, "    - replace _(string) by "
                    "_(string XOR <XOR_VAL>),\n");
    fprintf(stderr, "    - and output the result to './x_<file>'.\n\n");
    fprintf(stderr, "    _() is supposed to be defined as a macro in "
                    "the code, that\n");
    fprintf(stderr, "    will allow the program to decode the xor'ed string "
                    "at runtime.\n");
    fprintf(stderr, "    The effect is that the compiled executable does "
                    "not contain literal\n");
    fprintf(stderr, "    strings that may trivially be found with the Unix "
                    "'strings' command,\n");
    fprintf(stderr, "    and thus reveal the nature of "
                    "the program.\n");
    return -1;
  }
  --argv;
  ++argc;
  xor_base = atoi(argc[0]);
  if (xor_base < 0 || (xor_base > 0 && xor_base < 128) || xor_base > 255) {
    fprintf(stderr,
            "\nERROR: encode: XOR_VAL=%d is out of "
            "range (0, 128..255)\n",
            xor_base);
    fprintf(stderr, "** please follow these steps to fix the problem:\n\n");
    fprintf(stderr, "   make clean\n");
    fprintf(stderr, "   ./configure [more options] "
                    "--with-stealth=XOR_VAL (range 0, 128..255)\n");
    fprintf(stderr, "   make\n\n");
    return -1;
  }
  --argv;
  ++argc;
  while (argv > 0) {
    inf = fopen(argc[0], "r");
    if (inf == NULL) {
      fprintf(stderr, "Error opening %s\n", argc[0]);
      return -1;
    }
    i = 0;
    j = 0;
    while (argc[0][i] != '\0') {
      if (argc[0][i] == '/')
        j = i + 1;
      ++i;
    }
    i = 0;
    outfile[0] = 'x';
    outfile[1] = '_';
    outfile[2] = '\0';
    while (argc[0][j + i] != '\0') {
      outfile[i + 2] = argc[0][j + i];
      ++i;
    }
    outfile[i + 2] = '\0';
    ouf = fopen(outfile, "w");
    if (ouf == NULL) {
      fprintf(stderr, "Error opening %s\n", outfile);
      return -1;
    }
    count = 0;
    while (fread(&a, 1, 1, inf) != 0) {
      count++;
      if (a == '"' && quoted == 0) {
        quoted = 1;
        fwrite(&a, 1, 1, ouf);
        continue;
      }
      if (a == '"' && quoted == 1) {
        quoted = 0;
        fwrite(&a, 1, 1, ouf);
        continue;
      }
      if (a == '\n' && quoted == 1) {
        quoted = 0;
        fwrite(&a, 1, 1, ouf);
        continue;
      }
      if (a == '_' && inbracket == 0 && quoted == 0) {
        fwrite(&a, 1, 1, ouf);
        b = '\0';
        fread(&b, 1, 1, inf);
        count++;
        fwrite(&b, 1, 1, ouf);
        if (b == '(')
          inbracket = 1;
        continue;
      }
      if (a == ')' && quoted == 0 && inbracket == 1) {
        inbracket = 0;
        fwrite(&a, 1, 1, ouf);
        continue;
      }
      if (inbracket == 1 && quoted == 1) {
        if (a == '\\') {
          fread(&b, 1, 1, inf);
          if (b == 't' || b == 'n' || b == 'r' || b == '"') {
            fwrite(&a, 1, 1, ouf);
            fwrite(&b, 1, 1, ouf);
          } else {
            a ^= (char)xor_base;
            b ^= (char)xor_base;
          }
        } else {
          a ^= (char)xor_base;
          fwrite(&a, 1, 1, ouf);
        }
        continue;
      }
      fwrite(&a, 1, 1, ouf);
    }
    fclose(ouf);
    fclose(inf);
    --argv;
    ++argc;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xffffffff,-0x14(%rbp)
movl   $0x0,-0x444(%rbp)
movl   $0x0,-0x448(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    12a7 <main+0x147>
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
lea    0xe52(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2e24(%rip),%rax
mov    (%rax),%edi
lea    0xe5d(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
lea    0xe5e(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2df6(%rip),%rax
mov    (%rax),%edi
lea    0xe77(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2ddf(%rip),%rax
mov    (%rax),%edi
lea    0xea5(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2dc8(%rip),%rax
mov    (%rax),%edi
lea    0xec3(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2db1(%rip),%rax
mov    (%rax),%edi
lea    0xedb(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2d9a(%rip),%rax
mov    (%rax),%edi
lea    0xf04(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2d83(%rip),%rax
mov    (%rax),%edi
lea    0xf31(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2d6c(%rip),%rax
mov    (%rax),%edi
lea    0xf63(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2d55(%rip),%rax
mov    (%rax),%edi
lea    0xf96(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1804 <main+0x6a4>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     12f9 <main+0x199>
cmpl   $0x0,-0x14(%rbp)
jle    12ec <main+0x18c>
cmpl   $0x80,-0x14(%rbp)
jl     12f9 <main+0x199>
cmpl   $0xff,-0x14(%rbp)
jle    137b <main+0x21b>
mov    0x2ce0(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xf4e(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2cc6(%rip),%rax
mov    (%rax),%edi
lea    0xf71(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2caf(%rip),%rax
mov    (%rax),%edi
lea    0xf8d(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2c98(%rip),%rax
mov    (%rax),%edi
lea    0xf85(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2c81(%rip),%rax
mov    (%rax),%edi
lea    0xfb8(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1804 <main+0x6a4>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    17fd <main+0x69d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xf82(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    13e6 <main+0x286>
mov    0x2c1d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xf59(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1804 <main+0x6a4>
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movslq -0x30(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     143b <main+0x2db>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movslq -0x30(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    142d <main+0x2cd>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    13f4 <main+0x294>
movl   $0x0,-0x30(%rbp)
movb   $0x78,-0x440(%rbp)
movb   $0x5f,-0x43f(%rbp)
movb   $0x0,-0x43e(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x34(%rbp),%ecx
add    -0x30(%rbp),%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     14a4 <main+0x344>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x34(%rbp),%ecx
add    -0x30(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%cl
mov    -0x30(%rbp),%eax
add    $0x2,%eax
cltq
mov    %cl,-0x440(%rbp,%rax,1)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1457 <main+0x2f7>
mov    -0x30(%rbp),%eax
add    $0x2,%eax
cltq
movb   $0x0,-0x440(%rbp,%rax,1)
lea    -0x440(%rbp),%rdi
lea    0xe7c(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1500 <main+0x3a0>
mov    0x2b03(%rip),%rax
mov    (%rax),%edi
lea    -0x440(%rbp),%rdx
lea    0xe3f(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1804 <main+0x6a4>
movq   $0x0,-0x450(%rbp)
mov    -0x20(%rbp),%rcx
lea    -0x29(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
cmp    $0x0,%rax
je     17d1 <main+0x671>
mov    -0x450(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x450(%rbp)
movsbl -0x29(%rbp),%eax
cmp    $0x22,%eax
jne    1578 <main+0x418>
cmpl   $0x0,-0x448(%rbp)
jne    1578 <main+0x418>
movl   $0x1,-0x448(%rbp)
mov    -0x28(%rbp),%rcx
lea    -0x29(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1080 <fwrite@plt>
jmp    150b <main+0x3ab>
movsbl -0x29(%rbp),%eax
cmp    $0x22,%eax
jne    15b5 <main+0x455>
cmpl   $0x1,-0x448(%rbp)
jne    15b5 <main+0x455>
movl   $0x0,-0x448(%rbp)
mov    -0x28(%rbp),%rcx
lea    -0x29(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1080 <fwrite@plt>
jmp    150b <main+0x3ab>
movsbl -0x29(%rbp),%eax
cmp    $0xa,%eax
jne    15f2 <main+0x492>
cmpl   $0x1,-0x448(%rbp)
jne    15f2 <main+0x492>
movl   $0x0,-0x448(%rbp)
mov    -0x28(%rbp),%rcx
lea    -0x29(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1080 <fwrite@plt>
jmp    150b <main+0x3ab>
movsbl -0x29(%rbp),%eax
cmp    $0x5f,%eax
jne    1687 <main+0x527>
cmpl   $0x0,-0x444(%rbp)
jne    1687 <main+0x527>
cmpl   $0x0,-0x448(%rbp)
jne    1687 <main+0x527>
mov    -0x28(%rbp),%rcx
lea    -0x29(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1080 <fwrite@plt>
movb   $0x0,-0x2a(%rbp)
mov    -0x20(%rbp),%rcx
lea    -0x2a(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
mov    -0x450(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x450(%rbp)
mov    -0x28(%rbp),%rcx
lea    -0x2a(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1080 <fwrite@plt>
movsbl -0x2a(%rbp),%eax
cmp    $0x28,%eax
jne    1682 <main+0x522>
movl   $0x1,-0x444(%rbp)
jmp    150b <main+0x3ab>
movsbl -0x29(%rbp),%eax
cmp    $0x29,%eax
jne    16d1 <main+0x571>
cmpl   $0x0,-0x448(%rbp)
jne    16d1 <main+0x571>
cmpl   $0x1,-0x444(%rbp)
jne    16d1 <main+0x571>
movl   $0x0,-0x444(%rbp)
mov    -0x28(%rbp),%rcx
lea    -0x29(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1080 <fwrite@plt>
jmp    150b <main+0x3ab>
cmpl   $0x1,-0x444(%rbp)
jne    17b8 <main+0x658>
cmpl   $0x1,-0x448(%rbp)
jne    17b8 <main+0x658>
movsbl -0x29(%rbp),%eax
cmp    $0x5c,%eax
jne    1790 <main+0x630>
mov    -0x20(%rbp),%rcx
lea    -0x2a(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
movsbl -0x2a(%rbp),%eax
cmp    $0x74,%eax
je     1740 <main+0x5e0>
movsbl -0x2a(%rbp),%eax
cmp    $0x6e,%eax
je     1740 <main+0x5e0>
movsbl -0x2a(%rbp),%eax
cmp    $0x72,%eax
je     1740 <main+0x5e0>
movsbl -0x2a(%rbp),%eax
cmp    $0x22,%eax
jne    176d <main+0x60d>
mov    -0x28(%rbp),%rcx
lea    -0x29(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1080 <fwrite@plt>
mov    -0x28(%rbp),%rcx
lea    -0x2a(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1080 <fwrite@plt>
jmp    178b <main+0x62b>
mov    -0x14(%rbp),%eax
movsbl %al,%ecx
movsbl -0x29(%rbp),%eax
xor    %ecx,%eax
mov    %al,-0x29(%rbp)
mov    -0x14(%rbp),%eax
movsbl %al,%ecx
movsbl -0x2a(%rbp),%eax
xor    %ecx,%eax
mov    %al,-0x2a(%rbp)
jmp    17b3 <main+0x653>
mov    -0x14(%rbp),%eax
movsbl %al,%ecx
movsbl -0x29(%rbp),%eax
xor    %ecx,%eax
mov    %al,-0x29(%rbp)
mov    -0x28(%rbp),%rcx
lea    -0x29(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1080 <fwrite@plt>
jmp    150b <main+0x3ab>
mov    -0x28(%rbp),%rcx
lea    -0x29(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1080 <fwrite@plt>
jmp    150b <main+0x3ab>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    1390 <main+0x230>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x428,%rsp
cmp    $0x2,%edi
jg     122f <main+0xcf>
mov    0x2e5f(%rip),%rbx
mov    (%rbx),%edi
lea    0xe76(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe88(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe90(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    (%rbx),%edi
lea    0xeb0(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    (%rbx),%edi
lea    0xee5(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    (%rbx),%edi
lea    0xf0a(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    (%rbx),%edi
lea    0xf29(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    (%rbx),%edi
lea    0xf59(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    (%rbx),%edi
lea    0xf8d(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    (%rbx),%edi
lea    0xfc6(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    (%rbx),%edi
lea    0x1000(%rip),%rsi
jmp    1591 <main+0x431>
mov    %rsi,%rbp
mov    %edi,%r15d
mov    0x8(%rsi),%rdi
call   1080 <atoi@plt>
mov    %eax,%edx
test   %eax,%eax
js     1541 <main+0x3e1>
cmp    $0xff,%edx
ja     1541 <main+0x3e1>
mov    %edx,%eax
add    $0xffffffff,%eax
cmp    $0x7e,%eax
jbe    1541 <main+0x3e1>
add    $0xfffffffe,%r15d
add    $0x10,%rbp
mov    %edx,0xc(%rsp)
mov    %edx,%eax
xor    $0x5c,%al
mov    %al,0xb(%rsp)
xor    %r14d,%r14d
xor    %r12d,%r12d
jmp    12ad <main+0x14d>
xchg   %ax,%ax
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    %r13,%rdi
call   1040 <fclose@plt>
mov    0x10(%rsp),%rcx
lea    -0x1(%rcx),%eax
mov    0x18(%rsp),%rbp
add    $0x8,%rbp
cmp    $0x1,%ecx
mov    %eax,%r15d
jle    15af <main+0x44f>
mov    0x0(%rbp),%rdi
lea    0x1072(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     15b3 <main+0x453>
mov    %rax,%r13
mov    0x0(%rbp),%rax
xor    %ecx,%ecx
add    $0x1,%rcx
xor    %edx,%edx
jmp    12e4 <main+0x184>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rcx
movzbl -0x1(%rax,%rcx,1),%ebx
test   %bl,%bl
je     1300 <main+0x1a0>
cmp    $0x2f,%bl
jne    12e0 <main+0x180>
mov    %rcx,%rdx
add    $0x1,%rcx
jmp    12e4 <main+0x184>
nopl   0x0(%rax,%rax,1)
movw   $0x5f78,0x20(%rsp)
movb   $0x0,0x22(%rsp)
movslq %edx,%rdx
mov    (%rax,%rdx,1),%cl
test   %cl,%cl
mov    %rbp,0x18(%rsp)
mov    %r15,0x10(%rsp)
je     1350 <main+0x1f0>
add    %rax,%rdx
add    $0x1,%rdx
xor    %eax,%eax
nopl   0x0(%rax)
mov    %cl,0x22(%rsp,%rax,1)
movzbl (%rdx,%rax,1),%ecx
add    $0x1,%rax
test   %cl,%cl
jne    1330 <main+0x1d0>
jmp    1352 <main+0x1f2>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
add    $0x2,%eax
movb   $0x0,0x20(%rsp,%rax,1)
lea    0x20(%rsp),%rdi
lea    0xfd8(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
lea    0xa(%rsp),%rbp
je     15c9 <main+0x469>
mov    %rax,%r15
jmp    138e <main+0x22e>
mov    $0x1,%r14d
mov    %eax,%edi
mov    %r15,%rsi
call   1050 <fputc@plt>
mov    %rbp,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r13,%rcx
call   1030 <fread@plt>
test   %rax,%rax
je     1280 <main+0x120>
mov    %r12d,%eax
xor    $0x1,%eax
mov    %r14d,%ecx
xor    $0x1,%ecx
or     %eax,%ecx
sete   %bl
nopl   (%rax)
movsbl 0xa(%rsp),%edi
mov    $0x22,%eax
cmp    $0x22,%edi
jne    13d4 <main+0x274>
test   %r14d,%r14d
je     137e <main+0x21e>
cmp    $0x22,%dil
jne    13e0 <main+0x280>
cmp    $0x1,%r14d
je     1440 <main+0x2e0>
cmp    $0xa,%dil
jne    13ec <main+0x28c>
cmp    $0x1,%r14d
je     1448 <main+0x2e8>
cmp    $0x5f,%dil
jne    13fc <main+0x29c>
test   %r12d,%r12d
jne    13fc <main+0x29c>
test   %r14d,%r14d
je     1455 <main+0x2f5>
cmp    $0x29,%dil
jne    1411 <main+0x2b1>
test   %r14d,%r14d
jne    1411 <main+0x2b1>
cmp    $0x1,%r12d
je     149d <main+0x33d>
test   %bl,%bl
jne    14b5 <main+0x355>
mov    %r15,%rsi
call   1050 <fputc@plt>
mov    %rbp,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r13,%rcx
call   1030 <fread@plt>
test   %rax,%rax
jne    13c0 <main+0x260>
jmp    1280 <main+0x120>
xor    %r14d,%r14d
jmp    1384 <main+0x224>
mov    $0xa,%eax
xor    %r14d,%r14d
jmp    1384 <main+0x224>
mov    $0x5f,%edi
mov    %r15,%rsi
call   1050 <fputc@plt>
movb   $0x0,0x9(%rsp)
lea    0x9(%rsp),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r13,%rcx
call   1030 <fread@plt>
movsbl 0x9(%rsp),%edi
xor    %r12d,%r12d
cmp    $0x28,%edi
sete   %r12b
mov    %r15,%rsi
call   1050 <fputc@plt>
xor    %r14d,%r14d
jmp    138e <main+0x22e>
mov    $0x29,%edi
mov    %r15,%rsi
call   1050 <fputc@plt>
xor    %r12d,%r12d
xor    %r14d,%r14d
jmp    138e <main+0x22e>
cmp    $0x5c,%dil
jne    1508 <main+0x3a8>
lea    0x9(%rsp),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r13,%rcx
call   1030 <fread@plt>
mov    0x9(%rsp),%al
lea    -0x6e(%rax),%ecx
cmp    $0x6,%cl
ja     14eb <main+0x38b>
movzbl %cl,%ecx
mov    $0x51,%edx
bt     %ecx,%edx
jb     14ef <main+0x38f>
cmp    $0x22,%al
jne    152f <main+0x3cf>
movzbl %al,%ebp
mov    $0x5c,%edi
mov    %r15,%rsi
call   1050 <fputc@plt>
mov    %ebp,%edi
lea    0xa(%rsp),%rbp
jmp    1516 <main+0x3b6>
xor    0xc(%rsp),%dil
mov    %dil,0xa(%rsp)
movsbl %dil,%edi
mov    %r15,%rsi
call   1050 <fputc@plt>
mov    $0x1,%r12d
mov    $0x1,%r14d
jmp    138e <main+0x22e>
mov    0xb(%rsp),%cl
mov    %cl,0xa(%rsp)
xor    0xc(%rsp),%al
mov    %al,0x9(%rsp)
jmp    151e <main+0x3be>
mov    0x2a98(%rip),%rbx
mov    (%rbx),%edi
lea    0xd09(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    (%rbx),%edi
lea    0xd33(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    (%rbx),%edi
lea    0xd56(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    (%rbx),%edi
lea    0xd55(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    (%rbx),%edi
lea    0xd8f(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x428,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
jmp    159d <main+0x43d>
mov    0x2a26(%rip),%rax
mov    (%rax),%edi
mov    0x0(%rbp),%rdx
lea    0xd65(%rip),%rsi
jmp    15de <main+0x47e>
mov    0x2a10(%rip),%rax
mov    (%rax),%edi
lea    0xd53(%rip),%rsi
lea    0x20(%rsp),%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    1598 <main+0x438>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [34 x i8] c"\0AUsage: encode <XOR_VAL> <file>\0A\0A\00"
@.str.1 = [24 x i8] c" This program will:\0A\00"
@.str.2 = [48 x i8] c" - take as input a source code file <file>,\0A\00"
@.str.3 = [69 x i8] c" - search for literal strings inclosed by _(), like '_(string)',\0A\00"
@.str.4 = [53 x i8] c" - replace _(string) by _(string XOR <XOR_VAL>),\0A\00"
@.str.5 = [47 x i8] c" - and output the result to './x_<file>'.\0A\0A\00"
@.str.6 = [64 x i8] c" _() is supposed to be defined as a macro in the code, that\0A\00"
@.str.7 = [68 x i8] c" will allow the program to decode the xor'ed string at runtime.\0A\00"
@.str.8 = [73 x i8] c" The effect is that the compiled executable does not contain literal\0A\00"
@.str.9 = [74 x i8] c" strings that may trivially be found with the Unix 'strings' command,\0A\00"
@.str.10 = [48 x i8] c" and thus reveal the nature of the program.\0A\00"
@.str.11 = [58 x i8] c"\0AERROR: encode: XOR_VAL=%d is out of range (0, 128..255)\0A\00"
@.str.12 = [51 x i8] c"** please follow these steps to fix the problem:\0A\0A\00"
@.str.13 = [15 x i8] c" make clean\0A\00"
@.str.14 = [74 x i8] c" ./configure [more options] --with-stealth=XOR_VAL (range 0, 128..255)\0A\00"
@.str.15 = [10 x i8] c" make\0A\0A\00"
@.str.16 = [2 x i8] c"r\00"
@.str.17 = [18 x i8] c"Error opening %s\0A\00"
@.str.18 = [2 x i8] c"w\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i8
%10 = alloca i8
%11 = alloca i32
%12 = alloca i32
%13 = alloca [1024 x i8]
%14 = alloca i32
%15 = alloca i32
%16 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 -1, i32* %6
store i32 0, i32* %14
store i32 0, i32* %15
%17 = load i32, i32* %4
%18 = icmp slt i32 %17, 3
br i1 %18, label %19, label %42
19: ; preds = %2
%20 = load i32, i32* @stderr
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%22 = load i32, i32* @stderr
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%24 = load i32, i32* @stderr
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
%26 = load i32, i32* @stderr
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.3, i64 0, i64 0))
%28 = load i32, i32* @stderr
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0))
%30 = load i32, i32* @stderr
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.5, i64 0, i64 0))
%32 = load i32, i32* @stderr
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.6, i64 0, i64 0))
%34 = load i32, i32* @stderr
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.7, i64 0, i64 0))
%36 = load i32, i32* @stderr
%37 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.8, i64 0, i64 0))
%38 = load i32, i32* @stderr
%39 = call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.9, i64 0, i64 0))
%40 = load i32, i32* @stderr
%41 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.10, i64 0, i64 0))
store i32 -1, i32* %3
br label %314
42: ; preds = %2
%43 = load i32, i32* %4
%44 = add nsw i32 %43, -1
store i32 %44, i32* %4
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i32 1
store i8** %46, i8*** %5
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 0
%49 = load i8*, i8** %48
%50 = call i32 @atoi(i8* %49)
store i32 %50, i32* %6
%51 = load i32, i32* %6
%52 = icmp slt i32 %51, 0
br i1 %52, label %62, label %53
53: ; preds = %42
%54 = load i32, i32* %6
%55 = icmp sgt i32 %54, 0
br i1 %55, label %56, label %59
56: ; preds = %53
%57 = load i32, i32* %6
%58 = icmp slt i32 %57, 128
br i1 %58, label %62, label %59
59: ; preds = %56, %53
%60 = load i32, i32* %6
%61 = icmp sgt i32 %60, 255
br i1 %61, label %62, label %74
62: ; preds = %59, %56, %42
%63 = load i32, i32* @stderr
%64 = load i32, i32* %6
%65 = call i32 (i32, i8*, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.11, i64 0, i64 0), i32 %64)
%66 = load i32, i32* @stderr
%67 = call i32 (i32, i8*, ...) @fprintf(i32 %66, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.12, i64 0, i64 0))
%68 = load i32, i32* @stderr
%69 = call i32 (i32, i8*, ...) @fprintf(i32 %68, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.13, i64 0, i64 0))
%70 = load i32, i32* @stderr
%71 = call i32 (i32, i8*, ...) @fprintf(i32 %70, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.14, i64 0, i64 0))
%72 = load i32, i32* @stderr
%73 = call i32 (i32, i8*, ...) @fprintf(i32 %72, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0))
store i32 -1, i32* %3
br label %314
74: ; preds = %59
%75 = load i32, i32* %4
%76 = add nsw i32 %75, -1
store i32 %76, i32* %4
%77 = load i8**, i8*** %5
%78 = getelementptr inbounds i8*, i8** %77, i32 1
store i8** %78, i8*** %5
br label %79
79: ; preds = %304, %74
%80 = load i32, i32* %4
%81 = icmp sgt i32 %80, 0
br i1 %81, label %82, label %313
82: ; preds = %79
%83 = load i8**, i8*** %5
%84 = getelementptr inbounds i8*, i8** %83, i64 0
%85 = load i8*, i8** %84
%86 = call i32* @fopen(i8* %85, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.16, i64 0, i64 0))
store i32* %86, i32** %7
%87 = load i32*, i32** %7
%88 = icmp eq i32* %87, null
br i1 %88, label %89, label %95
89: ; preds = %82
%90 = load i32, i32* @stderr
%91 = load i8**, i8*** %5
%92 = getelementptr inbounds i8*, i8** %91, i64 0
%93 = load i8*, i8** %92
%94 = call i32 (i32, i8*, ...) @fprintf(i32 %90, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.17, i64 0, i64 0), i8* %93)
store i32 -1, i32* %3
br label %314
95: ; preds = %82
store i32 0, i32* %11
store i32 0, i32* %12
br label %96
96: ; preds = %119, %95
%97 = load i8**, i8*** %5
%98 = getelementptr inbounds i8*, i8** %97, i64 0
%99 = load i8*, i8** %98
%100 = load i32, i32* %11
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds i8, i8* %99, i64 %101
%103 = load i8, i8* %102
%104 = sext i8 %103 to i32
%105 = icmp ne i32 %104, 0
br i1 %105, label %106, label %122
106: ; preds = %96
%107 = load i8**, i8*** %5
%108 = getelementptr inbounds i8*, i8** %107, i64 0
%109 = load i8*, i8** %108
%110 = load i32, i32* %11
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds i8, i8* %109, i64 %111
%113 = load i8, i8* %112
%114 = sext i8 %113 to i32
%115 = icmp eq i32 %114, 47
br i1 %115, label %116, label %119
116: ; preds = %106
%117 = load i32, i32* %11
%118 = add nsw i32 %117, 1
store i32 %118, i32* %12
br label %119
119: ; preds = %116, %106
%120 = load i32, i32* %11
%121 = add nsw i32 %120, 1
store i32 %121, i32* %11
br label %96
122: ; preds = %96
store i32 0, i32* %11
%123 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
store i8 120, i8* %123
%124 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 1
store i8 95, i8* %124
%125 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 2
store i8 0, i8* %125
br label %126
126: ; preds = %138, %122
%127 = load i8**, i8*** %5
%128 = getelementptr inbounds i8*, i8** %127, i64 0
%129 = load i8*, i8** %128
%130 = load i32, i32* %12
%131 = load i32, i32* %11
%132 = add nsw i32 %130, %131
%133 = sext i32 %132 to i64
%134 = getelementptr inbounds i8, i8* %129, i64 %133
%135 = load i8, i8* %134
%136 = sext i8 %135 to i32
%137 = icmp ne i32 %136, 0
br i1 %137, label %138, label %154
138: ; preds = %126
%139 = load i8**, i8*** %5
%140 = getelementptr inbounds i8*, i8** %139, i64 0
%141 = load i8*, i8** %140
%142 = load i32, i32* %12
%143 = load i32, i32* %11
%144 = add nsw i32 %142, %143
%145 = sext i32 %144 to i64
%146 = getelementptr inbounds i8, i8* %141, i64 %145
%147 = load i8, i8* %146
%148 = load i32, i32* %11
%149 = add nsw i32 %148, 2
%150 = sext i32 %149 to i64
%151 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 %150
store i8 %147, i8* %151
%152 = load i32, i32* %11
%153 = add nsw i32 %152, 1
store i32 %153, i32* %11
br label %126
154: ; preds = %126
%155 = load i32, i32* %11
%156 = add nsw i32 %155, 2
%157 = sext i32 %156 to i64
%158 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 %157
store i8 0, i8* %158
%159 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%160 = call i32* @fopen(i8* %159, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.18, i64 0, i64 0))
store i32* %160, i32** %8
%161 = load i32*, i32** %8
%162 = icmp eq i32* %161, null
br i1 %162, label %163, label %167
163: ; preds = %154
%164 = load i32, i32* @stderr
%165 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%166 = call i32 (i32, i8*, ...) @fprintf(i32 %164, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.17, i64 0, i64 0), i8* %165)
store i32 -1, i32* %3
br label %314
167: ; preds = %154
store i64 0, i64* %16
br label %168
168: ; preds = %301, %300, %238, %227, %201, %191, %181, %167
%169 = load i32*, i32** %7
%170 = call i64 @fread(i8* %9, i32 1, i32 1, i32* %169)
%171 = icmp ne i64 %170, 0
br i1 %171, label %172, label %304
172: ; preds = %168
%173 = load i64, i64* %16
%174 = add i64 %173, 1
store i64 %174, i64* %16
%175 = load i8, i8* %9
%176 = sext i8 %175 to i32
%177 = icmp eq i32 %176, 34
br i1 %177, label %178, label %184
178: ; preds = %172
%179 = load i32, i32* %15
%180 = icmp eq i32 %179, 0
br i1 %180, label %181, label %184
181: ; preds = %178
store i32 1, i32* %15
%182 = load i32*, i32** %8
%183 = call i32 @fwrite(i8* %9, i32 1, i32 1, i32* %182)
br label %168
184: ; preds = %178, %172
%185 = load i8, i8* %9
%186 = sext i8 %185 to i32
%187 = icmp eq i32 %186, 34
br i1 %187, label %188, label %194
188: ; preds = %184
%189 = load i32, i32* %15
%190 = icmp eq i32 %189, 1
br i1 %190, label %191, label %194
191: ; preds = %188
store i32 0, i32* %15
%192 = load i32*, i32** %8
%193 = call i32 @fwrite(i8* %9, i32 1, i32 1, i32* %192)
br label %168
194: ; preds = %188, %184
%195 = load i8, i8* %9
%196 = sext i8 %195 to i32
%197 = icmp eq i32 %196, 10
br i1 %197, label %198, label %204
198: ; preds = %194
%199 = load i32, i32* %15
%200 = icmp eq i32 %199, 1
br i1 %200, label %201, label %204
201: ; preds = %198
store i32 0, i32* %15
%202 = load i32*, i32** %8
%203 = call i32 @fwrite(i8* %9, i32 1, i32 1, i32* %202)
br label %168
204: ; preds = %198, %194
%205 = load i8, i8* %9
%206 = sext i8 %205 to i32
%207 = icmp eq i32 %206, 95
br i1 %207, label %208, label %228
208: ; preds = %204
%209 = load i32, i32* %14
%210 = icmp eq i32 %209, 0
br i1 %210, label %211, label %228
211: ; preds = %208
%212 = load i32, i32* %15
%213 = icmp eq i32 %212, 0
br i1 %213, label %214, label %228
214: ; preds = %211
%215 = load i32*, i32** %8
%216 = call i32 @fwrite(i8* %9, i32 1, i32 1, i32* %215)
store i8 0, i8* %10
%217 = load i32*, i32** %7
%218 = call i64 @fread(i8* %10, i32 1, i32 1, i32* %217)
%219 = load i64, i64* %16
%220 = add i64 %219, 1
store i64 %220, i64* %16
%221 = load i32*, i32** %8
%222 = call i32 @fwrite(i8* %10, i32 1, i32 1, i32* %221)
%223 = load i8, i8* %10
%224 = sext i8 %223 to i32
%225 = icmp eq i32 %224, 40
br i1 %225, label %226, label %227
226: ; preds = %214
store i32 1, i32* %14
br label %227
227: ; preds = %226, %214
br label %168
228: ; preds = %211, %208, %204
%229 = load i8, i8* %9
%230 = sext i8 %229 to i32
%231 = icmp eq i32 %230, 41
br i1 %231, label %232, label %241
232: ; preds = %228
%233 = load i32, i32* %15
%234 = icmp eq i32 %233, 0
br i1 %234, label %235, label %241
235: ; preds = %232
%236 = load i32, i32* %14
%237 = icmp eq i32 %236, 1
br i1 %237, label %238, label %241
238: ; preds = %235
store i32 0, i32* %14
%239 = load i32*, i32** %8
%240 = call i32 @fwrite(i8* %9, i32 1, i32 1, i32* %239)
br label %168
241: ; preds = %235, %232, %228
%242 = load i32, i32* %14
%243 = icmp eq i32 %242, 1
br i1 %243, label %244, label %301
244: ; preds = %241
%245 = load i32, i32* %15
%246 = icmp eq i32 %245, 1
br i1 %246, label %247, label %301
247: ; preds = %244
%248 = load i8, i8* %9
%249 = sext i8 %248 to i32
%250 = icmp eq i32 %249, 92
br i1 %250, label %251, label %290
251: ; preds = %247
%252 = load i32*, i32** %7
%253 = call i64 @fread(i8* %10, i32 1, i32 1, i32* %252)
%254 = load i8, i8* %10
%255 = sext i8 %254 to i32
%256 = icmp eq i32 %255, 116
br i1 %256, label %269, label %257
257: ; preds = %251
%258 = load i8, i8* %10
%259 = sext i8 %258 to i32
%260 = icmp eq i32 %259, 110
br i1 %260, label %269, label %261
261: ; preds = %257
%262 = load i8, i8* %10
%263 = sext i8 %262 to i32
%264 = icmp eq i32 %263, 114
br i1 %264, label %269, label %265
265: ; preds = %261
%266 = load i8, i8* %10
%267 = sext i8 %266 to i32
%268 = icmp eq i32 %267, 34
br i1 %268, label %269, label %274
269: ; preds = %265, %261, %257, %251
%270 = load i32*, i32** %8
%271 = call i32 @fwrite(i8* %9, i32 1, i32 1, i32* %270)
%272 = load i32*, i32** %8
%273 = call i32 @fwrite(i8* %10, i32 1, i32 1, i32* %272)
br label %289
274: ; preds = %265
%275 = load i32, i32* %6
%276 = trunc i32 %275 to i8
%277 = sext i8 %276 to i32
%278 = load i8, i8* %9
%279 = sext i8 %278 to i32
%280 = xor i32 %279, %277
%281 = trunc i32 %280 to i8
store i8 %281, i8* %9
%282 = load i32, i32* %6
%283 = trunc i32 %282 to i8
%284 = sext i8 %283 to i32
%285 = load i8, i8* %10
%286 = sext i8 %285 to i32
%287 = xor i32 %286, %284
%288 = trunc i32 %287 to i8
store i8 %288, i8* %10
br label %289
289: ; preds = %274, %269
br label %300
290: ; preds = %247
%291 = load i32, i32* %6
%292 = trunc i32 %291 to i8
%293 = sext i8 %292 to i32
%294 = load i8, i8* %9
%295 = sext i8 %294 to i32
%296 = xor i32 %295, %293
%297 = trunc i32 %296 to i8
store i8 %297, i8* %9
%298 = load i32*, i32** %8
%299 = call i32 @fwrite(i8* %9, i32 1, i32 1, i32* %298)
br label %300
300: ; preds = %290, %289
br label %168
301: ; preds = %244, %241
%302 = load i32*, i32** %8
%303 = call i32 @fwrite(i8* %9, i32 1, i32 1, i32* %302)
br label %168
304: ; preds = %168
%305 = load i32*, i32** %8
%306 = call i32 @fclose(i32* %305)
%307 = load i32*, i32** %7
%308 = call i32 @fclose(i32* %307)
%309 = load i32, i32* %4
%310 = add nsw i32 %309, -1
store i32 %310, i32* %4
%311 = load i8**, i8*** %5
%312 = getelementptr inbounds i8*, i8** %311, i32 1
store i8** %312, i8*** %5
br label %79
313: ; preds = %79
store i32 0, i32* %3
br label %314
314: ; preds = %313, %163, %89, %62, %19
%315 = load i32, i32* %3
ret i32 %315
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [34 x i8] c"\0AUsage: encode <XOR_VAL> <file>\0A\0A\00"
@.str.1 = [24 x i8] c" This program will:\0A\00"
@.str.2 = [48 x i8] c" - take as input a source code file <file>,\0A\00"
@.str.3 = [69 x i8] c" - search for literal strings inclosed by _(), like '_(string)',\0A\00"
@.str.4 = [53 x i8] c" - replace _(string) by _(string XOR <XOR_VAL>),\0A\00"
@.str.5 = [47 x i8] c" - and output the result to './x_<file>'.\0A\0A\00"
@.str.6 = [64 x i8] c" _() is supposed to be defined as a macro in the code, that\0A\00"
@.str.7 = [68 x i8] c" will allow the program to decode the xor'ed string at runtime.\0A\00"
@.str.8 = [73 x i8] c" The effect is that the compiled executable does not contain literal\0A\00"
@.str.9 = [74 x i8] c" strings that may trivially be found with the Unix 'strings' command,\0A\00"
@.str.10 = [48 x i8] c" and thus reveal the nature of the program.\0A\00"
@.str.11 = [58 x i8] c"\0AERROR: encode: XOR_VAL=%d is out of range (0, 128..255)\0A\00"
@.str.12 = [51 x i8] c"** please follow these steps to fix the problem:\0A\0A\00"
@.str.13 = [15 x i8] c" make clean\0A\00"
@.str.14 = [74 x i8] c" ./configure [more options] --with-stealth=XOR_VAL (range 0, 128..255)\0A\00"
@.str.15 = [10 x i8] c" make\0A\0A\00"
@.str.16 = [2 x i8] c"r\00"
@.str.17 = [18 x i8] c"Error opening %s\0A\00"
@.str.18 = [2 x i8] c"w\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8
%4 = alloca i8
%5 = alloca [1024 x i8]
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%7 = icmp slt i32 %0, 3
br i1 %7, label %8, label %31
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @stderr
%12 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32, i32* @stderr
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
%15 = load i32, i32* @stderr
%16 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.3, i64 0, i64 0))
%17 = load i32, i32* @stderr
%18 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0))
%19 = load i32, i32* @stderr
%20 = tail call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.5, i64 0, i64 0))
%21 = load i32, i32* @stderr
%22 = tail call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.6, i64 0, i64 0))
%23 = load i32, i32* @stderr
%24 = tail call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.7, i64 0, i64 0))
%25 = load i32, i32* @stderr
%26 = tail call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.8, i64 0, i64 0))
%27 = load i32, i32* @stderr
%28 = tail call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.9, i64 0, i64 0))
%29 = load i32, i32* @stderr
%30 = tail call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.10, i64 0, i64 0))
br label %189
31: ; preds = %2
%32 = getelementptr inbounds i8*, i8** %1, i64 1
%33 = load i8*, i8** %32
%34 = tail call i32 @atoi(i8* %33)
%35 = icmp slt i32 %34, 0
br i1 %35, label %41, label %36
36: ; preds = %31
%37 = add nsw i32 %34, -1
%38 = icmp ult i32 %37, 127
%39 = icmp ugt i32 %34, 255
%40 = or i1 %39, %38
br i1 %40, label %41, label %52
41: ; preds = %36, %31
%42 = load i32, i32* @stderr
%43 = tail call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.11, i64 0, i64 0), i32 %34)
%44 = load i32, i32* @stderr
%45 = tail call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.12, i64 0, i64 0))
%46 = load i32, i32* @stderr
%47 = tail call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.13, i64 0, i64 0))
%48 = load i32, i32* @stderr
%49 = tail call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.14, i64 0, i64 0))
%50 = load i32, i32* @stderr
%51 = tail call i32 (i32, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0))
br label %189
52: ; preds = %36
%53 = add nsw i32 %0, -2
%54 = getelementptr inbounds i8*, i8** %1, i64 2
%55 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 1
%56 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 2
%57 = trunc i32 %34 to i8
%58 = xor i8 %57, 92
br label %59
59: ; preds = %52, %181
%60 = phi i32 [ 0, %52 ], [ %183, %181 ]
%61 = phi i32 [ 0, %52 ], [ %182, %181 ]
%62 = phi i32 [ %53, %52 ], [ %186, %181 ]
%63 = phi i8** [ %54, %52 ], [ %187, %181 ]
%64 = load i8*, i8** %63
%65 = tail call i32* @fopen(i8* %64, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.16, i64 0, i64 0))
%66 = icmp eq i32* %65, null
br i1 %66, label %71, label %67
67: ; preds = %59
%68 = load i8*, i8** %63
br label %69
69: ; preds = %81, %67
%70 = phi i64 [ %82, %81 ], [ 0, %67 ]
br label %75
71: ; preds = %59
%72 = load i32, i32* @stderr
%73 = load i8*, i8** %63
%74 = tail call i32 (i32, i8*, ...) @fprintf(i32 %72, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.17, i64 0, i64 0), i8* %73)
br label %189
75: ; preds = %69, %79
%76 = phi i64 [ %80, %79 ], [ %70, %69 ]
%77 = getelementptr inbounds i8, i8* %68, i64 %76
%78 = load i8, i8* %77
switch i8 %78, label %79 [
i8 0, label %83
i8 47, label %81
]
79: ; preds = %75
%80 = add nuw i64 %76, 1
br label %75
81: ; preds = %75
%82 = add nuw i64 %76, 1
br label %69
83: ; preds = %75
store i8 120, i8* %6
store i8 95, i8* %55
store i8 0, i8* %56
%84 = shl i64 %70, 32
%85 = ashr exact i64 %84, 32
%86 = getelementptr inbounds i8, i8* %68, i64 %85
%87 = load i8, i8* %86
%88 = icmp eq i8 %87, 0
br i1 %88, label %99, label %89
89: ; preds = %83, %89
%90 = phi i64 [ %94, %89 ], [ 0, %83 ]
%91 = phi i8 [ %97, %89 ], [ %87, %83 ]
%92 = add nuw nsw i64 %90, 2
%93 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %92
store i8 %91, i8* %93
%94 = add nuw nsw i64 %90, 1
%95 = add nsw i64 %94, %85
%96 = getelementptr inbounds i8, i8* %68, i64 %95
%97 = load i8, i8* %96
%98 = icmp eq i8 %97, 0
br i1 %98, label %99, label %89
99: ; preds = %89, %83
%100 = phi i64 [ 0, %83 ], [ %94, %89 ]
%101 = add i64 %100, 2
%102 = and i64 %101, 4294967295
%103 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %102
store i8 0, i8* %103
%104 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.18, i64 0, i64 0))
%105 = icmp eq i32* %104, null
br i1 %105, label %109, label %106
106: ; preds = %99
%107 = call i64 @fread(i8* %3, i32 1, i32 1, i32* %65)
%108 = icmp eq i64 %107, 0
br i1 %108, label %181, label %149
109: ; preds = %99
%110 = load i32, i32* @stderr
%111 = call i32 (i32, i8*, ...) @fprintf(i32 %110, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.17, i64 0, i64 0), i8* %6)
br label %189
112: ; preds = %122, %176
%113 = load i8, i8* %3
%114 = icmp eq i8 %113, 34
%115 = select i1 %114, i1 %124, i1 false
br i1 %115, label %116, label %127
116: ; preds = %112, %129, %127
%117 = phi i32 [ 34, %127 ], [ 10, %129 ], [ 34, %112 ]
%118 = phi i32 [ 0, %127 ], [ 0, %129 ], [ 1, %112 ]
%119 = tail call i32 @fputc(i32 %117, i32* %104)
%120 = call i64 @fread(i8* %3, i32 1, i32 1, i32* %65)
%121 = icmp eq i64 %120, 0
br i1 %121, label %181, label %122
122: ; preds = %149, %116
%123 = phi i32 [ %150, %149 ], [ %118, %116 ]
%124 = icmp eq i32 %123, 0
%125 = icmp eq i32 %123, 1
%126 = select i1 %153, i1 %125, i1 false
br label %112
127: ; preds = %112
%128 = select i1 %114, i1 %125, i1 false
br i1 %128, label %116, label %129
129: ; preds = %127
%130 = icmp eq i8 %113, 10
%131 = select i1 %130, i1 %125, i1 false
br i1 %131, label %116, label %132
132: ; preds = %129
%133 = icmp eq i8 %113, 95
%134 = select i1 %133, i1 %152, i1 false
%135 = select i1 %134, i1 %124, i1 false
br i1 %135, label %136, label %154
136: ; preds = %132
%137 = tail call i32 @fputc(i32 95, i32* %104)
store i8 0, i8* %4
%138 = call i64 @fread(i8* %4, i32 1, i32 1, i32* %65)
%139 = load i8, i8* %4
%140 = sext i8 %139 to i32
%141 = tail call i32 @fputc(i32 %140, i32* %104)
%142 = icmp eq i8 %139, 40
%143 = zext i1 %142 to i32
br label %144
144: ; preds = %172, %170, %166, %136, %158
%145 = phi i32 [ 0, %158 ], [ %143, %136 ], [ 1, %166 ], [ 1, %170 ], [ 1, %172 ]
%146 = phi i32 [ 0, %158 ], [ 0, %136 ], [ 1, %166 ], [ 1, %170 ], [ 1, %172 ]
%147 = call i64 @fread(i8* %3, i32 1, i32 1, i32* %65)
%148 = icmp eq i64 %147, 0
br i1 %148, label %181, label %149
149: ; preds = %106, %144
%150 = phi i32 [ %146, %144 ], [ %60, %106 ]
%151 = phi i32 [ %145, %144 ], [ %61, %106 ]
%152 = icmp eq i32 %151, 0
%153 = icmp eq i32 %151, 1
br label %122
154: ; preds = %132
%155 = icmp eq i8 %113, 41
%156 = select i1 %155, i1 %124, i1 false
%157 = select i1 %156, i1 %153, i1 false
br i1 %157, label %158, label %160
158: ; preds = %154
%159 = tail call i32 @fputc(i32 41, i32* %104)
br label %144
160: ; preds = %154
br i1 %126, label %161, label %176
161: ; preds = %160
%162 = icmp eq i8 %113, 92
br i1 %162, label %163, label %172
163: ; preds = %161
%164 = call i64 @fread(i8* %4, i32 1, i32 1, i32* %65)
%165 = load i8, i8* %4
switch i8 %165, label %170 [
i8 116, label %166
i8 114, label %166
i8 110, label %166
i8 34, label %166
]
166: ; preds = %163, %163, %163, %163
%167 = tail call i32 @fputc(i32 92, i32* %104)
%168 = zext i8 %165 to i32
%169 = tail call i32 @fputc(i32 %168, i32* %104)
br label %144
170: ; preds = %163
store i8 %58, i8* %3
%171 = xor i8 %165, %57
store i8 %171, i8* %4
br label %144
172: ; preds = %161
%173 = xor i8 %113, %57
store i8 %173, i8* %3
%174 = sext i8 %173 to i32
%175 = tail call i32 @fputc(i32 %174, i32* %104)
br label %144
176: ; preds = %160
%177 = sext i8 %113 to i32
%178 = tail call i32 @fputc(i32 %177, i32* %104)
%179 = call i64 @fread(i8* %3, i32 1, i32 1, i32* %65)
%180 = icmp eq i64 %179, 0
br i1 %180, label %181, label %112
181: ; preds = %144, %116, %176, %106
%182 = phi i32 [ %61, %106 ], [ %151, %176 ], [ %151, %116 ], [ %145, %144 ]
%183 = phi i32 [ %60, %106 ], [ %123, %176 ], [ %118, %116 ], [ %146, %144 ]
%184 = tail call i32 @fclose(i32* %104)
%185 = tail call i32 @fclose(i32* %65)
%186 = add nsw i32 %62, -1
%187 = getelementptr inbounds i8*, i8** %63, i64 1
%188 = icmp sgt i32 %62, 1
br i1 %188, label %59, label %189
189: ; preds = %181, %109, %71, %41, %8
%190 = phi i32 [ -1, %8 ], [ -1, %41 ], [ -1, %71 ], [ -1, %109 ], [ 0, %181 ]
ret i32 %190
}