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

/* Forward declarations */

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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ put_name(int /*<<< orphan*/ *, char *, int);
void write_as_matrix(char **file, char *x, int *N, int *M, char **rnames,
                     char **cnames, int *asalleles, int *append, int *quote,
                     char **sep, char **eol, char **na, int *row_names,
                     int *col_names, int *iferror) {
  int zerom = (int)'0' - 1;
  int nrow = *N;
  int ncol = *M;
  FILE *outfile;
  int i = 0, j = 0, ij = 0;
  if (*append)
    outfile = fopen(*file, "a");
  else
    outfile = fopen(*file, "w");
  if (!outfile) {
    *iferror = 1;
    return;
  }
  if (*col_names) {
    for (i = 0; i < ncol; i++) {
      if (i)
        fputs(*sep, outfile);
      put_name(outfile, cnames[i], *quote);
    }
    fputs(*eol, outfile);
  }
  for (i = 0; i < nrow; i++) {
    if (*row_names) {
      put_name(outfile, rnames[i], *quote);
      fputs(*sep, outfile);
    }
    for (j = 0, ij = i; j < ncol; j++, ij += nrow) {
      if (j)
        fputs(*sep, outfile);
      int g = (int)x[ij];
      if (*asalleles) {
        if (!g) {
          fputs(*na, outfile);
          fputs(*sep, outfile);
          fputs(*na, outfile);
        } else {
          fputc(g < 3 ? '1' : '2', outfile);
          fputs(*sep, outfile);
          fputc(g < 2 ? '1' : '2', outfile);
        }
      } else {
        if (!g)
          fputs(*na, outfile);
        else {
          g += zerom;
          fputc((char)g, outfile);
        }
      }
    }
    fputs(*eol, outfile);
  }
  fclose(outfile);
  *iferror = 0;
  return;
}


