#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 fabs(double);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ *stdout;
void vecout(double *vec, int beg, int end, char *tag, char *file_name) {
  FILE *file;
  int i;
  if (file_name != NULL) {
    file = fopen(file_name, "w");
  } else {
    file = stdout;
  }
  fprintf(file, "%s:\n", tag);
  for (i = beg; i <= end; i++) {
    if (fabs(vec[i]) >= 1.0e-16) {
      fprintf(file, "%2d.   %24.16f\n", i, vec[i]);
    } else {
      fprintf(file, "%2d.         %g \n", i, vec[i]);
    }
  }
  if (file_name != NULL) {
    fclose(file);
  }
}


x86 assembly (clang, -O0):
<vecout>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     116e <vecout+0x3e>
mov    -0x20(%rbp),%rdi
lea    0xec0(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x28(%rbp)
jmp    117c <vecout+0x4c>
mov    0x2e6b(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe97(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     122a <vecout+0xfa>
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movaps 0xe58(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xe3c(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11f5 <vecout+0xc5>
mov    -0x28(%rbp),%rdi
mov    -0x2c(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe3e(%rip),%rsi
mov    $0x1,%al
call   1040 <fprintf@plt>
jmp    1217 <vecout+0xe7>
mov    -0x28(%rbp),%rdi
mov    -0x2c(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe27(%rip),%rsi
mov    $0x1,%al
call   1040 <fprintf@plt>
jmp    121c <vecout+0xec>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1198 <vecout+0x68>
cmpq   $0x0,-0x20(%rbp)
je     123e <vecout+0x10e>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vecout>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r13
mov    %edx,%r15d
mov    %esi,%ebx
mov    %rdi,%rbp
test   %r8,%r8
mov    %r8,(%rsp)
je     1163 <vecout+0x33>
lea    0xec2(%rip),%rsi
mov    %r8,%rdi
call   1050 <fopen@plt>
mov    %rax,%r12
jmp    116d <vecout+0x3d>
mov    0x2e76(%rip),%rax
mov    (%rax),%r12
lea    0xea6(%rip),%rsi
mov    %r12,%rdi
mov    %r13,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
cmp    %r15d,%ebx
jle    11a3 <vecout+0x73>
cmpq   $0x0,(%rsp)
je     11fb <vecout+0xcb>
mov    %r12,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>
movslq %ebx,%rax
add    $0x1,%r15d
lea    0x0(%rbp,%rax,8),%rbp
lea    0xe79(%rip),%r13
lea    0xe62(%rip),%r14
jmp    11d8 <vecout+0xa8>
nop
mov    %r12,%rdi
mov    %ebx,%edx
mov    $0x1,%al
call   1040 <fprintf@plt>
add    $0x1,%ebx
add    $0x8,%rbp
cmp    %ebx,%r15d
je     1186 <vecout+0x56>
movsd  0x0(%rbp),%xmm0
movapd %xmm0,%xmm1
andpd  0xe17(%rip),%xmm1
ucomisd 0xe1f(%rip),%xmm1
mov    %r13,%rsi
jb     11c0 <vecout+0x90>
mov    %r14,%rsi
jmp    11c0 <vecout+0x90>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"w\00"
@stdout = global i32* null
@.str.1 = [5 x i8] c"%s:\0A\00"
@.str.2 = [16 x i8] c"%2d. %24.16f\0A\00"
@.str.3 = [18 x i8] c"%2d. %g \0A\00"
define void @vecout(double* %0, i32 %1, i32 %2, i8* %3, i8* %4) {
%6 = alloca double*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32*
%12 = alloca i32
store double* %0, double** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i8* %3, i8** %9
store i8* %4, i8** %10
%13 = load i8*, i8** %10
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %18
15: ; preds = %5
%16 = load i8*, i8** %10
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %17, i32** %11
br label %20
18: ; preds = %5
%19 = load i32*, i32** @stdout
store i32* %19, i32** %11
br label %20
20: ; preds = %18, %15
%21 = load i32*, i32** %11
%22 = load i8*, i8** %9
%23 = call i32 (i32*, i8*, ...) @fprintf(i32* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %22)
%24 = load i32, i32* %7
store i32 %24, i32* %12
br label %25
25: ; preds = %56, %20
%26 = load i32, i32* %12
%27 = load i32, i32* %8
%28 = icmp sle i32 %26, %27
br i1 %28, label %29, label %59
29: ; preds = %25
%30 = load double*, double** %6
%31 = load i32, i32* %12
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds double, double* %30, i64 %32
%34 = load double, double* %33
%35 = call double @llvm.fabs.f64(double %34)
%36 = fcmp oge double %35, 0x3C9CD2B297D889BC
br i1 %36, label %37, label %46
37: ; preds = %29
%38 = load i32*, i32** %11
%39 = load i32, i32* %12
%40 = load double*, double** %6
%41 = load i32, i32* %12
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds double, double* %40, i64 %42
%44 = load double, double* %43
%45 = call i32 (i32*, i8*, ...) @fprintf(i32* %38, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %39, double %44)
br label %55
46: ; preds = %29
%47 = load i32*, i32** %11
%48 = load i32, i32* %12
%49 = load double*, double** %6
%50 = load i32, i32* %12
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds double, double* %49, i64 %51
%53 = load double, double* %52
%54 = call i32 (i32*, i8*, ...) @fprintf(i32* %47, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %48, double %53)
br label %55
55: ; preds = %46, %37
br label %56
56: ; preds = %55
%57 = load i32, i32* %12
%58 = add nsw i32 %57, 1
store i32 %58, i32* %12
br label %25
59: ; preds = %25
%60 = load i8*, i8** %10
%61 = icmp ne i8* %60, null
br i1 %61, label %62, label %65
62: ; preds = %59
%63 = load i32*, i32** %11
%64 = call i32 @fclose(i32* %63)
br label %65
65: ; preds = %62, %59
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
@stdout = global i32* null
@.str.1 = [5 x i8] c"%s:\0A\00"
@.str.2 = [16 x i8] c"%2d. %24.16f\0A\00"
@.str.3 = [18 x i8] c"%2d. %g \0A\00"
define void @vecout(double* nocapture %0, i32 %1, i32 %2, i8* %3, i8* %4) {
%6 = icmp eq i8* %4, null
br i1 %6, label %9, label %7
7: ; preds = %5
%8 = tail call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %11
9: ; preds = %5
%10 = load i32*, i32** @stdout
br label %11
11: ; preds = %9, %7
%12 = phi i32* [ %8, %7 ], [ %10, %9 ]
%13 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%14 = icmp sgt i32 %1, %2
br i1 %14, label %30, label %15
15: ; preds = %11
%16 = sext i32 %1 to i64
%17 = add i32 %2, 1
br label %18
18: ; preds = %15, %18
%19 = phi i64 [ %16, %15 ], [ %27, %18 ]
%20 = getelementptr inbounds double, double* %0, i64 %19
%21 = load double, double* %20
%22 = tail call double @llvm.fabs.f64(double %21)
%23 = fcmp ult double %22, 0x3C9CD2B297D889BC
%24 = trunc i64 %19 to i32
%25 = select i1 %23, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0)
%26 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %12, i8* %25, i32 %24, double %21)
%27 = add nsw i64 %19, 1
%28 = trunc i64 %27 to i32
%29 = icmp eq i32 %17, %28
br i1 %29, label %30, label %18
30: ; preds = %18, %11
br i1 %6, label %33, label %31
31: ; preds = %30
%32 = tail call i32 @fclose(i32* %12)
br label %33
33: ; preds = %31, %30
ret void
}