#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*/ fprintf(int /*<<< orphan*/ *, char *, double);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ nrerror(char *);
void write_dmatrix_number(double **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_dmatrix_number");
  }
  fprintf(f, "%4d", 0);
  for (j = ncl; j <= nch; j++) {
    fprintf(f, format, (float)j);
  }
  fputc('\n', f);
  for (i = nrl; i <= nrh; i++) {
    fprintf(f, "%4d", i);
    for (j = ncl; j <= nch; j++) {
      fprintf(f, format, m[i][j]);
    }
    fputc('\n', f);
  }
  fclose(f);
}


x86 assembly (clang, -O0):
<write_dmatrix_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_dmatrix_number+0x4f>
lea    0xe69(%rip),%rdi
call   1030 <nrerror@plt>
mov    -0x48(%rbp),%rdi
lea    0xe81(%rip),%rsi
xorps  %xmm0,%xmm0
call   1060 <fprintf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
cmp    -0x28(%rbp),%rax
jg     11f0 <write_dmatrix_number+0xa0>
mov    -0x48(%rbp),%rdi
mov    -0x30(%rbp),%rsi
cvtsi2ssq -0x40(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
call   1060 <fprintf@plt>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    11ba <write_dmatrix_number+0x6a>
mov    -0x48(%rbp),%rsi
mov    $0xa,%edi
call   1050 <fputc@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x18(%rbp),%rax
jg     1292 <write_dmatrix_number+0x142>
mov    -0x48(%rbp),%rdi
cvtsi2sdq -0x38(%rbp),%xmm0
lea    0xe06(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
cmp    -0x28(%rbp),%rax
jg     1273 <write_dmatrix_number+0x123>
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
movsd  (%rax,%rcx,8),%xmm0
call   1060 <fprintf@plt>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    1232 <write_dmatrix_number+0xe2>
mov    -0x48(%rbp),%rsi
mov    $0xa,%edi
call   1050 <fputc@plt>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    1206 <write_dmatrix_number+0xb6>
mov    -0x48(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_dmatrix_number>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9,%r13
mov    %r8,%r14
mov    %rcx,%rbx
mov    %rdx,0x18(%rsp)
mov    %rsi,%rbp
mov    %rdi,0x20(%rsp)
mov    0x60(%rsp),%rdi
lea    0xe80(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r12
test   %rax,%rax
jne    1199 <write_dmatrix_number+0x49>
lea    0xe6f(%rip),%rdi
call   1030 <nrerror@plt>
lea    0xe8b(%rip),%rsi
xorps  %xmm0,%xmm0
mov    %r12,%rdi
call   1060 <fprintf@plt>
mov    %r14,0x8(%rsp)
mov    %rbx,0x10(%rsp)
cmp    %r14,%rbx
jg     11f0 <write_dmatrix_number+0xa0>
mov    0x8(%rsp),%rax
lea    0x1(%rax),%r14
mov    0x10(%rsp),%r15
nopl   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2ss %r15,%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r12,%rdi
mov    %r13,%rsi
call   1060 <fprintf@plt>
add    $0x1,%r15
cmp    %r15,%r14
jne    11d0 <write_dmatrix_number+0x80>
mov    $0xa,%edi
mov    %r12,%rsi
call   1050 <fputc@plt>
cmp    0x18(%rsp),%rbp
jle    121a <write_dmatrix_number+0xca>
mov    %r12,%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),%r14
mov    0x20(%rsp),%r15
jmp    124b <write_dmatrix_number+0xfb>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
mov    %r12,%rsi
call   1050 <fputc@plt>
lea    0x1(%rbp),%rax
cmp    0x18(%rsp),%rbp
mov    %rax,%rbp
je     1204 <write_dmatrix_number+0xb4>
xorps  %xmm0,%xmm0
cvtsi2sd %rbp,%xmm0
mov    %r12,%rdi
lea    0xdce(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x8(%rsp),%rax
cmp    %rax,0x10(%rsp)
jg     1230 <write_dmatrix_number+0xe0>
mov    0x10(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r15,%rbp,8),%rax
movsd  (%rax,%rbx,8),%xmm0
mov    %r12,%rdi
mov    %r13,%rsi
call   1060 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1280 <write_dmatrix_number+0x130>
jmp    1230 <write_dmatrix_number+0xe0>

LLVM IR (-O0):
@.str = [3 x i8] c"wt\00"
@.str.1 = [40 x i8] c"Can't open file in write_dmatrix_number\00"
@.str.2 = [4 x i8] c"%4d\00"
define void @write_dmatrix_number(double** %0, i64 %1, i64 %2, i64 %3, i64 %4, i8* %5, i8* %6) {
%8 = alloca double**
%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 double** %0, double*** %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 ([40 x i8], [40 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), double 0.000000e+00)
%27 = load i64, i64* %11
store i64 %27, i64* %16
br label %28
28: ; preds = %39, %24
%29 = load i64, i64* %16
%30 = load i64, i64* %12
%31 = icmp sle i64 %29, %30
br i1 %31, label %32, label %42
32: ; preds = %28
%33 = load i32*, i32** %17
%34 = load i8*, i8** %13
%35 = load i64, i64* %16
%36 = sitofp i64 %35 to float
%37 = fpext float %36 to double
%38 = call i32 @fprintf(i32* %33, i8* %34, double %37)
br label %39
39: ; preds = %32
%40 = load i64, i64* %16
%41 = add nsw i64 %40, 1
store i64 %41, i64* %16
br label %28
42: ; preds = %28
%43 = load i32*, i32** %17
%44 = call i32 @fputc(i8 signext 10, i32* %43)
%45 = load i64, i64* %9
store i64 %45, i64* %15
br label %46
46: ; preds = %77, %42
%47 = load i64, i64* %15
%48 = load i64, i64* %10
%49 = icmp sle i64 %47, %48
br i1 %49, label %50, label %80
50: ; preds = %46
%51 = load i32*, i32** %17
%52 = load i64, i64* %15
%53 = sitofp i64 %52 to double
%54 = call i32 @fprintf(i32* %51, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %53)
%55 = load i64, i64* %11
store i64 %55, i64* %16
br label %56
56: ; preds = %71, %50
%57 = load i64, i64* %16
%58 = load i64, i64* %12
%59 = icmp sle i64 %57, %58
br i1 %59, label %60, label %74
60: ; preds = %56
%61 = load i32*, i32** %17
%62 = load i8*, i8** %13
%63 = load double**, double*** %8
%64 = load i64, i64* %15
%65 = getelementptr inbounds double*, double** %63, i64 %64
%66 = load double*, double** %65
%67 = load i64, i64* %16
%68 = getelementptr inbounds double, double* %66, i64 %67
%69 = load double, double* %68
%70 = call i32 @fprintf(i32* %61, i8* %62, double %69)
br label %71
71: ; preds = %60
%72 = load i64, i64* %16
%73 = add nsw i64 %72, 1
store i64 %73, i64* %16
br label %56
74: ; preds = %56
%75 = load i32*, i32** %17
%76 = call i32 @fputc(i8 signext 10, i32* %75)
br label %77
77: ; preds = %74
%78 = load i64, i64* %15
%79 = add nsw i64 %78, 1
store i64 %79, i64* %15
br label %46
80: ; preds = %46
%81 = load i32*, i32** %17
%82 = call i32 @fclose(i32* %81)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"wt\00"
@.str.1 = [40 x i8] c"Can't open file in write_dmatrix_number\00"
@.str.2 = [4 x i8] c"%4d\00"
define void @write_dmatrix_number(double** 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 ([40 x i8], [40 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), double 0.000000e+00)
%14 = icmp sgt i64 %3, %4
br i1 %14, label %22, label %15
15: ; preds = %12, %15
%16 = phi i64 [ %20, %15 ], [ %3, %12 ]
%17 = sitofp i64 %16 to float
%18 = fpext float %17 to double
%19 = tail call i32 @fprintf(i32* %8, i8* %5, double %18)
%20 = add i64 %16, 1
%21 = icmp eq i64 %16, %4
br i1 %21, label %22, label %15
22: ; preds = %15, %12
%23 = tail call i32 @fputc(i8 signext 10, i32* %8)
%24 = icmp sgt i64 %1, %2
br i1 %24, label %43, label %25
25: ; preds = %22, %39
%26 = phi i64 [ %41, %39 ], [ %1, %22 ]
%27 = sitofp i64 %26 to double
%28 = tail call i32 @fprintf(i32* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %27)
br i1 %14, label %39, label %29
29: ; preds = %25
%30 = getelementptr inbounds double*, double** %0, i64 %26
br label %31
31: ; preds = %29, %31
%32 = phi i64 [ %3, %29 ], [ %37, %31 ]
%33 = load double*, double** %30
%34 = getelementptr inbounds double, double* %33, i64 %32
%35 = load double, double* %34
%36 = tail call i32 @fprintf(i32* %8, i8* %5, double %35)
%37 = add i64 %32, 1
%38 = icmp eq i64 %32, %4
br i1 %38, label %39, label %31
39: ; preds = %31, %25
%40 = tail call i32 @fputc(i8 signext 10, i32* %8)
%41 = add i64 %26, 1
%42 = icmp eq i64 %26, %2
br i1 %42, label %43, label %25
43: ; preds = %39, %22
%44 = tail call i32 @fclose(i32* %8)
ret void
}