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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ nrerror(char *);
void write_usmatrix_T(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");
  }
  for (j = ncl; j <= nch; 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>:
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+0x4f>
lea    0xe69(%rip),%rdi
call   1030 <nrerror@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
cmp    -0x28(%rbp),%rax
jg     121b <write_usmatrix_T+0xcb>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x18(%rbp),%rax
jg     11fc <write_usmatrix_T+0xac>
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,4),%edx
call   1060 <fprintf@plt>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    11bd <write_usmatrix_T+0x6d>
mov    -0x48(%rbp),%rsi
mov    $0xa,%edi
call   1050 <fputc@plt>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    11a7 <write_usmatrix_T+0x57>
mov    -0x48(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_usmatrix_T>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,%r12
mov    %r8,%r13
mov    %rcx,%rbx
mov    %rdx,(%rsp)
mov    %rsi,0x8(%rsp)
mov    %rdi,%rbp
mov    0x50(%rsp),%rdi
lea    0xe81(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r15
test   %rax,%rax
je     1193 <write_usmatrix_T+0x43>
cmp    %r13,%rbx
jg     11a4 <write_usmatrix_T+0x54>
jmp    11ba <write_usmatrix_T+0x6a>
lea    0xe69(%rip),%rdi
call   1030 <nrerror@plt>
cmp    %r13,%rbx
jle    11ba <write_usmatrix_T+0x6a>
mov    %r15,%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fclose@plt>
mov    (%rsp),%rax
lea    0x1(%rax),%r14
mov    %r13,0x10(%rsp)
jmp    11ee <write_usmatrix_T+0x9e>
nopl   0x0(%rax)
mov    $0xa,%edi
mov    %r15,%rsi
call   1050 <fputc@plt>
lea    0x1(%rbx),%rax
mov    0x10(%rsp),%r13
cmp    %r13,%rbx
mov    %rax,%rbx
je     11a4 <write_usmatrix_T+0x54>
mov    0x8(%rsp),%rax
cmp    (%rsp),%rax
jg     11d0 <write_usmatrix_T+0x80>
mov    0x8(%rsp),%r13
xchg   %ax,%ax
mov    0x0(%rbp,%r13,8),%rax
mov    (%rax,%rbx,4),%edx
mov    %r15,%rdi
mov    %r12,%rsi
call   1060 <fprintf@plt>
add    $0x1,%r13
cmp    %r13,%r14
jne    1200 <write_usmatrix_T+0xb0>
jmp    11d0 <write_usmatrix_T+0x80>

LLVM IR (-O0):
@.str = [3 x i8] c"wt\00"
@.str.1 = [36 x i8] c"Can't open file in write_usmatrix_T\00"
define void @write_usmatrix_T(i32** %0, i64 %1, i64 %2, i64 %3, i64 %4, i8* %5, i8* %6) {
%8 = alloca i32**
%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 i32** %0, i32*** %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 ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %22, %7
%25 = load i64, i64* %11
store i64 %25, i64* %16
br label %26
26: ; preds = %53, %24
%27 = load i64, i64* %16
%28 = load i64, i64* %12
%29 = icmp sle i64 %27, %28
br i1 %29, label %30, label %56
30: ; preds = %26
%31 = load i64, i64* %9
store i64 %31, i64* %15
br label %32
32: ; preds = %47, %30
%33 = load i64, i64* %15
%34 = load i64, i64* %10
%35 = icmp sle i64 %33, %34
br i1 %35, label %36, label %50
36: ; preds = %32
%37 = load i32*, i32** %17
%38 = load i8*, i8** %13
%39 = load i32**, i32*** %8
%40 = load i64, i64* %15
%41 = getelementptr inbounds i32*, i32** %39, i64 %40
%42 = load i32*, i32** %41
%43 = load i64, i64* %16
%44 = getelementptr inbounds i32, i32* %42, i64 %43
%45 = load i32, i32* %44
%46 = call i32 @fprintf(i32* %37, i8* %38, i32 %45)
br label %47
47: ; preds = %36
%48 = load i64, i64* %15
%49 = add nsw i64 %48, 1
store i64 %49, i64* %15
br label %32
50: ; preds = %32
%51 = load i32*, i32** %17
%52 = call i32 @fputc(i8 signext 10, i32* %51)
br label %53
53: ; preds = %50
%54 = load i64, i64* %16
%55 = add nsw i64 %54, 1
store i64 %55, i64* %16
br label %26
56: ; preds = %26
%57 = load i32*, i32** %17
%58 = call i32 @fclose(i32* %57)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"wt\00"
@.str.1 = [36 x i8] c"Can't open file in write_usmatrix_T\00"
define void @write_usmatrix_T(i32** 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 ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %10, %7
%13 = icmp sgt i64 %3, %4
br i1 %13, label %31, label %14
14: ; preds = %12
%15 = icmp sgt i64 %1, %2
br label %16
16: ; preds = %14, %27
%17 = phi i64 [ %3, %14 ], [ %29, %27 ]
br i1 %15, label %27, label %18
18: ; preds = %16, %18
%19 = phi i64 [ %25, %18 ], [ %1, %16 ]
%20 = getelementptr inbounds i32*, i32** %0, i64 %19
%21 = load i32*, i32** %20
%22 = getelementptr inbounds i32, i32* %21, i64 %17
%23 = load i32, i32* %22
%24 = tail call i32 @fprintf(i32* %8, i8* %5, i32 %23)
%25 = add i64 %19, 1
%26 = icmp eq i64 %19, %2
br i1 %26, label %27, label %18
27: ; preds = %18, %16
%28 = tail call i32 @fputc(i8 signext 10, i32* %8)
%29 = add i64 %17, 1
%30 = icmp eq i64 %17, %4
br i1 %30, label %31, label %16
31: ; preds = %27, %12
%32 = tail call i32 @fclose(i32* %8)
ret void
}