; LLVM IR from AasmundResell/CFD-Marker-and-Cell :: Marin_Datalab/src/calStreamFunction.ll (Z14streamFunctionRK5FieldR9Field_Vald)

; 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"

%struct.Field = type { [2704 x double], [2704 x double], [2704 x double] }
%struct.Field_Val = type { [2500 x double], [2500 x double], [2500 x double], [2601 x double] }

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z14streamFunctionRK5FieldR9Field_Vald(ptr noundef nonnull align 8 dereferenceable(64896) %0, ptr noundef nonnull align 8 dereferenceable(80808) %1, double noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca double, align 8
  %7 = alloca [2601 x double], align 16
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store double %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 20808, ptr %7) #4
  call void @llvm.memset.p0.i64(ptr align 16 %7, i8 0, i64 20808, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 1, ptr %8, align 4, !tbaa !11
  br label %14

14:                                               ; preds = %39, %3
  %15 = load i32, ptr %8, align 4, !tbaa !11
  %16 = icmp slt i32 %15, 51
  br i1 %16, label %18, label %17

17:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %42

18:                                               ; preds = %14
  %19 = load i32, ptr %8, align 4, !tbaa !11
  %20 = sub nsw i32 %19, 1
  %21 = add nsw i32 %20, 0
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [2601 x double], ptr %7, i64 0, i64 %22
  %24 = load double, ptr %23, align 8, !tbaa !9
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.Field, ptr %25, i32 0, i32 1
  %27 = load i32, ptr %8, align 4, !tbaa !11
  %28 = add nsw i32 %27, 0
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [2704 x double], ptr %26, i64 0, i64 %29
  %31 = load double, ptr %30, align 8, !tbaa !9
  %32 = load double, ptr %6, align 8, !tbaa !9
  %33 = fneg double %31
  %34 = call double @llvm.fmuladd.f64(double %33, double %32, double %24)
  %35 = load i32, ptr %8, align 4, !tbaa !11
  %36 = add nsw i32 %35, 0
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [2601 x double], ptr %7, i64 0, i64 %37
  store double %34, ptr %38, align 8, !tbaa !9
  br label %39

39:                                               ; preds = %18
  %40 = load i32, ptr %8, align 4, !tbaa !11
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %8, align 4, !tbaa !11
  br label %14, !llvm.loop !13

42:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %9, align 4, !tbaa !11
  br label %43

43:                                               ; preds = %82, %42
  %44 = load i32, ptr %9, align 4, !tbaa !11
  %45 = icmp slt i32 %44, 51
  br i1 %45, label %47, label %46

46:                                               ; preds = %43
  store i32 5, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %85

47:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 1, ptr %11, align 4, !tbaa !11
  br label %48

48:                                               ; preds = %78, %47
  %49 = load i32, ptr %11, align 4, !tbaa !11
  %50 = icmp slt i32 %49, 51
  br i1 %50, label %52, label %51

51:                                               ; preds = %48
  store i32 8, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %81

52:                                               ; preds = %48
  %53 = load i32, ptr %9, align 4, !tbaa !11
  %54 = load i32, ptr %11, align 4, !tbaa !11
  %55 = sub nsw i32 %54, 1
  %56 = mul nsw i32 %55, 50
  %57 = add nsw i32 %53, %56
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [2601 x double], ptr %7, i64 0, i64 %58
  %60 = load double, ptr %59, align 8, !tbaa !9
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.Field, ptr %61, i32 0, i32 0
  %63 = load i32, ptr %9, align 4, !tbaa !11
  %64 = load i32, ptr %11, align 4, !tbaa !11
  %65 = mul nsw i32 %64, 52
  %66 = add nsw i32 %63, %65
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [2704 x double], ptr %62, i64 0, i64 %67
  %69 = load double, ptr %68, align 8, !tbaa !9
  %70 = load double, ptr %6, align 8, !tbaa !9
  %71 = call double @llvm.fmuladd.f64(double %69, double %70, double %60)
  %72 = load i32, ptr %9, align 4, !tbaa !11
  %73 = load i32, ptr %11, align 4, !tbaa !11
  %74 = mul nsw i32 %73, 50
  %75 = add nsw i32 %72, %74
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [2601 x double], ptr %7, i64 0, i64 %76
  store double %71, ptr %77, align 8, !tbaa !9
  br label %78

78:                                               ; preds = %52
  %79 = load i32, ptr %11, align 4, !tbaa !11
  %80 = add nsw i32 %79, 1
  store i32 %80, ptr %11, align 4, !tbaa !11
  br label %48, !llvm.loop !15

81:                                               ; preds = %51
  br label %82

82:                                               ; preds = %81
  %83 = load i32, ptr %9, align 4, !tbaa !11
  %84 = add nsw i32 %83, 1
  store i32 %84, ptr %9, align 4, !tbaa !11
  br label %43, !llvm.loop !16

85:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  store i32 0, ptr %12, align 4, !tbaa !11
  br label %86

86:                                               ; preds = %116, %85
  %87 = load i32, ptr %12, align 4, !tbaa !11
  %88 = icmp sle i32 %87, 50
  br i1 %88, label %90, label %89

89:                                               ; preds = %86
  store i32 11, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %119

90:                                               ; preds = %86
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  store i32 0, ptr %13, align 4, !tbaa !11
  br label %91

91:                                               ; preds = %112, %90
  %92 = load i32, ptr %13, align 4, !tbaa !11
  %93 = icmp sle i32 %92, 50
  br i1 %93, label %95, label %94

94:                                               ; preds = %91
  store i32 14, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  br label %115

95:                                               ; preds = %91
  %96 = load i32, ptr %13, align 4, !tbaa !11
  %97 = load i32, ptr %12, align 4, !tbaa !11
  %98 = mul nsw i32 %97, 50
  %99 = add nsw i32 %96, %98
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [2601 x double], ptr %7, i64 0, i64 %100
  %102 = load double, ptr %101, align 8, !tbaa !9
  %103 = fneg double %102
  %104 = load ptr, ptr %5, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.Field_Val, ptr %104, i32 0, i32 3
  %106 = load i32, ptr %12, align 4, !tbaa !11
  %107 = load i32, ptr %13, align 4, !tbaa !11
  %108 = mul nsw i32 %107, 50
  %109 = add nsw i32 %106, %108
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [2601 x double], ptr %105, i64 0, i64 %110
  store double %103, ptr %111, align 8, !tbaa !9
  br label %112

112:                                              ; preds = %95
  %113 = load i32, ptr %13, align 4, !tbaa !11
  %114 = add nsw i32 %113, 1
  store i32 %114, ptr %13, align 4, !tbaa !11
  br label %91, !llvm.loop !17

115:                                              ; preds = %94
  br label %116

116:                                              ; preds = %115
  %117 = load i32, ptr %12, align 4, !tbaa !11
  %118 = add nsw i32 %117, 1
  store i32 %118, ptr %12, align 4, !tbaa !11
  br label %86, !llvm.loop !18

119:                                              ; preds = %89
  call void @llvm.lifetime.end.p0(i64 20808, ptr %7) #4
  ret void
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

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

attributes #0 = { mustprogress 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !14}
!18 = distinct !{!18, !14}


; 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"

; Function Attrs: mustprogress nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local void @_Z14streamFunctionRK5FieldR9Field_Vald(ptr nocapture noundef nonnull readonly align 8 dereferenceable(64896) %0, ptr nocapture noundef nonnull writeonly align 8 dereferenceable(80808) %1, double noundef %2) local_unnamed_addr #0 {
  %4 = alloca [2601 x double], align 16
  call void @llvm.lifetime.start.p0(i64 20808, ptr nonnull %4) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(20808) %4, i8 0, i64 20808, i1 false)
  %5 = getelementptr inbounds i8, ptr %0, i64 21632
  br label %6

