#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 *, ...);
int /*<<< orphan*/ printf(char *, char *);
void save_oct_double(char *filename, double *input, int in_len, double *output,
                     int out_len) {
  FILE *file;
  int k;
  printf("Dumping input and output data to file : %s.\n\n", filename);
  if (!(file = fopen(filename, "w")))
    return;
  fprintf(file, "# Not created by Octave\n");
  fprintf(file, "# name: input\n");
  fprintf(file, "# type: matrix\n");
  fprintf(file, "# rows: %d\n", in_len);
  fprintf(file, "# columns: 1\n");
  for (k = 0; k < in_len; k++)
    fprintf(file, "% g\n", input[k]);
  fprintf(file, "# name: output\n");
  fprintf(file, "# type: matrix\n");
  fprintf(file, "# rows: %d\n", out_len);
  fprintf(file, "# columns: 1\n");
  for (k = 0; k < out_len; k++)
    fprintf(file, "% g\n", output[k]);
  fclose(file);
  return;
}


x86 assembly (clang, -O0):
<save_oct_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe9a(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    0xeb8(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    118e <save_oct_double+0x4e>
jmp    12bf <save_oct_double+0x17f>
mov    -0x30(%rbp),%rdi
lea    0xe97(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x30(%rbp),%rdi
lea    0xe9e(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x30(%rbp),%rdi
lea    0xe9b(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe96(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x30(%rbp),%rdi
lea    0xe90(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    122b <save_oct_double+0xeb>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe6c(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11f2 <save_oct_double+0xb2>
mov    -0x30(%rbp),%rdi
lea    0xe51(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x30(%rbp),%rdi
lea    0xe10(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x24(%rbp),%edx
lea    0xe0b(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x30(%rbp),%rdi
lea    0xe05(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    12b6 <save_oct_double+0x176>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xde1(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    127d <save_oct_double+0x13d>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<save_oct_double>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%ebp
mov    %rcx,(%rsp)
mov    %edx,%r12d
mov    %rsi,%r13
mov    %rdi,%rbx
lea    0xe8e(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
lea    0xead(%rip),%rsi
mov    %rbx,%rdi
call   1060 <fopen@plt>
test   %rax,%rax
je     12f2 <save_oct_double+0x1a2>
mov    %rax,%r14
mov    %ebp,%ebx
lea    0xe92(%rip),%rdi
mov    $0x18,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1070 <fwrite@plt>
lea    0xe92(%rip),%rdi
mov    $0xe,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1070 <fwrite@plt>
lea    0xe88(%rip),%rdi
mov    $0xf,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1070 <fwrite@plt>
lea    0xe7f(%rip),%rsi
mov    %r14,%rdi
mov    %r12d,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0xe77(%rip),%rdi
mov    $0xd,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1070 <fwrite@plt>
test   %r12d,%r12d
jle    124d <save_oct_double+0xfd>
mov    %r12d,%ebp
xor    %r15d,%r15d
lea    0xe61(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  0x0(%r13,%r15,8),%xmm0
mov    %r14,%rdi
mov    %r12,%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
add    $0x1,%r15
cmp    %r15,%rbp
jne    1230 <save_oct_double+0xe0>
lea    0xe33(%rip),%rdi
mov    $0xf,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1070 <fwrite@plt>
lea    0xdeb(%rip),%rdi
mov    $0xf,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1070 <fwrite@plt>
lea    0xde2(%rip),%rsi
mov    %r14,%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0xddb(%rip),%rdi
mov    $0xd,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1070 <fwrite@plt>
test   %ebx,%ebx
mov    (%rsp),%r12
jle    12dc <save_oct_double+0x18c>
mov    %ebx,%ebp
xor    %ebx,%ebx
lea    0xdc4(%rip),%r15
xchg   %ax,%ax
movsd  (%r12,%rbx,8),%xmm0
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    12c0 <save_oct_double+0x170>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [46 x i8] c"Dumping input and output data to file : %s.\0A\0A\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [25 x i8] c"# Not created by Octave\0A\00"
@.str.3 = [15 x i8] c"# name: input\0A\00"
@.str.4 = [16 x i8] c"# type: matrix\0A\00"
@.str.5 = [12 x i8] c"# rows: %d\0A\00"
@.str.6 = [14 x i8] c"# columns: 1\0A\00"
@.str.7 = [5 x i8] c"% g\0A\00"
@.str.8 = [16 x i8] c"# name: output\0A\00"
define void @save_oct_double(i8* %0, double* %1, i32 %2, double* %3, i32 %4) {
%6 = alloca i8*
%7 = alloca double*
%8 = alloca i32
%9 = alloca double*
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i32
store i8* %0, i8** %6
store double* %1, double** %7
store i32 %2, i32* %8
store double* %3, double** %9
store i32 %4, i32* %10
%13 = load i8*, i8** %6
%14 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = load i8*, i8** %6
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %16, i32** %11
%17 = icmp ne i32* %16, null
br i1 %17, label %19, label %18
18: ; preds = %5
br label %74
19: ; preds = %5
%20 = load i32*, i32** %11
%21 = call i32 (i32*, i8*, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%22 = load i32*, i32** %11
%23 = call i32 (i32*, i8*, ...) @fprintf(i32* %22, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%24 = load i32*, i32** %11
%25 = call i32 (i32*, i8*, ...) @fprintf(i32* %24, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%26 = load i32*, i32** %11
%27 = load i32, i32* %8
%28 = call i32 (i32*, i8*, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %27)
%29 = load i32*, i32** %11
%30 = call i32 (i32*, i8*, ...) @fprintf(i32* %29, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %12
br label %31
31: ; preds = %43, %19
%32 = load i32, i32* %12
%33 = load i32, i32* %8
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %46
35: ; preds = %31
%36 = load i32*, i32** %11
%37 = load double*, double** %7
%38 = load i32, i32* %12
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double, double* %37, i64 %39
%41 = load double, double* %40
%42 = call i32 (i32*, i8*, ...) @fprintf(i32* %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), double %41)
br label %43
43: ; preds = %35
%44 = load i32, i32* %12
%45 = add nsw i32 %44, 1
store i32 %45, i32* %12
br label %31
46: ; preds = %31
%47 = load i32*, i32** %11
%48 = call i32 (i32*, i8*, ...) @fprintf(i32* %47, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0))
%49 = load i32*, i32** %11
%50 = call i32 (i32*, i8*, ...) @fprintf(i32* %49, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%51 = load i32*, i32** %11
%52 = load i32, i32* %10
%53 = call i32 (i32*, i8*, ...) @fprintf(i32* %51, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %52)
%54 = load i32*, i32** %11
%55 = call i32 (i32*, i8*, ...) @fprintf(i32* %54, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %12
br label %56
56: ; preds = %68, %46
%57 = load i32, i32* %12
%58 = load i32, i32* %10
%59 = icmp slt i32 %57, %58
br i1 %59, label %60, label %71
60: ; preds = %56
%61 = load i32*, i32** %11
%62 = load double*, double** %9
%63 = load i32, i32* %12
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds double, double* %62, i64 %64
%66 = load double, double* %65
%67 = call i32 (i32*, i8*, ...) @fprintf(i32* %61, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), double %66)
br label %68
68: ; preds = %60
%69 = load i32, i32* %12
%70 = add nsw i32 %69, 1
store i32 %70, i32* %12
br label %56
71: ; preds = %56
%72 = load i32*, i32** %11
%73 = call i32 @fclose(i32* %72)
br label %74
74: ; preds = %71, %18
ret void
}

LLVM IR (-O2):
@.str = [46 x i8] c"Dumping input and output data to file : %s.\0A\0A\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [25 x i8] c"# Not created by Octave\0A\00"
@.str.3 = [15 x i8] c"# name: input\0A\00"
@.str.4 = [16 x i8] c"# type: matrix\0A\00"
@.str.5 = [12 x i8] c"# rows: %d\0A\00"
@.str.6 = [14 x i8] c"# columns: 1\0A\00"
@.str.7 = [5 x i8] c"% g\0A\00"
@.str.8 = [16 x i8] c"# name: output\0A\00"
define void @save_oct_double(i8* %0, double* nocapture %1, i32 %2, double* nocapture %3, i32 %4) {
%6 = tail call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8* %0)
%7 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %42, label %9
9: ; preds = %5
%10 = tail call i64 @fwrite(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i64 24, i64 1, i32* %7)
%11 = tail call i64 @fwrite(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i64 14, i64 1, i32* %7)
%12 = tail call i64 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i64 15, i64 1, i32* %7)
%13 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %2)
%14 = tail call i64 @fwrite(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i64 13, i64 1, i32* %7)
%15 = icmp sgt i32 %2, 0
br i1 %15, label %16, label %25
16: ; preds = %9
%17 = zext i32 %2 to i64
br label %18
18: ; preds = %16, %18
%19 = phi i64 [ 0, %16 ], [ %23, %18 ]
%20 = getelementptr inbounds double, double* %1, i64 %19
%21 = load double, double* %20
%22 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), double %21)
%23 = add nuw nsw i64 %19, 1
%24 = icmp eq i64 %23, %17
br i1 %24, label %25, label %18
25: ; preds = %18, %9
%26 = tail call i64 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i64 15, i64 1, i32* %7)
%27 = tail call i64 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i64 15, i64 1, i32* %7)
%28 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %4)
%29 = tail call i64 @fwrite(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i64 13, i64 1, i32* %7)
%30 = icmp sgt i32 %4, 0
br i1 %30, label %31, label %40
31: ; preds = %25
%32 = zext i32 %4 to i64
br label %33
33: ; preds = %31, %33
%34 = phi i64 [ 0, %31 ], [ %38, %33 ]
%35 = getelementptr inbounds double, double* %3, i64 %34
%36 = load double, double* %35
%37 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), double %36)
%38 = add nuw nsw i64 %34, 1
%39 = icmp eq i64 %38, %32
br i1 %39, label %40, label %33
40: ; preds = %33, %25
%41 = tail call i32 @fclose(i32* %7)
br label %42
42: ; preds = %5, %40
ret void
}