; LLVM IR from bonamarton/phys_num :: euler_RK4_moon (RK4_moon)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@.str = external hidden unnamed_addr constant [12 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [27 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca [9 x double], align 16
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca double, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #5
  %13 = call i64 @clock() #5
  store i64 %13, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 10000000, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 1000, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 4, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 72, ptr %6) #5
  %14 = getelementptr inbounds [9 x double], ptr %6, i64 0, i64 0
  store double 5.973600e+24, ptr %14, align 16, !tbaa !11
  %15 = getelementptr inbounds [9 x double], ptr %6, i64 0, i64 1
  store double 7.349000e+22, ptr %15, align 8, !tbaa !11
  %16 = getelementptr inbounds [9 x double], ptr %6, i64 0, i64 2
  store double 4.055000e+08, ptr %16, align 16, !tbaa !11
  %17 = getelementptr inbounds [9 x double], ptr %6, i64 0, i64 3
  store double 3.633000e+08, ptr %17, align 8, !tbaa !11
  %18 = getelementptr inbounds [9 x double], ptr %6, i64 0, i64 4
  store double 9.640000e+02, ptr %18, align 16, !tbaa !11
  %19 = getelementptr inbounds [9 x double], ptr %6, i64 0, i64 5
  store double 1.076000e+03, ptr %19, align 8, !tbaa !11
  %20 = getelementptr inbounds [9 x double], ptr %6, i64 0, i64 6
  store double -6.673840e-11, ptr %20, align 16, !tbaa !11
  %21 = getelementptr inbounds [9 x double], ptr %6, i64 0, i64 6
  %22 = load double, ptr %21, align 16, !tbaa !11
  %23 = getelementptr inbounds [9 x double], ptr %6, i64 0, i64 0
  %24 = load double, ptr %23, align 16, !tbaa !11
  %25 = fmul double %22, %24
  %26 = getelementptr inbounds [9 x double], ptr %6, i64 0, i64 7
  store double %25, ptr %26, align 8, !tbaa !11
  %27 = getelementptr inbounds [9 x double], ptr %6, i64 0, i64 7
  %28 = load double, ptr %27, align 8, !tbaa !11
  %29 = getelementptr inbounds [9 x double], ptr %6, i64 0, i64 1
  %30 = load double, ptr %29, align 8, !tbaa !11
  %31 = fmul double %28, %30
  %32 = getelementptr inbounds [9 x double], ptr %6, i64 0, i64 8
  store double %31, ptr %32, align 16, !tbaa !11
  %33 = call ptr @llvm.stacksave.p0()
  store ptr %33, ptr %7, align 8
  %34 = alloca double, i64 8, align 16
  %35 = getelementptr inbounds double, ptr %34, i64 0
  store double 0.000000e+00, ptr %35, align 16, !tbaa !11
  %36 = getelementptr inbounds double, ptr %34, i64 1
  store double 3.633000e+08, ptr %36, align 8, !tbaa !11
  %37 = getelementptr inbounds double, ptr %34, i64 2
  store double 1.076000e+03, ptr %37, align 16, !tbaa !11
  %38 = getelementptr inbounds double, ptr %34, i64 3
  store double 0.000000e+00, ptr %38, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %39 = call noalias ptr @fopen(ptr noundef @.str, ptr noundef @.str.1)
  store ptr %39, ptr %8, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store i32 0, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %40 = call i32 @printIdx(i32 noundef 1000, i32 noundef 10000000, i32 noundef 100000)
  store i32 %40, ptr %11, align 4, !tbaa !9
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %41

41:                                               ; preds = %61, %0
  %42 = load i32, ptr %9, align 4, !tbaa !9
  %43 = icmp slt i32 %42, 10000000
  br i1 %43, label %44, label %64

44:                                               ; preds = %41
  %45 = load i32, ptr %10, align 4, !tbaa !9
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr %10, align 4, !tbaa !9
  %47 = load i32, ptr %11, align 4, !tbaa !9
  %48 = icmp eq i32 %46, %47
  br i1 %48, label %49, label %59

49:                                               ; preds = %44
  %50 = load ptr, ptr %8, align 8, !tbaa !13
  %51 = load i32, ptr %9, align 4, !tbaa !9
  %52 = getelementptr inbounds double, ptr %34, i64 0
  %53 = load double, ptr %52, align 16, !tbaa !11
  %54 = getelementptr inbounds double, ptr %34, i64 1
  %55 = load double, ptr %54, align 8, !tbaa !11
  %56 = getelementptr inbounds [9 x double], ptr %6, i64 0, i64 0
  %57 = call double @energy(ptr noundef %56, ptr noundef %34)
  %58 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %50, ptr noundef @.str.2, i32 noundef %51, double noundef %53, double noundef %55, double noundef %57) #5
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %59

59:                                               ; preds = %49, %44
  %60 = getelementptr inbounds [9 x double], ptr %6, i64 0, i64 0
  call void @RK4Step(ptr noundef %60, ptr noundef %34, i32 noundef 4, i32 noundef 1000)
  br label %61

61:                                               ; preds = %59
  %62 = load i32, ptr %9, align 4, !tbaa !9
  %63 = add nsw i32 %62, 1000
  store i32 %63, ptr %9, align 4, !tbaa !9
  br label %41, !llvm.loop !15