6:                                                ; preds = %6, %3
  %7 = phi double [ 0.000000e+00, %3 ], [ %16, %6 ]
  %indvars.iv = phi i64 [ 1, %3 ], [ %indvars.iv.next.1, %6 ]
  %8 = getelementptr inbounds [2704 x double], ptr %5, i64 0, i64 %indvars.iv
  %9 = load double, ptr %8, align 8, !tbaa !5
  %10 = fneg double %9
  %11 = tail call double @llvm.fmuladd.f64(double %10, double %2, double %7)
  %12 = getelementptr inbounds [2601 x double], ptr %4, i64 0, i64 %indvars.iv
  store double %11, ptr %12, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %13 = getelementptr inbounds [2704 x double], ptr %5, i64 0, i64 %indvars.iv.next
  %14 = load double, ptr %13, align 8, !tbaa !5
  %15 = fneg double %14
  %16 = tail call double @llvm.fmuladd.f64(double %15, double %2, double %11)
  %17 = getelementptr inbounds [2601 x double], ptr %4, i64 0, i64 %indvars.iv.next
  store double %16, ptr %17, align 8, !tbaa !5
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next.1, 51
  br i1 %exitcond.not.1, label %.preheader32, label %6, !llvm.loop !9

.preheader32:                                     ; preds = %6, %20
  %indvars.iv44 = phi i64 [ %indvars.iv.next45, %20 ], [ 0, %6 ]
  %18 = add nsw i64 %indvars.iv44, -50
  br label %21

.preheader31:                                     ; preds = %20
  %19 = getelementptr inbounds i8, ptr %1, i64 60000
  br label %.preheader

20:                                               ; preds = %21
  %indvars.iv.next45 = add nuw nsw i64 %indvars.iv44, 1
  %exitcond47.not = icmp eq i64 %indvars.iv.next45, 51
  br i1 %exitcond47.not, label %.preheader31, label %.preheader32, !llvm.loop !11

