#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 */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getopt(int, char **, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putc(int, int /*<<< orphan*/);
char *stbi_failure_reason();
scalar_t__ stbi_load(char *, int *, int *, int *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ usage();
int main(int argc, char **argv) {
  extern char *optarg;
  extern int optind;
  int ch, format;
  int x, y, n;
  int nx, ny;
  unsigned char *data;
  int offset, count, total;
  format = 'b';
  count = total = 0;
  while ((ch = getopt(argc, argv, "abcd")) != -1) {
    switch (ch) {
    case 'a':
      format = 'a';
      break;
    case 'b':
      format = 'b';
      break;
    case 'c':
      format = 'c';
      break;
    case 'd':
      format = 'd';
      break;
    case '?':
    default:
      usage();
    }
  }
  argc -= optind;
  argv += optind;
  if (!argv[0]) {
    (void)fprintf(stderr, "no input image provided\n");
    usage();
  }
  data = (unsigned char *)stbi_load(argv[0], &x, &y, &n, 3);
  if (!data) {
    (void)fprintf(stderr, "stbi_load: %s\n", stbi_failure_reason());
    exit(1);
  }
  if (x != 48 || y != 32) {
    (void)fprintf(stderr, "image must be %dx%d\n", 48, 32);
    exit(1);
  }
  if (format == 'c')
    printf("static const char initimg%dx%d[%d] = {\n", 48, 32, ((48 * 32) / 8));
  for (ny = 0; ny < y; ny++) {
    if (format == 'a')
      printf(".byte ");
    for (nx = 0; nx < x; nx++) {
      offset = (nx + ny * x) * 3 - 1;
      total = (total << 1) |
              !(data[offset + 1] + data[offset + 2] + data[offset + 3]);
      count += 1;
      if (count == 8) {
        switch (format) {
        case 'a':
          printf("%%%c%c%c%c%c%c%c%c", (total & 0x80 ? '1' : '0'),
                 (total & 0x40 ? '1' : '0'), (total & 0x20 ? '1' : '0'),
                 (total & 0x10 ? '1' : '0'), (total & 0x08 ? '1' : '0'),
                 (total & 0x04 ? '1' : '0'), (total & 0x02 ? '1' : '0'),
                 (total & 0x01 ? '1' : '0'));
          if (nx != 47) {
            printf(",");
          }
          break;
        case 'b':
          printf("%c%c%c%c%c%c%c%c", (total & 0x80 ? '1' : '0'),
                 (total & 0x40 ? '1' : '0'), (total & 0x20 ? '1' : '0'),
                 (total & 0x10 ? '1' : '0'), (total & 0x08 ? '1' : '0'),
                 (total & 0x04 ? '1' : '0'), (total & 0x02 ? '1' : '0'),
                 (total & 0x01 ? '1' : '0'));
          break;
        case 'c':
          printf("0x%02x", total);
          if (ny == 31 && nx == 47) {
            printf("\n};\n");
          } else {
            printf(", ");
          }
          break;
        case 'd':
          putc(total, stdout);
          break;
        }
        count = total = 0;
      }
    }
    if (format != 'd')
      printf("\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x78,%rsp
movl   $0x0,-0xc(%rbp)
mov    %edi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x62,-0x20(%rbp)
movl   $0x0,-0x4c(%rbp)
movl   $0x0,-0x48(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x18(%rbp),%rsi
lea    0xeee(%rip),%rdx
call   1090 <getopt@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
je     1235 <main+0xb5>
mov    -0x1c(%rbp),%eax
add    $0xffffffc1,%eax
mov    %eax,%ecx
mov    %rcx,-0x58(%rbp)
sub    $0x25,%eax
ja     1229 <main+0xa9>
mov    -0x58(%rbp),%rax
lea    0xe25(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x61,-0x20(%rbp)
jmp    1230 <main+0xb0>
movl   $0x62,-0x20(%rbp)
jmp    1230 <main+0xb0>
movl   $0x63,-0x20(%rbp)
jmp    1230 <main+0xb0>
movl   $0x64,-0x20(%rbp)
jmp    1230 <main+0xb0>
jmp    1229 <main+0xa9>
mov    $0x0,%al
call   1080 <usage@plt>
jmp    11ac <main+0x2c>
mov    0x2d94(%rip),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    0x2d83(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
jne    128d <main+0x10d>
mov    0x2d6a(%rip),%rax
mov    (%rax),%edi
lea    0xe2e(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x0,%al
call   1080 <usage@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
lea    -0x24(%rbp),%rsi
lea    -0x28(%rbp),%rdx
lea    -0x2c(%rbp),%rcx
mov    $0x3,%r8d
call   1050 <stbi_load@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    12eb <main+0x16b>
mov    0x2d1f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x5c(%rbp)
mov    $0x0,%al
call   1040 <stbi_failure_reason@plt>
mov    -0x5c(%rbp),%edi
mov    %rax,%rdx
lea    0xdec(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
cmpl   $0x30,-0x24(%rbp)
jne    12ff <main+0x17f>
cmpl   $0x20,-0x28(%rbp)
je     132a <main+0x1aa>
mov    0x2cda(%rip),%rax
mov    (%rax),%edi
lea    0xdc6(%rip),%rsi
mov    $0x30,%edx
mov    $0x20,%ecx
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
cmpl   $0x63,-0x20(%rbp)
jne    1351 <main+0x1d1>
lea    0xdaf(%rip),%rdi
mov    $0x30,%esi
mov    $0x20,%edx
mov    $0xc0,%ecx
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    16a7 <main+0x527>
cmpl   $0x61,-0x20(%rbp)
jne    137c <main+0x1fc>
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    167c <main+0x4fc>
mov    -0x30(%rbp),%eax
mov    -0x34(%rbp),%ecx
imul   -0x24(%rbp),%ecx
add    %ecx,%eax
imul   $0x3,%eax,%eax
sub    $0x1,%eax
mov    %eax,-0x44(%rbp)
mov    -0x4c(%rbp),%eax
shl    $0x1,%eax
mov    -0x40(%rbp),%rcx
mov    -0x44(%rbp),%edx
add    $0x1,%edx
movslq %edx,%rdx
movzbl (%rcx,%rdx,1),%ecx
mov    -0x40(%rbp),%rdx
mov    -0x44(%rbp),%esi
add    $0x2,%esi
movslq %esi,%rsi
movzbl (%rdx,%rsi,1),%edx
add    %edx,%ecx
mov    -0x40(%rbp),%rdx
mov    -0x44(%rbp),%esi
add    $0x3,%esi
movslq %esi,%rsi
movzbl (%rdx,%rsi,1),%edx
add    %edx,%ecx
cmp    $0x0,%ecx
setne  %cl
xor    $0xff,%cl
and    $0x1,%cl
movzbl %cl,%ecx
or     %ecx,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
cmpl   $0x8,-0x48(%rbp)
jne    1669 <main+0x4e9>
mov    -0x20(%rbp),%eax
add    $0xffffff9f,%eax
mov    %eax,%ecx
mov    %rcx,-0x68(%rbp)
sub    $0x3,%eax
ja     165b <main+0x4db>
mov    -0x68(%rbp),%rax
lea    0xbd8(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x4c(%rbp),%ecx
and    $0x80,%ecx
mov    $0x30,%esi
mov    $0x31,%eax
cmp    $0x0,%ecx
cmovne %eax,%esi
mov    -0x4c(%rbp),%ecx
and    $0x40,%ecx
mov    $0x30,%edx
mov    $0x31,%eax
cmp    $0x0,%ecx
cmovne %eax,%edx
mov    -0x4c(%rbp),%edi
and    $0x20,%edi
mov    $0x30,%ecx
mov    $0x31,%eax
cmp    $0x0,%edi
cmovne %eax,%ecx
mov    -0x4c(%rbp),%edi
and    $0x10,%edi
mov    $0x30,%r8d
mov    $0x31,%eax
cmp    $0x0,%edi
cmovne %eax,%r8d
mov    -0x4c(%rbp),%edi
and    $0x8,%edi
mov    $0x30,%r9d
mov    $0x31,%eax
cmp    $0x0,%edi
cmovne %eax,%r9d
mov    -0x4c(%rbp),%edi
and    $0x4,%edi
mov    $0x30,%r11d
mov    $0x31,%eax
cmp    $0x0,%edi
cmovne %eax,%r11d
mov    -0x4c(%rbp),%edi
and    $0x2,%edi
mov    $0x30,%r10d
mov    $0x31,%eax
cmp    $0x0,%edi
cmovne %eax,%r10d
mov    -0x4c(%rbp),%ebx
and    $0x1,%ebx
mov    $0x30,%eax
mov    $0x31,%edi
cmp    $0x0,%ebx
cmovne %edi,%eax
lea    0xc26(%rip),%rdi
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x2f,-0x30(%rbp)
je     151f <main+0x39f>
lea    0xc14(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    165b <main+0x4db>
mov    -0x4c(%rbp),%ecx
and    $0x80,%ecx
mov    $0x30,%esi
mov    $0x31,%eax
cmp    $0x0,%ecx
cmovne %eax,%esi
mov    -0x4c(%rbp),%ecx
and    $0x40,%ecx
mov    $0x30,%edx
mov    $0x31,%eax
cmp    $0x0,%ecx
cmovne %eax,%edx
mov    -0x4c(%rbp),%edi
and    $0x20,%edi
mov    $0x30,%ecx
mov    $0x31,%eax
cmp    $0x0,%edi
cmovne %eax,%ecx
mov    -0x4c(%rbp),%edi
and    $0x10,%edi
mov    $0x30,%r8d
mov    $0x31,%eax
cmp    $0x0,%edi
cmovne %eax,%r8d
mov    -0x4c(%rbp),%edi
and    $0x8,%edi
mov    $0x30,%r9d
mov    $0x31,%eax
cmp    $0x0,%edi
cmovne %eax,%r9d
mov    -0x4c(%rbp),%edi
and    $0x4,%edi
mov    $0x30,%r11d
mov    $0x31,%eax
cmp    $0x0,%edi
cmovne %eax,%r11d
mov    -0x4c(%rbp),%edi
and    $0x2,%edi
mov    $0x30,%r10d
mov    $0x31,%eax
cmp    $0x0,%edi
cmovne %eax,%r10d
mov    -0x4c(%rbp),%ebx
and    $0x1,%ebx
mov    $0x30,%eax
mov    $0x31,%edi
cmp    $0x0,%ebx
cmovne %edi,%eax
lea    0xb35(%rip),%rdi
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
jmp    165b <main+0x4db>
mov    -0x4c(%rbp),%esi
lea    0xb25(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x1f,-0x34(%rbp)
jne    1637 <main+0x4b7>
cmpl   $0x2f,-0x30(%rbp)
jne    1637 <main+0x4b7>
lea    0xb0a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1645 <main+0x4c5>
lea    0xafc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    165b <main+0x4db>
mov    -0x4c(%rbp),%edi
mov    0x2984(%rip),%rax
mov    (%rax),%esi
call   1060 <putc@plt>
movl   $0x0,-0x4c(%rbp)
movl   $0x0,-0x48(%rbp)
jmp    166e <main+0x4ee>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1383 <main+0x203>
cmpl   $0x64,-0x20(%rbp)
je     1694 <main+0x514>
lea    0xaab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1699 <main+0x519>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1358 <main+0x1d8>
mov    -0xc(%rbp),%eax
add    $0x78,%rsp
pop    %rbx
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    %edi,%ebp
mov    $0x62,%eax
mov    %rax,0x8(%rsp)
lea    0xe4c(%rip),%r14
jmp    11d0 <main+0x30>
mov    %rax,0x8(%rsp)
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   10b0 <getopt@plt>
lea    -0x61(%rax),%ecx
cmp    $0x4,%ecx
jb     11c6 <main+0x26>
cmp    $0xffffffff,%eax
je     11f3 <main+0x53>
xor    %eax,%eax
call   10a0 <usage@plt>
jmp    11d0 <main+0x30>
mov    0x2dd6(%rip),%rax
movslq (%rax),%rbp
mov    (%rbx,%rbp,8),%rdi
test   %rdi,%rdi
jne    1228 <main+0x88>
mov    0x2dd3(%rip),%rax
mov    (%rax),%edi
lea    0xdff(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
xor    %eax,%eax
call   10a0 <usage@plt>
mov    (%rbx,%rbp,8),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
lea    0x14(%rsp),%rcx
mov    $0x3,%r8d
call   1070 <stbi_load@plt>
test   %rax,%rax
je     151b <main+0x37b>
cmpl   $0x30,0x4(%rsp)
jne    1548 <main+0x3a8>
cmpl   $0x20,(%rsp)
jne    1548 <main+0x3a8>
mov    %rax,%r15
cmpl   $0x63,0x8(%rsp)
jne    128f <main+0xef>
lea    0xde3(%rip),%rdi
mov    $0x30,%esi
mov    $0x20,%edx
mov    $0xc0,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x0,(%rsp)
jle    150a <main+0x36a>
xor    %ebp,%ebp
xor    %r14d,%r14d
xor    %r12d,%r12d
jmp    12ae <main+0x10e>
nopl   0x0(%rax)
add    $0x1,%r12d
cmp    (%rsp),%r12d
jge    150a <main+0x36a>
cmpl   $0x61,0x8(%rsp)
jne    12c3 <main+0x123>
lea    0xdbe(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
jle    14f0 <main+0x350>
xor    %r13d,%r13d
mov    %ebp,%ebx
jmp    1305 <main+0x165>
mov    0x2cfb(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
call   1080 <putc@plt>
cs nopw 0x0(%rax,%rax,1)
xor    %ebp,%ebp
add    $0x1,%r13d
mov    0x4(%rsp),%eax
mov    %ebp,%ebx
cmp    %eax,%r13d
jge    14f0 <main+0x350>
imul   %r12d,%eax
add    %r13d,%eax
cltq
lea    (%rax,%rax,2),%rcx
movzbl (%r15,%rcx,1),%edx
movzbl 0x1(%r15,%rcx,1),%eax
add    %edx,%eax
movzbl 0x2(%r15,%rcx,1),%ecx
neg    %ecx
xor    %edx,%edx
cmp    %ecx,%eax
sete   %dl
lea    (%rdx,%rbx,2),%ebp
add    $0x1,%r14d
cmp    $0x8,%r14d
jne    12f2 <main+0x152>
xor    %r14d,%r14d
mov    0x8(%rsp),%rdx
add    $0xffffff9f,%edx
cmp    $0x3,%edx
ja     12f0 <main+0x150>
lea    0xcae(%rip),%rsi
movslq (%rsi,%rdx,4),%rdx
add    %rsi,%rdx
jmp    *%rdx
xor    %ebp,%ebp
cmp    %ecx,%eax
sete   %bpl
mov    %ebx,%eax
and    $0x40,%eax
cmp    $0x1,%eax
mov    $0x31,%esi
sbb    $0x0,%esi
mov    %ebx,%eax
and    $0x20,%eax
cmp    $0x1,%eax
mov    $0x31,%edx
sbb    $0x0,%edx
mov    %ebx,%eax
and    $0x10,%eax
cmp    $0x1,%eax
mov    $0x31,%ecx
sbb    $0x0,%ecx
mov    %ebx,%eax
and    $0x8,%eax
cmp    $0x1,%eax
mov    $0x31,%r8d
sbb    $0x0,%r8d
mov    %ebx,%eax
and    $0x4,%eax
cmp    $0x1,%eax
mov    $0x31,%r9d
sbb    $0x0,%r9d
mov    %ebx,%eax
and    $0x2,%eax
cmp    $0x1,%eax
mov    $0x31,%r10d
sbb    $0x0,%r10d
and    $0x1,%ebx
or     $0x30,%ebx
or     $0x30,%ebp
sub    $0x8,%rsp
xor    %r14d,%r14d
lea    0xca1(%rip),%rdi
xor    %eax,%eax
push   %rbp
push   %rbx
push   %r10
call   1050 <printf@plt>
add    $0x20,%rsp
cmp    $0x2f,%r13d
je     12f0 <main+0x150>
mov    $0x2c,%edi
call   1030 <putchar@plt>
jmp    12f0 <main+0x150>
lea    0xc85(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0x1f,%r12d
jne    14d6 <main+0x336>
cmp    $0x2f,%r13d
jne    14d6 <main+0x336>
lea    0xc6b(%rip),%rdi
call   1040 <puts@plt>
jmp    12f0 <main+0x150>
xor    %ebp,%ebp
cmp    %ecx,%eax
sete   %bpl
mov    %ebx,%eax
and    $0x40,%eax
cmp    $0x1,%eax
mov    $0x31,%esi
sbb    $0x0,%esi
mov    %ebx,%eax
and    $0x20,%eax
cmp    $0x1,%eax
mov    $0x31,%edx
sbb    $0x0,%edx
mov    %ebx,%eax
and    $0x10,%eax
cmp    $0x1,%eax
mov    $0x31,%ecx
sbb    $0x0,%ecx
mov    %ebx,%eax
and    $0x8,%eax
cmp    $0x1,%eax
mov    $0x31,%r8d
sbb    $0x0,%r8d
mov    %ebx,%eax
and    $0x4,%eax
cmp    $0x1,%eax
mov    $0x31,%r9d
sbb    $0x0,%r9d
mov    %ebx,%eax
and    $0x2,%eax
cmp    $0x1,%eax
mov    $0x31,%r10d
sbb    $0x0,%r10d
and    $0x1,%ebx
or     $0x30,%ebx
or     $0x30,%ebp
sub    $0x8,%rsp
xor    %r14d,%r14d
lea    0xbc1(%rip),%rdi
xor    %eax,%eax
push   %rbp
push   %rbx
push   %r10
call   1050 <printf@plt>
add    $0x20,%rsp
jmp    12f0 <main+0x150>
xor    %r14d,%r14d
lea    0xbbb(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    12f0 <main+0x150>
nopl   0x0(%rax)
cmpl   $0x64,0x8(%rsp)
je     12a0 <main+0x100>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    12a0 <main+0x100>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2abe(%rip),%rax
mov    (%rax),%ebx
xor    %eax,%eax
call   1060 <stbi_failure_reason@plt>
lea    0xafc(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    0x2a91(%rip),%rax
mov    (%rax),%edi
lea    0xae5(%rip),%rsi
mov    $0x30,%edx
mov    $0x20,%ecx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"abcd\00"
@optind = external global i32
@stderr = global i32 0
@.str.1 = [25 x i8] c"no input image provided\0A\00"
@.str.2 = [15 x i8] c"stbi_load: %s\0A\00"
@.str.3 = [21 x i8] c"image must be %dx%d\0A\00"
@.str.4 = [40 x i8] c"static const char initimg%dx%d[%d] = {\0A\00"
@.str.5 = [7 x i8] c".byte \00"
@.str.6 = [19 x i8] c"%%%c%c%c%c%c%c%c%c\00"
@.str.7 = [2 x i8] c",\00"
@.str.8 = [17 x i8] c"%c%c%c%c%c%c%c%c\00"
@.str.9 = [7 x i8] c"0x%02x\00"
@.str.10 = [5 x i8] c"\0A};\0A\00"
@.str.11 = [3 x i8] c", \00"
@stdout = global i32 0
@.str.12 = [2 x i8] c"\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 i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 98, i32* %7
store i32 0, i32* %16
store i32 0, i32* %15
br label %17
17: ; preds = %31, %2
%18 = load i32, i32* %4
%19 = load i8**, i8*** %5
%20 = call i32 @getopt(i32 %18, i8** %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %20, i32* %6
%21 = icmp ne i32 %20, -1
br i1 %21, label %22, label %32
22: ; preds = %17
%23 = load i32, i32* %6
switch i32 %23, label %29 [
i32 97, label %24
i32 98, label %25
i32 99, label %26
i32 100, label %27
i32 63, label %28
]
24: ; preds = %22
store i32 97, i32* %7
br label %31
25: ; preds = %22
store i32 98, i32* %7
br label %31
26: ; preds = %22
store i32 99, i32* %7
br label %31
27: ; preds = %22
store i32 100, i32* %7
br label %31
28: ; preds = %22
br label %29
29: ; preds = %22, %28
%30 = call i32 (...) @usage()
br label %31
31: ; preds = %29, %27, %26, %25, %24
br label %17
32: ; preds = %17
%33 = load i32, i32* @optind
%34 = load i32, i32* %4
%35 = sub nsw i32 %34, %33
store i32 %35, i32* %4
%36 = load i32, i32* @optind
%37 = load i8**, i8*** %5
%38 = sext i32 %36 to i64
%39 = getelementptr inbounds i8*, i8** %37, i64 %38
store i8** %39, i8*** %5
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 0
%42 = load i8*, i8** %41
%43 = icmp ne i8* %42, null
br i1 %43, label %48, label %44
44: ; preds = %32
%45 = load i32, i32* @stderr
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%47 = call i32 (...) @usage()
br label %48
48: ; preds = %44, %32
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 0
%51 = load i8*, i8** %50
%52 = call i64 @stbi_load(i8* %51, i32* %8, i32* %9, i32* %10, i32 3)
%53 = inttoptr i64 %52 to i8*
store i8* %53, i8** %13
%54 = load i8*, i8** %13
%55 = icmp ne i8* %54, null
br i1 %55, label %61, label %56
56: ; preds = %48
%57 = load i32, i32* @stderr
%58 = call i8* (...) @stbi_failure_reason()
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %58)
%60 = call i32 @exit(i32 1)
unreachable
61: ; preds = %48
%62 = load i32, i32* %8
%63 = icmp ne i32 %62, 48
br i1 %63, label %67, label %64
64: ; preds = %61
%65 = load i32, i32* %9
%66 = icmp ne i32 %65, 32
br i1 %66, label %67, label %71
67: ; preds = %64, %61
%68 = load i32, i32* @stderr
%69 = call i32 (i32, i8*, ...) @fprintf(i32 %68, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 48, i32 32)
%70 = call i32 @exit(i32 1)
unreachable
71: ; preds = %64
%72 = load i32, i32* %7
%73 = icmp eq i32 %72, 99
br i1 %73, label %74, label %76
74: ; preds = %71
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i32 48, i32 32, i32 192)
br label %76
76: ; preds = %74, %71
store i32 0, i32* %12
br label %77
77: ; preds = %251, %76
%78 = load i32, i32* %12
%79 = load i32, i32* %9
%80 = icmp slt i32 %78, %79
br i1 %80, label %81, label %254
81: ; preds = %77
%82 = load i32, i32* %7
%83 = icmp eq i32 %82, 97
br i1 %83, label %84, label %86
84: ; preds = %81
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %86
86: ; preds = %84, %81
store i32 0, i32* %11
br label %87
87: ; preds = %242, %86
%88 = load i32, i32* %11
%89 = load i32, i32* %8
%90 = icmp slt i32 %88, %89
br i1 %90, label %91, label %245
91: ; preds = %87
%92 = load i32, i32* %11
%93 = load i32, i32* %12
%94 = load i32, i32* %8
%95 = mul nsw i32 %93, %94
%96 = add nsw i32 %92, %95
%97 = mul nsw i32 %96, 3
%98 = sub nsw i32 %97, 1
store i32 %98, i32* %14
%99 = load i32, i32* %16
%100 = shl i32 %99, 1
%101 = load i8*, i8** %13
%102 = load i32, i32* %14
%103 = add nsw i32 %102, 1
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds i8, i8* %101, i64 %104
%106 = load i8, i8* %105
%107 = zext i8 %106 to i32
%108 = load i8*, i8** %13
%109 = load i32, i32* %14
%110 = add nsw i32 %109, 2
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds i8, i8* %108, i64 %111
%113 = load i8, i8* %112
%114 = zext i8 %113 to i32
%115 = add nsw i32 %107, %114
%116 = load i8*, i8** %13
%117 = load i32, i32* %14
%118 = add nsw i32 %117, 3
%119 = sext i32 %118 to i64
%120 = getelementptr inbounds i8, i8* %116, i64 %119
%121 = load i8, i8* %120
%122 = zext i8 %121 to i32
%123 = add nsw i32 %115, %122
%124 = icmp ne i32 %123, 0
%125 = xor i1 %124, true
%126 = zext i1 %125 to i32
%127 = or i32 %100, %126
store i32 %127, i32* %16
%128 = load i32, i32* %15
%129 = add nsw i32 %128, 1
store i32 %129, i32* %15
%130 = load i32, i32* %15
%131 = icmp eq i32 %130, 8
br i1 %131, label %132, label %241
132: ; preds = %91
%133 = load i32, i32* %7
switch i32 %133, label %240 [
i32 97, label %134
i32 98, label %181
i32 99, label %223
i32 100, label %236
]
134: ; preds = %132
%135 = load i32, i32* %16
%136 = and i32 %135, 128
%137 = icmp ne i32 %136, 0
%138 = zext i1 %137 to i64
%139 = select i1 %137, i32 49, i32 48
%140 = load i32, i32* %16
%141 = and i32 %140, 64
%142 = icmp ne i32 %141, 0
%143 = zext i1 %142 to i64
%144 = select i1 %142, i32 49, i32 48
%145 = load i32, i32* %16
%146 = and i32 %145, 32
%147 = icmp ne i32 %146, 0
%148 = zext i1 %147 to i64
%149 = select i1 %147, i32 49, i32 48
%150 = load i32, i32* %16
%151 = and i32 %150, 16
%152 = icmp ne i32 %151, 0
%153 = zext i1 %152 to i64
%154 = select i1 %152, i32 49, i32 48
%155 = load i32, i32* %16
%156 = and i32 %155, 8
%157 = icmp ne i32 %156, 0
%158 = zext i1 %157 to i64
%159 = select i1 %157, i32 49, i32 48
%160 = load i32, i32* %16
%161 = and i32 %160, 4
%162 = icmp ne i32 %161, 0
%163 = zext i1 %162 to i64
%164 = select i1 %162, i32 49, i32 48
%165 = load i32, i32* %16
%166 = and i32 %165, 2
%167 = icmp ne i32 %166, 0
%168 = zext i1 %167 to i64
%169 = select i1 %167, i32 49, i32 48
%170 = load i32, i32* %16
%171 = and i32 %170, 1
%172 = icmp ne i32 %171, 0
%173 = zext i1 %172 to i64
%174 = select i1 %172, i32 49, i32 48
%175 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i32 %139, i32 %144, i32 %149, i32 %154, i32 %159, i32 %164, i32 %169, i32 %174)
%176 = load i32, i32* %11
%177 = icmp ne i32 %176, 47
br i1 %177, label %178, label %180
178: ; preds = %134
%179 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %180
180: ; preds = %178, %134
br label %240
181: ; preds = %132
%182 = load i32, i32* %16
%183 = and i32 %182, 128
%184 = icmp ne i32 %183, 0
%185 = zext i1 %184 to i64
%186 = select i1 %184, i32 49, i32 48
%187 = load i32, i32* %16
%188 = and i32 %187, 64
%189 = icmp ne i32 %188, 0
%190 = zext i1 %189 to i64
%191 = select i1 %189, i32 49, i32 48
%192 = load i32, i32* %16
%193 = and i32 %192, 32
%194 = icmp ne i32 %193, 0
%195 = zext i1 %194 to i64
%196 = select i1 %194, i32 49, i32 48
%197 = load i32, i32* %16
%198 = and i32 %197, 16
%199 = icmp ne i32 %198, 0
%200 = zext i1 %199 to i64
%201 = select i1 %199, i32 49, i32 48
%202 = load i32, i32* %16
%203 = and i32 %202, 8
%204 = icmp ne i32 %203, 0
%205 = zext i1 %204 to i64
%206 = select i1 %204, i32 49, i32 48
%207 = load i32, i32* %16
%208 = and i32 %207, 4
%209 = icmp ne i32 %208, 0
%210 = zext i1 %209 to i64
%211 = select i1 %209, i32 49, i32 48
%212 = load i32, i32* %16
%213 = and i32 %212, 2
%214 = icmp ne i32 %213, 0
%215 = zext i1 %214 to i64
%216 = select i1 %214, i32 49, i32 48
%217 = load i32, i32* %16
%218 = and i32 %217, 1
%219 = icmp ne i32 %218, 0
%220 = zext i1 %219 to i64
%221 = select i1 %219, i32 49, i32 48
%222 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i32 %186, i32 %191, i32 %196, i32 %201, i32 %206, i32 %211, i32 %216, i32 %221)
br label %240
223: ; preds = %132
%224 = load i32, i32* %16
%225 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i32 %224)
%226 = load i32, i32* %12
%227 = icmp eq i32 %226, 31
br i1 %227, label %228, label %233
228: ; preds = %223
%229 = load i32, i32* %11
%230 = icmp eq i32 %229, 47
br i1 %230, label %231, label %233
231: ; preds = %228
%232 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
br label %235
233: ; preds = %228, %223
%234 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
br label %235
235: ; preds = %233, %231
br label %240
236: ; preds = %132
%237 = load i32, i32* %16
%238 = load i32, i32* @stdout
%239 = call i32 @putc(i32 %237, i32 %238)
br label %240
240: ; preds = %132, %236, %235, %181, %180
store i32 0, i32* %16
store i32 0, i32* %15
br label %241
241: ; preds = %240, %91
br label %242
242: ; preds = %241
%243 = load i32, i32* %11
%244 = add nsw i32 %243, 1
store i32 %244, i32* %11
br label %87
245: ; preds = %87
%246 = load i32, i32* %7
%247 = icmp ne i32 %246, 100
br i1 %247, label %248, label %250
248: ; preds = %245
%249 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
br label %250
250: ; preds = %248, %245
br label %251
251: ; preds = %250
%252 = load i32, i32* %12
%253 = add nsw i32 %252, 1
store i32 %253, i32* %12
br label %77
254: ; preds = %77
%255 = load i32, i32* %3
ret i32 %255
}

LLVM IR (-O2):
@.str = [5 x i8] c"abcd\00"
@optind = external global i32
@stderr = global i32 0
@.str.1 = [25 x i8] c"no input image provided\0A\00"
@.str.2 = [15 x i8] c"stbi_load: %s\0A\00"
@.str.3 = [21 x i8] c"image must be %dx%d\0A\00"
@.str.4 = [40 x i8] c"static const char initimg%dx%d[%d] = {\0A\00"
@.str.5 = [7 x i8] c".byte \00"
@.str.6 = [19 x i8] c"%%%c%c%c%c%c%c%c%c\00"
@.str.8 = [17 x i8] c"%c%c%c%c%c%c%c%c\00"
@.str.9 = [7 x i8] c"0x%02x\00"
@.str.11 = [3 x i8] c", \00"
@stdout = global i32 0
@str = [4 x i8] c"\0A};\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
br label %10
9: ; preds = %12, %12, %12, %12
br label %10
10: ; preds = %9, %2
%11 = phi i32 [ 98, %2 ], [ %13, %9 ]
br label %12
12: ; preds = %10, %14
%13 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
switch i32 %13, label %14 [
i32 -1, label %16
i32 97, label %9
i32 98, label %9
i32 99, label %9
i32 100, label %9
]
14: ; preds = %12
%15 = tail call i32 (...) @usage()
br label %12
16: ; preds = %12
%17 = load i32, i32* @optind
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8*, i8** %1, i64 %18
%20 = load i8*, i8** %19
%21 = icmp eq i8* %20, null
br i1 %21, label %22, label %27
22: ; preds = %16
%23 = load i32, i32* @stderr
%24 = tail call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%25 = tail call i32 (...) @usage()
%26 = load i8*, i8** %19
br label %27
27: ; preds = %22, %16
%28 = phi i8* [ %26, %22 ], [ %20, %16 ]
%29 = call i64 @stbi_load(i8* %28, i32* %3, i32* %4, i32* %5, i32 3)
%30 = inttoptr i64 %29 to i8*
%31 = icmp eq i64 %29, 0
br i1 %31, label %32, label %37
32: ; preds = %27
%33 = load i32, i32* @stderr
%34 = call i8* (...) @stbi_failure_reason()
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %34)
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %27
%38 = load i32, i32* %3
%39 = icmp ne i32 %38, 48
%40 = load i32, i32* %4
%41 = icmp ne i32 %40, 32
%42 = select i1 %39, i1 true, i1 %41
br i1 %42, label %43, label %47
43: ; preds = %37
%44 = load i32, i32* @stderr
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 48, i32 32)
%46 = call i32 @exit(i32 1)
unreachable
47: ; preds = %37
%48 = icmp eq i32 %11, 99
br i1 %48, label %49, label %53
49: ; preds = %47
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i32 48, i32 32, i32 192)
%51 = load i32, i32* %4
%52 = icmp sgt i32 %51, 0
br i1 %52, label %53, label %173
53: ; preds = %47, %49
%54 = icmp eq i32 %11, 97
%55 = icmp eq i32 %11, 100
br label %56
56: ; preds = %53, %169
%57 = phi i32 [ 0, %53 ], [ %166, %169 ]
%58 = phi i32 [ 0, %53 ], [ %165, %169 ]
%59 = phi i32 [ 0, %53 ], [ %170, %169 ]
br i1 %54, label %60, label %62
60: ; preds = %56
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %62
62: ; preds = %60, %56
%63 = load i32, i32* %3
%64 = icmp sgt i32 %63, 0
br i1 %64, label %65, label %164
65: ; preds = %62
%66 = icmp eq i32 %59, 31
br label %67
67: ; preds = %65, %158
%68 = phi i32 [ %63, %65 ], [ %162, %158 ]
%69 = phi i32 [ %57, %65 ], [ %160, %158 ]
%70 = phi i32 [ %58, %65 ], [ %159, %158 ]
%71 = phi i32 [ 0, %65 ], [ %161, %158 ]
%72 = mul nsw i32 %68, %59
%73 = add nsw i32 %72, %71
%74 = mul nsw i32 %73, 3
%75 = shl i32 %69, 1
%76 = sext i32 %74 to i64
%77 = getelementptr inbounds i8, i8* %30, i64 %76
%78 = load i8, i8* %77
%79 = zext i8 %78 to i32
%80 = add nsw i32 %74, 1
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds i8, i8* %30, i64 %81
%83 = load i8, i8* %82
%84 = zext i8 %83 to i32
%85 = add nuw nsw i32 %84, %79
%86 = add nsw i32 %74, 2
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds i8, i8* %30, i64 %87
%89 = load i8, i8* %88
%90 = zext i8 %89 to i32
%91 = sub nsw i32 0, %90
%92 = icmp eq i32 %85, %91
%93 = zext i1 %92 to i32
%94 = or i32 %75, %93
%95 = add nsw i32 %70, 1
%96 = icmp eq i32 %95, 8
br i1 %96, label %97, label %158
97: ; preds = %67
switch i32 %11, label %158 [
i32 97, label %98
i32 98, label %124
i32 99, label %147
i32 100, label %155
]
98: ; preds = %97
%99 = and i32 %69, 64
%100 = icmp eq i32 %99, 0
%101 = select i1 %100, i32 48, i32 49
%102 = and i32 %69, 32
%103 = icmp eq i32 %102, 0
%104 = select i1 %103, i32 48, i32 49
%105 = and i32 %69, 16
%106 = icmp eq i32 %105, 0
%107 = select i1 %106, i32 48, i32 49
%108 = and i32 %69, 8
%109 = icmp eq i32 %108, 0
%110 = select i1 %109, i32 48, i32 49
%111 = and i32 %69, 4
%112 = icmp eq i32 %111, 0
%113 = select i1 %112, i32 48, i32 49
%114 = and i32 %69, 2
%115 = icmp eq i32 %114, 0
%116 = select i1 %115, i32 48, i32 49
%117 = and i32 %69, 1
%118 = or i32 %117, 48
%119 = select i1 %92, i32 49, i32 48
%120 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i32 %101, i32 %104, i32 %107, i32 %110, i32 %113, i32 %116, i32 %118, i32 %119)
%121 = icmp eq i32 %71, 47
br i1 %121, label %158, label %122
122: ; preds = %98
%123 = call i32 @putchar(i32 44)
br label %158
124: ; preds = %97
%125 = and i32 %69, 64
%126 = icmp eq i32 %125, 0
%127 = select i1 %126, i32 48, i32 49
%128 = and i32 %69, 32
%129 = icmp eq i32 %128, 0
%130 = select i1 %129, i32 48, i32 49
%131 = and i32 %69, 16
%132 = icmp eq i32 %131, 0
%133 = select i1 %132, i32 48, i32 49
%134 = and i32 %69, 8
%135 = icmp eq i32 %134, 0
%136 = select i1 %135, i32 48, i32 49
%137 = and i32 %69, 4
%138 = icmp eq i32 %137, 0
%139 = select i1 %138, i32 48, i32 49
%140 = and i32 %69, 2
%141 = icmp eq i32 %140, 0
%142 = select i1 %141, i32 48, i32 49
%143 = and i32 %69, 1
%144 = or i32 %143, 48
%145 = select i1 %92, i32 49, i32 48
%146 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i32 %127, i32 %130, i32 %133, i32 %136, i32 %139, i32 %142, i32 %144, i32 %145)
br label %158
147: ; preds = %97
%148 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i32 %94)
%149 = icmp eq i32 %71, 47
%150 = select i1 %66, i1 %149, i1 false
br i1 %150, label %151, label %153
151: ; preds = %147
%152 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
br label %158
153: ; preds = %147
%154 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
br label %158
155: ; preds = %97
%156 = load i32, i32* @stdout
%157 = call i32 @putc(i32 %94, i32 %156)
br label %158
158: ; preds = %124, %155, %97, %122, %98, %153, %151, %67
%159 = phi i32 [ %95, %67 ], [ 0, %151 ], [ 0, %153 ], [ 0, %98 ], [ 0, %122 ], [ 0, %97 ], [ 0, %155 ], [ 0, %124 ]
%160 = phi i32 [ %94, %67 ], [ 0, %151 ], [ 0, %153 ], [ 0, %98 ], [ 0, %122 ], [ 0, %97 ], [ 0, %155 ], [ 0, %124 ]
%161 = add nuw nsw i32 %71, 1
%162 = load i32, i32* %3
%163 = icmp slt i32 %161, %162
br i1 %163, label %67, label %164
164: ; preds = %158, %62
%165 = phi i32 [ %58, %62 ], [ %159, %158 ]
%166 = phi i32 [ %57, %62 ], [ %160, %158 ]
br i1 %55, label %169, label %167
167: ; preds = %164
%168 = call i32 @putchar(i32 10)
br label %169
169: ; preds = %164, %167
%170 = add nuw nsw i32 %59, 1
%171 = load i32, i32* %4
%172 = icmp slt i32 %170, %171
br i1 %172, label %56, label %173
173: ; preds = %169, %49
ret i32 0
}