64:                                               ; preds = %41
  %65 = load ptr, ptr %8, align 8, !tbaa !13
  %66 = call ptr @freopen(ptr noundef @.str.3, ptr noundef @.str.1, ptr noundef %65)
  store ptr %66, ptr %8, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %67 = call i64 @clock() #5
  %68 = load i64, ptr %2, align 8, !tbaa !5
  %69 = sub nsw i64 %67, %68
  %70 = sitofp i64 %69 to double
  %71 = fdiv double %70, 1.000000e+06
  store double %71, ptr %12, align 8, !tbaa !11
  %72 = load ptr, ptr %8, align 8, !tbaa !13
  %73 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %72, ptr noundef @.str.4, i32 noundef 1000) #5
  %74 = load ptr, ptr %8, align 8, !tbaa !13
  %75 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %74, ptr noundef @.str.5, i32 noundef 10000000) #5
  %76 = load ptr, ptr %8, align 8, !tbaa !13
  %77 = load double, ptr %12, align 8, !tbaa !11
  %78 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %76, ptr noundef @.str.6, double noundef %77) #5
  %79 = load ptr, ptr %8, align 8, !tbaa !13
  %80 = call i32 @fclose(ptr noundef %79)
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  %81 = load ptr, ptr %7, align 8
  call void @llvm.stackrestore.p0(ptr %81)
  call void @llvm.lifetime.end.p0(i64 72, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #5
  %82 = load i32, ptr %1, align 4
  ret i32 %82
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind
declare i64 @clock() #2

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #3

declare noalias ptr @fopen(ptr noundef, ptr noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local i32 @printIdx(i32 noundef, i32 noundef, i32 noundef) #0

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #2

; Function Attrs: nounwind uwtable
declare dso_local double @energy(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @RK4Step(ptr noundef, ptr noundef, i32 noundef, i32 noundef) #0

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) #4

declare i32 @fclose(ptr noundef) #4

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #3

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nosync nounwind willreturn }
attributes #4 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"any pointer", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@.str = external hidden unnamed_addr constant [12 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [27 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca [9 x double], align 16
  %2 = tail call i64 @clock() #6
  call void @llvm.lifetime.start.p0(i64 72, ptr nonnull %1) #6
  store <2 x double> <double 5.973600e+24, double 7.349000e+22>, ptr %1, align 16, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %1, i64 16
  store <2 x double> <double 4.055000e+08, double 3.633000e+08>, ptr %3, align 16, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %1, i64 32
  store <2 x double> <double 9.640000e+02, double 1.076000e+03>, ptr %4, align 16, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %1, i64 48
  store <2 x double> <double -6.673840e-11, double 0xC2F6A963EB294000>, ptr %5, align 16, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %1, i64 64
  store double 0xC7B60A9E3F732281, ptr %6, align 16, !tbaa !5
  %7 = tail call ptr @llvm.stacksave.p0()
  %8 = alloca [8 x double], align 16
  %9 = getelementptr inbounds i8, ptr %8, i64 8
  store <2 x double> <double 0.000000e+00, double 3.633000e+08>, ptr %8, align 16, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %8, i64 16
  store <2 x double> <double 1.076000e+03, double 0.000000e+00>, ptr %10, align 16, !tbaa !5
  %11 = tail call noalias ptr @fopen(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1)
  %12 = tail call i32 @printIdx(i32 noundef 1000, i32 noundef 10000000, i32 noundef 100000)
  br label %13

13:                                               ; preds = %0, %21
  %.017 = phi i32 [ 0, %0 ], [ %.1, %21 ]
  %.01416 = phi i32 [ 0, %0 ], [ %22, %21 ]
  %14 = add nsw i32 %.017, 1
  %15 = icmp eq i32 %14, %12
  br i1 %15, label %16, label %21

16:                                               ; preds = %13
  %17 = load double, ptr %8, align 16, !tbaa !5
  %18 = load double, ptr %9, align 8, !tbaa !5
  %19 = call double @energy(ptr noundef nonnull %1, ptr noundef nonnull %8)
  %20 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef nonnull @.str.2, i32 noundef %.01416, double noundef %17, double noundef %18, double noundef %19) #6
  br label %21

21:                                               ; preds = %16, %13
  %.1 = phi i32 [ 0, %16 ], [ %14, %13 ]
  call void @RK4Step(ptr noundef nonnull %1, ptr noundef nonnull %8, i32 noundef 4, i32 noundef 1000)
  %22 = add nuw nsw i32 %.01416, 1000
  %23 = icmp ult i32 %.01416, 9999000
  br i1 %23, label %13, label %24, !llvm.loop !9

24:                                               ; preds = %21
  %25 = call ptr @freopen(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, ptr noundef %11) #6
  %26 = call i64 @clock() #6
  %27 = sub nsw i64 %26, %2
  %28 = sitofp i64 %27 to double
  %29 = fdiv double %28, 1.000000e+06
  %30 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %25, ptr noundef nonnull @.str.4, i32 noundef 1000) #6
  %31 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %25, ptr noundef nonnull @.str.5, i32 noundef 10000000) #6
  %32 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %25, ptr noundef nonnull @.str.6, double noundef %29) #6
  %33 = call i32 @fclose(ptr noundef %25)
  call void @llvm.stackrestore.p0(ptr %7)
  call void @llvm.lifetime.end.p0(i64 72, ptr nonnull %1) #6
  ret i32 0
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind
declare i64 @clock() local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #3

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
declare dso_local i32 @printIdx(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
declare dso_local double @energy(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @RK4Step(ptr noundef, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #5

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #3

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nocallback nofree nosync nounwind willreturn }
attributes #4 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass