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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, long);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ nrerror(char *);
void write_usmatrix_T_number(ushort **m, long nrl, long nrh, long ncl, long nch,
                             char *format, char *filename) {
  long i, j;
  FILE *f;
  f = fopen(filename, "wt");
  if (f == NULL) {
    nrerror("Can't open file in write_usmatrix_T_number");
  }
  fprintf(f, "%5c", '#');
  for (i = nrl; i <= nrh; i++) {
    fprintf(f, format, i);
  }
  fputc('\n', f);
  for (j = ncl; j <= nch; j++) {
    fprintf(f, "[%3d]", j);
    for (i = nrl; i <= nrh; i++) {
      fprintf(f, format, m[i][j]);
    }
    fputc('\n', f);
  }
  fclose(f);
}


x86 assembly (clang, -O0):
<write_usmatrix_T_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
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)
mov    0x10(%rbp),%rdi
lea    0xe81(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    119f <write_usmatrix_T_number+0x4f>
lea    0xe69(%rip),%rdi
call   1030 <nrerror@plt>
mov    -0x48(%rbp),%rdi
lea    0xe84(%rip),%rsi
mov    $0x23,%edx
call   1060 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x18(%rbp),%rax
jg     11ec <write_usmatrix_T_number+0x9c>
mov    -0x48(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
call   1060 <fprintf@plt>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    11bc <write_usmatrix_T_number+0x6c>
mov    -0x48(%rbp),%rsi
mov    $0xa,%edi
call   1050 <fputc@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
cmp    -0x28(%rbp),%rax
jg     128b <write_usmatrix_T_number+0x13b>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rdx
lea    0xe13(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x18(%rbp),%rax
jg     126c <write_usmatrix_T_number+0x11c>
mov    -0x48(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x8(%rbp),%rax
mov    -0x38(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x40(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
call   1060 <fprintf@plt>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    122c <write_usmatrix_T_number+0xdc>
mov    -0x48(%rbp),%rsi
mov    $0xa,%edi
call   1050 <fputc@plt>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    1202 <write_usmatrix_T_number+0xb2>
mov    -0x48(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_usmatrix_T_number>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9,%r12
mov    %r8,0x18(%rsp)
mov    %rcx,%r15
mov    %rdx,%rbx
mov    %rsi,%rbp
mov    %rdi,0x20(%rsp)
mov    0x60(%rsp),%rdi
lea    0xe80(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
jne    1199 <write_usmatrix_T_number+0x49>
lea    0xe6f(%rip),%rdi
call   1030 <nrerror@plt>
lea    0xe8e(%rip),%rsi
mov    $0x23,%edx
mov    %r14,%rdi
call   1060 <fprintf@plt>
mov    %rbx,0x8(%rsp)
mov    %rbp,0x10(%rsp)
cmp    %rbx,%rbp
jg     11e7 <write_usmatrix_T_number+0x97>
mov    0x8(%rsp),%rax
lea    0x1(%rax),%rbx
mov    0x10(%rsp),%r13
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1060 <fprintf@plt>
add    $0x1,%r13
cmp    %r13,%rbx
jne    11d0 <write_usmatrix_T_number+0x80>
mov    $0xa,%edi
mov    %r14,%rsi
call   1050 <fputc@plt>
cmp    0x18(%rsp),%r15
jle    1211 <write_usmatrix_T_number+0xc1>
mov    %r14,%rdi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fclose@plt>
mov    0x8(%rsp),%rax
lea    0x1(%rax),%rbp
mov    0x20(%rsp),%r13
jmp    124b <write_usmatrix_T_number+0xfb>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
mov    %r14,%rsi
call   1050 <fputc@plt>
lea    0x1(%r15),%rax
cmp    0x18(%rsp),%r15
mov    %rax,%r15
je     11fb <write_usmatrix_T_number+0xab>
mov    %r14,%rdi
lea    0xddd(%rip),%rsi
mov    %r15,%rdx
call   1060 <fprintf@plt>
mov    0x10(%rsp),%rax
cmp    0x8(%rsp),%rax
jg     1230 <write_usmatrix_T_number+0xe0>
mov    0x10(%rsp),%rbx
xchg   %ax,%ax
mov    0x0(%r13,%rbx,8),%rax
mov    (%rax,%r15,8),%rdx
mov    %r14,%rdi
mov    %r12,%rsi
call   1060 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1270 <write_usmatrix_T_number+0x120>
jmp    1230 <write_usmatrix_T_number+0xe0>

LLVM IR (-O0):
@.str = [3 x i8] c"wt\00"
@.str.1 = [43 x i8] c"Can't open file in write_usmatrix_T_number\00"
@.str.2 = [4 x i8] c"%5c\00"
@.str.3 = [6 x i8] c"[%3d]\00"
define void @write_usmatrix_T_number(i64** %0, i64 %1, i64 %2, i64 %3, i64 %4, i8* %5, i8* %6) {
%8 = alloca i64**
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i64
%16 = alloca i64
%17 = alloca i32*
store i64** %0, i64*** %8
store i64 %1, i64* %9
store i64 %2, i64* %10
store i64 %3, i64* %11
store i64 %4, i64* %12
store i8* %5, i8** %13
store i8* %6, i8** %14
%18 = load i8*, i8** %14
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %19, i32** %17
%20 = load i32*, i32** %17
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %24
22: ; preds = %7
%23 = call i32 @nrerror(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %22, %7
%25 = load i32*, i32** %17
%26 = call i32 @fprintf(i32* %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64 35)
%27 = load i64, i64* %9
store i64 %27, i64* %15
br label %28
28: ; preds = %37, %24
%29 = load i64, i64* %15
%30 = load i64, i64* %10
%31 = icmp sle i64 %29, %30
br i1 %31, label %32, label %40
32: ; preds = %28
%33 = load i32*, i32** %17
%34 = load i8*, i8** %13
%35 = load i64, i64* %15
%36 = call i32 @fprintf(i32* %33, i8* %34, i64 %35)
br label %37
37: ; preds = %32
%38 = load i64, i64* %15
%39 = add nsw i64 %38, 1
store i64 %39, i64* %15
br label %28
40: ; preds = %28
%41 = load i32*, i32** %17
%42 = call i32 @fputc(i8 signext 10, i32* %41)
%43 = load i64, i64* %11
store i64 %43, i64* %16
br label %44
44: ; preds = %74, %40
%45 = load i64, i64* %16
%46 = load i64, i64* %12
%47 = icmp sle i64 %45, %46
br i1 %47, label %48, label %77
48: ; preds = %44
%49 = load i32*, i32** %17
%50 = load i64, i64* %16
%51 = call i32 @fprintf(i32* %49, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i64 %50)
%52 = load i64, i64* %9
store i64 %52, i64* %15
br label %53
53: ; preds = %68, %48
%54 = load i64, i64* %15
%55 = load i64, i64* %10
%56 = icmp sle i64 %54, %55
br i1 %56, label %57, label %71
57: ; preds = %53
%58 = load i32*, i32** %17
%59 = load i8*, i8** %13
%60 = load i64**, i64*** %8
%61 = load i64, i64* %15
%62 = getelementptr inbounds i64*, i64** %60, i64 %61
%63 = load i64*, i64** %62
%64 = load i64, i64* %16
%65 = getelementptr inbounds i64, i64* %63, i64 %64
%66 = load i64, i64* %65
%67 = call i32 @fprintf(i32* %58, i8* %59, i64 %66)
br label %68
68: ; preds = %57
%69 = load i64, i64* %15
%70 = add nsw i64 %69, 1
store i64 %70, i64* %15
br label %53
71: ; preds = %53
%72 = load i32*, i32** %17
%73 = call i32 @fputc(i8 signext 10, i32* %72)
br label %74
74: ; preds = %71
%75 = load i64, i64* %16
%76 = add nsw i64 %75, 1
store i64 %76, i64* %16
br label %44
77: ; preds = %44
%78 = load i32*, i32** %17
%79 = call i32 @fclose(i32* %78)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"wt\00"
@.str.1 = [43 x i8] c"Can't open file in write_usmatrix_T_number\00"
@.str.2 = [4 x i8] c"%5c\00"
@.str.3 = [6 x i8] c"[%3d]\00"
define void @write_usmatrix_T_number(i64** nocapture %0, i64 %1, i64 %2, i64 %3, i64 %4, i8* nocapture %5, i8* nocapture %6) {
%8 = tail call i32* @fopen(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = tail call i32 @nrerror(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %10, %7
%13 = tail call i32 @fprintf(i32* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64 35)
%14 = icmp sgt i64 %1, %2
br i1 %14, label %20, label %15
15: ; preds = %12, %15
%16 = phi i64 [ %18, %15 ], [ %1, %12 ]
%17 = tail call i32 @fprintf(i32* %8, i8* %5, i64 %16)
%18 = add i64 %16, 1
%19 = icmp eq i64 %16, %2
br i1 %19, label %20, label %15
20: ; preds = %15, %12
%21 = tail call i32 @fputc(i8 signext 10, i32* %8)
%22 = icmp sgt i64 %3, %4
br i1 %22, label %39, label %23
23: ; preds = %20, %35
%24 = phi i64 [ %37, %35 ], [ %3, %20 ]
%25 = tail call i32 @fprintf(i32* %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i64 %24)
br i1 %14, label %35, label %26
26: ; preds = %23, %26
%27 = phi i64 [ %33, %26 ], [ %1, %23 ]
%28 = getelementptr inbounds i64*, i64** %0, i64 %27
%29 = load i64*, i64** %28
%30 = getelementptr inbounds i64, i64* %29, i64 %24
%31 = load i64, i64* %30
%32 = tail call i32 @fprintf(i32* %8, i8* %5, i64 %31)
%33 = add i64 %27, 1
%34 = icmp eq i64 %27, %2
br i1 %34, label %35, label %26
35: ; preds = %26, %23
%36 = tail call i32 @fputc(i8 signext 10, i32* %8)
%37 = add i64 %24, 1
%38 = icmp eq i64 %24, %4
br i1 %38, label %39, label %23
39: ; preds = %35, %20
%40 = tail call i32 @fclose(i32* %8)
ret void
}