#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 */
double DBL_DIG;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, double, double, ...);
int saveBlock(int i0, int i1, int j0, int j1, double *mat, FILE *store) {
  long i;
  fprintf(store, "#%d,%d,%d,%d\n", i0, i1, j0, j1);
  int size = (i1 - i0) * (j1 - j0);
  for (i = 0; i < size; i++) {
    fprintf(store, "%.*f\n", DBL_DIG, mat[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<saveBlock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8,-0x18(%rbp)
mov    %r9,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
cvtsi2sdl -0x4(%rbp),%xmm0
cvtsi2sdl -0x8(%rbp),%xmm1
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xeb9(%rip),%rsi
mov    $0x2,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%eax
sub    -0x4(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    -0xc(%rbp),%ecx
imul   %ecx,%eax
mov    %eax,-0x2c(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
cmp    %rcx,%rax
jge    11b4 <saveBlock+0xa4>
mov    -0x20(%rbp),%rdi
mov    0x2e64(%rip),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
lea    0xe72(%rip),%rsi
mov    $0x2,%al
call   1030 <fprintf@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1168 <saveBlock+0x58>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<saveBlock>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,%r13
mov    %r8,%r14
mov    %ecx,%ebp
mov    %edx,%r15d
mov    %esi,%r12d
mov    %edi,%ebx
cvtsi2sd %edi,%xmm0
cvtsi2sd %esi,%xmm1
lea    0xec6(%rip),%rsi
mov    %r9,%rdi
mov    $0x2,%al
call   1030 <fprintf@plt>
sub    %ebx,%r12d
sub    %r15d,%ebp
imul   %r12d,%ebp
test   %ebp,%ebp
jle    1192 <saveBlock+0x82>
movslq %ebp,%rbp
xor    %ebx,%ebx
mov    0x2e8a(%rip),%r12
lea    0xea9(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
movsd  (%r12),%xmm0
movsd  (%r14,%rbx,8),%xmm1
mov    %r13,%rdi
mov    %r15,%rsi
mov    $0x2,%al
call   1030 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1170 <saveBlock+0x60>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"#%d,%d,%d,%d\0A\00"
@.str.1 = [6 x i8] c"%.*f\0A\00"
@DBL_DIG = global double 0.000000e+00
define i32 @saveBlock(i32 %0, i32 %1, i32 %2, i32 %3, double* %4, i32* %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca double*
%12 = alloca i32*
%13 = alloca i64
%14 = alloca i32
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store double* %4, double** %11
store i32* %5, i32** %12
%15 = load i32*, i32** %12
%16 = load i32, i32* %7
%17 = sitofp i32 %16 to double
%18 = load i32, i32* %8
%19 = sitofp i32 %18 to double
%20 = load i32, i32* %9
%21 = load i32, i32* %10
%22 = call i32 (i32*, i8*, double, double, ...) @fprintf(i32* %15, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), double %17, double %19, i32 %20, i32 %21)
%23 = load i32, i32* %8
%24 = load i32, i32* %7
%25 = sub nsw i32 %23, %24
%26 = load i32, i32* %10
%27 = load i32, i32* %9
%28 = sub nsw i32 %26, %27
%29 = mul nsw i32 %25, %28
store i32 %29, i32* %14
store i64 0, i64* %13
br label %30
30: ; preds = %43, %6
%31 = load i64, i64* %13
%32 = load i32, i32* %14
%33 = sext i32 %32 to i64
%34 = icmp slt i64 %31, %33
br i1 %34, label %35, label %46
35: ; preds = %30
%36 = load i32*, i32** %12
%37 = load double, double* @DBL_DIG
%38 = load double*, double** %11
%39 = load i64, i64* %13
%40 = getelementptr inbounds double, double* %38, i64 %39
%41 = load double, double* %40
%42 = call i32 (i32*, i8*, double, double, ...) @fprintf(i32* %36, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %37, double %41)
br label %43
43: ; preds = %35
%44 = load i64, i64* %13
%45 = add nsw i64 %44, 1
store i64 %45, i64* %13
br label %30
46: ; preds = %30
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"#%d,%d,%d,%d\0A\00"
@.str.1 = [6 x i8] c"%.*f\0A\00"
@DBL_DIG = global double 0.000000e+00
define i32 @saveBlock(i32 %0, i32 %1, i32 %2, i32 %3, double* nocapture %4, i32* nocapture %5) {
%7 = sitofp i32 %0 to double
%8 = sitofp i32 %1 to double
%9 = tail call i32 (i32*, i8*, double, double, ...) @fprintf(i32* %5, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), double %7, double %8, i32 %2, i32 %3)
%10 = sub nsw i32 %1, %0
%11 = sub nsw i32 %3, %2
%12 = mul nsw i32 %11, %10
%13 = sext i32 %12 to i64
%14 = icmp sgt i32 %12, 0
br i1 %14, label %15, label %23
15: ; preds = %6, %15
%16 = phi i64 [ %21, %15 ], [ 0, %6 ]
%17 = load double, double* @DBL_DIG
%18 = getelementptr inbounds double, double* %4, i64 %16
%19 = load double, double* %18
%20 = tail call i32 (i32*, i8*, double, double, ...) @fprintf(i32* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %17, double %19)
%21 = add nuw nsw i64 %16, 1
%22 = icmp eq i64 %21, %13
br i1 %22, label %23, label %15
23: ; preds = %15, %6
ret i32 0
}