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

/* Variables and functions */
char *ctime(int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char const *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void save_dvector(char filename[], double *V, int nl, int nh,
                  const char *mode) {
  FILE *fp_v;
  int i;
  time_t now;
  if ((fp_v = fopen(filename, mode)) == NULL) {
    printf(" error: cannot open file: '%s' \n", filename);
    exit(1011);
  }
  (void)time(&now);
  fprintf(fp_v, "%% filename: %s - %s", filename, ctime(&now));
  fprintf(fp_v, "%% type: vector\n");
  fprintf(fp_v, "%% rows: %d\n", 1);
  fprintf(fp_v, "%% columns: %d\n", nh - nl + 1);
  for (i = nl; i <= nh; i++) {
    if (V[i] != 0)
      fprintf(fp_v, "%21.12e", V[i]);
    else
      fprintf(fp_v, "    0                ");
    fprintf(fp_v, "\n");
  }
  fclose(fp_v);
  return;
}


x86 assembly (clang, -O0):
<save_dvector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    11bf <save_dvector+0x4f>
mov    -0x8(%rbp),%rsi
lea    0xe50(%rip),%rdi
call   1050 <printf@plt>
mov    $0x3f3,%edi
call   1090 <exit@plt>
lea    -0x30(%rbp),%rdi
call   1070 <time@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    -0x30(%rbp),%rdi
call   1040 <ctime@plt>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rdx
mov    %rax,%rcx
lea    0xe2e(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xe31(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xe30(%rip),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%edx
sub    -0x14(%rbp),%edx
add    $0x1,%edx
lea    0xe1d(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     12cb <save_dvector+0x15b>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1275 <save_dvector+0x105>
jp     1275 <save_dvector+0x105>
jmp    1299 <save_dvector+0x129>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xdd7(%rip),%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
jmp    12ab <save_dvector+0x13b>
mov    -0x28(%rbp),%rdi
lea    0xdc8(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xd69(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1244 <save_dvector+0xd4>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<save_dvector>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %edx,%r12d
mov    %rsi,%r15
mov    %rdi,%rbp
mov    %r8,%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     12bd <save_dvector+0x12d>
mov    %rax,%rbx
lea    0x4(%rsp),%r13
mov    %r13,%rdi
call   1080 <time@plt>
mov    %r13,%rdi
call   1040 <ctime@plt>
lea    0xe52(%rip),%rsi
mov    %rbx,%rdi
mov    %rbp,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1070 <fprintf@plt>
lea    0xe50(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <fprintf@plt>
lea    0xe50(%rip),%rsi
mov    %rbx,%rdi
mov    $0x1,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %r14d,%edx
sub    %r12d,%edx
add    $0x1,%edx
lea    0xe3e(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <fprintf@plt>
sub    %r12d,%r14d
jge    1244 <save_dvector+0xb4>
mov    %rbx,%rdi
call   1030 <fclose@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
movslq %r12d,%rax
lea    (%r15,%rax,8),%r13
add    $0x1,%r14d
xor    %ebp,%ebp
lea    0xe14(%rip),%r12
lea    0xe15(%rip),%r15
jmp    129b <save_dvector+0x10b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x15,%esi
mov    $0x1,%edx
mov    %r15,%rdi
mov    %rbx,%rcx
call   10b0 <fwrite@plt>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1060 <fputc@plt>
add    $0x1,%rbp
cmp    %ebp,%r14d
je     122d <save_dvector+0x9d>
movsd  0x0(%r13,%rbp,8),%xmm0
ucomisd 0xd56(%rip),%xmm0
jne    12ae <save_dvector+0x11e>
jnp    1270 <save_dvector+0xe0>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x1,%al
call   1070 <fprintf@plt>
jmp    1285 <save_dvector+0xf5>
lea    0xd44(%rip),%rdi
mov    %rbp,%rsi
call   1050 <printf@plt>
mov    $0x3f3,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [33 x i8] c" error: cannot open file: '%s' \0A\00"
@.str.1 = [21 x i8] c"%% filename: %s - %s\00"
@.str.2 = [17 x i8] c"%% type: vector\0A\00"
@.str.3 = [13 x i8] c"%% rows: %d\0A\00"
@.str.4 = [16 x i8] c"%% columns: %d\0A\00"
@.str.5 = [8 x i8] c"%21.12e\00"
@.str.6 = [22 x i8] c" 0 \00"
@.str.7 = [2 x i8] c"\0A\00"
define void @save_dvector(i8* %0, double* %1, i32 %2, i32 %3, i8* %4) {
%6 = alloca i8*
%7 = alloca double*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32*
%12 = alloca i32
%13 = alloca i32
store i8* %0, i8** %6
store double* %1, double** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i8* %4, i8** %10
%14 = load i8*, i8** %6
%15 = load i8*, i8** %10
%16 = call i32* @fopen(i8* %14, i8* %15)
store i32* %16, i32** %11
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %22
18: ; preds = %5
%19 = load i8*, i8** %6
%20 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = call i32 @exit(i32 1011)
unreachable
22: ; preds = %5
%23 = call i32 @time(i32* %13)
%24 = load i32*, i32** %11
%25 = load i8*, i8** %6
%26 = call i8* @ctime(i32* %13)
%27 = call i32 (i32*, i8*, ...) @fprintf(i32* %24, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %25, i8* %26)
%28 = load i32*, i32** %11
%29 = call i32 (i32*, i8*, ...) @fprintf(i32* %28, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%30 = load i32*, i32** %11
%31 = call i32 (i32*, i8*, ...) @fprintf(i32* %30, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 1)
%32 = load i32*, i32** %11
%33 = load i32, i32* %9
%34 = load i32, i32* %8
%35 = sub nsw i32 %33, %34
%36 = add nsw i32 %35, 1
%37 = call i32 (i32*, i8*, ...) @fprintf(i32* %32, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %36)
%38 = load i32, i32* %8
store i32 %38, i32* %12
br label %39
39: ; preds = %64, %22
%40 = load i32, i32* %12
%41 = load i32, i32* %9
%42 = icmp sle i32 %40, %41
br i1 %42, label %43, label %67
43: ; preds = %39
%44 = load double*, double** %7
%45 = load i32, i32* %12
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds double, double* %44, i64 %46
%48 = load double, double* %47
%49 = fcmp une double %48, 0.000000e+00
br i1 %49, label %50, label %58
50: ; preds = %43
%51 = load i32*, i32** %11
%52 = load double*, double** %7
%53 = load i32, i32* %12
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds double, double* %52, i64 %54
%56 = load double, double* %55
%57 = call i32 (i32*, i8*, ...) @fprintf(i32* %51, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), double %56)
br label %61
58: ; preds = %43
%59 = load i32*, i32** %11
%60 = call i32 (i32*, i8*, ...) @fprintf(i32* %59, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
br label %61
61: ; preds = %58, %50
%62 = load i32*, i32** %11
%63 = call i32 (i32*, i8*, ...) @fprintf(i32* %62, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %64
64: ; preds = %61
%65 = load i32, i32* %12
%66 = add nsw i32 %65, 1
store i32 %66, i32* %12
br label %39
67: ; preds = %39
%68 = load i32*, i32** %11
%69 = call i32 @fclose(i32* %68)
ret void
}

LLVM IR (-O2):
@.str = [33 x i8] c" error: cannot open file: '%s' \0A\00"
@.str.1 = [21 x i8] c"%% filename: %s - %s\00"
@.str.2 = [17 x i8] c"%% type: vector\0A\00"
@.str.3 = [13 x i8] c"%% rows: %d\0A\00"
@.str.4 = [16 x i8] c"%% columns: %d\0A\00"
@.str.5 = [8 x i8] c"%21.12e\00"
@.str.6 = [22 x i8] c" 0 \00"
define void @save_dvector(i8* %0, double* nocapture %1, i32 %2, i32 %3, i8* nocapture %4) {
%6 = alloca i32
%7 = bitcast i32* %6 to i8*
%8 = tail call i32* @fopen(i8* %0, i8* %4)
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %13
10: ; preds = %5
%11 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %0)
%12 = tail call i32 @exit(i32 1011)
unreachable
13: ; preds = %5
%14 = call i32 @time(i32* %6)
%15 = call i8* @ctime(i32* %6)
%16 = call i32 (i32*, i8*, ...) @fprintf(i32* %8, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %15)
%17 = call i32 (i32*, i8*, ...) @fprintf(i32* %8, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 (i32*, i8*, ...) @fprintf(i32* %8, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 1)
%19 = sub i32 1, %2
%20 = add i32 %19, %3
%21 = call i32 (i32*, i8*, ...) @fprintf(i32* %8, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %20)
%22 = icmp sgt i32 %2, %3
br i1 %22, label %40, label %23
23: ; preds = %13
%24 = sext i32 %2 to i64
%25 = add i32 %3, 1
br label %26
26: ; preds = %23, %35
%27 = phi i64 [ %24, %23 ], [ %37, %35 ]
%28 = getelementptr inbounds double, double* %1, i64 %27
%29 = load double, double* %28
%30 = fcmp une double %29, 0.000000e+00
br i1 %30, label %31, label %33
31: ; preds = %26
%32 = call i32 (i32*, i8*, ...) @fprintf(i32* %8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), double %29)
br label %35
33: ; preds = %26
%34 = call i64 @fwrite(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i64 21, i64 1, i32* %8)
br label %35
35: ; preds = %33, %31
%36 = call i32 @fputc(i32 10, i32* %8)
%37 = add nsw i64 %27, 1
%38 = trunc i64 %37 to i32
%39 = icmp eq i32 %25, %38
br i1 %39, label %40, label %26
40: ; preds = %35, %13
%41 = call i32 @fclose(i32* %8)
ret void
}