#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*/ time_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
char *ctime(int /*<<< orphan*/ *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int fscanf(int /*<<< orphan*/ *, char *, int *, char *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/);
scalar_t__ write_rop3_func(int /*<<< orphan*/ *, int, char *);
int main(int argc, const char *argv[]) {
  FILE *in = 0;
  FILE *out = 0;
  int irop = 0, i;
  char ropstr[32];
  int ret = 0;
  time_t now;
  if (argc != 3) {
    fprintf(stderr, "usage: %s <in> <out>.\n", argv[0]);
    return 1;
  }
  in = fopen(argv[1], "rb");
  if (!in) {
    fprintf(stderr, "%s: Error opening file <%s>: %s.\n", argv[0], argv[1],
            strerror(errno));
    ret = 1;
    goto cleanup;
  }
  out = fopen(argv[2], "wb");
  if (!out) {
    fprintf(stderr, "%s: Error opening file <%s>: %s.\n", argv[0], argv[2],
            strerror(errno));
    ret = 1;
    goto cleanup;
  }
  now = time(0);
  fprintf(out, "/* Generated automatically by %s at %.24s.\n", argv[0],
          ctime(&now));
  fprintf(out, "   Do not edit!\n");
  fprintf(out, " */\n");
  fprintf(out, "#include <hpgs.h>\n\n");
  while (fscanf(in, "%d %31s", &i, ropstr) == 2) {
    if (i != irop) {
      fprintf(stderr, "%s: Illegal count %d in stanza %d.\n", argv[0], i, irop);
      ret = 1;
      goto cleanup;
    }
    if (write_rop3_func(out, irop, ropstr))
      goto cleanup;
    ++irop;
  }
  fprintf(out, "static hpgs_rop3_func_t rop3_table[][2][2] = {\n");
  for (i = 0; i < irop; ++i)
    fprintf(out, "  {{rop3_%d_0_0,rop3_%d_0_1},{rop3_%d_1_0,rop3_%d_1_1}}%s\n",
            i, i, i, i, i < irop - 1 ? "," : "");
  fprintf(out, "};\n\n");
  fprintf(out,
          "hpgs_rop3_func_t hpgs_rop3_func(int rop3,\n"
          "                                hpgs_bool src_transparency,\n"
          "                                hpgs_bool pattern_transparency)\n"
          "{\n"
          "  if (rop3 < 0 || rop3 >= %d) return 0;\n"
          "  return "
          "rop3_table[rop3][src_transparency!=0][pattern_transparency!=0];\n"
          "}\n",
          irop);
  fprintf(out, "static hpgs_xrop3_func_t xrop3_table[][2][2] = {\n");
  for (i = 0; i < irop; ++i)
    fprintf(out,
            "  {{xrop3_%d_0_0,xrop3_%d_0_1},{xrop3_%d_1_0,xrop3_%d_1_1}}%s\n",
            i, i, i, i, i < irop - 1 ? "," : "");
  fprintf(out, "};\n\n");
  fprintf(out,
          "hpgs_xrop3_func_t hpgs_xrop3_func(int rop3,\n"
          "                                  hpgs_bool src_transparency,\n"
          "                                  hpgs_bool pattern_transparency)\n"
          "{\n"
          "  if (rop3 < 0 || rop3 >= %d) return 0;\n"
          "  return "
          "xrop3_table[rop3][src_transparency!=0][pattern_transparency!=0];\n"
          "}\n",
          irop);
cleanup:
  if (in)
    fclose(in);
  if (out)
    fclose(out);
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x54(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11ec <main+0x6c>
mov    0x2e18(%rip),%rax
movslq (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe27(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1569 <main+0x3e9>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe1c(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    126b <main+0xeb>
mov    0x2dca(%rip),%rax
movslq (%rax),%rax
mov    %rax,-0x70(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x68(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x60(%rbp)
mov    0x2d9d(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x70(%rbp),%rdi
mov    -0x68(%rbp),%rdx
mov    -0x60(%rbp),%rcx
mov    %rax,%r8
lea    0xdc2(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x1,-0x54(%rbp)
jmp    153b <main+0x3bb>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdc2(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    12f0 <main+0x170>
mov    0x2d4b(%rip),%rax
movslq (%rax),%rax
mov    %rax,-0x88(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x80(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x78(%rbp)
mov    0x2d1b(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x88(%rbp),%rdi
mov    -0x80(%rbp),%rdx
mov    -0x78(%rbp),%rcx
mov    %rax,%r8
lea    0xd3d(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x1,-0x54(%rbp)
jmp    153b <main+0x3bb>
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,-0x58(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x90(%rbp)
lea    -0x58(%rbp),%rdi
call   1050 <ctime@plt>
mov    -0x98(%rbp),%rdi
mov    -0x90(%rbp),%rdx
mov    %rax,%rcx
lea    0xd0b(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xd25(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xd24(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xd17(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x50(%rbp),%rcx
lea    0xd15(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1060 <fscanf@plt>
cmp    $0x2,%eax
jne    13fd <main+0x27d>
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
je     13d0 <main+0x250>
mov    0x2c3b(%rip),%rax
movslq (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x28(%rbp),%ecx
mov    -0x24(%rbp),%r8d
lea    0xce0(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x1,-0x54(%rbp)
jmp    153b <main+0x3bb>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
lea    -0x50(%rbp),%rdx
call   1030 <write_rop3_func@plt>
cmp    $0x0,%rax
je     13ef <main+0x26f>
jmp    153b <main+0x3bb>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1371 <main+0x1f1>
mov    -0x20(%rbp),%rdi
lea    0xcb9(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1475 <main+0x2f5>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%edx
mov    -0x28(%rbp),%ecx
mov    -0x28(%rbp),%r8d
mov    -0x28(%rbp),%r9d
mov    -0x28(%rbp),%r10d
mov    -0x24(%rbp),%r11d
sub    $0x1,%r11d
lea    0xceb(%rip),%rax
lea    0xcde(%rip),%rsi
cmp    %r11d,%r10d
cmovl  %rsi,%rax
lea    0xc95(%rip),%rsi
mov    %rax,(%rsp)
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1416 <main+0x296>
mov    -0x20(%rbp),%rdi
lea    0xcae(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%edx
lea    0xc9e(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xda8(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1514 <main+0x394>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%edx
mov    -0x28(%rbp),%ecx
mov    -0x28(%rbp),%r8d
mov    -0x28(%rbp),%r9d
mov    -0x28(%rbp),%r10d
mov    -0x24(%rbp),%r11d
sub    $0x1,%r11d
lea    0xc4c(%rip),%rax
lea    0xc3f(%rip),%rsi
cmp    %r11d,%r10d
cmovl  %rsi,%rax
lea    0xd86(%rip),%rsi
mov    %rax,(%rsp)
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    14b5 <main+0x335>
mov    -0x20(%rbp),%rdi
lea    0xc0f(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%edx
lea    0xd8c(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
cmpq   $0x0,-0x18(%rbp)
je     154f <main+0x3cf>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
cmpq   $0x0,-0x20(%rbp)
je     1563 <main+0x3e3>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x54(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%r12
cmp    $0x3,%edi
jne    136a <main+0x1da>
mov    0x8(%r12),%rdi
lea    0xe61(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,0x10(%rsp)
test   %rax,%rax
je     1390 <main+0x200>
mov    0x10(%r12),%rdi
lea    0xe67(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     13d5 <main+0x245>
mov    %rax,%rbx
xor    %r13d,%r13d
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,0x1c(%rsp)
mov    (%r12),%rbp
lea    0x1c(%rsp),%rdi
call   1050 <ctime@plt>
lea    0xe36(%rip),%rsi
mov    %rbx,%rdi
mov    %rbp,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1070 <fprintf@plt>
lea    0xe4b(%rip),%rdi
mov    $0x10,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
lea    0xe43(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
lea    0xe2f(%rip),%rdi
mov    $0x13,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
lea    0xe2a(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0x20(%rsp),%rcx
mov    0x10(%rsp),%rdi
call   1060 <fscanf@plt>
mov    %eax,%ebp
cmp    $0x2,%eax
jne    1424 <main+0x294>
mov    %ebp,0x18(%rsp)
mov    $0xffffffff,%ebp
lea    0x20(%rsp),%r15
lea    0xdf6(%rip),%r13
lea    0xc(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%ebp
mov    0xc(%rsp),%ecx
cmp    %ecx,%ebp
jne    1544 <main+0x3b4>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r15,%rdx
call   1030 <write_rop3_func@plt>
test   %rax,%rax
jne    151f <main+0x38f>
mov    0x10(%rsp),%rdi
mov    %r13,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
call   1060 <fscanf@plt>
cmp    $0x2,%eax
je     12b0 <main+0x120>
lea    0xdcd(%rip),%rdi
mov    $0x2f,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
movl   $0x0,0xc(%rsp)
lea    0x1(%rbp),%r13d
lea    0xe13(%rip),%r12
lea    0xe12(%rip),%r15
lea    0xdca(%rip),%r14
xor    %ecx,%ecx
nopl   0x0(%rax)
cmp    %ebp,%ecx
mov    %r15,%rax
cmovl  %r12,%rax
mov    %rax,(%rsp)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %ecx,%edx
mov    %ecx,%r8d
mov    %ecx,%r9d
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0xc(%rsp),%eax
lea    0x1(%rax),%ecx
mov    %ecx,0xc(%rsp)
cmp    %ebp,%eax
jl     1330 <main+0x1a0>
mov    0x18(%rsp),%ebp
jmp    1445 <main+0x2b5>
mov    0x2c6f(%rip),%rax
movslq (%rax),%rdi
mov    (%r12),%rdx
lea    0xc81(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x1,%ebp
jmp    1533 <main+0x3a3>
mov    0x2c49(%rip),%rax
movslq (%rax),%rbx
mov    (%r12),%rbp
mov    0x8(%r12),%r14
mov    0x2c2e(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
lea    0xc62(%rip),%rsi
mov    %rbx,%rdi
mov    %rbp,%rdx
mov    %r14,%rcx
mov    %rax,%r8
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x1,%ebp
jmp    1533 <main+0x3a3>
mov    0x2c04(%rip),%rax
movslq (%rax),%rbx
mov    (%r12),%rbp
mov    0x10(%r12),%r14
mov    0x2be9(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
lea    0xc1d(%rip),%rsi
mov    %rbx,%rdi
mov    %rbp,%rdx
mov    %r14,%rcx
mov    %rax,%r8
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x10(%rsp),%rdi
call   1040 <fclose@plt>
mov    $0x1,%ebp
jmp    1533 <main+0x3a3>
lea    0xc96(%rip),%rdi
mov    $0x2f,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
movl   $0x0,0xc(%rsp)
lea    0xce2(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
lea    0xcce(%rip),%rsi
mov    %rbx,%rdi
mov    %r13d,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
lea    0xdd6(%rip),%rdi
mov    $0x31,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
movl   $0x0,0xc(%rsp)
cmp    $0x2,%ebp
jne    14f2 <main+0x362>
lea    -0x1(%r13),%ebp
lea    0xc89(%rip),%r14
lea    0xc88(%rip),%r15
lea    0xdd0(%rip),%r12
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    %ebp,%ecx
mov    %r15,%rax
cmovl  %r14,%rax
mov    %rax,(%rsp)
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %ecx,%edx
mov    %ecx,%r8d
mov    %ecx,%r9d
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0xc(%rsp),%ecx
add    $0x1,%ecx
mov    %ecx,0xc(%rsp)
cmp    %r13d,%ecx
jl     14c0 <main+0x330>
lea    0xc35(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
lea    0xdae(%rip),%rsi
mov    %rbx,%rdi
mov    %r13d,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
xor    %ebp,%ebp
mov    0x10(%rsp),%rdi
call   1040 <fclose@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %ebp,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2a95(%rip),%rax
movslq (%rax),%rdi
mov    (%r12),%rdx
lea    0xb44(%rip),%rsi
mov    %ebp,%r8d
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x1,%ebp
jmp    1521 <main+0x391>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [23 x i8] c"usage: %s <in> <out>.\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [34 x i8] c"%s: Error opening file <%s>: %s.\0A\00"
@errno = global i32 0
@.str.3 = [3 x i8] c"wb\00"
@.str.4 = [44 x i8] c"/* Generated automatically by %s at %.24s.\0A\00"
@.str.5 = [17 x i8] c" Do not edit!\0A\00"
@.str.6 = [5 x i8] c" */\0A\00"
@.str.7 = [20 x i8] c"#include <hpgs.h>\0A\0A\00"
@.str.8 = [8 x i8] c"%d %31s\00"
@.str.9 = [36 x i8] c"%s: Illegal count %d in stanza %d.\0A\00"
@.str.10 = [48 x i8] c"static hpgs_rop3_func_t rop3_table[][2][2] = {\0A\00"
@.str.11 = [59 x i8] c" {{rop3_%d_0_0,rop3_%d_0_1},{rop3_%d_1_0,rop3_%d_1_1}}%s\0A\00"
@.str.12 = [2 x i8] c",\00"
@.str.13 = [1 x i8] zeroinitializer
@.str.14 = [5 x i8] c"};\0A\0A\00"
@.str.15 = [284 x i8] c"hpgs_rop3_func_t hpgs_rop3_func(int rop3,\0A hpgs_bool src_transparency,\0A hpgs_bool pattern_transparency)\0A{\0A if (rop3 < 0 || rop3 >= %d) return 0;\0A return rop3_table[rop3][src_transparency!=0][pattern_transparency!=0];\0A}\0A\00"
@.str.16 = [50 x i8] c"static hpgs_xrop3_func_t xrop3_table[][2][2] = {\0A\00"
@.str.17 = [63 x i8] c" {{xrop3_%d_0_0,xrop3_%d_0_1},{xrop3_%d_1_0,xrop3_%d_1_1}}%s\0A\00"
@.str.18 = [291 x i8] c"hpgs_xrop3_func_t hpgs_xrop3_func(int rop3,\0A hpgs_bool src_transparency,\0A hpgs_bool pattern_transparency)\0A{\0A if (rop3 < 0 || rop3 >= %d) return 0;\0A return xrop3_table[rop3][src_transparency!=0][pattern_transparency!=0];\0A}\0A\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 i32
%10 = alloca [32 x i8]
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* null, i32** %6
store i32* null, i32** %7
store i32 0, i32* %8
store i32 0, i32* %11
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 3
br i1 %14, label %15, label %23
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = sext i32 %16 to i64
%18 = inttoptr i64 %17 to i32*
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 0
%21 = load i8*, i8** %20
%22 = call i32 (i32*, i8*, ...) @fprintf(i32* %18, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %21)
store i32 1, i32* %3
br label %177
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32* @fopen(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %27, i32** %6
%28 = load i32*, i32** %6
%29 = icmp ne i32* %28, null
br i1 %29, label %43, label %30
30: ; preds = %23
%31 = load i32, i32* @stderr
%32 = sext i32 %31 to i64
%33 = inttoptr i64 %32 to i32*
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 0
%36 = load i8*, i8** %35
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 1
%39 = load i8*, i8** %38
%40 = load i32, i32* @errno
%41 = call i8* @strerror(i32 %40)
%42 = call i32 (i32*, i8*, ...) @fprintf(i32* %33, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %36, i8* %39, i8* %41)
store i32 1, i32* %11
br label %163
43: ; preds = %23
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 2
%46 = load i8*, i8** %45
%47 = call i32* @fopen(i8* %46, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %47, i32** %7
%48 = load i32*, i32** %7
%49 = icmp ne i32* %48, null
br i1 %49, label %63, label %50
50: ; preds = %43
%51 = load i32, i32* @stderr
%52 = sext i32 %51 to i64
%53 = inttoptr i64 %52 to i32*
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 0
%56 = load i8*, i8** %55
%57 = load i8**, i8*** %5
%58 = getelementptr inbounds i8*, i8** %57, i64 2
%59 = load i8*, i8** %58
%60 = load i32, i32* @errno
%61 = call i8* @strerror(i32 %60)
%62 = call i32 (i32*, i8*, ...) @fprintf(i32* %53, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %56, i8* %59, i8* %61)
store i32 1, i32* %11
br label %163
63: ; preds = %43
%64 = call i32 @time(i32 0)
store i32 %64, i32* %12
%65 = load i32*, i32** %7
%66 = load i8**, i8*** %5
%67 = getelementptr inbounds i8*, i8** %66, i64 0
%68 = load i8*, i8** %67
%69 = call i8* @ctime(i32* %12)
%70 = call i32 (i32*, i8*, ...) @fprintf(i32* %65, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0), i8* %68, i8* %69)
%71 = load i32*, i32** %7
%72 = call i32 (i32*, i8*, ...) @fprintf(i32* %71, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%73 = load i32*, i32** %7
%74 = call i32 (i32*, i8*, ...) @fprintf(i32* %73, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%75 = load i32*, i32** %7
%76 = call i32 (i32*, i8*, ...) @fprintf(i32* %75, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
br label %77
77: ; preds = %103, %63
%78 = load i32*, i32** %6
%79 = getelementptr inbounds [32 x i8], [32 x i8]* %10, i64 0, i64 0
%80 = call i32 @fscanf(i32* %78, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i32* %9, i8* %79)
%81 = icmp eq i32 %80, 2
br i1 %81, label %82, label %106
82: ; preds = %77
%83 = load i32, i32* %9
%84 = load i32, i32* %8
%85 = icmp ne i32 %83, %84
br i1 %85, label %86, label %96
86: ; preds = %82
%87 = load i32, i32* @stderr
%88 = sext i32 %87 to i64
%89 = inttoptr i64 %88 to i32*
%90 = load i8**, i8*** %5
%91 = getelementptr inbounds i8*, i8** %90, i64 0
%92 = load i8*, i8** %91
%93 = load i32, i32* %9
%94 = load i32, i32* %8
%95 = call i32 (i32*, i8*, ...) @fprintf(i32* %89, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.9, i64 0, i64 0), i8* %92, i32 %93, i32 %94)
store i32 1, i32* %11
br label %163
96: ; preds = %82
%97 = load i32*, i32** %7
%98 = load i32, i32* %8
%99 = getelementptr inbounds [32 x i8], [32 x i8]* %10, i64 0, i64 0
%100 = call i64 @write_rop3_func(i32* %97, i32 %98, i8* %99)
%101 = icmp ne i64 %100, 0
br i1 %101, label %102, label %103
102: ; preds = %96
br label %163
103: ; preds = %96
%104 = load i32, i32* %8
%105 = add nsw i32 %104, 1
store i32 %105, i32* %8
br label %77
106: ; preds = %77
%107 = load i32*, i32** %7
%108 = call i32 (i32*, i8*, ...) @fprintf(i32* %107, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.10, i64 0, i64 0))
store i32 0, i32* %9
br label %109
109: ; preds = %126, %106
%110 = load i32, i32* %9
%111 = load i32, i32* %8
%112 = icmp slt i32 %110, %111
br i1 %112, label %113, label %129
113: ; preds = %109
%114 = load i32*, i32** %7
%115 = load i32, i32* %9
%116 = load i32, i32* %9
%117 = load i32, i32* %9
%118 = load i32, i32* %9
%119 = load i32, i32* %9
%120 = load i32, i32* %8
%121 = sub nsw i32 %120, 1
%122 = icmp slt i32 %119, %121
%123 = zext i1 %122 to i64
%124 = select i1 %122, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.13, i64 0, i64 0)
%125 = call i32 (i32*, i8*, ...) @fprintf(i32* %114, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.11, i64 0, i64 0), i32 %115, i32 %116, i32 %117, i32 %118, i8* %124)
br label %126
126: ; preds = %113
%127 = load i32, i32* %9
%128 = add nsw i32 %127, 1
store i32 %128, i32* %9
br label %109
129: ; preds = %109
%130 = load i32*, i32** %7
%131 = call i32 (i32*, i8*, ...) @fprintf(i32* %130, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0))
%132 = load i32*, i32** %7
%133 = load i32, i32* %8
%134 = call i32 (i32*, i8*, ...) @fprintf(i32* %132, i8* getelementptr inbounds ([284 x i8], [284 x i8]* @.str.15, i64 0, i64 0), i32 %133)
%135 = load i32*, i32** %7
%136 = call i32 (i32*, i8*, ...) @fprintf(i32* %135, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.16, i64 0, i64 0))
store i32 0, i32* %9
br label %137
137: ; preds = %154, %129
%138 = load i32, i32* %9
%139 = load i32, i32* %8
%140 = icmp slt i32 %138, %139
br i1 %140, label %141, label %157
141: ; preds = %137
%142 = load i32*, i32** %7
%143 = load i32, i32* %9
%144 = load i32, i32* %9
%145 = load i32, i32* %9
%146 = load i32, i32* %9
%147 = load i32, i32* %9
%148 = load i32, i32* %8
%149 = sub nsw i32 %148, 1
%150 = icmp slt i32 %147, %149
%151 = zext i1 %150 to i64
%152 = select i1 %150, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.13, i64 0, i64 0)
%153 = call i32 (i32*, i8*, ...) @fprintf(i32* %142, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.17, i64 0, i64 0), i32 %143, i32 %144, i32 %145, i32 %146, i8* %152)
br label %154
154: ; preds = %141
%155 = load i32, i32* %9
%156 = add nsw i32 %155, 1
store i32 %156, i32* %9
br label %137
157: ; preds = %137
%158 = load i32*, i32** %7
%159 = call i32 (i32*, i8*, ...) @fprintf(i32* %158, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0))
%160 = load i32*, i32** %7
%161 = load i32, i32* %8
%162 = call i32 (i32*, i8*, ...) @fprintf(i32* %160, i8* getelementptr inbounds ([291 x i8], [291 x i8]* @.str.18, i64 0, i64 0), i32 %161)
br label %163
163: ; preds = %157, %102, %86, %50, %30
%164 = load i32*, i32** %6
%165 = icmp ne i32* %164, null
br i1 %165, label %166, label %169
166: ; preds = %163
%167 = load i32*, i32** %6
%168 = call i32 @fclose(i32* %167)
br label %169
169: ; preds = %166, %163
%170 = load i32*, i32** %7
%171 = icmp ne i32* %170, null
br i1 %171, label %172, label %175
172: ; preds = %169
%173 = load i32*, i32** %7
%174 = call i32 @fclose(i32* %173)
br label %175
175: ; preds = %172, %169
%176 = load i32, i32* %11
store i32 %176, i32* %3
br label %177
177: ; preds = %175, %15
%178 = load i32, i32* %3
ret i32 %178
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [23 x i8] c"usage: %s <in> <out>.\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [34 x i8] c"%s: Error opening file <%s>: %s.\0A\00"
@errno = global i32 0
@.str.3 = [3 x i8] c"wb\00"
@.str.4 = [44 x i8] c"/* Generated automatically by %s at %.24s.\0A\00"
@.str.5 = [17 x i8] c" Do not edit!\0A\00"
@.str.6 = [5 x i8] c" */\0A\00"
@.str.7 = [20 x i8] c"#include <hpgs.h>\0A\0A\00"
@.str.8 = [8 x i8] c"%d %31s\00"
@.str.9 = [36 x i8] c"%s: Illegal count %d in stanza %d.\0A\00"
@.str.10 = [48 x i8] c"static hpgs_rop3_func_t rop3_table[][2][2] = {\0A\00"
@.str.11 = [59 x i8] c" {{rop3_%d_0_0,rop3_%d_0_1},{rop3_%d_1_0,rop3_%d_1_1}}%s\0A\00"
@.str.12 = [2 x i8] c",\00"
@.str.13 = [1 x i8] zeroinitializer
@.str.14 = [5 x i8] c"};\0A\0A\00"
@.str.15 = [284 x i8] c"hpgs_rop3_func_t hpgs_rop3_func(int rop3,\0A hpgs_bool src_transparency,\0A hpgs_bool pattern_transparency)\0A{\0A if (rop3 < 0 || rop3 >= %d) return 0;\0A return rop3_table[rop3][src_transparency!=0][pattern_transparency!=0];\0A}\0A\00"
@.str.16 = [50 x i8] c"static hpgs_xrop3_func_t xrop3_table[][2][2] = {\0A\00"
@.str.17 = [63 x i8] c" {{xrop3_%d_0_0,xrop3_%d_0_1},{xrop3_%d_1_0,xrop3_%d_1_1}}%s\0A\00"
@.str.18 = [291 x i8] c"hpgs_xrop3_func_t hpgs_xrop3_func(int rop3,\0A hpgs_bool src_transparency,\0A hpgs_bool pattern_transparency)\0A{\0A if (rop3 < 0 || rop3 >= %d) return 0;\0A return xrop3_table[rop3][src_transparency!=0][pattern_transparency!=0];\0A}\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [32 x i8]
%5 = alloca i32
%6 = bitcast i32* %3 to i8*
%7 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%8 = bitcast i32* %5 to i8*
%9 = icmp eq i32 %0, 3
br i1 %9, label %16, label %10
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = sext i32 %11 to i64
%13 = inttoptr i64 %12 to i32*
%14 = load i8*, i8** %1
%15 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %13, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %14)
br label %106
16: ; preds = %2
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = tail call i32* @fopen(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %30
21: ; preds = %16
%22 = load i32, i32* @stderr
%23 = sext i32 %22 to i64
%24 = inttoptr i64 %23 to i32*
%25 = load i8*, i8** %1
%26 = load i8*, i8** %17
%27 = load i32, i32* @errno
%28 = tail call i8* @strerror(i32 %27)
%29 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %24, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %25, i8* %26, i8* %28)
br label %106
30: ; preds = %16
%31 = getelementptr inbounds i8*, i8** %1, i64 2
%32 = load i8*, i8** %31
%33 = tail call i32* @fopen(i8* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%34 = icmp eq i32* %33, null
br i1 %34, label %35, label %45
35: ; preds = %30
%36 = load i32, i32* @stderr
%37 = sext i32 %36 to i64
%38 = inttoptr i64 %37 to i32*
%39 = load i8*, i8** %1
%40 = load i8*, i8** %31
%41 = load i32, i32* @errno
%42 = tail call i8* @strerror(i32 %41)
%43 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %38, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %39, i8* %40, i8* %42)
%44 = call i32 @fclose(i32* %19)
br label %106
45: ; preds = %30
%46 = tail call i32 @time(i32 0)
store i32 %46, i32* %5
%47 = load i8*, i8** %1
%48 = call i8* @ctime(i32* %5)
%49 = call i32 (i32*, i8*, ...) @fprintf(i32* %33, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0), i8* %47, i8* %48)
%50 = call i64 @fwrite(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i64 16, i64 1, i32* %33)
%51 = call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i64 4, i64 1, i32* %33)
%52 = call i64 @fwrite(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i64 19, i64 1, i32* %33)
%53 = call i32 @fscanf(i32* %19, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i32* %3, i8* %7)
%54 = icmp eq i32 %53, 2
br i1 %54, label %55, label %72
55: ; preds = %45, %68
%56 = phi i32 [ %69, %68 ], [ 0, %45 ]
%57 = load i32, i32* %3
%58 = icmp eq i32 %57, %56
br i1 %58, label %65, label %59
59: ; preds = %55
%60 = load i32, i32* @stderr
%61 = sext i32 %60 to i64
%62 = inttoptr i64 %61 to i32*
%63 = load i8*, i8** %1
%64 = call i32 (i32*, i8*, ...) @fprintf(i32* %62, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.9, i64 0, i64 0), i8* %63, i32 %57, i32 %56)
br label %102
65: ; preds = %55
%66 = call i64 @write_rop3_func(i32* %33, i32 %56, i8* %7)
%67 = icmp eq i64 %66, 0
br i1 %67, label %68, label %102
68: ; preds = %65
%69 = add nuw nsw i32 %56, 1
%70 = call i32 @fscanf(i32* %19, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i32* %3, i8* %7)
%71 = icmp eq i32 %70, 2
br i1 %71, label %55, label %74
72: ; preds = %45
%73 = call i64 @fwrite(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.10, i64 0, i64 0), i64 47, i64 1, i32* %33)
store i32 0, i32* %3
br label %84
74: ; preds = %68
%75 = call i64 @fwrite(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.10, i64 0, i64 0), i64 47, i64 1, i32* %33)
store i32 0, i32* %3
br label %76
76: ; preds = %74, %76
%77 = phi i32 [ 0, %74 ], [ %82, %76 ]
%78 = icmp slt i32 %77, %56
%79 = select i1 %78, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.13, i64 0, i64 0)
%80 = call i32 (i32*, i8*, ...) @fprintf(i32* %33, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.11, i64 0, i64 0), i32 %77, i32 %77, i32 %77, i32 %77, i8* %79)
%81 = load i32, i32* %3
%82 = add nsw i32 %81, 1
store i32 %82, i32* %3
%83 = icmp slt i32 %81, %56
br i1 %83, label %76, label %84
84: ; preds = %76, %72
%85 = phi i32 [ 0, %72 ], [ %69, %76 ]
%86 = call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0), i64 4, i64 1, i32* %33)
%87 = call i32 (i32*, i8*, ...) @fprintf(i32* %33, i8* getelementptr inbounds ([284 x i8], [284 x i8]* @.str.15, i64 0, i64 0), i32 %85)
%88 = call i64 @fwrite(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.16, i64 0, i64 0), i64 49, i64 1, i32* %33)
store i32 0, i32* %3
br i1 %54, label %89, label %99
89: ; preds = %84
%90 = add nsw i32 %85, -1
br label %91
91: ; preds = %89, %91
%92 = phi i32 [ 0, %89 ], [ %97, %91 ]
%93 = icmp slt i32 %92, %90
%94 = select i1 %93, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.13, i64 0, i64 0)
%95 = call i32 (i32*, i8*, ...) @fprintf(i32* %33, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.17, i64 0, i64 0), i32 %92, i32 %92, i32 %92, i32 %92, i8* %94)
%96 = load i32, i32* %3
%97 = add nsw i32 %96, 1
store i32 %97, i32* %3
%98 = icmp slt i32 %97, %85
br i1 %98, label %91, label %99
99: ; preds = %91, %84
%100 = call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0), i64 4, i64 1, i32* %33)
%101 = call i32 (i32*, i8*, ...) @fprintf(i32* %33, i8* getelementptr inbounds ([291 x i8], [291 x i8]* @.str.18, i64 0, i64 0), i32 %85)
br label %102
102: ; preds = %65, %99, %59
%103 = phi i32 [ 1, %59 ], [ 0, %99 ], [ 0, %65 ]
%104 = call i32 @fclose(i32* %19)
%105 = call i32 @fclose(i32* %33)
br label %106
106: ; preds = %35, %21, %102, %10
%107 = phi i32 [ 1, %10 ], [ %103, %102 ], [ 1, %21 ], [ 1, %35 ]
ret i32 %107
}