#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*/ exit(int);
int /*<<< orphan*/ *fopen(char *, char *);
int fprintf(int /*<<< orphan*/, char *, int);
int fscanf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
void readnbody(int *nj, double *mj, double (*xj)[3], double (*vj)[3],
               char *fname) {
  int i, dummy, fi;
  double dummyd;
  FILE *fp;
  fp = fopen(fname, "r");
  if (fp == NULL) {
    perror("readnbody");
    exit(1);
  }
  fi = fscanf(fp, "%d\n", nj);
  fi = fscanf(fp, "%d\n", &dummy);
  fi = fscanf(fp, "%lf\n", &dummyd);
  fi = fprintf(stderr, "nj: %d\n", *nj);
  for (i = 0; i < *nj; i++) {
    fi = fscanf(fp, "%lf\n", mj + i);
  }
  for (i = 0; i < *nj; i++) {
    fi = fscanf(fp, "%lf %lf %lf\n", xj[i] + 0, xj[i] + 1, xj[i] + 2);
  }
  for (i = 0; i < *nj; i++) {
    fi = fscanf(fp, "%lf %lf %lf\n", vj[i] + 0, vj[i] + 1, vj[i] + 2);
  }
}


x86 assembly (clang, -O0):
<readnbody>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe89(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    11a1 <readnbody+0x51>
lea    0xe70(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x48(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe60(%rip),%rsi
mov    $0x0,%al
call   1030 <fscanf@plt>
mov    %eax,-0x34(%rbp)
mov    -0x48(%rbp),%rdi
lea    0xe4b(%rip),%rsi
lea    -0x30(%rbp),%rdx
mov    $0x0,%al
call   1030 <fscanf@plt>
mov    %eax,-0x34(%rbp)
mov    -0x48(%rbp),%rdi
lea    0xe3e(%rip),%rsi
lea    -0x40(%rbp),%rdx
mov    $0x0,%al
call   1030 <fscanf@plt>
mov    %eax,-0x34(%rbp)
mov    0x2ded(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
mov    (%rax),%edx
lea    0xe0a(%rip),%rsi
call   1040 <fprintf@plt>
mov    %eax,-0x34(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0x8(%rbp),%rcx
cmp    (%rcx),%eax
jge    1252 <readnbody+0x102>
mov    -0x48(%rbp),%rdi
mov    -0x10(%rbp),%rdx
movslq -0x2c(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdx
lea    0xde2(%rip),%rsi
mov    $0x0,%al
call   1030 <fscanf@plt>
mov    %eax,-0x34(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1211 <readnbody+0xc1>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0x8(%rbp),%rcx
cmp    (%rcx),%eax
jge    12c0 <readnbody+0x170>
mov    -0x48(%rbp),%rdi
mov    -0x18(%rbp),%rdx
movslq -0x2c(%rbp),%rax
imul   $0x18,%rax,%rax
add    %rax,%rdx
mov    -0x18(%rbp),%rcx
movslq -0x2c(%rbp),%rax
imul   $0x18,%rax,%rax
add    %rax,%rcx
add    $0x8,%rcx
mov    -0x18(%rbp),%r8
movslq -0x2c(%rbp),%rax
imul   $0x18,%rax,%rax
add    %rax,%r8
add    $0x10,%r8
lea    0xd6c(%rip),%rsi
mov    $0x0,%al
call   1030 <fscanf@plt>
mov    %eax,-0x34(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1259 <readnbody+0x109>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0x8(%rbp),%rcx
cmp    (%rcx),%eax
jge    132e <readnbody+0x1de>
mov    -0x48(%rbp),%rdi
mov    -0x20(%rbp),%rdx
movslq -0x2c(%rbp),%rax
imul   $0x18,%rax,%rax
add    %rax,%rdx
mov    -0x20(%rbp),%rcx
movslq -0x2c(%rbp),%rax
imul   $0x18,%rax,%rax
add    %rax,%rcx
add    $0x8,%rcx
mov    -0x20(%rbp),%r8
movslq -0x2c(%rbp),%rax
imul   $0x18,%rax,%rax
add    %rax,%r8
add    $0x10,%r8
lea    0xcfe(%rip),%rsi
mov    $0x0,%al
call   1030 <fscanf@plt>
mov    %eax,-0x34(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    12c7 <readnbody+0x177>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readnbody>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r12
mov    %rdx,%r13
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xe8f(%rip),%rsi
mov    %r8,%rdi
call   1050 <fopen@plt>
test   %rax,%rax
je     12a9 <readnbody+0x159>
mov    %rax,%r15
lea    0xe84(%rip),%rbp
mov    %rax,%rdi
mov    %rbp,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <fscanf@plt>
lea    0xc(%rsp),%rdx
mov    %r15,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1030 <fscanf@plt>
lea    0xe67(%rip),%rsi
lea    0x10(%rsp),%rdx
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <fscanf@plt>
mov    0x2e15(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%edx
lea    0xe35(%rip),%rsi
call   1040 <fprintf@plt>
cmpl   $0x0,(%r14)
jle    129a <readnbody+0x14a>
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
lea    0xe22(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <fscanf@plt>
add    $0x1,%rbp
movslq (%r14),%rax
add    $0x8,%rbx
cmp    %rax,%rbp
jl     11f0 <readnbody+0xa0>
test   %eax,%eax
jle    129a <readnbody+0x14a>
lea    0xdf1(%rip),%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
lea    0x8(%r13),%rcx
lea    0x10(%r13),%r8
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1030 <fscanf@plt>
add    $0x1,%rbp
movslq (%r14),%rax
add    $0x18,%r13
cmp    %rax,%rbp
jl     1230 <readnbody+0xe0>
test   %eax,%eax
jle    129a <readnbody+0x14a>
lea    0xdb1(%rip),%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
lea    0x8(%r12),%rcx
lea    0x10(%r12),%r8
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1030 <fscanf@plt>
add    $0x1,%rbp
movslq (%r14),%rax
add    $0x18,%r12
cmp    %rax,%rbp
jl     1270 <readnbody+0x120>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd52(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [10 x i8] c"readnbody\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [5 x i8] c"%lf\0A\00"
@stderr = global i32 0
@.str.4 = [8 x i8] c"nj: %d\0A\00"
@.str.5 = [13 x i8] c"%lf %lf %lf\0A\00"
define void @readnbody(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
%13 = alloca i32
%14 = alloca double
%15 = 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
%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** %15
%18 = load i32*, i32** %15
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %23
20: ; preds = %5
%21 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %5
%24 = load i32*, i32** %15
%25 = load i32*, i32** %6
%26 = call i32 (i32*, i8*, ...) @fscanf(i32* %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %25)
store i32 %26, i32* %13
%27 = load i32*, i32** %15
%28 = call i32 (i32*, i8*, ...) @fscanf(i32* %27, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %12)
store i32 %28, i32* %13
%29 = load i32*, i32** %15
%30 = call i32 (i32*, i8*, ...) @fscanf(i32* %29, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), double* %14)
store i32 %30, i32* %13
%31 = load i32, i32* @stderr
%32 = load i32*, i32** %6
%33 = load i32, i32* %32
%34 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %33)
store i32 %34, i32* %13
store i32 0, i32* %11
br label %35
35: ; preds = %47, %23
%36 = load i32, i32* %11
%37 = load i32*, i32** %6
%38 = load i32, i32* %37
%39 = icmp slt i32 %36, %38
br i1 %39, label %40, label %50
40: ; preds = %35
%41 = load i32*, i32** %15
%42 = load double*, double** %7
%43 = load i32, i32* %11
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds double, double* %42, i64 %44
%46 = call i32 (i32*, i8*, ...) @fscanf(i32* %41, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), double* %45)
store i32 %46, i32* %13
br label %47
47: ; preds = %40
%48 = load i32, i32* %11
%49 = add nsw i32 %48, 1
store i32 %49, i32* %11
br label %35
50: ; preds = %35
store i32 0, i32* %11
br label %51
51: ; preds = %77, %50
%52 = load i32, i32* %11
%53 = load i32*, i32** %6
%54 = load i32, i32* %53
%55 = icmp slt i32 %52, %54
br i1 %55, label %56, label %80
56: ; preds = %51
%57 = load i32*, i32** %15
%58 = load [3 x double]*, [3 x double]** %8
%59 = load i32, i32* %11
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [3 x double], [3 x double]* %58, i64 %60
%62 = getelementptr inbounds [3 x double], [3 x double]* %61, i64 0, i64 0
%63 = getelementptr inbounds double, double* %62, i64 0
%64 = load [3 x double]*, [3 x double]** %8
%65 = load i32, i32* %11
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [3 x double], [3 x double]* %64, i64 %66
%68 = getelementptr inbounds [3 x double], [3 x double]* %67, i64 0, i64 0
%69 = getelementptr inbounds double, double* %68, i64 1
%70 = load [3 x double]*, [3 x double]** %8
%71 = load i32, i32* %11
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds [3 x double], [3 x double]* %70, i64 %72
%74 = getelementptr inbounds [3 x double], [3 x double]* %73, i64 0, i64 0
%75 = getelementptr inbounds double, double* %74, i64 2
%76 = call i32 (i32*, i8*, ...) @fscanf(i32* %57, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), double* %63, double* %69, double* %75)
store i32 %76, i32* %13
br label %77
77: ; preds = %56
%78 = load i32, i32* %11
%79 = add nsw i32 %78, 1
store i32 %79, i32* %11
br label %51
80: ; preds = %51
store i32 0, i32* %11
br label %81
81: ; preds = %107, %80
%82 = load i32, i32* %11
%83 = load i32*, i32** %6
%84 = load i32, i32* %83
%85 = icmp slt i32 %82, %84
br i1 %85, label %86, label %110
86: ; preds = %81
%87 = load i32*, i32** %15
%88 = load [3 x double]*, [3 x double]** %9
%89 = load i32, i32* %11
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds [3 x double], [3 x double]* %88, i64 %90
%92 = getelementptr inbounds [3 x double], [3 x double]* %91, i64 0, i64 0
%93 = getelementptr inbounds double, double* %92, i64 0
%94 = load [3 x double]*, [3 x double]** %9
%95 = load i32, i32* %11
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds [3 x double], [3 x double]* %94, i64 %96
%98 = getelementptr inbounds [3 x double], [3 x double]* %97, i64 0, i64 0
%99 = getelementptr inbounds double, double* %98, i64 1
%100 = load [3 x double]*, [3 x double]** %9
%101 = load i32, i32* %11
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds [3 x double], [3 x double]* %100, i64 %102
%104 = getelementptr inbounds [3 x double], [3 x double]* %103, i64 0, i64 0
%105 = getelementptr inbounds double, double* %104, i64 2
%106 = call i32 (i32*, i8*, ...) @fscanf(i32* %87, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), double* %93, double* %99, double* %105)
store i32 %106, i32* %13
br label %107
107: ; preds = %86
%108 = load i32, i32* %11
%109 = add nsw i32 %108, 1
store i32 %109, i32* %11
br label %81
110: ; preds = %81
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [10 x i8] c"readnbody\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [5 x i8] c"%lf\0A\00"
@stderr = global i32 0
@.str.4 = [8 x i8] c"nj: %d\0A\00"
@.str.5 = [13 x i8] c"%lf %lf %lf\0A\00"
define void @readnbody(i32* %0, double* %1, [3 x double]* %2, [3 x double]* %3, i8* nocapture %4) {
%6 = alloca i32
%7 = alloca double
%8 = bitcast i32* %6 to i8*
%9 = bitcast double* %7 to i8*
%10 = tail call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %15
12: ; preds = %5
%13 = tail call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%14 = tail call i32 @exit(i32 1)
unreachable
15: ; preds = %5
%16 = tail call i32 (i32*, i8*, ...) @fscanf(i32* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %0)
%17 = call i32 (i32*, i8*, ...) @fscanf(i32* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %6)
%18 = call i32 (i32*, i8*, ...) @fscanf(i32* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), double* %7)
%19 = load i32, i32* @stderr
%20 = load i32, i32* %0
%21 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %20)
%22 = load i32, i32* %0
%23 = icmp sgt i32 %22, 0
br i1 %23, label %26, label %56
24: ; preds = %26
%25 = icmp sgt i32 %31, 0
br i1 %25, label %36, label %56
26: ; preds = %15, %26
%27 = phi i64 [ %30, %26 ], [ 0, %15 ]
%28 = getelementptr inbounds double, double* %1, i64 %27
%29 = call i32 (i32*, i8*, ...) @fscanf(i32* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), double* %28)
%30 = add nuw nsw i64 %27, 1
%31 = load i32, i32* %0
%32 = sext i32 %31 to i64
%33 = icmp slt i64 %30, %32
br i1 %33, label %26, label %24
34: ; preds = %36
%35 = icmp sgt i32 %43, 0
br i1 %35, label %46, label %56
36: ; preds = %24, %36
%37 = phi i64 [ %42, %36 ], [ 0, %24 ]
%38 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 %37, i64 0
%39 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 %37, i64 1
%40 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 %37, i64 2
%41 = call i32 (i32*, i8*, ...) @fscanf(i32* %10, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), double* %38, double* %39, double* %40)
%42 = add nuw nsw i64 %37, 1
%43 = load i32, i32* %0
%44 = sext i32 %43 to i64
%45 = icmp slt i64 %42, %44
br i1 %45, label %36, label %34
46: ; preds = %34, %46
%47 = phi i64 [ %52, %46 ], [ 0, %34 ]
%48 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 %47, i64 0
%49 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 %47, i64 1
%50 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 %47, i64 2
%51 = call i32 (i32*, i8*, ...) @fscanf(i32* %10, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), double* %48, double* %49, double* %50)
%52 = add nuw nsw i64 %47, 1
%53 = load i32, i32* %0
%54 = sext i32 %53 to i64
%55 = icmp slt i64 %52, %54
br i1 %55, label %46, label %56
56: ; preds = %46, %15, %24, %34
ret void
}