x86 assembly (clang, -O0):
<write_as_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x50(%rbp),%rax
mov    0x48(%rbp),%rax
mov    0x40(%rbp),%rax
mov    0x38(%rbp),%rax
mov    0x30(%rbp),%rax
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movl   $0x2f,-0x34(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
movl   $0x0,-0x4c(%rbp)
movl   $0x0,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
mov    0x18(%rbp),%rax
cmpl   $0x0,(%rax)
je     11eb <write_as_matrix+0x9b>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
lea    0xe23(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x48(%rbp)
jmp    1202 <write_as_matrix+0xb2>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
lea    0xe09(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    121c <write_as_matrix+0xcc>
mov    0x50(%rbp),%rax
movl   $0x1,(%rax)
jmp    1444 <write_as_matrix+0x2f4>
mov    0x48(%rbp),%rax
cmpl   $0x0,(%rax)
je     128f <write_as_matrix+0x13f>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    127f <write_as_matrix+0x12f>
cmpl   $0x0,-0x4c(%rbp)
je     1256 <write_as_matrix+0x106>
mov    0x28(%rbp),%rax
mov    (%rax),%rdi
mov    -0x48(%rbp),%rsi
call   1040 <fputs@plt>
mov    -0x48(%rbp),%rdi
mov    -0x30(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    0x20(%rbp),%rax
mov    (%rax),%edx
call   1060 <put_name@plt>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1230 <write_as_matrix+0xe0>
mov    0x30(%rbp),%rax
mov    (%rax),%rdi
mov    -0x48(%rbp),%rsi
call   1040 <fputs@plt>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x38(%rbp),%eax
jge    1431 <write_as_matrix+0x2e1>
mov    0x40(%rbp),%rax
cmpl   $0x0,(%rax)
je     12da <write_as_matrix+0x18a>
mov    -0x48(%rbp),%rdi
mov    -0x28(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    0x20(%rbp),%rax
mov    (%rax),%edx
call   1060 <put_name@plt>
mov    0x28(%rbp),%rax
mov    (%rax),%rdi
mov    -0x48(%rbp),%rsi
call   1040 <fputs@plt>
movl   $0x0,-0x50(%rbp)
mov    -0x4c(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    1413 <write_as_matrix+0x2c3>
cmpl   $0x0,-0x50(%rbp)
je     130d <write_as_matrix+0x1bd>
mov    0x28(%rbp),%rax
mov    (%rax),%rdi
mov    -0x48(%rbp),%rsi
call   1040 <fputs@plt>
mov    -0x10(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x58(%rbp)
mov    0x10(%rbp),%rax
cmpl   $0x0,(%rax)
je     13bb <write_as_matrix+0x26b>
cmpl   $0x0,-0x58(%rbp)
jne    1368 <write_as_matrix+0x218>
mov    0x38(%rbp),%rax
mov    (%rax),%rdi
mov    -0x48(%rbp),%rsi
call   1040 <fputs@plt>
mov    0x28(%rbp),%rax
mov    (%rax),%rdi
mov    -0x48(%rbp),%rsi
call   1040 <fputs@plt>
mov    0x38(%rbp),%rax
mov    (%rax),%rdi
mov    -0x48(%rbp),%rsi
call   1040 <fputs@plt>
jmp    13b6 <write_as_matrix+0x266>
mov    -0x58(%rbp),%edx
mov    $0x32,%eax
mov    $0x31,%ecx
cmp    $0x3,%edx
cmovl  %ecx,%eax
mov    -0x48(%rbp),%rsi
movsbl %al,%edi
call   1050 <fputc@plt>
mov    0x28(%rbp),%rax
mov    (%rax),%rdi
mov    -0x48(%rbp),%rsi
call   1040 <fputs@plt>
mov    -0x58(%rbp),%edx
mov    $0x32,%eax
mov    $0x31,%ecx
cmp    $0x2,%edx
cmovl  %ecx,%eax
mov    -0x48(%rbp),%rsi
movsbl %al,%edi
call   1050 <fputc@plt>
jmp    13f7 <write_as_matrix+0x2a7>
cmpl   $0x0,-0x58(%rbp)
jne    13da <write_as_matrix+0x28a>
mov    0x38(%rbp),%rax
mov    (%rax),%rdi
mov    -0x48(%rbp),%rsi
call   1040 <fputs@plt>
jmp    13f2 <write_as_matrix+0x2a2>
mov    -0x34(%rbp),%eax
add    -0x58(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    -0x58(%rbp),%eax
mov    -0x48(%rbp),%rsi
movsbl %al,%edi
call   1050 <fputc@plt>
jmp    13f7 <write_as_matrix+0x2a7>
jmp    13fc <write_as_matrix+0x2ac>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
mov    -0x38(%rbp),%eax
add    -0x54(%rbp),%eax
mov    %eax,-0x54(%rbp)
jmp    12e7 <write_as_matrix+0x197>
mov    0x30(%rbp),%rax
mov    (%rax),%rdi
mov    -0x48(%rbp),%rsi
call   1040 <fputs@plt>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1296 <write_as_matrix+0x146>
mov    -0x48(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x50(%rbp),%rax
movl   $0x0,(%rax)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_as_matrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r9,%r14
mov    %r8,0x30(%rsp)
mov    %rsi,0x18(%rsp)
mov    0xb0(%rsp),%rbp
mov    0x78(%rsp),%rax
mov    (%rdx),%ebx
mov    (%rcx),%r15d
cmpl   $0x0,(%rax)
mov    (%rdi),%rdi
lea    0xe78(%rip),%rax
lea    0xe6f(%rip),%rsi
cmove  %rax,%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     149b <write_as_matrix+0x34b>
mov    %rax,%r12
mov    0xa8(%rsp),%rax
mov    0x80(%rsp),%rcx
cmpl   $0x0,(%rax)
mov    %rbx,0x8(%rsp)
je     122e <write_as_matrix+0xde>
test   %r15d,%r15d
mov    %rcx,%rbx
mov    0x88(%rsp),%r13
jle    1213 <write_as_matrix+0xc3>
mov    (%r14),%rsi
mov    (%rbx),%edx
mov    %r12,%rdi
call   1060 <put_name@plt>
cmp    $0x1,%r15d
je     1213 <write_as_matrix+0xc3>
mov    $0x1,%ebp
nopl   0x0(%rax,%rax,1)
mov    0x0(%r13),%rdi
mov    %r12,%rsi
call   1040 <fputs@plt>
mov    (%r14,%rbp,8),%rsi
mov    (%rbx),%edx
mov    %r12,%rdi
call   1060 <put_name@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
jne    11f0 <write_as_matrix+0xa0>
mov    0x90(%rsp),%rax
mov    (%rax),%rdi
mov    %r12,%rsi
call   1040 <fputs@plt>
mov    %rbx,%rcx
mov    0x8(%rsp),%rbx
test   %ebx,%ebx
mov    0x88(%rsp),%rbp
jle    1487 <write_as_matrix+0x337>
mov    0x18(%rsp),%rax
mov    0x8(%rsp),%rdx
add    %rdx,%rax
mov    %rax,0x20(%rsp)
lea    -0x1(%r15),%eax
mov    %eax,0x14(%rsp)
xor    %ebx,%ebx
mov    %r15,(%rsp)
jmp    129a <write_as_matrix+0x14a>
mov    0x90(%rsp),%rax
mov    (%rax),%rdi
mov    %r12,%rsi
call   1040 <fputs@plt>
mov    %rbx,%rax
mov    0x28(%rsp),%rbx
add    $0x1,%rbx
addq   $0x1,0x20(%rsp)
cmp    %rax,%rbx
mov    (%rsp),%r15
mov    0x80(%rsp),%rcx
je     1487 <write_as_matrix+0x337>
mov    0xa0(%rsp),%rax
cmpl   $0x0,(%rax)
je     12c6 <write_as_matrix+0x176>
mov    0x30(%rsp),%rax
mov    (%rax,%rbx,8),%rsi
mov    (%rcx),%edx
mov    %r12,%rdi
call   1060 <put_name@plt>
mov    0x0(%rbp),%rdi
mov    %r12,%rsi
call   1040 <fputs@plt>
mov    %rbx,0x28(%rsp)
test   %r15d,%r15d
mov    0x8(%rsp),%rbx
jle    1260 <write_as_matrix+0x110>
mov    0x18(%rsp),%rax
mov    0x28(%rsp),%rcx
mov    (%rax,%rcx,1),%r15b
mov    0x70(%rsp),%rax
cmpl   $0x0,(%rax)
je     1330 <write_as_matrix+0x1e0>
test   %r15b,%r15b
je     1347 <write_as_matrix+0x1f7>
xor    %eax,%eax
cmp    $0x3,%r15b
setl   %al
mov    $0x32,%edi
sub    %eax,%edi
mov    %r12,%rsi
call   1050 <fputc@plt>
mov    0x0(%rbp),%rdi
mov    %r12,%rsi
call   1040 <fputs@plt>
xor    %eax,%eax
cmp    $0x2,%r15b
setl   %al
mov    $0x32,%edi
sub    %eax,%edi
jmp    133d <write_as_matrix+0x1ed>
nopl   0x0(%rax,%rax,1)
test   %r15b,%r15b
je     136b <write_as_matrix+0x21b>
add    $0x2f,%r15b
movsbl %r15b,%edi
mov    %r12,%rsi
call   1050 <fputc@plt>
jmp    137e <write_as_matrix+0x22e>
mov    0x98(%rsp),%r14
mov    (%r14),%rdi
mov    %r12,%rsi
call   1040 <fputs@plt>
mov    0x0(%rbp),%rdi
mov    %r12,%rsi
call   1040 <fputs@plt>
mov    (%r14),%rdi
jmp    1376 <write_as_matrix+0x226>
mov    0x98(%rsp),%rax
mov    (%rax),%rdi
mov    %r12,%rsi
call   1040 <fputs@plt>
mov    (%rsp),%rax
cmp    $0x1,%eax
je     1260 <write_as_matrix+0x110>
mov    0x14(%rsp),%r15d
mov    0x20(%rsp),%r13
jmp    13f1 <write_as_matrix+0x2a1>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
cmp    $0x3,%r14b
setl   %al
mov    $0x32,%edi
sub    %eax,%edi
mov    %r12,%rsi
call   1050 <fputc@plt>
mov    0x88(%rsp),%rbp
mov    0x0(%rbp),%rdi
mov    %r12,%rsi
call   1040 <fputs@plt>
xor    %eax,%eax
cmp    $0x2,%r14b
setl   %al
mov    $0x32,%edi
sub    %eax,%edi
mov    %r12,%rsi
call   1050 <fputc@plt>
add    %rbx,%r13
add    $0xffffffff,%r15d
je     1260 <write_as_matrix+0x110>
mov    0x0(%rbp),%rdi
mov    %r12,%rsi
call   1040 <fputs@plt>
movzbl 0x0(%r13),%r14d
mov    0x70(%rsp),%rax
cmpl   $0x0,(%rax)
je     1450 <write_as_matrix+0x300>
test   %r14b,%r14b
jne    13a0 <write_as_matrix+0x250>
mov    0x98(%rsp),%r14
mov    (%r14),%rdi
mov    %r12,%rsi
call   1040 <fputs@plt>
mov    0x88(%rsp),%rbp
mov    0x0(%rbp),%rdi
mov    %r12,%rsi
call   1040 <fputs@plt>
mov    (%r14),%rdi
mov    %r12,%rsi
call   1040 <fputs@plt>
jmp    13e4 <write_as_matrix+0x294>
cs nopw 0x0(%rax,%rax,1)
nop
test   %r14b,%r14b
je     1467 <write_as_matrix+0x317>
add    $0x2f,%r14b
movsbl %r14b,%edi
mov    %r12,%rsi
call   1050 <fputc@plt>
jmp    147a <write_as_matrix+0x32a>
mov    0x98(%rsp),%rax
mov    (%rax),%rdi
mov    %r12,%rsi
call   1040 <fputs@plt>
mov    0x88(%rsp),%rbp
jmp    13e4 <write_as_matrix+0x294>
mov    %r12,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
mov    0xb0(%rsp),%rbp
jmp    14a0 <write_as_matrix+0x350>
mov    $0x1,%eax
mov    %eax,0x0(%rbp)
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"a\00"
@.str.1 = [2 x i8] c"w\00"
define void @write_as_matrix(i8** nocapture %0, i8* nocapture %1, i32* nocapture %2, i32* nocapture %3, i8** nocapture %4, i8** nocapture %5, i32* nocapture %6, i32* nocapture %7, i32* nocapture %8, i8** nocapture %9, i8** nocapture %10, i8** nocapture %11, i32* nocapture %12, i32* nocapture %13, i32* nocapture writeonly %14) {
%16 = load i32, i32* %2
%17 = load i32, i32* %3
%18 = load i32, i32* %7
%19 = icmp eq i32 %18, 0
%20 = load i8*, i8** %0
%21 = select i1 %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0)
%22 = tail call i32* @fopen(i8* %20, i8* %21)
%23 = icmp eq i32* %22, null
br i1 %23, label %143, label %24
24: ; preds = %15
%25 = load i32, i32* %13
%26 = icmp eq i32 %25, 0
br i1 %26, label %48, label %27
27: ; preds = %24
%28 = icmp sgt i32 %17, 0
br i1 %28, label %29, label %45
29: ; preds = %27
%30 = zext i32 %17 to i64
%31 = load i8*, i8** %5
%32 = load i32, i32* %8
%33 = tail call i32 @put_name(i32* %22, i8* %31, i32 %32)
%34 = icmp eq i32 %17, 1
br i1 %34, label %45, label %35
35: ; preds = %29, %35
%36 = phi i64 [ %43, %35 ], [ 1, %29 ]
%37 = load i8*, i8** %9
%38 = tail call i32 @fputs(i8* %37, i32* %22)
%39 = getelementptr inbounds i8*, i8** %5, i64 %36
%40 = load i8*, i8** %39
%41 = load i32, i32* %8
%42 = tail call i32 @put_name(i32* %22, i8* %40, i32 %41)
%43 = add nuw nsw i64 %36, 1
%44 = icmp eq i64 %43, %30
br i1 %44, label %45, label %35
45: ; preds = %35, %29, %27
%46 = load i8*, i8** %10
%47 = tail call i32 @fputs(i8* %46, i32* %22)
br label %48
48: ; preds = %45, %24
%49 = icmp sgt i32 %16, 0
br i1 %49, label %50, label %141
50: ; preds = %48
%51 = icmp sgt i32 %17, 0
%52 = zext i32 %16 to i64
%53 = zext i32 %16 to i64
%54 = icmp eq i32 %17, 1
br label %55
55: ; preds = %50, %136
%56 = phi i64 [ 0, %50 ], [ %139, %136 ]
%57 = load i32, i32* %12
%58 = icmp eq i32 %57, 0
br i1 %58, label %66, label %59
59: ; preds = %55
%60 = getelementptr inbounds i8*, i8** %4, i64 %56
%61 = load i8*, i8** %60
%62 = load i32, i32* %8
%63 = tail call i32 @put_name(i32* %22, i8* %61, i32 %62)
%64 = load i8*, i8** %9
%65 = tail call i32 @fputs(i8* %64, i32* %22)
br label %66
66: ; preds = %59, %55
br i1 %51, label %67, label %136
67: ; preds = %66
%68 = getelementptr inbounds i8, i8* %1, i64 %56
%69 = load i8, i8* %68
%70 = load i32, i32* %6
%71 = icmp eq i32 %70, 0
%72 = icmp eq i8 %69, 0
br i1 %71, label %90, label %73
73: ; preds = %67
br i1 %72, label %83, label %74
74: ; preds = %73
%75 = icmp slt i8 %69, 3
%76 = select i1 %75, i8 49, i8 50
%77 = tail call i32 @fputc(i8 signext %76, i32* %22)
%78 = load i8*, i8** %9
%79 = tail call i32 @fputs(i8* %78, i32* %22)
%80 = icmp slt i8 %69, 2
%81 = select i1 %80, i8 49, i8 50
%82 = tail call i32 @fputc(i8 signext %81, i32* %22)
br label %97
83: ; preds = %73
%84 = load i8*, i8** %11
%85 = tail call i32 @fputs(i8* %84, i32* %22)
%86 = load i8*, i8** %9
%87 = tail call i32 @fputs(i8* %86, i32* %22)
%88 = load i8*, i8** %11
%89 = tail call i32 @fputs(i8* %88, i32* %22)
br label %97
90: ; preds = %67
br i1 %72, label %94, label %91
91: ; preds = %90
%92 = add i8 %69, 47
%93 = tail call i32 @fputc(i8 signext %92, i32* %22)
br label %97
94: ; preds = %90
%95 = load i8*, i8** %11
%96 = tail call i32 @fputs(i8* %95, i32* %22)
br label %97
97: ; preds = %94, %91, %83, %74
br i1 %54, label %136, label %98
98: ; preds = %97, %133
%99 = phi i64 [ %101, %133 ], [ %56, %97 ]
%100 = phi i32 [ %134, %133 ], [ 1, %97 ]
%101 = add nuw nsw i64 %99, %52
%102 = load i8*, i8** %9
%103 = tail call i32 @fputs(i8* %102, i32* %22)
%104 = getelementptr inbounds i8, i8* %1, i64 %101
%105 = load i8, i8* %104
%106 = load i32, i32* %6
%107 = icmp eq i32 %106, 0
%108 = icmp eq i8 %105, 0
br i1 %107, label %126, label %109
109: ; preds = %98
br i1 %108, label %110, label %117
110: ; preds = %109
%111 = load i8*, i8** %11
%112 = tail call i32 @fputs(i8* %111, i32* %22)
%113 = load i8*, i8** %9
%114 = tail call i32 @fputs(i8* %113, i32* %22)
%115 = load i8*, i8** %11
%116 = tail call i32 @fputs(i8* %115, i32* %22)
br label %133
117: ; preds = %109
%118 = icmp slt i8 %105, 3
%119 = select i1 %118, i8 49, i8 50
%120 = tail call i32 @fputc(i8 signext %119, i32* %22)
%121 = load i8*, i8** %9
%122 = tail call i32 @fputs(i8* %121, i32* %22)
%123 = icmp slt i8 %105, 2
%124 = select i1 %123, i8 49, i8 50
%125 = tail call i32 @fputc(i8 signext %124, i32* %22)
br label %133
126: ; preds = %98
br i1 %108, label %127, label %130
127: ; preds = %126
%128 = load i8*, i8** %11
%129 = tail call i32 @fputs(i8* %128, i32* %22)
br label %133
130: ; preds = %126
%131 = add i8 %105, 47
%132 = tail call i32 @fputc(i8 signext %131, i32* %22)
br label %133
133: ; preds = %127, %130, %110, %117
%134 = add nuw nsw i32 %100, 1
%135 = icmp eq i32 %134, %17
br i1 %135, label %136, label %98
136: ; preds = %133, %97, %66
%137 = load i8*, i8** %10
%138 = tail call i32 @fputs(i8* %137, i32* %22)
%139 = add nuw nsw i64 %56, 1
%140 = icmp eq i64 %139, %53
br i1 %140, label %141, label %55
141: ; preds = %136, %48
%142 = tail call i32 @fclose(i32* %22)
br label %143
143: ; preds = %15, %141
%144 = phi i32 [ 0, %141 ], [ 1, %15 ]
store i32 %144, i32* %14
ret void
}