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

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int read(int /*<<< orphan*/, int *, int);
int /*<<< orphan*/ *stderr;
int main(int argc, char *argv[]) {
  uint32_t x, y, width = 0, height = 0;
  uint32_t tile;
  FILE *map_h, *map_c;
  if (argc < 3) {
    fprintf(stderr, "Usage %s <width> <height>\n", argv[0]);
    exit(1);
  }
  width = atoi(argv[1]);
  height = atoi(argv[2]);
  if ((width % 16 != 0) || (height % 8 != 0)) {
    fprintf(stderr, "Invalid map size %dx%d: Only multiples of 16x8 supported",
            width, height);
    exit(1);
  }
  if (NULL == (map_h = fopen("map.h", "w"))) {
    fprintf(stderr, "Can't open map.h\n");
    exit(1);
  }
  fprintf(map_h, "#ifndef MAP_H\n");
  fprintf(map_h, "#define MAP_H 1\n");
  fprintf(map_h, "#include \"common.h\"\n");
  fprintf(map_h, "#define MAP_WIDTH %d\n", width);
  fprintf(map_h, "#define MAP_HEIGHT %d\n", height);
  fprintf(map_h, "#define MAP_EMPTY 1\n");
  fprintf(map_h, "extern const uint8_t map[MAP_WIDTH*MAP_HEIGHT];\n");
  fprintf(map_h, "#endif\n");
  fclose(map_h);
  if (NULL == (map_c = fopen("map.c", "w"))) {
    fprintf(stderr, "Can't open map.c\n");
    exit(1);
  }
  fprintf(map_c, "#include \"common.h\"\n");
  fprintf(map_c, "#include \"map.h\"\n\n");
  fprintf(map_c, "const uint8_t map[] = \n");
  fprintf(map_c, "{\n\t");
  for (y = 0; y < height; y++) {
    for (x = 0; x < width; x++) {
      if (4 != read(0, &tile, 4)) {
        fprintf(stderr, "Read failed\n");
        exit(1);
      }
      fprintf(map_c, "0x%02X,", tile);
    }
    fprintf(map_c, "\n");
    if (y != height - 1)
      fprintf(map_c, "\t");
  }
  fprintf(map_c, "};\n");
  fclose(map_c);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11b7 <main+0x57>
mov    0x2e4b(%rip),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe5a(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11ff <main+0x9f>
mov    -0x20(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1227 <main+0xc7>
mov    0x2dda(%rip),%rax
mov    (%rax),%rdi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
lea    0xe05(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    0xe26(%rip),%rdi
lea    0xe25(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rcx
mov    %rcx,-0x30(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
jne    126e <main+0x10e>
mov    0x2d8d(%rip),%rax
mov    (%rax),%rdi
lea    0xdff(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x30(%rbp),%rdi
lea    0xdf5(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x30(%rbp),%rdi
lea    0xdf2(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x30(%rbp),%rdi
lea    0xdf1(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0xdf1(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%edx
lea    0xdf2(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x30(%rbp),%rdi
lea    0xdf7(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x30(%rbp),%rdi
lea    0xdfa(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x30(%rbp),%rdi
lea    0xe19(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xe0a(%rip),%rdi
lea    0xd3f(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rcx
mov    %rcx,-0x38(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
jne    1354 <main+0x1f4>
mov    0x2ca7(%rip),%rax
mov    (%rax),%rdi
lea    0xde1(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x38(%rbp),%rdi
lea    0xd2f(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x38(%rbp),%rdi
lea    0xdc5(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x38(%rbp),%rdi
lea    0xdc6(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x38(%rbp),%rdi
lea    0xdcc(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    146e <main+0x30e>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1426 <main+0x2c6>
xor    %edi,%edi
lea    -0x24(%rbp),%rsi
mov    $0x4,%edx
call   1040 <read@plt>
mov    %eax,%ecx
mov    $0x4,%eax
cmp    %ecx,%eax
je     1403 <main+0x2a3>
mov    0x2bf8(%rip),%rax
mov    (%rax),%rdi
lea    0xd73(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x38(%rbp),%rdi
mov    -0x24(%rbp),%edx
lea    0xd61(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    13b6 <main+0x256>
mov    -0x38(%rbp),%rdi
lea    0xd16(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%eax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     145b <main+0x2fb>
mov    -0x38(%rbp),%rdi
lea    0xd0f(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1460 <main+0x300>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    13a3 <main+0x243>
mov    -0x38(%rbp),%rdi
lea    0xd01(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x40,%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
cmp    $0x2,%edi
jle    141a <main+0x29a>
mov    0x8(%rbx),%rdi
call   1080 <atoi@plt>
mov    %eax,%ebp
mov    0x10(%rbx),%rdi
call   1080 <atoi@plt>
mov    %eax,%r13d
mov    %ebp,0xc(%rsp)
and    $0xf,%ebp
mov    %eax,%ecx
and    $0x7,%ecx
or     %ebp,%ecx
jne    143f <main+0x2bf>
lea    0xe88(%rip),%rdi
lea    0xe87(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1468 <main+0x2e8>
mov    %rax,%rbx
lea    0xe83(%rip),%rdi
mov    $0xe,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   10a0 <fwrite@plt>
lea    0xe79(%rip),%rdi
mov    $0x10,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
lea    0xe71(%rip),%rdi
mov    $0x14,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
lea    0xe6d(%rip),%rsi
mov    %rbx,%rdi
mov    0xc(%rsp),%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
lea    0xe6e(%rip),%rsi
mov    %rbx,%rdi
mov    %r13d,%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
lea    0xe71(%rip),%rdi
mov    $0x14,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
lea    0xe6d(%rip),%rdi
mov    $0x30,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
lea    0xe85(%rip),%rdi
mov    $0x7,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
lea    0xe6c(%rip),%rdi
lea    0xda1(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     147b <main+0x2fb>
mov    %rax,%rbx
lea    0xdbd(%rip),%rdi
mov    $0x14,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   10a0 <fwrite@plt>
lea    0xe4c(%rip),%rdi
mov    $0x12,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
lea    0xe46(%rip),%rdi
mov    $0x17,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
lea    0xe45(%rip),%rdi
mov    $0x3,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
test   %r13d,%r13d
jle    13be <main+0x23e>
lea    -0x1(%r13),%eax
mov    %eax,0x10(%rsp)
lea    0x14(%rsp),%r12
lea    0xe27(%rip),%rbp
xor    %r14d,%r14d
jmp    1359 <main+0x1d9>
add    $0x1,%r14d
cmp    %r13d,%r14d
je     13be <main+0x23e>
cmpl   $0x0,0xc(%rsp)
jle    139b <main+0x21b>
mov    0xc(%rsp),%r15d
cs nopw 0x0(%rax,%rax,1)
nop
xor    %edi,%edi
mov    %r12,%rsi
mov    $0x4,%edx
call   1050 <read@plt>
cmp    $0x4,%eax
jne    13f0 <main+0x270>
mov    0x14(%rsp),%edx
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
add    $0xffffffff,%r15d
jne    1370 <main+0x1f0>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
cmp    0x10(%rsp),%r14d
je     1350 <main+0x1d0>
mov    $0x9,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
jmp    1350 <main+0x1d0>
lea    0xdb5(%rip),%rdi
mov    $0x3,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2be9(%rip),%rax
mov    (%rax),%rcx
lea    0xd64(%rip),%rdi
mov    $0xc,%esi
mov    $0x1,%edx
call   10a0 <fwrite@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    0x2bbf(%rip),%rax
mov    (%rax),%rdi
mov    (%rbx),%rdx
lea    0xbd2(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    0x2b9a(%rip),%rax
mov    (%rax),%rdi
lea    0xbcb(%rip),%rsi
mov    0xc(%rsp),%edx
mov    %r13d,%ecx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    0x2b71(%rip),%rax
mov    (%rax),%rcx
lea    0xbe3(%rip),%rdi
jmp    148c <main+0x30c>
mov    0x2b5e(%rip),%rax
mov    (%rax),%rcx
lea    0xc98(%rip),%rdi
mov    $0x11,%esi
jmp    1406 <main+0x286>

LLVM IR (-O0):
@stderr = global i32* null
@.str = [27 x i8] c"Usage %s <width> <height>\0A\00"
@.str.1 = [57 x i8] c"Invalid map size %dx%d: Only multiples of 16x8 supported\00"
@.str.2 = [6 x i8] c"map.h\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [18 x i8] c"Can't open map.h\0A\00"
@.str.5 = [15 x i8] c"#ifndef MAP_H\0A\00"
@.str.6 = [17 x i8] c"#define MAP_H 1\0A\00"
@.str.7 = [21 x i8] c"#include \22common.h\22\0A\00"
@.str.8 = [22 x i8] c"#define MAP_WIDTH %d\0A\00"
@.str.9 = [23 x i8] c"#define MAP_HEIGHT %d\0A\00"
@.str.10 = [21 x i8] c"#define MAP_EMPTY 1\0A\00"
@.str.11 = [49 x i8] c"extern const uint8_t map[MAP_WIDTH*MAP_HEIGHT];\0A\00"
@.str.12 = [8 x i8] c"#endif\0A\00"
@.str.13 = [6 x i8] c"map.c\00"
@.str.14 = [18 x i8] c"Can't open map.c\0A\00"
@.str.15 = [19 x i8] c"#include \22map.h\22\0A\0A\00"
@.str.16 = [24 x i8] c"const uint8_t map[] = \0A\00"
@.str.17 = [4 x i8] c"{\0A\09\00"
@.str.18 = [13 x i8] c"Read failed\0A\00"
@.str.19 = [8 x i8] c"0x%02X,\00"
@.str.20 = [2 x i8] c"\0A\00"
@.str.21 = [2 x i8] c"\09\00"
@.str.22 = [4 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*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
store i32 0, i32* %9
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 3
br i1 %14, label %15, label %22
15: ; preds = %2
%16 = load i32*, i32** @stderr
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 (i32*, i8*, ...) @fprintf(i32* %16, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32 @atoi(i8* %25)
store i32 %26, i32* %8
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 2
%29 = load i8*, i8** %28
%30 = call i32 @atoi(i8* %29)
store i32 %30, i32* %9
%31 = load i32, i32* %8
%32 = srem i32 %31, 16
%33 = icmp ne i32 %32, 0
br i1 %33, label %38, label %34
34: ; preds = %22
%35 = load i32, i32* %9
%36 = srem i32 %35, 8
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %44
38: ; preds = %34, %22
%39 = load i32*, i32** @stderr
%40 = load i32, i32* %8
%41 = load i32, i32* %9
%42 = call i32 (i32*, i8*, ...) @fprintf(i32* %39, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0), i32 %40, i32 %41)
%43 = call i32 @exit(i32 1)
unreachable
44: ; preds = %34
%45 = call i32* @fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %45, i32** %11
%46 = icmp eq i32* null, %45
br i1 %46, label %47, label %51
47: ; preds = %44
%48 = load i32*, i32** @stderr
%49 = call i32 (i32*, i8*, ...) @fprintf(i32* %48, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%50 = call i32 @exit(i32 1)
unreachable
51: ; preds = %44
%52 = load i32*, i32** %11
%53 = call i32 (i32*, i8*, ...) @fprintf(i32* %52, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%54 = load i32*, i32** %11
%55 = call i32 (i32*, i8*, ...) @fprintf(i32* %54, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
%56 = load i32*, i32** %11
%57 = call i32 (i32*, i8*, ...) @fprintf(i32* %56, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
%58 = load i32*, i32** %11
%59 = load i32, i32* %8
%60 = call i32 (i32*, i8*, ...) @fprintf(i32* %58, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i32 %59)
%61 = load i32*, i32** %11
%62 = load i32, i32* %9
%63 = call i32 (i32*, i8*, ...) @fprintf(i32* %61, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i32 %62)
%64 = load i32*, i32** %11
%65 = call i32 (i32*, i8*, ...) @fprintf(i32* %64, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0))
%66 = load i32*, i32** %11
%67 = call i32 (i32*, i8*, ...) @fprintf(i32* %66, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.11, i64 0, i64 0))
%68 = load i32*, i32** %11
%69 = call i32 (i32*, i8*, ...) @fprintf(i32* %68, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0))
%70 = load i32*, i32** %11
%71 = call i32 @fclose(i32* %70)
%72 = call i32* @fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %72, i32** %12
%73 = icmp eq i32* null, %72
br i1 %73, label %74, label %78
74: ; preds = %51
%75 = load i32*, i32** @stderr
%76 = call i32 (i32*, i8*, ...) @fprintf(i32* %75, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.14, i64 0, i64 0))
%77 = call i32 @exit(i32 1)
unreachable
78: ; preds = %51
%79 = load i32*, i32** %12
%80 = call i32 (i32*, i8*, ...) @fprintf(i32* %79, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
%81 = load i32*, i32** %12
%82 = call i32 (i32*, i8*, ...) @fprintf(i32* %81, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.15, i64 0, i64 0))
%83 = load i32*, i32** %12
%84 = call i32 (i32*, i8*, ...) @fprintf(i32* %83, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.16, i64 0, i64 0))
%85 = load i32*, i32** %12
%86 = call i32 (i32*, i8*, ...) @fprintf(i32* %85, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.17, i64 0, i64 0))
store i32 0, i32* %7
br label %87
87: ; preds = %121, %78
%88 = load i32, i32* %7
%89 = load i32, i32* %9
%90 = icmp slt i32 %88, %89
br i1 %90, label %91, label %124
91: ; preds = %87
store i32 0, i32* %6
br label %92
92: ; preds = %107, %91
%93 = load i32, i32* %6
%94 = load i32, i32* %8
%95 = icmp slt i32 %93, %94
br i1 %95, label %96, label %110
96: ; preds = %92
%97 = call i32 @read(i32 0, i32* %10, i32 4)
%98 = icmp ne i32 4, %97
br i1 %98, label %99, label %103
99: ; preds = %96
%100 = load i32*, i32** @stderr
%101 = call i32 (i32*, i8*, ...) @fprintf(i32* %100, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.18, i64 0, i64 0))
%102 = call i32 @exit(i32 1)
unreachable
103: ; preds = %96
%104 = load i32*, i32** %12
%105 = load i32, i32* %10
%106 = call i32 (i32*, i8*, ...) @fprintf(i32* %104, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.19, i64 0, i64 0), i32 %105)
br label %107
107: ; preds = %103
%108 = load i32, i32* %6
%109 = add nsw i32 %108, 1
store i32 %109, i32* %6
br label %92
110: ; preds = %92
%111 = load i32*, i32** %12
%112 = call i32 (i32*, i8*, ...) @fprintf(i32* %111, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.20, i64 0, i64 0))
%113 = load i32, i32* %7
%114 = load i32, i32* %9
%115 = sub nsw i32 %114, 1
%116 = icmp ne i32 %113, %115
br i1 %116, label %117, label %120
117: ; preds = %110
%118 = load i32*, i32** %12
%119 = call i32 (i32*, i8*, ...) @fprintf(i32* %118, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.21, i64 0, i64 0))
br label %120
120: ; preds = %117, %110
br label %121
121: ; preds = %120
%122 = load i32, i32* %7
%123 = add nsw i32 %122, 1
store i32 %123, i32* %7
br label %87
124: ; preds = %87
%125 = load i32*, i32** %12
%126 = call i32 (i32*, i8*, ...) @fprintf(i32* %125, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.22, i64 0, i64 0))
%127 = load i32*, i32** %12
%128 = call i32 @fclose(i32* %127)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32* null
@.str = [27 x i8] c"Usage %s <width> <height>\0A\00"
@.str.1 = [57 x i8] c"Invalid map size %dx%d: Only multiples of 16x8 supported\00"
@.str.2 = [6 x i8] c"map.h\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [18 x i8] c"Can't open map.h\0A\00"
@.str.5 = [15 x i8] c"#ifndef MAP_H\0A\00"
@.str.6 = [17 x i8] c"#define MAP_H 1\0A\00"
@.str.7 = [21 x i8] c"#include \22common.h\22\0A\00"
@.str.8 = [22 x i8] c"#define MAP_WIDTH %d\0A\00"
@.str.9 = [23 x i8] c"#define MAP_HEIGHT %d\0A\00"
@.str.10 = [21 x i8] c"#define MAP_EMPTY 1\0A\00"
@.str.11 = [49 x i8] c"extern const uint8_t map[MAP_WIDTH*MAP_HEIGHT];\0A\00"
@.str.12 = [8 x i8] c"#endif\0A\00"
@.str.13 = [6 x i8] c"map.c\00"
@.str.14 = [18 x i8] c"Can't open map.c\0A\00"
@.str.15 = [19 x i8] c"#include \22map.h\22\0A\0A\00"
@.str.16 = [24 x i8] c"const uint8_t map[] = \0A\00"
@.str.17 = [4 x i8] c"{\0A\09\00"
@.str.18 = [13 x i8] c"Read failed\0A\00"
@.str.19 = [8 x i8] c"0x%02X,\00"
@.str.22 = [4 x i8] c"};\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = icmp slt i32 %0, 3
br i1 %5, label %6, label %11
6: ; preds = %2
%7 = load i32*, i32** @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = tail call i32 @atoi(i8* %16)
%18 = and i32 %14, 15
%19 = icmp eq i32 %18, 0
%20 = and i32 %17, 7
%21 = icmp eq i32 %20, 0
%22 = select i1 %19, i1 %21, i1 false
br i1 %22, label %27, label %23
23: ; preds = %11
%24 = load i32*, i32** @stderr
%25 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %24, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0), i32 %14, i32 %17)
%26 = tail call i32 @exit(i32 1)
unreachable
27: ; preds = %11
%28 = tail call i32* @fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%29 = icmp eq i32* %28, null
br i1 %29, label %30, label %34
30: ; preds = %27
%31 = load i32*, i32** @stderr
%32 = tail call i64 @fwrite(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i64 17, i64 1, i32* %31)
%33 = tail call i32 @exit(i32 1)
unreachable
34: ; preds = %27
%35 = tail call i64 @fwrite(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i64 14, i64 1, i32* %28)
%36 = tail call i64 @fwrite(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i64 16, i64 1, i32* %28)
%37 = tail call i64 @fwrite(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i64 20, i64 1, i32* %28)
%38 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %28, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i32 %14)
%39 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %28, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i32 %17)
%40 = tail call i64 @fwrite(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0), i64 20, i64 1, i32* %28)
%41 = tail call i64 @fwrite(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.11, i64 0, i64 0), i64 48, i64 1, i32* %28)
%42 = tail call i64 @fwrite(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0), i64 7, i64 1, i32* %28)
%43 = tail call i32 @fclose(i32* %28)
%44 = tail call i32* @fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%45 = icmp eq i32* %44, null
br i1 %45, label %46, label %50
46: ; preds = %34
%47 = load i32*, i32** @stderr
%48 = tail call i64 @fwrite(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.14, i64 0, i64 0), i64 17, i64 1, i32* %47)
%49 = tail call i32 @exit(i32 1)
unreachable
50: ; preds = %34
%51 = tail call i64 @fwrite(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i64 20, i64 1, i32* %44)
%52 = tail call i64 @fwrite(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.15, i64 0, i64 0), i64 18, i64 1, i32* %44)
%53 = tail call i64 @fwrite(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.16, i64 0, i64 0), i64 23, i64 1, i32* %44)
%54 = tail call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.17, i64 0, i64 0), i64 3, i64 1, i32* %44)
%55 = icmp sgt i32 %17, 0
br i1 %55, label %56, label %82
56: ; preds = %50
%57 = icmp sgt i32 %14, 0
%58 = add nsw i32 %17, -1
br label %59
59: ; preds = %56, %79
%60 = phi i32 [ 0, %56 ], [ %80, %79 ]
br i1 %57, label %61, label %74
61: ; preds = %59, %69
%62 = phi i32 [ %72, %69 ], [ 0, %59 ]
%63 = call i32 @read(i32 0, i32* %3, i32 4)
%64 = icmp eq i32 %63, 4
br i1 %64, label %69, label %65
65: ; preds = %61
%66 = load i32*, i32** @stderr
%67 = tail call i64 @fwrite(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.18, i64 0, i64 0), i64 12, i64 1, i32* %66)
%68 = tail call i32 @exit(i32 1)
unreachable
69: ; preds = %61
%70 = load i32, i32* %3
%71 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %44, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.19, i64 0, i64 0), i32 %70)
%72 = add nuw nsw i32 %62, 1
%73 = icmp eq i32 %72, %14
br i1 %73, label %74, label %61
74: ; preds = %69, %59
%75 = tail call i32 @fputc(i32 10, i32* %44)
%76 = icmp eq i32 %60, %58
br i1 %76, label %79, label %77
77: ; preds = %74
%78 = tail call i32 @fputc(i32 9, i32* %44)
br label %79
79: ; preds = %74, %77
%80 = add nuw nsw i32 %60, 1
%81 = icmp eq i32 %80, %17
br i1 %81, label %82, label %59
82: ; preds = %79, %50
%83 = tail call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.22, i64 0, i64 0), i64 3, i64 1, i32* %44)
%84 = tail call i32 @fclose(i32* %44)
ret i32 0
}