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

; 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] }

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z11cavityBoxBCR5Field(ptr noundef nonnull align 8 dereferenceable(64896) %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %5

5:                                                ; preds = %56, %1
  %6 = load i32, ptr %3, align 4, !tbaa !9
  %7 = icmp sle i32 %6, 51
  br i1 %7, label %9, label %8

8:                                                ; preds = %5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  br label %59

9:                                                ; preds = %5
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.Field, ptr %10, i32 0, i32 0
  %12 = load i32, ptr %3, align 4, !tbaa !9
  %13 = mul nsw i32 %12, 52
  %14 = add nsw i32 0, %13
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [2704 x double], ptr %11, i64 0, i64 %15
  store double 0.000000e+00, ptr %16, align 8, !tbaa !11
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.Field, ptr %17, i32 0, i32 1
  %19 = load i32, ptr %3, align 4, !tbaa !9
  %20 = mul nsw i32 %19, 52
  %21 = add nsw i32 1, %20
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [2704 x double], ptr %18, i64 0, i64 %22
  %24 = load double, ptr %23, align 8, !tbaa !11
  %25 = fneg double %24
  %26 = load ptr, ptr %2, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.Field, ptr %26, i32 0, i32 1
  %28 = load i32, ptr %3, align 4, !tbaa !9
  %29 = mul nsw i32 %28, 52
  %30 = add nsw i32 0, %29
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [2704 x double], ptr %27, i64 0, i64 %31
  store double %25, ptr %32, align 8, !tbaa !11
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.Field, ptr %33, i32 0, i32 0
  %35 = load i32, ptr %3, align 4, !tbaa !9
  %36 = mul nsw i32 %35, 52
  %37 = add nsw i32 50, %36
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [2704 x double], ptr %34, i64 0, i64 %38
  store double 0.000000e+00, ptr %39, align 8, !tbaa !11
  %40 = load ptr, ptr %2, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.Field, ptr %40, i32 0, i32 1
  %42 = load i32, ptr %3, align 4, !tbaa !9
  %43 = mul nsw i32 %42, 52
  %44 = add nsw i32 50, %43
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [2704 x double], ptr %41, i64 0, i64 %45
  %47 = load double, ptr %46, align 8, !tbaa !11
  %48 = fneg double %47
  %49 = load ptr, ptr %2, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.Field, ptr %49, i32 0, i32 1
  %51 = load i32, ptr %3, align 4, !tbaa !9
  %52 = mul nsw i32 %51, 52
  %53 = add nsw i32 51, %52
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [2704 x double], ptr %50, i64 0, i64 %54
  store double %48, ptr %55, align 8, !tbaa !11
  br label %56

56:                                               ; preds = %9
  %57 = load i32, ptr %3, align 4, !tbaa !9
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %3, align 4, !tbaa !9
  br label %5, !llvm.loop !13

59:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %60

60:                                               ; preds = %106, %59
  %61 = load i32, ptr %4, align 4, !tbaa !9
  %62 = icmp sle i32 %61, 51
  br i1 %62, label %64, label %63

63:                                               ; preds = %60
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  br label %109

64:                                               ; preds = %60
  %65 = load ptr, ptr %2, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.Field, ptr %65, i32 0, i32 1
  %67 = load i32, ptr %4, align 4, !tbaa !9
  %68 = add nsw i32 %67, 2600
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [2704 x double], ptr %66, i64 0, i64 %69
  store double 0.000000e+00, ptr %70, align 8, !tbaa !11
  %71 = load ptr, ptr %2, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.Field, ptr %71, i32 0, i32 1
  %73 = load i32, ptr %4, align 4, !tbaa !9
  %74 = add nsw i32 %73, 0
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [2704 x double], ptr %72, i64 0, i64 %75
  store double 0.000000e+00, ptr %76, align 8, !tbaa !11
  %77 = load ptr, ptr %2, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.Field, ptr %77, i32 0, i32 0
  %79 = load i32, ptr %4, align 4, !tbaa !9
  %80 = add nsw i32 %79, 2600
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [2704 x double], ptr %78, i64 0, i64 %81
  %83 = load double, ptr %82, align 8, !tbaa !11
  %84 = fneg double %83
  %85 = fadd double %84, 2.000000e+00
  %86 = load ptr, ptr %2, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.Field, ptr %86, i32 0, i32 0
  %88 = load i32, ptr %4, align 4, !tbaa !9
  %89 = add nsw i32 %88, 2652
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [2704 x double], ptr %87, i64 0, i64 %90
  store double %85, ptr %91, align 8, !tbaa !11
  %92 = load ptr, ptr %2, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.Field, ptr %92, i32 0, i32 0
  %94 = load i32, ptr %4, align 4, !tbaa !9
  %95 = add nsw i32 %94, 52
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [2704 x double], ptr %93, i64 0, i64 %96
  %98 = load double, ptr %97, align 8, !tbaa !11
  %99 = fneg double %98
  %100 = load ptr, ptr %2, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.Field, ptr %100, i32 0, i32 0
  %102 = load i32, ptr %4, align 4, !tbaa !9
  %103 = add nsw i32 %102, 0
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [2704 x double], ptr %101, i64 0, i64 %104
  store double %99, ptr %105, align 8, !tbaa !11
  br label %106

106:                                              ; preds = %64
  %107 = load i32, ptr %4, align 4, !tbaa !9
  %108 = add nsw i32 %107, 1
  store i32 %108, ptr %4, align 4, !tbaa !9
  br label %60, !llvm.loop !15

109:                                              ; preds = %63
  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 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 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !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 @_Z11cavityBoxBCR5Field(ptr nocapture noundef nonnull align 8 dereferenceable(64896) %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 21632
  br label %3

3:                                                ; preds = %1, %3
  %indvars.iv = phi i64 [ 0, %1 ], [ %indvars.iv.next, %3 ]
  %4 = mul nuw nsw i64 %indvars.iv, 52
  %5 = getelementptr inbounds [2704 x double], ptr %0, i64 0, i64 %4
  store double 0.000000e+00, ptr %5, align 8, !tbaa !5
  %6 = or disjoint i64 %4, 1
  %7 = getelementptr inbounds [2704 x double], ptr %2, i64 0, i64 %6
  %8 = load double, ptr %7, align 8, !tbaa !5
  %9 = fneg double %8
  %10 = getelementptr inbounds [2704 x double], ptr %2, i64 0, i64 %4
  store double %9, ptr %10, align 8, !tbaa !5
  %11 = add nuw nsw i64 %4, 50
  %12 = getelementptr inbounds [2704 x double], ptr %0, i64 0, i64 %11
  store double 0.000000e+00, ptr %12, align 8, !tbaa !5
  %13 = getelementptr inbounds [2704 x double], ptr %2, i64 0, i64 %11
  %14 = load double, ptr %13, align 8, !tbaa !5
  %15 = fneg double %14
  %16 = add nuw nsw i64 %4, 51
  %17 = getelementptr inbounds [2704 x double], ptr %2, i64 0, i64 %16
  store double %15, ptr %17, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 52
  br i1 %exitcond.not, label %vector.body, label %3, !llvm.loop !9

vector.body:                                      ; preds = %3, %vector.body
  %index = phi i64 [ %index.next, %vector.body ], [ 0, %3 ]
  %18 = add nuw nsw i64 %index, 2600
  %19 = getelementptr inbounds [2704 x double], ptr %2, i64 0, i64 %18
  store <2 x double> zeroinitializer, ptr %19, align 8, !tbaa !5
  %20 = getelementptr inbounds [2704 x double], ptr %2, i64 0, i64 %index
  store <2 x double> zeroinitializer, ptr %20, align 8, !tbaa !5
  %21 = getelementptr inbounds [2704 x double], ptr %0, i64 0, i64 %18
  %wide.load = load <2 x double>, ptr %21, align 8, !tbaa !5
  %22 = fsub <2 x double> <double 2.000000e+00, double 2.000000e+00>, %wide.load
  %23 = add nuw nsw i64 %index, 2652
  %24 = getelementptr inbounds [2704 x double], ptr %0, i64 0, i64 %23
  store <2 x double> %22, ptr %24, align 8, !tbaa !5
  %25 = add nuw nsw i64 %index, 52
  %26 = getelementptr inbounds [2704 x double], ptr %0, i64 0, i64 %25
  %wide.load35 = load <2 x double>, ptr %26, align 8, !tbaa !5
  %27 = fneg <2 x double> %wide.load35
  %28 = getelementptr inbounds [2704 x double], ptr %0, i64 0, i64 %index
  store <2 x double> %27, ptr %28, align 8, !tbaa !5
  %index.next = add nuw i64 %index, 2
  %29 = icmp eq i64 %index.next, 52
  br i1 %29, label %middle.block, label %vector.body, !llvm.loop !11

middle.block:                                     ; preds = %vector.body
  ret void
}

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

!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, !13}
!12 = !{!"llvm.loop.isvectorized", i32 1}
!13 = !{!"llvm.loop.unroll.runtime.disable"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass