#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 *, double, double, ...);
void writecols3(char *fname, double x[], double y[], double z[], size_t N,
                int three, int unit) {
  if (unit != 1) {
    double scaling = 1;
    if (unit == 2) {
      scaling = 86400.0;
    } else if (unit == 3) {
      scaling = 1e6;
    }
    for (size_t j = 0; j < N + 1; ++j) {
      x[j] /= scaling;
    }
  }
  FILE *outfile = fopen(fname, "w");
  if (outfile != NULL) {
    if (three == 0) {
      for (size_t i = 0; i < N; ++i) {
        fprintf(outfile, "%15.9e %18.9e\n", x[i], y[i]);
      }
    } else {
      for (size_t i = 0; i < N; ++i) {
        fprintf(outfile, "%15.9e %18.9e %18.9e\n", x[i], y[i], z[i]);
      }
    }
    fclose(outfile);
  }
}


x86 assembly (clang, -O0):
<writecols3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
cmpl   $0x1,0x10(%rbp)
je     11f0 <writecols3+0xc0>
movsd  0xe9b(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
cmpl   $0x2,0x10(%rbp)
jne    1186 <writecols3+0x56>
movsd  0xe94(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    11a2 <writecols3+0x72>
cmpl   $0x3,0x10(%rbp)
jne    119d <writecols3+0x6d>
movsd  0xe70(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    11a2 <writecols3+0x72>
movq   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    -0x28(%rbp),%rcx
add    $0x1,%rcx
cmp    %rcx,%rax
jae    11eb <writecols3+0xbb>
movsd  -0x38(%rbp),%xmm1
mov    -0x10(%rbp),%rax
mov    -0x40(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    11aa <writecols3+0x7a>
jmp    11f0 <writecols3+0xc0>
mov    -0x8(%rbp),%rdi
lea    0xe1d(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
je     12df <writecols3+0x1af>
cmpl   $0x0,-0x2c(%rbp)
jne    1271 <writecols3+0x141>
movq   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    126c <writecols3+0x13c>
mov    -0x48(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x50(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x50(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
lea    0xdc6(%rip),%rsi
mov    $0x2,%al
call   1040 <fprintf@plt>
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
jmp    1221 <writecols3+0xf1>
jmp    12d6 <writecols3+0x1a6>
movq   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    12d1 <writecols3+0x1a1>
mov    -0x48(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x58(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x58(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x20(%rbp),%rax
mov    -0x58(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
lea    0xd70(%rip),%rsi
mov    $0x3,%al
call   1040 <fprintf@plt>
mov    -0x58(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x58(%rbp)
jmp    1279 <writecols3+0x149>
jmp    12d6 <writecols3+0x1a6>
mov    -0x48(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writecols3>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%r13d
mov    %r8,%r15
mov    %rcx,%rbp
mov    %rdx,%r12
mov    %rsi,%rbx
mov    0x40(%rsp),%eax
cmp    $0x1,%eax
je     1247 <writecols3+0x117>
cmp    $0x2,%eax
je     1174 <writecols3+0x44>
cmp    $0x3,%eax
jne    1187 <writecols3+0x57>
movsd  0xe9f(%rip),%xmm0
cmp    $0xffffffffffffffff,%r15
jne    1199 <writecols3+0x69>
jmp    1247 <writecols3+0x117>
movsd  0xe84(%rip),%xmm0
cmp    $0xffffffffffffffff,%r15
jne    1199 <writecols3+0x69>
jmp    1247 <writecols3+0x117>
movsd  0xe81(%rip),%xmm0
cmp    $0xffffffffffffffff,%r15
je     1247 <writecols3+0x117>
lea    0x1(%r15),%rax
cmp    $0x2,%rax
jae    11aa <writecols3+0x7a>
xor    %ecx,%ecx
jmp    1230 <writecols3+0x100>
mov    %rbp,%r8
mov    %rax,%rcx
and    $0xfffffffffffffffe,%rcx
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
lea    -0x2(%rcx),%rdx
mov    %rdx,%rbp
shr    %rbp
add    $0x1,%rbp
test   %rdx,%rdx
je     12f8 <writecols3+0x1c8>
mov    %rbp,%rdx
and    $0xfffffffffffffffe,%rdx
xor    %esi,%esi
nopl   0x0(%rax)
movupd (%rbx,%rsi,8),%xmm2
movupd 0x10(%rbx,%rsi,8),%xmm3
divpd  %xmm1,%xmm2
movupd %xmm2,(%rbx,%rsi,8)
divpd  %xmm1,%xmm3
movupd %xmm3,0x10(%rbx,%rsi,8)
add    $0x4,%rsi
add    $0xfffffffffffffffe,%rdx
jne    11e0 <writecols3+0xb0>
test   $0x1,%bpl
je     121c <writecols3+0xec>
movupd (%rbx,%rsi,8),%xmm2
divpd  %xmm1,%xmm2
movupd %xmm2,(%rbx,%rsi,8)
cmp    %rcx,%rax
mov    %r8,%rbp
je     1247 <writecols3+0x117>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  (%rbx,%rcx,8),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%rbx,%rcx,8)
add    $0x1,%rcx
cmp    %rcx,%rax
jne    1230 <writecols3+0x100>
lea    0xdca(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     12a0 <writecols3+0x170>
mov    %rax,%r14
test   %r13d,%r13d
je     12af <writecols3+0x17f>
test   %r15,%r15
je     12e2 <writecols3+0x1b2>
mov    %rbp,%r13
mov    %r12,%rbp
xor    %r12d,%r12d
xchg   %ax,%ax
movsd  (%rbx,%r12,8),%xmm0
movsd  0x0(%rbp,%r12,8),%xmm1
movsd  0x0(%r13,%r12,8),%xmm2
mov    %r14,%rdi
lea    0xd9b(%rip),%rsi
mov    $0x3,%al
call   1040 <fprintf@plt>
add    $0x1,%r12
cmp    %r12,%r15
jne    1270 <writecols3+0x140>
jmp    12e2 <writecols3+0x1b2>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
test   %r15,%r15
je     12e2 <writecols3+0x1b2>
mov    %r12,%r13
xor    %ebp,%ebp
lea    0xd5a(%rip),%r12
movsd  (%rbx,%rbp,8),%xmm0
movsd  0x0(%r13,%rbp,8),%xmm1
mov    %r14,%rdi
mov    %r12,%rsi
mov    $0x2,%al
call   1040 <fprintf@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
jne    12c0 <writecols3+0x190>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>
xor    %esi,%esi
test   $0x1,%bpl
jne    120e <writecols3+0xde>
jmp    121c <writecols3+0xec>

LLVM IR (-O0):
@.str = [2 x i8] c"w\00"
@.str.1 = [15 x i8] c"%15.9e %18.9e\0A\00"
@.str.2 = [22 x i8] c"%15.9e %18.9e %18.9e\0A\00"
define void @writecols3(i8* %0, double* %1, double* %2, double* %3, i64 %4, i32 %5, i32 %6) {
%8 = alloca i8*
%9 = alloca double*
%10 = alloca double*
%11 = alloca double*
%12 = alloca i64
%13 = alloca i32
%14 = alloca i32
%15 = alloca double
%16 = alloca i64
%17 = alloca i32*
%18 = alloca i64
%19 = alloca i64
store i8* %0, i8** %8
store double* %1, double** %9
store double* %2, double** %10
store double* %3, double** %11
store i64 %4, i64* %12
store i32 %5, i32* %13
store i32 %6, i32* %14
%20 = load i32, i32* %14
%21 = icmp ne i32 %20, 1
br i1 %21, label %22, label %48
22: ; preds = %7
store double 1.000000e+00, double* %15
%23 = load i32, i32* %14
%24 = icmp eq i32 %23, 2
br i1 %24, label %25, label %26
25: ; preds = %22
store double 8.640000e+04, double* %15
br label %31
26: ; preds = %22
%27 = load i32, i32* %14
%28 = icmp eq i32 %27, 3
br i1 %28, label %29, label %30
29: ; preds = %26
store double 1.000000e+06, double* %15
br label %30
30: ; preds = %29, %26
br label %31
31: ; preds = %30, %25
store i64 0, i64* %16
br label %32
32: ; preds = %44, %31
%33 = load i64, i64* %16
%34 = load i64, i64* %12
%35 = add i64 %34, 1
%36 = icmp ult i64 %33, %35
br i1 %36, label %37, label %47
37: ; preds = %32
%38 = load double, double* %15
%39 = load double*, double** %9
%40 = load i64, i64* %16
%41 = getelementptr inbounds double, double* %39, i64 %40
%42 = load double, double* %41
%43 = fdiv double %42, %38
store double %43, double* %41
br label %44
44: ; preds = %37
%45 = load i64, i64* %16
%46 = add i64 %45, 1
store i64 %46, i64* %16
br label %32
47: ; preds = %32
br label %48
48: ; preds = %47, %7
%49 = load i8*, i8** %8
%50 = call i32* @fopen(i8* %49, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %50, i32** %17
%51 = load i32*, i32** %17
%52 = icmp ne i32* %51, null
br i1 %52, label %53, label %103
53: ; preds = %48
%54 = load i32, i32* %13
%55 = icmp eq i32 %54, 0
br i1 %55, label %56, label %76
56: ; preds = %53
store i64 0, i64* %18
br label %57
57: ; preds = %72, %56
%58 = load i64, i64* %18
%59 = load i64, i64* %12
%60 = icmp ult i64 %58, %59
br i1 %60, label %61, label %75
61: ; preds = %57
%62 = load i32*, i32** %17
%63 = load double*, double** %9
%64 = load i64, i64* %18
%65 = getelementptr inbounds double, double* %63, i64 %64
%66 = load double, double* %65
%67 = load double*, double** %10
%68 = load i64, i64* %18
%69 = getelementptr inbounds double, double* %67, i64 %68
%70 = load double, double* %69
%71 = call i32 (i32*, i8*, double, double, ...) @fprintf(i32* %62, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), double %66, double %70)
br label %72
72: ; preds = %61
%73 = load i64, i64* %18
%74 = add i64 %73, 1
store i64 %74, i64* %18
br label %57
75: ; preds = %57
br label %100
76: ; preds = %53
store i64 0, i64* %19
br label %77
77: ; preds = %96, %76
%78 = load i64, i64* %19
%79 = load i64, i64* %12
%80 = icmp ult i64 %78, %79
br i1 %80, label %81, label %99
81: ; preds = %77
%82 = load i32*, i32** %17
%83 = load double*, double** %9
%84 = load i64, i64* %19
%85 = getelementptr inbounds double, double* %83, i64 %84
%86 = load double, double* %85
%87 = load double*, double** %10
%88 = load i64, i64* %19
%89 = getelementptr inbounds double, double* %87, i64 %88
%90 = load double, double* %89
%91 = load double*, double** %11
%92 = load i64, i64* %19
%93 = getelementptr inbounds double, double* %91, i64 %92
%94 = load double, double* %93
%95 = call i32 (i32*, i8*, double, double, ...) @fprintf(i32* %82, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), double %86, double %90, double %94)
br label %96
96: ; preds = %81
%97 = load i64, i64* %19
%98 = add i64 %97, 1
store i64 %98, i64* %19
br label %77
99: ; preds = %77
br label %100
100: ; preds = %99, %75
%101 = load i32*, i32** %17
%102 = call i32 @fclose(i32* %101)
br label %103
103: ; preds = %100, %48
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
@.str.1 = [15 x i8] c"%15.9e %18.9e\0A\00"
@.str.2 = [22 x i8] c"%15.9e %18.9e %18.9e\0A\00"
define void @writecols3(i8* nocapture %0, double* nocapture %1, double* nocapture %2, double* nocapture %3, i64 %4, i32 %5, i32 %6) {
switch i32 %6, label %9 [
i32 1, label %64
i32 2, label %10
i32 3, label %8
]
8: ; preds = %7
br label %10
9: ; preds = %7
br label %10
10: ; preds = %7, %9, %8
%11 = phi double [ 1.000000e+06, %8 ], [ 8.640000e+04, %7 ], [ 1.000000e+00, %9 ]
%12 = icmp eq i64 %4, -1
br i1 %12, label %64, label %13
13: ; preds = %10
%14 = add i64 %4, 1
%15 = icmp ult i64 %14, 2
br i1 %15, label %55, label %16
16: ; preds = %13
%17 = and i64 %14, -2
%18 = insertelement <2 x double> poison, double %11, i64 0
%19 = shufflevector <2 x double> %18, <2 x double> poison, <2 x i32> zeroinitializer
%20 = add i64 %17, -2
%21 = lshr exact i64 %20, 1
%22 = add nuw i64 %21, 1
%23 = and i64 %22, 1
%24 = icmp eq i64 %20, 0
br i1 %24, label %44, label %25
25: ; preds = %16
%26 = and i64 %22, -2
br label %27
27: ; preds = %27, %25
%28 = phi i64 [ 0, %25 ], [ %41, %27 ]
%29 = phi i64 [ 0, %25 ], [ %42, %27 ]
%30 = getelementptr inbounds double, double* %1, i64 %28
%31 = bitcast double* %30 to <2 x double>*
%32 = load <2 x double>, <2 x double>* %31
%33 = fdiv <2 x double> %32, %19
%34 = bitcast double* %30 to <2 x double>*
store <2 x double> %33, <2 x double>* %34
%35 = or i64 %28, 2
%36 = getelementptr inbounds double, double* %1, i64 %35
%37 = bitcast double* %36 to <2 x double>*
%38 = load <2 x double>, <2 x double>* %37
%39 = fdiv <2 x double> %38, %19
%40 = bitcast double* %36 to <2 x double>*
store <2 x double> %39, <2 x double>* %40
%41 = add nuw i64 %28, 4
%42 = add nuw i64 %29, 2
%43 = icmp eq i64 %42, %26
br i1 %43, label %44, label %27
44: ; preds = %27, %16
%45 = phi i64 [ 0, %16 ], [ %41, %27 ]
%46 = icmp eq i64 %23, 0
br i1 %46, label %53, label %47
47: ; preds = %44
%48 = getelementptr inbounds double, double* %1, i64 %45
%49 = bitcast double* %48 to <2 x double>*
%50 = load <2 x double>, <2 x double>* %49
%51 = fdiv <2 x double> %50, %19
%52 = bitcast double* %48 to <2 x double>*
store <2 x double> %51, <2 x double>* %52
br label %53
53: ; preds = %44, %47
%54 = icmp eq i64 %14, %17
br i1 %54, label %64, label %55
55: ; preds = %13, %53
%56 = phi i64 [ 0, %13 ], [ %17, %53 ]
br label %57
57: ; preds = %55, %57
%58 = phi i64 [ %62, %57 ], [ %56, %55 ]
%59 = getelementptr inbounds double, double* %1, i64 %58
%60 = load double, double* %59
%61 = fdiv double %60, %11
store double %61, double* %59
%62 = add nuw i64 %58, 1
%63 = icmp eq i64 %58, %4
br i1 %63, label %64, label %57
64: ; preds = %57, %53, %10, %7
%65 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%66 = icmp eq i32* %65, null
br i1 %66, label %94, label %67
67: ; preds = %64
%68 = icmp eq i32 %5, 0
%69 = icmp eq i64 %4, 0
br i1 %68, label %71, label %70
70: ; preds = %67
br i1 %69, label %92, label %81
71: ; preds = %67
br i1 %69, label %92, label %72
72: ; preds = %71, %72
%73 = phi i64 [ %79, %72 ], [ 0, %71 ]
%74 = getelementptr inbounds double, double* %1, i64 %73
%75 = load double, double* %74
%76 = getelementptr inbounds double, double* %2, i64 %73
%77 = load double, double* %76
%78 = tail call i32 (i32*, i8*, double, double, ...) @fprintf(i32* %65, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), double %75, double %77)
%79 = add nuw i64 %73, 1
%80 = icmp eq i64 %79, %4
br i1 %80, label %92, label %72
81: ; preds = %70, %81
%82 = phi i64 [ %90, %81 ], [ 0, %70 ]
%83 = getelementptr inbounds double, double* %1, i64 %82
%84 = load double, double* %83
%85 = getelementptr inbounds double, double* %2, i64 %82
%86 = load double, double* %85
%87 = getelementptr inbounds double, double* %3, i64 %82
%88 = load double, double* %87
%89 = tail call i32 (i32*, i8*, double, double, ...) @fprintf(i32* %65, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), double %84, double %86, double %88)
%90 = add nuw i64 %82, 1
%91 = icmp eq i64 %90, %4
br i1 %91, label %92, label %81
92: ; preds = %81, %72, %70, %71
%93 = tail call i32 @fclose(i32* %65)
br label %94
94: ; preds = %92, %64
ret void
}