21:                                               ; preds = %21, %.preheader32
  %indvars.iv40 = phi i64 [ 1, %.preheader32 ], [ %indvars.iv.next41.1, %21 ]
  %22 = mul nuw nsw i64 %indvars.iv40, 50
  %23 = add nsw i64 %18, %22
  %24 = getelementptr inbounds [2601 x double], ptr %4, i64 0, i64 %23
  %25 = load double, ptr %24, align 8, !tbaa !5
  %26 = mul nuw nsw i64 %indvars.iv40, 52
  %27 = add nuw nsw i64 %26, %indvars.iv44
  %28 = getelementptr inbounds [2704 x double], ptr %0, i64 0, i64 %27
  %29 = load double, ptr %28, align 8, !tbaa !5
  %30 = tail call double @llvm.fmuladd.f64(double %29, double %2, double %25)
  %31 = add nuw nsw i64 %22, %indvars.iv44
  %32 = getelementptr inbounds [2601 x double], ptr %4, i64 0, i64 %31
  store double %30, ptr %32, align 8, !tbaa !5
  %indvars.iv.next41 = add nuw nsw i64 %indvars.iv40, 1
  %33 = mul nuw nsw i64 %indvars.iv.next41, 50
  %34 = add nsw i64 %18, %33
  %35 = getelementptr inbounds [2601 x double], ptr %4, i64 0, i64 %34
  %36 = load double, ptr %35, align 8, !tbaa !5
  %37 = mul nuw nsw i64 %indvars.iv.next41, 52
  %38 = add nuw nsw i64 %37, %indvars.iv44
  %39 = getelementptr inbounds [2704 x double], ptr %0, i64 0, i64 %38
  %40 = load double, ptr %39, align 8, !tbaa !5
  %41 = tail call double @llvm.fmuladd.f64(double %40, double %2, double %36)
  %42 = add nuw nsw i64 %33, %indvars.iv44
  %43 = getelementptr inbounds [2601 x double], ptr %4, i64 0, i64 %42
  store double %41, ptr %43, align 8, !tbaa !5
  %indvars.iv.next41.1 = add nuw nsw i64 %indvars.iv40, 2
  %exitcond43.not.1 = icmp eq i64 %indvars.iv.next41.1, 51
  br i1 %exitcond43.not.1, label %20, label %21, !llvm.loop !12

.preheader:                                       ; preds = %.preheader31, %46
  %indvars.iv52 = phi i64 [ 0, %.preheader31 ], [ %indvars.iv.next53, %46 ]
  %44 = mul nuw nsw i64 %indvars.iv52, 50
  br label %47

45:                                               ; preds = %46
  call void @llvm.lifetime.end.p0(i64 20808, ptr nonnull %4) #4
  ret void

46:                                               ; preds = %47
  %indvars.iv.next53 = add nuw nsw i64 %indvars.iv52, 1
  %exitcond55.not = icmp eq i64 %indvars.iv.next53, 51
  br i1 %exitcond55.not, label %45, label %.preheader, !llvm.loop !13

47:                                               ; preds = %47, %.preheader
  %indvars.iv48 = phi i64 [ 0, %.preheader ], [ %indvars.iv.next49.2, %47 ]
  %48 = add nuw nsw i64 %indvars.iv48, %44
  %49 = getelementptr inbounds [2601 x double], ptr %4, i64 0, i64 %48
  %50 = load double, ptr %49, align 8, !tbaa !5
  %51 = fneg double %50
  %52 = mul nuw nsw i64 %indvars.iv48, 50
  %53 = add nuw nsw i64 %52, %indvars.iv52
  %54 = getelementptr inbounds [2601 x double], ptr %19, i64 0, i64 %53
  store double %51, ptr %54, align 8, !tbaa !5
  %indvars.iv.next49 = add nuw nsw i64 %indvars.iv48, 1
  %55 = add nuw nsw i64 %indvars.iv.next49, %44
  %56 = getelementptr inbounds [2601 x double], ptr %4, i64 0, i64 %55
  %57 = load double, ptr %56, align 8, !tbaa !5
  %58 = fneg double %57
  %59 = mul nuw nsw i64 %indvars.iv.next49, 50
  %60 = add nuw nsw i64 %59, %indvars.iv52
  %61 = getelementptr inbounds [2601 x double], ptr %19, i64 0, i64 %60
  store double %58, ptr %61, align 8, !tbaa !5
  %indvars.iv.next49.1 = add nuw nsw i64 %indvars.iv48, 2
  %62 = add nuw nsw i64 %indvars.iv.next49.1, %44
  %63 = getelementptr inbounds [2601 x double], ptr %4, i64 0, i64 %62
  %64 = load double, ptr %63, align 8, !tbaa !5
  %65 = fneg double %64
  %66 = mul nuw nsw i64 %indvars.iv.next49.1, 50
  %67 = add nuw nsw i64 %66, %indvars.iv52
  %68 = getelementptr inbounds [2601 x double], ptr %19, i64 0, i64 %67
  store double %65, ptr %68, align 8, !tbaa !5
  %indvars.iv.next49.2 = add nuw nsw i64 %indvars.iv48, 3
  %exitcond51.not.2 = icmp eq i64 %indvars.iv.next49.2, 51
  br i1 %exitcond51.not.2, label %46, label %47, !llvm.loop !14
}

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

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

attributes #0 = { mustprogress nofree norecurse nosync nounwind memory(argmem: readwrite) 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass