#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 */

/* Variables and functions */
scalar_t__ eq_cstr(char *, char const *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ free(char *);
char *read_text_file(char const *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ write_switch_file(char const *, char const *, char const *,
                                     char const *, char *);
int main(int argc, const char **argv) {
  int argi = 1;
  const char *strname = 0;
  const char *casepfx = 0;
  const char *xfilename = 0;
  const char *ofilename = 0;
  const char *array_name = 0;
  char *text = 0;
  (void)argc;
  strname = argv[argi++];
  if (!strname)
    do {
      fprintf(stderr, "%s\n", "Need an argument.");
      fprintf(stderr,
              "Usage: %s strname -x list.txt -case-pfx 'fn = testfn_' -o "
              "switch.h\n",
              argv[0]);
      return 1;
    } while (0);
  while (argv[argi]) {
    const char *arg = argv[argi++];
    if (eq_cstr("-x", arg)) {
      xfilename = argv[argi++];
      if (!xfilename)
        do {
          fprintf(stderr, "%s\n", "Need something after -x.");
          fprintf(stderr,
                  "Usage: %s strname -x list.txt -case-pfx 'fn = testfn_' -o "
                  "switch.h\n",
                  argv[0]);
          return 1;
        } while (0);
    } else if (eq_cstr("-o", arg)) {
      ofilename = argv[argi++];
      if (!ofilename)
        do {
          fprintf(stderr, "%s\n", "Need something after -o.");
          fprintf(stderr,
                  "Usage: %s strname -x list.txt -case-pfx 'fn = testfn_' -o "
                  "switch.h\n",
                  argv[0]);
          return 1;
        } while (0);
    } else if (eq_cstr("-case-pfx", arg)) {
      casepfx = argv[argi++];
      if (!casepfx)
        do {
          fprintf(stderr, "%s\n", "Need something after -case-pfx.");
          fprintf(stderr,
                  "Usage: %s strname -x list.txt -case-pfx 'fn = testfn_' -o "
                  "switch.h\n",
                  argv[0]);
          return 1;
        } while (0);
    } else if (eq_cstr("-array", arg)) {
      array_name = argv[argi++];
      if (!casepfx)
        do {
          fprintf(stderr, "%s\n", "Need something after -array.");
          fprintf(stderr,
                  "Usage: %s strname -x list.txt -case-pfx 'fn = testfn_' -o "
                  "switch.h\n",
                  argv[0]);
          return 1;
        } while (0);
    }
  }
  if (!xfilename)
    do {
      fprintf(stderr, "%s\n", "Please supply -x.");
      fprintf(stderr,
              "Usage: %s strname -x list.txt -case-pfx 'fn = testfn_' -o "
              "switch.h\n",
              argv[0]);
      return 1;
    } while (0);
  if (!ofilename)
    do {
      fprintf(stderr, "%s\n", "Please supply -o.");
      fprintf(stderr,
              "Usage: %s strname -x list.txt -case-pfx 'fn = testfn_' -o "
              "switch.h\n",
              argv[0]);
      return 1;
    } while (0);
  if (!casepfx)
    do {
      fprintf(stderr, "%s\n", "Please supply -case-pfx.");
      fprintf(stderr,
              "Usage: %s strname -x list.txt -case-pfx 'fn = testfn_' -o "
              "switch.h\n",
              argv[0]);
      return 1;
    } while (0);
  text = read_text_file(xfilename);
  if (!text)
    do {
      fprintf(stderr, "%s\n", "Cannot read input.");
      fprintf(stderr,
              "Usage: %s strname -x list.txt -case-pfx 'fn = testfn_' -o "
              "switch.h\n",
              argv[0]);
      return 1;
    } while (0);
  if (!write_switch_file(ofilename, strname, casepfx, array_name, text)) {
    do {
      fprintf(stderr, "%s\n", "Failed to write switch file.");
      fprintf(stderr,
              "Usage: %s strname -x list.txt -case-pfx 'fn = testfn_' -o "
              "switch.h\n",
              argv[0]);
      return 1;
    } while (0);
  }
  free(text);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x14(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    120b <main+0xbb>
jmp    11c7 <main+0x77>
mov    0x2e12(%rip),%rax
mov    (%rax),%edi
lea    0xe29(%rip),%rsi
lea    0xe26(%rip),%rdx
call   1060 <fprintf@plt>
mov    0x2df6(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe1c(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    165d <main+0x50d>
jmp    1210 <main+0xc0>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1485 <main+0x335>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x14(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rsi
lea    0xe12(%rip),%rdi
call   1040 <eq_cstr@plt>
cmp    $0x0,%rax
je     12ca <main+0x17a>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x14(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    12c5 <main+0x175>
jmp    1281 <main+0x131>
mov    0x2d58(%rip),%rax
mov    (%rax),%edi
lea    0xd6f(%rip),%rsi
lea    0xdc5(%rip),%rdx
call   1060 <fprintf@plt>
mov    0x2d3c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd62(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    165d <main+0x50d>
jmp    1480 <main+0x330>
mov    -0x50(%rbp),%rsi
lea    0xda1(%rip),%rdi
call   1040 <eq_cstr@plt>
cmp    $0x0,%rax
je     1357 <main+0x207>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x14(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1352 <main+0x202>
jmp    130e <main+0x1be>
mov    0x2ccb(%rip),%rax
mov    (%rax),%edi
lea    0xce2(%rip),%rsi
lea    0xd54(%rip),%rdx
call   1060 <fprintf@plt>
mov    0x2caf(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xcd5(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    165d <main+0x50d>
jmp    147b <main+0x32b>
mov    -0x50(%rbp),%rsi
lea    0xd30(%rip),%rdi
call   1040 <eq_cstr@plt>
cmp    $0x0,%rax
je     13e4 <main+0x294>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x14(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    13df <main+0x28f>
jmp    139b <main+0x24b>
mov    0x2c3e(%rip),%rax
mov    (%rax),%edi
lea    0xc55(%rip),%rsi
lea    0xcea(%rip),%rdx
call   1060 <fprintf@plt>
mov    0x2c22(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xc48(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    165d <main+0x50d>
jmp    1476 <main+0x326>
mov    -0x50(%rbp),%rsi
lea    0xccd(%rip),%rdi
call   1040 <eq_cstr@plt>
cmp    $0x0,%rax
je     1471 <main+0x321>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x14(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    146c <main+0x31c>
jmp    1428 <main+0x2d8>
mov    0x2bb1(%rip),%rax
mov    (%rax),%edi
lea    0xbc8(%rip),%rsi
lea    0xc84(%rip),%rdx
call   1060 <fprintf@plt>
mov    0x2b95(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xbbb(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    165d <main+0x50d>
jmp    1471 <main+0x321>
jmp    1476 <main+0x326>
jmp    147b <main+0x32b>
jmp    1480 <main+0x330>
jmp    1210 <main+0xc0>
cmpq   $0x0,-0x30(%rbp)
jne    14d9 <main+0x389>
jmp    1495 <main+0x345>
mov    0x2b44(%rip),%rax
mov    (%rax),%edi
lea    0xb5b(%rip),%rsi
lea    0xc34(%rip),%rdx
call   1060 <fprintf@plt>
mov    0x2b28(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xb4e(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    165d <main+0x50d>
cmpq   $0x0,-0x38(%rbp)
jne    152d <main+0x3dd>
jmp    14e9 <main+0x399>
mov    0x2af0(%rip),%rax
mov    (%rax),%edi
lea    0xb07(%rip),%rsi
lea    0xbf2(%rip),%rdx
call   1060 <fprintf@plt>
mov    0x2ad4(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xafa(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    165d <main+0x50d>
cmpq   $0x0,-0x28(%rbp)
jne    1581 <main+0x431>
jmp    153d <main+0x3ed>
mov    0x2a9c(%rip),%rax
mov    (%rax),%edi
lea    0xab3(%rip),%rsi
lea    0xbb0(%rip),%rdx
call   1060 <fprintf@plt>
mov    0x2a80(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xaa6(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    165d <main+0x50d>
mov    -0x30(%rbp),%rdi
call   1050 <read_text_file@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    15e2 <main+0x492>
jmp    159e <main+0x44e>
mov    0x2a3b(%rip),%rax
mov    (%rax),%edi
lea    0xa52(%rip),%rsi
lea    0xb68(%rip),%rdx
call   1060 <fprintf@plt>
mov    0x2a1f(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xa45(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    165d <main+0x50d>
mov    -0x38(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x40(%rbp),%rcx
mov    -0x48(%rbp),%r8
call   1070 <write_switch_file@plt>
cmp    $0x0,%eax
jne    164d <main+0x4fd>
jmp    1609 <main+0x4b9>
mov    0x29d0(%rip),%rax
mov    (%rax),%edi
lea    0x9e7(%rip),%rsi
lea    0xb10(%rip),%rdx
call   1060 <fprintf@plt>
mov    0x29b4(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0x9da(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    165d <main+0x50d>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    0x8(%rsi),%rax
test   %rax,%rax
je     126d <main+0x11d>
mov    0x10(%rbx),%r14
test   %r14,%r14
je     12ea <main+0x19a>
mov    %rax,0x10(%rsp)
mov    $0x2,%r12d
xor    %eax,%eax
mov    %rax,0x8(%rsp)
xor    %r13d,%r13d
xor    %ebp,%ebp
xor    %eax,%eax
mov    %rax,(%rsp)
nopl   0x0(%rax,%rax,1)
lea    0x1(%r12),%r15d
lea    0xeae(%rip),%rdi
mov    %r14,%rsi
call   1040 <eq_cstr@plt>
test   %rax,%rax
je     11d0 <main+0x80>
movslq %r15d,%rax
mov    (%rbx,%rax,8),%rbp
test   %rbp,%rbp
jne    1220 <main+0xd0>
jmp    1307 <main+0x1b7>
nopw   0x0(%rax,%rax,1)
lea    0xe9f(%rip),%rdi
mov    %r14,%rsi
call   1040 <eq_cstr@plt>
test   %rax,%rax
je     11f5 <main+0xa5>
movslq %r15d,%rax
mov    (%rbx,%rax,8),%r13
test   %r13,%r13
jne    1220 <main+0xd0>
jmp    1324 <main+0x1d4>
lea    0xe96(%rip),%rdi
mov    %r14,%rsi
call   1040 <eq_cstr@plt>
test   %rax,%rax
je     123c <main+0xec>
movslq %r15d,%rax
mov    (%rbx,%rax,8),%rcx
mov    %rcx,%rax
mov    %rcx,(%rsp)
test   %rcx,%rcx
je     1378 <main+0x228>
add    $0x2,%r12d
mov    %r12d,%r15d
movslq %r15d,%rax
mov    (%rbx,%rax,8),%r14
mov    %r15d,%r12d
test   %r14,%r14
jne    11a0 <main+0x50>
jmp    128a <main+0x13a>
lea    0xe79(%rip),%rdi
mov    %r14,%rsi
call   1040 <eq_cstr@plt>
test   %rax,%rax
je     1227 <main+0xd7>
cmpq   $0x0,(%rsp)
je     13c6 <main+0x276>
add    $0x2,%r12d
movslq %r15d,%rax
mov    (%rbx,%rax,8),%rax
mov    %rax,0x8(%rsp)
jmp    1224 <main+0xd4>
mov    0x2d6c(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xd82(%rip),%rsi
lea    0xd7f(%rip),%rdx
jmp    13de <main+0x28e>
test   %rbp,%rbp
mov    0x10(%rsp),%r14
je     12ea <main+0x19a>
test   %r13,%r13
je     1341 <main+0x1f1>
cmpq   $0x0,(%rsp)
je     135e <main+0x20e>
mov    %rbp,%rdi
call   1050 <read_text_file@plt>
test   %rax,%rax
je     1392 <main+0x242>
mov    %rax,%rbp
mov    %r13,%rdi
mov    %r14,%rsi
mov    (%rsp),%rdx
mov    0x8(%rsp),%rcx
mov    %rax,%r8
call   1070 <write_switch_file@plt>
test   %eax,%eax
je     13ac <main+0x25c>
mov    %rbp,%rdi
call   1030 <free@plt>
xor    %eax,%eax
jmp    13fa <main+0x2aa>
mov    0x2cef(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xd05(%rip),%rsi
lea    0xdde(%rip),%rdx
jmp    13de <main+0x28e>
mov    0x2cd2(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xce8(%rip),%rsi
lea    0xd3e(%rip),%rdx
jmp    13de <main+0x28e>
mov    0x2cb5(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xccb(%rip),%rsi
lea    0xd3d(%rip),%rdx
jmp    13de <main+0x28e>
mov    0x2c98(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xcae(%rip),%rsi
lea    0xd99(%rip),%rdx
jmp    13de <main+0x28e>
mov    0x2c7b(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xc91(%rip),%rsi
lea    0xd8e(%rip),%rdx
jmp    13de <main+0x28e>
mov    0x2c61(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xc77(%rip),%rsi
lea    0xd0c(%rip),%rdx
jmp    13de <main+0x28e>
mov    0x2c47(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xc5d(%rip),%rsi
lea    0xd73(%rip),%rdx
jmp    13de <main+0x28e>
mov    0x2c2d(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xc43(%rip),%rsi
lea    0xd6c(%rip),%rdx
jmp    13de <main+0x28e>
mov    0x2c13(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xc29(%rip),%rsi
lea    0xce5(%rip),%rdx
call   1060 <fprintf@plt>
mov    0x0(%rbp),%edi
mov    (%rbx),%rdx
lea    0xc26(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [18 x i8] c"Need an argument.\00"
@.str.2 = [68 x i8] c"Usage: %s strname -x list.txt -case-pfx 'fn = testfn_' -o switch.h\0A\00"
@.str.3 = [3 x i8] c"-x\00"
@.str.4 = [25 x i8] c"Need something after -x.\00"
@.str.5 = [3 x i8] c"-o\00"
@.str.6 = [25 x i8] c"Need something after -o.\00"
@.str.7 = [10 x i8] c"-case-pfx\00"
@.str.8 = [32 x i8] c"Need something after -case-pfx.\00"
@.str.9 = [7 x i8] c"-array\00"
@.str.10 = [29 x i8] c"Need something after -array.\00"
@.str.11 = [18 x i8] c"Please supply -x.\00"
@.str.12 = [18 x i8] c"Please supply -o.\00"
@.str.13 = [25 x i8] c"Please supply -case-pfx.\00"
@.str.14 = [19 x i8] c"Cannot read input.\00"
@.str.15 = [29 x i8] c"Failed to write switch file.\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
store i8* null, i8** %7
store i8* null, i8** %8
store i8* null, i8** %9
store i8* null, i8** %10
store i8* null, i8** %11
store i8* null, i8** %12
%14 = load i32, i32* %4
%15 = load i8**, i8*** %5
%16 = load i32, i32* %6
%17 = add nsw i32 %16, 1
store i32 %17, i32* %6
%18 = sext i32 %16 to i64
%19 = getelementptr inbounds i8*, i8** %15, i64 %18
%20 = load i8*, i8** %19
store i8* %20, i8** %7
%21 = load i8*, i8** %7
%22 = icmp ne i8* %21, null
br i1 %22, label %33, label %23
23: ; preds = %2
br label %24
24: ; preds = %23
%25 = load i32, i32* @stderr
%26 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%27 = load i32, i32* @stderr
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 0
%30 = load i8*, i8** %29
%31 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.2, i64 0, i64 0), i8* %30)
store i32 1, i32* %3
br label %222
32: ; No predecessors!
br label %33
33: ; preds = %32, %2
br label %34
34: ; preds = %146, %33
%35 = load i8**, i8*** %5
%36 = load i32, i32* %6
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8*, i8** %35, i64 %37
%39 = load i8*, i8** %38
%40 = icmp ne i8* %39, null
br i1 %40, label %41, label %147
41: ; preds = %34
%42 = load i8**, i8*** %5
%43 = load i32, i32* %6
%44 = add nsw i32 %43, 1
store i32 %44, i32* %6
%45 = sext i32 %43 to i64
%46 = getelementptr inbounds i8*, i8** %42, i64 %45
%47 = load i8*, i8** %46
store i8* %47, i8** %13
%48 = load i8*, i8** %13
%49 = call i64 @eq_cstr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %48)
%50 = icmp ne i64 %49, 0
br i1 %50, label %51, label %71
51: ; preds = %41
%52 = load i8**, i8*** %5
%53 = load i32, i32* %6
%54 = add nsw i32 %53, 1
store i32 %54, i32* %6
%55 = sext i32 %53 to i64
%56 = getelementptr inbounds i8*, i8** %52, i64 %55
%57 = load i8*, i8** %56
store i8* %57, i8** %9
%58 = load i8*, i8** %9
%59 = icmp ne i8* %58, null
br i1 %59, label %70, label %60
60: ; preds = %51
br label %61
61: ; preds = %60
%62 = load i32, i32* @stderr
%63 = call i32 @fprintf(i32 %62, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
%64 = load i32, i32* @stderr
%65 = load i8**, i8*** %5
%66 = getelementptr inbounds i8*, i8** %65, i64 0
%67 = load i8*, i8** %66
%68 = call i32 @fprintf(i32 %64, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.2, i64 0, i64 0), i8* %67)
store i32 1, i32* %3
br label %222
69: ; No predecessors!
br label %70
70: ; preds = %69, %51
br label %146
71: ; preds = %41
%72 = load i8*, i8** %13
%73 = call i64 @eq_cstr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %72)
%74 = icmp ne i64 %73, 0
br i1 %74, label %75, label %95
75: ; preds = %71
%76 = load i8**, i8*** %5
%77 = load i32, i32* %6
%78 = add nsw i32 %77, 1
store i32 %78, i32* %6
%79 = sext i32 %77 to i64
%80 = getelementptr inbounds i8*, i8** %76, i64 %79
%81 = load i8*, i8** %80
store i8* %81, i8** %10
%82 = load i8*, i8** %10
%83 = icmp ne i8* %82, null
br i1 %83, label %94, label %84
84: ; preds = %75
br label %85
85: ; preds = %84
%86 = load i32, i32* @stderr
%87 = call i32 @fprintf(i32 %86, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
%88 = load i32, i32* @stderr
%89 = load i8**, i8*** %5
%90 = getelementptr inbounds i8*, i8** %89, i64 0
%91 = load i8*, i8** %90
%92 = call i32 @fprintf(i32 %88, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.2, i64 0, i64 0), i8* %91)
store i32 1, i32* %3
br label %222
93: ; No predecessors!
br label %94
94: ; preds = %93, %75
br label %145
95: ; preds = %71
%96 = load i8*, i8** %13
%97 = call i64 @eq_cstr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* %96)
%98 = icmp ne i64 %97, 0
br i1 %98, label %99, label %119
99: ; preds = %95
%100 = load i8**, i8*** %5
%101 = load i32, i32* %6
%102 = add nsw i32 %101, 1
store i32 %102, i32* %6
%103 = sext i32 %101 to i64
%104 = getelementptr inbounds i8*, i8** %100, i64 %103
%105 = load i8*, i8** %104
store i8* %105, i8** %8
%106 = load i8*, i8** %8
%107 = icmp ne i8* %106, null
br i1 %107, label %118, label %108
108: ; preds = %99
br label %109
109: ; preds = %108
%110 = load i32, i32* @stderr
%111 = call i32 @fprintf(i32 %110, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0))
%112 = load i32, i32* @stderr
%113 = load i8**, i8*** %5
%114 = getelementptr inbounds i8*, i8** %113, i64 0
%115 = load i8*, i8** %114
%116 = call i32 @fprintf(i32 %112, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.2, i64 0, i64 0), i8* %115)
store i32 1, i32* %3
br label %222
117: ; No predecessors!
br label %118
118: ; preds = %117, %99
br label %144
119: ; preds = %95
%120 = load i8*, i8** %13
%121 = call i64 @eq_cstr(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i8* %120)
%122 = icmp ne i64 %121, 0
br i1 %122, label %123, label %143
123: ; preds = %119
%124 = load i8**, i8*** %5
%125 = load i32, i32* %6
%126 = add nsw i32 %125, 1
store i32 %126, i32* %6
%127 = sext i32 %125 to i64
%128 = getelementptr inbounds i8*, i8** %124, i64 %127
%129 = load i8*, i8** %128
store i8* %129, i8** %11
%130 = load i8*, i8** %8
%131 = icmp ne i8* %130, null
br i1 %131, label %142, label %132
132: ; preds = %123
br label %133
133: ; preds = %132
%134 = load i32, i32* @stderr
%135 = call i32 @fprintf(i32 %134, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0))
%136 = load i32, i32* @stderr
%137 = load i8**, i8*** %5
%138 = getelementptr inbounds i8*, i8** %137, i64 0
%139 = load i8*, i8** %138
%140 = call i32 @fprintf(i32 %136, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.2, i64 0, i64 0), i8* %139)
store i32 1, i32* %3
br label %222
141: ; No predecessors!
br label %142
142: ; preds = %141, %123
br label %143
143: ; preds = %142, %119
br label %144
144: ; preds = %143, %118
br label %145
145: ; preds = %144, %94
br label %146
146: ; preds = %145, %70
br label %34
147: ; preds = %34
%148 = load i8*, i8** %9
%149 = icmp ne i8* %148, null
br i1 %149, label %160, label %150
150: ; preds = %147
br label %151
151: ; preds = %150
%152 = load i32, i32* @stderr
%153 = call i32 @fprintf(i32 %152, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0))
%154 = load i32, i32* @stderr
%155 = load i8**, i8*** %5
%156 = getelementptr inbounds i8*, i8** %155, i64 0
%157 = load i8*, i8** %156
%158 = call i32 @fprintf(i32 %154, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.2, i64 0, i64 0), i8* %157)
store i32 1, i32* %3
br label %222
159: ; No predecessors!
br label %160
160: ; preds = %159, %147
%161 = load i8*, i8** %10
%162 = icmp ne i8* %161, null
br i1 %162, label %173, label %163
163: ; preds = %160
br label %164
164: ; preds = %163
%165 = load i32, i32* @stderr
%166 = call i32 @fprintf(i32 %165, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.12, i64 0, i64 0))
%167 = load i32, i32* @stderr
%168 = load i8**, i8*** %5
%169 = getelementptr inbounds i8*, i8** %168, i64 0
%170 = load i8*, i8** %169
%171 = call i32 @fprintf(i32 %167, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.2, i64 0, i64 0), i8* %170)
store i32 1, i32* %3
br label %222
172: ; No predecessors!
br label %173
173: ; preds = %172, %160
%174 = load i8*, i8** %8
%175 = icmp ne i8* %174, null
br i1 %175, label %186, label %176
176: ; preds = %173
br label %177
177: ; preds = %176
%178 = load i32, i32* @stderr
%179 = call i32 @fprintf(i32 %178, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.13, i64 0, i64 0))
%180 = load i32, i32* @stderr
%181 = load i8**, i8*** %5
%182 = getelementptr inbounds i8*, i8** %181, i64 0
%183 = load i8*, i8** %182
%184 = call i32 @fprintf(i32 %180, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.2, i64 0, i64 0), i8* %183)
store i32 1, i32* %3
br label %222
185: ; No predecessors!
br label %186
186: ; preds = %185, %173
%187 = load i8*, i8** %9
%188 = call i8* @read_text_file(i8* %187)
store i8* %188, i8** %12
%189 = load i8*, i8** %12
%190 = icmp ne i8* %189, null
br i1 %190, label %201, label %191
191: ; preds = %186
br label %192
192: ; preds = %191
%193 = load i32, i32* @stderr
%194 = call i32 @fprintf(i32 %193, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.14, i64 0, i64 0))
%195 = load i32, i32* @stderr
%196 = load i8**, i8*** %5
%197 = getelementptr inbounds i8*, i8** %196, i64 0
%198 = load i8*, i8** %197
%199 = call i32 @fprintf(i32 %195, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.2, i64 0, i64 0), i8* %198)
store i32 1, i32* %3
br label %222
200: ; No predecessors!
br label %201
201: ; preds = %200, %186
%202 = load i8*, i8** %10
%203 = load i8*, i8** %7
%204 = load i8*, i8** %8
%205 = load i8*, i8** %11
%206 = load i8*, i8** %12
%207 = call i32 @write_switch_file(i8* %202, i8* %203, i8* %204, i8* %205, i8* %206)
%208 = icmp ne i32 %207, 0
br i1 %208, label %219, label %209
209: ; preds = %201
br label %210
210: ; preds = %209
%211 = load i32, i32* @stderr
%212 = call i32 @fprintf(i32 %211, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.15, i64 0, i64 0))
%213 = load i32, i32* @stderr
%214 = load i8**, i8*** %5
%215 = getelementptr inbounds i8*, i8** %214, i64 0
%216 = load i8*, i8** %215
%217 = call i32 @fprintf(i32 %213, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.2, i64 0, i64 0), i8* %216)
store i32 1, i32* %3
br label %222
218: ; No predecessors!
br label %219
219: ; preds = %218, %201
%220 = load i8*, i8** %12
%221 = call i32 @free(i8* %220)
store i32 0, i32* %3
br label %222
222: ; preds = %219, %210, %192, %177, %164, %151, %133, %109, %85, %61, %24
%223 = load i32, i32* %3
ret i32 %223
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [18 x i8] c"Need an argument.\00"
@.str.2 = [68 x i8] c"Usage: %s strname -x list.txt -case-pfx 'fn = testfn_' -o switch.h\0A\00"
@.str.3 = [3 x i8] c"-x\00"
@.str.4 = [25 x i8] c"Need something after -x.\00"
@.str.5 = [3 x i8] c"-o\00"
@.str.6 = [25 x i8] c"Need something after -o.\00"
@.str.7 = [10 x i8] c"-case-pfx\00"
@.str.8 = [32 x i8] c"Need something after -case-pfx.\00"
@.str.9 = [7 x i8] c"-array\00"
@.str.10 = [29 x i8] c"Need something after -array.\00"
@.str.11 = [18 x i8] c"Please supply -x.\00"
@.str.12 = [18 x i8] c"Please supply -o.\00"
@.str.13 = [25 x i8] c"Please supply -case-pfx.\00"
@.str.14 = [19 x i8] c"Cannot read input.\00"
@.str.15 = [29 x i8] c"Failed to write switch file.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = icmp eq i8* %4, null
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 2
%8 = load i8*, i8** %7
%9 = icmp eq i8* %8, null
br i1 %9, label %95, label %16
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %1
%15 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.2, i64 0, i64 0), i8* %14)
br label %137
16: ; preds = %6, %83
%17 = phi i8* [ %91, %83 ], [ %8, %6 ]
%18 = phi i8* [ %88, %83 ], [ null, %6 ]
%19 = phi i8* [ %87, %83 ], [ null, %6 ]
%20 = phi i8* [ %86, %83 ], [ null, %6 ]
%21 = phi i8* [ %85, %83 ], [ null, %6 ]
%22 = phi i32 [ %84, %83 ], [ 2, %6 ]
%23 = add nsw i32 %22, 1
%24 = tail call i64 @eq_cstr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %17)
%25 = icmp eq i64 %24, 0
br i1 %25, label %38, label %26
26: ; preds = %16
%27 = add nsw i32 %22, 2
%28 = sext i32 %23 to i64
%29 = getelementptr inbounds i8*, i8** %1, i64 %28
%30 = load i8*, i8** %29
%31 = icmp eq i8* %30, null
br i1 %31, label %32, label %83
32: ; preds = %26
%33 = load i32, i32* @stderr
%34 = tail call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
%35 = load i32, i32* @stderr
%36 = load i8*, i8** %1
%37 = tail call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.2, i64 0, i64 0), i8* %36)
br label %137
38: ; preds = %16
%39 = tail call i64 @eq_cstr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %17)
%40 = icmp eq i64 %39, 0
br i1 %40, label %53, label %41
41: ; preds = %38
%42 = add nsw i32 %22, 2
%43 = sext i32 %23 to i64
%44 = getelementptr inbounds i8*, i8** %1, i64 %43
%45 = load i8*, i8** %44
%46 = icmp eq i8* %45, null
br i1 %46, label %47, label %83
47: ; preds = %41
%48 = load i32, i32* @stderr
%49 = tail call i32 @fprintf(i32 %48, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
%50 = load i32, i32* @stderr
%51 = load i8*, i8** %1
%52 = tail call i32 @fprintf(i32 %50, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.2, i64 0, i64 0), i8* %51)
br label %137
53: ; preds = %38
%54 = tail call i64 @eq_cstr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* %17)
%55 = icmp eq i64 %54, 0
br i1 %55, label %68, label %56
56: ; preds = %53
%57 = add nsw i32 %22, 2
%58 = sext i32 %23 to i64
%59 = getelementptr inbounds i8*, i8** %1, i64 %58
%60 = load i8*, i8** %59
%61 = icmp eq i8* %60, null
br i1 %61, label %62, label %83
62: ; preds = %56
%63 = load i32, i32* @stderr
%64 = tail call i32 @fprintf(i32 %63, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0))
%65 = load i32, i32* @stderr
%66 = load i8*, i8** %1
%67 = tail call i32 @fprintf(i32 %65, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.2, i64 0, i64 0), i8* %66)
br label %137
68: ; preds = %53
%69 = tail call i64 @eq_cstr(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i8* %17)
%70 = icmp eq i64 %69, 0
br i1 %70, label %83, label %71
71: ; preds = %68
%72 = add nsw i32 %22, 2
%73 = sext i32 %23 to i64
%74 = getelementptr inbounds i8*, i8** %1, i64 %73
%75 = load i8*, i8** %74
%76 = icmp eq i8* %21, null
br i1 %76, label %77, label %83
77: ; preds = %71
%78 = load i32, i32* @stderr
%79 = tail call i32 @fprintf(i32 %78, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0))
%80 = load i32, i32* @stderr
%81 = load i8*, i8** %1
%82 = tail call i32 @fprintf(i32 %80, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.2, i64 0, i64 0), i8* %81)
br label %137
83: ; preds = %26, %56, %71, %68, %41
%84 = phi i32 [ %27, %26 ], [ %42, %41 ], [ %57, %56 ], [ %72, %71 ], [ %23, %68 ]
%85 = phi i8* [ %21, %26 ], [ %21, %41 ], [ %60, %56 ], [ %21, %71 ], [ %21, %68 ]
%86 = phi i8* [ %30, %26 ], [ %20, %41 ], [ %20, %56 ], [ %20, %71 ], [ %20, %68 ]
%87 = phi i8* [ %19, %26 ], [ %45, %41 ], [ %19, %56 ], [ %19, %71 ], [ %19, %68 ]
%88 = phi i8* [ %18, %26 ], [ %18, %41 ], [ %18, %56 ], [ %75, %71 ], [ %18, %68 ]
%89 = sext i32 %84 to i64
%90 = getelementptr inbounds i8*, i8** %1, i64 %89
%91 = load i8*, i8** %90
%92 = icmp eq i8* %91, null
br i1 %92, label %93, label %16
93: ; preds = %83
%94 = icmp eq i8* %86, null
br i1 %94, label %95, label %101
95: ; preds = %6, %93
%96 = load i32, i32* @stderr
%97 = tail call i32 @fprintf(i32 %96, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0))
%98 = load i32, i32* @stderr
%99 = load i8*, i8** %1
%100 = tail call i32 @fprintf(i32 %98, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.2, i64 0, i64 0), i8* %99)
br label %137
101: ; preds = %93
%102 = icmp eq i8* %87, null
br i1 %102, label %103, label %109
103: ; preds = %101
%104 = load i32, i32* @stderr
%105 = tail call i32 @fprintf(i32 %104, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.12, i64 0, i64 0))
%106 = load i32, i32* @stderr
%107 = load i8*, i8** %1
%108 = tail call i32 @fprintf(i32 %106, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.2, i64 0, i64 0), i8* %107)
br label %137
109: ; preds = %101
%110 = icmp eq i8* %85, null
br i1 %110, label %111, label %117
111: ; preds = %109
%112 = load i32, i32* @stderr
%113 = tail call i32 @fprintf(i32 %112, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.13, i64 0, i64 0))
%114 = load i32, i32* @stderr
%115 = load i8*, i8** %1
%116 = tail call i32 @fprintf(i32 %114, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.2, i64 0, i64 0), i8* %115)
br label %137
117: ; preds = %109
%118 = tail call i8* @read_text_file(i8* %86)
%119 = icmp eq i8* %118, null
br i1 %119, label %120, label %126
120: ; preds = %117
%121 = load i32, i32* @stderr
%122 = tail call i32 @fprintf(i32 %121, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.14, i64 0, i64 0))
%123 = load i32, i32* @stderr
%124 = load i8*, i8** %1
%125 = tail call i32 @fprintf(i32 %123, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.2, i64 0, i64 0), i8* %124)
br label %137
126: ; preds = %117
%127 = tail call i32 @write_switch_file(i8* %87, i8* %4, i8* %85, i8* %88, i8* %118)
%128 = icmp eq i32 %127, 0
br i1 %128, label %129, label %135
129: ; preds = %126
%130 = load i32, i32* @stderr
%131 = tail call i32 @fprintf(i32 %130, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.15, i64 0, i64 0))
%132 = load i32, i32* @stderr
%133 = load i8*, i8** %1
%134 = tail call i32 @fprintf(i32 %132, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.2, i64 0, i64 0), i8* %133)
br label %137
135: ; preds = %126
%136 = tail call i32 @free(i8* %118)
br label %137
137: ; preds = %77, %62, %47, %32, %135, %129, %120, %111, %103, %95, %10
%138 = phi i32 [ 0, %135 ], [ 1, %129 ], [ 1, %120 ], [ 1, %111 ], [ 1, %103 ], [ 1, %95 ], [ 1, %10 ], [ 1, %32 ], [ 1, %47 ], [ 1, %62 ], [ 1, %77 ]
ret i32 %138
}