#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*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, double, ...);
void writenbody(int nj, double *mj, double (*xj)[3], double (*vj)[3],
                char *fname) {
  int i;
  FILE *fp;
  fp = fopen(fname, "w");
  fprintf(fp, "%d\n", nj);
  fprintf(fp, "%d\n", 3);
  fprintf(fp, "%e\n", 0.0);
  for (i = 0; i < nj; i++) {
    fprintf(fp, "%e\n", mj[i]);
  }
  for (i = 0; i < nj; i++) {
    fprintf(fp, "%e %e %e\n", xj[i][0], xj[i][1], xj[i][2]);
  }
  for (i = 0; i < nj; i++) {
    fprintf(fp, "%e %e %e\n", vj[i][0], vj[i][1], vj[i][2]);
  }
}


x86 assembly (clang, -O0):
<writenbody>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xec2(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
cvtsi2sdl -0x4(%rbp),%xmm0
lea    0xeab(%rip),%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
mov    -0x38(%rbp),%rdi
lea    0xe99(%rip),%rsi
movsd  0xe87(%rip),%xmm0
mov    $0x1,%al
call   1030 <fprintf@plt>
mov    -0x38(%rbp),%rdi
lea    0xe89(%rip),%rsi
xorps  %xmm0,%xmm0
mov    $0x1,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11d5 <writenbody+0xb5>
mov    -0x38(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe54(%rip),%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    119c <writenbody+0x7c>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1243 <writenbody+0x123>
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  0x8(%rax),%xmm1
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  0x10(%rax),%xmm2
lea    0xde0(%rip),%rsi
mov    $0x3,%al
call   1030 <fprintf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11dc <writenbody+0xbc>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    12b1 <writenbody+0x191>
mov    -0x38(%rbp),%rdi
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  (%rax),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  0x8(%rax),%xmm1
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  0x10(%rax),%xmm2
lea    0xd72(%rip),%rsi
mov    $0x3,%al
call   1030 <fprintf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    124a <writenbody+0x12a>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writenbody>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r14
mov    %rdx,%rbx
mov    %rsi,%rbp
mov    %edi,%r12d
lea    0xec7(%rip),%rsi
mov    %r8,%rdi
call   1040 <fopen@plt>
mov    %rax,%r15
cvtsi2sd %r12d,%xmm0
lea    0xeb2(%rip),%r13
mov    %rax,%rdi
mov    %r13,%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
movsd  0xe93(%rip),%xmm0
mov    %r15,%rdi
mov    %r13,%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
lea    0xe93(%rip),%rsi
xorps  %xmm0,%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1030 <fprintf@plt>
test   %r12d,%r12d
jle    1268 <writenbody+0x148>
mov    %r14,0x10(%rsp)
mov    %r12d,0xc(%rsp)
mov    %r12d,%r12d
xor    %r14d,%r14d
lea    0xe66(%rip),%r13
xchg   %ax,%ax
movsd  0x0(%rbp,%r14,8),%xmm0
mov    %r15,%rdi
mov    %r13,%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
add    $0x1,%r14
cmp    %r14,%r12
jne    11b0 <writenbody+0x90>
cmpl   $0x0,0xc(%rsp)
mov    0x10(%rsp),%rbp
jle    1268 <writenbody+0x148>
lea    0x0(,%r12,8),%rax
lea    (%rax,%rax,2),%r14
xor    %r13d,%r13d
nopl   0x0(%rax)
movsd  (%rbx,%r13,1),%xmm0
movsd  0x8(%rbx,%r13,1),%xmm1
movsd  0x10(%rbx,%r13,1),%xmm2
mov    %r15,%rdi
lea    0xe00(%rip),%rsi
mov    $0x3,%al
call   1030 <fprintf@plt>
add    $0x18,%r13
cmp    %r13,%r14
jne    11f0 <writenbody+0xd0>
cmpl   $0x0,0xc(%rsp)
jle    1268 <writenbody+0x148>
shl    $0x3,%r12
lea    (%r12,%r12,2),%r14
xor    %ebx,%ebx
lea    0xdd8(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
movsd  0x0(%rbp,%rbx,1),%xmm0
movsd  0x8(%rbp,%rbx,1),%xmm1
movsd  0x10(%rbp,%rbx,1),%xmm2
mov    %r15,%rdi
mov    %r12,%rsi
mov    $0x3,%al
call   1030 <fprintf@plt>
add    $0x18,%rbx
cmp    %rbx,%r14
jne    1240 <writenbody+0x120>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [4 x i8] c"%e\0A\00"
@.str.3 = [10 x i8] c"%e %e %e\0A\00"
define void @writenbody(i32 %0, double* nocapture %1, [3 x double]* nocapture %2, [3 x double]* nocapture %3, i8* nocapture %4) {
%6 = tail call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = sitofp i32 %0 to double
%8 = tail call i32 (i32*, i8*, double, ...) @fprintf(i32* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %7)
%9 = tail call i32 (i32*, i8*, double, ...) @fprintf(i32* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double 3.000000e+00)
%10 = tail call i32 (i32*, i8*, double, ...) @fprintf(i32* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double 0.000000e+00)
%11 = icmp sgt i32 %0, 0
br i1 %11, label %12, label %49
12: ; preds = %5
%13 = zext i32 %0 to i64
br label %17
14: ; preds = %17
br i1 %11, label %15, label %49
15: ; preds = %14
%16 = zext i32 %0 to i64
br label %27
17: ; preds = %12, %17
%18 = phi i64 [ 0, %12 ], [ %22, %17 ]
%19 = getelementptr inbounds double, double* %1, i64 %18
%20 = load double, double* %19
%21 = tail call i32 (i32*, i8*, double, ...) @fprintf(i32* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %20)
%22 = add nuw nsw i64 %18, 1
%23 = icmp eq i64 %22, %13
br i1 %23, label %14, label %17
24: ; preds = %27
br i1 %11, label %25, label %49
25: ; preds = %24
%26 = zext i32 %0 to i64
br label %38
27: ; preds = %15, %27
%28 = phi i64 [ 0, %15 ], [ %36, %27 ]
%29 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 %28, i64 0
%30 = load double, double* %29
%31 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 %28, i64 1
%32 = load double, double* %31
%33 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 %28, i64 2
%34 = load double, double* %33
%35 = tail call i32 (i32*, i8*, double, ...) @fprintf(i32* %6, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), double %30, double %32, double %34)
%36 = add nuw nsw i64 %28, 1
%37 = icmp eq i64 %36, %16
br i1 %37, label %24, label %27
38: ; preds = %25, %38
%39 = phi i64 [ 0, %25 ], [ %47, %38 ]
%40 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 %39, i64 0
%41 = load double, double* %40
%42 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 %39, i64 1
%43 = load double, double* %42
%44 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 %39, i64 2
%45 = load double, double* %44
%46 = tail call i32 (i32*, i8*, double, ...) @fprintf(i32* %6, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), double %41, double %43, double %45)
%47 = add nuw nsw i64 %39, 1
%48 = icmp eq i64 %47, %26
br i1 %48, label %49, label %38
49: ; preds = %38, %5, %14, %24
ret void
}