#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_float(char *filename, float *input, int in_len, float *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_float>:
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_float+0x4e>
jmp    12c7 <save_oct_float+0x187>
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    122f <save_oct_float+0xef>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe68(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11f2 <save_oct_float+0xb2>
mov    -0x30(%rbp),%rdi
lea    0xe4d(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x30(%rbp),%rdi
lea    0xe0c(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x24(%rbp),%edx
lea    0xe07(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x30(%rbp),%rdi
lea    0xe01(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    12be <save_oct_float+0x17e>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdd9(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1281 <save_oct_float+0x141>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<save_oct_float>:
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     1306 <save_oct_float+0x1b6>
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    1251 <save_oct_float+0x101>
mov    %r12d,%ebp
xor    %r15d,%r15d
lea    0xe61(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movss  0x0(%r13,%r15,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r14,%rdi
mov    %r12,%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
add    $0x1,%r15
cmp    %r15,%rbp
jne    1230 <save_oct_float+0xe0>
lea    0xe2f(%rip),%rdi
mov    $0xf,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1070 <fwrite@plt>
lea    0xde7(%rip),%rdi
mov    $0xf,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1070 <fwrite@plt>
lea    0xdde(%rip),%rsi
mov    %r14,%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0xdd7(%rip),%rdi
mov    $0xd,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1070 <fwrite@plt>
test   %ebx,%ebx
mov    (%rsp),%r12
jle    12f0 <save_oct_float+0x1a0>
mov    %ebx,%ebp
xor    %ebx,%ebx
lea    0xdc0(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movss  (%r12,%rbx,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    12d0 <save_oct_float+0x180>
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_float(i8* %0, float* %1, i32 %2, float* %3, i32 %4) {
%6 = alloca i8*
%7 = alloca float*
%8 = alloca i32
%9 = alloca float*
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i32
store i8* %0, i8** %6
store float* %1, float** %7
store i32 %2, i32* %8
store float* %3, float** %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 %76
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 = %44, %19
%32 = load i32, i32* %12
%33 = load i32, i32* %8
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %47
35: ; preds = %31
%36 = load i32*, i32** %11
%37 = load float*, float** %7
%38 = load i32, i32* %12
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds float, float* %37, i64 %39
%41 = load float, float* %40
%42 = fpext float %41 to double
%43 = call i32 (i32*, i8*, ...) @fprintf(i32* %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), double %42)
br label %44
44: ; preds = %35
%45 = load i32, i32* %12
%46 = add nsw i32 %45, 1
store i32 %46, i32* %12
br label %31
47: ; preds = %31
%48 = load i32*, i32** %11
%49 = call i32 (i32*, i8*, ...) @fprintf(i32* %48, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0))
%50 = load i32*, i32** %11
%51 = call i32 (i32*, i8*, ...) @fprintf(i32* %50, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%52 = load i32*, i32** %11
%53 = load i32, i32* %10
%54 = call i32 (i32*, i8*, ...) @fprintf(i32* %52, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %53)
%55 = load i32*, i32** %11
%56 = call i32 (i32*, i8*, ...) @fprintf(i32* %55, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %12
br label %57
57: ; preds = %70, %47
%58 = load i32, i32* %12
%59 = load i32, i32* %10
%60 = icmp slt i32 %58, %59
br i1 %60, label %61, label %73
61: ; preds = %57
%62 = load i32*, i32** %11
%63 = load float*, float** %9
%64 = load i32, i32* %12
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds float, float* %63, i64 %65
%67 = load float, float* %66
%68 = fpext float %67 to double
%69 = call i32 (i32*, i8*, ...) @fprintf(i32* %62, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), double %68)
br label %70
70: ; preds = %61
%71 = load i32, i32* %12
%72 = add nsw i32 %71, 1
store i32 %72, i32* %12
br label %57
73: ; preds = %57
%74 = load i32*, i32** %11
%75 = call i32 @fclose(i32* %74)
br label %76
76: ; preds = %73, %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_float(i8* %0, float* nocapture %1, i32 %2, float* 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 %44, 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 %26
16: ; preds = %9
%17 = zext i32 %2 to i64
br label %18
18: ; preds = %16, %18
%19 = phi i64 [ 0, %16 ], [ %24, %18 ]
%20 = getelementptr inbounds float, float* %1, i64 %19
%21 = load float, float* %20
%22 = fpext float %21 to double
%23 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), double %22)
%24 = add nuw nsw i64 %19, 1
%25 = icmp eq i64 %24, %17
br i1 %25, label %26, label %18
26: ; preds = %18, %9
%27 = 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)
%28 = 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)
%29 = 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)
%30 = 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)
%31 = icmp sgt i32 %4, 0
br i1 %31, label %32, label %42
32: ; preds = %26
%33 = zext i32 %4 to i64
br label %34
34: ; preds = %32, %34
%35 = phi i64 [ 0, %32 ], [ %40, %34 ]
%36 = getelementptr inbounds float, float* %3, i64 %35
%37 = load float, float* %36
%38 = fpext float %37 to double
%39 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), double %38)
%40 = add nuw nsw i64 %35, 1
%41 = icmp eq i64 %40, %33
br i1 %41, label %42, label %34
42: ; preds = %34, %26
%43 = tail call i32 @fclose(i32* %7)
br label %44
44: ; preds = %5, %42
ret void
}