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

; 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 @_Z18flowAroundVPlateBCR5Field(ptr noundef nonnull align 8 dereferenceable(64896) %0) #0 {
  %2 = alloca ptr, align 8
  %3 = 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 %4

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

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

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

55:                                               ; preds = %8
  %56 = load i32, ptr %3, align 4, !tbaa !9
  %57 = icmp sle i32 %56, 37
  br i1 %57, label %58, label %82

58:                                               ; preds = %55
  %59 = load ptr, ptr %2, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.Field, ptr %59, i32 0, i32 0
  %61 = load i32, ptr %3, align 4, !tbaa !9
  %62 = mul nsw i32 %61, 52
  %63 = add nsw i32 16, %62
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [2704 x double], ptr %60, i64 0, i64 %64
  store double 0.000000e+00, ptr %65, align 8, !tbaa !11
  %66 = load ptr, ptr %2, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.Field, ptr %66, i32 0, i32 1
  %68 = load i32, ptr %3, align 4, !tbaa !9
  %69 = mul nsw i32 %68, 52
  %70 = add nsw i32 17, %69
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [2704 x double], ptr %67, i64 0, i64 %71
  %73 = load double, ptr %72, align 8, !tbaa !11
  %74 = fneg double %73
  %75 = load ptr, ptr %2, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.Field, ptr %75, i32 0, i32 1
  %77 = load i32, ptr %3, align 4, !tbaa !9
  %78 = mul nsw i32 %77, 52
  %79 = add nsw i32 16, %78
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [2704 x double], ptr %76, i64 0, i64 %80
  store double %74, ptr %81, align 8, !tbaa !11
  br label %82

82:                                               ; preds = %58, %55, %8
  %83 = load ptr, ptr %2, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.Field, ptr %83, i32 0, i32 0
  %85 = load i32, ptr %3, align 4, !tbaa !9
  %86 = add nsw i32 %85, 52
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [2704 x double], ptr %84, i64 0, i64 %87
  %89 = load double, ptr %88, align 8, !tbaa !11
  %90 = fneg double %89
  %91 = load ptr, ptr %2, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.Field, ptr %91, i32 0, i32 0
  %93 = load i32, ptr %3, align 4, !tbaa !9
  %94 = add nsw i32 %93, 0
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [2704 x double], ptr %92, i64 0, i64 %95
  store double %90, ptr %96, align 8, !tbaa !11
  %97 = load ptr, ptr %2, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.Field, ptr %97, i32 0, i32 1
  %99 = load i32, ptr %3, align 4, !tbaa !9
  %100 = add nsw i32 %99, 0
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [2704 x double], ptr %98, i64 0, i64 %101
  store double 0.000000e+00, ptr %102, align 8, !tbaa !11
  %103 = load ptr, ptr %2, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.Field, ptr %103, i32 0, i32 0
  %105 = load i32, ptr %3, align 4, !tbaa !9
  %106 = add nsw i32 %105, 2600
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds [2704 x double], ptr %104, i64 0, i64 %107
  %109 = load double, ptr %108, align 8, !tbaa !11
  %110 = fneg double %109
  %111 = load ptr, ptr %2, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.Field, ptr %111, i32 0, i32 0
  %113 = load i32, ptr %3, align 4, !tbaa !9
  %114 = add nsw i32 %113, 2652
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds [2704 x double], ptr %112, i64 0, i64 %115
  store double %110, ptr %116, align 8, !tbaa !11
  %117 = load ptr, ptr %2, align 8, !tbaa !5
  %118 = getelementptr inbounds %struct.Field, ptr %117, i32 0, i32 1
  %119 = load i32, ptr %3, align 4, !tbaa !9
  %120 = add nsw i32 %119, 2600
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [2704 x double], ptr %118, i64 0, i64 %121
  store double 0.000000e+00, ptr %122, align 8, !tbaa !11
  br label %123

123:                                              ; preds = %82
  %124 = load i32, ptr %3, align 4, !tbaa !9
  %125 = add nsw i32 %124, 1
  store i32 %125, ptr %3, align 4, !tbaa !9
  br label %4, !llvm.loop !13

126:                                              ; preds = %7
  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"}


; 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 @_Z18flowAroundVPlateBCR5Field(ptr nocapture noundef nonnull align 8 dereferenceable(64896) %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 21632
  br label %4

3:                                                ; preds = %23
  ret void

4:                                                ; preds = %1, %23
  %indvars.iv = phi i64 [ 0, %1 ], [ %indvars.iv.next, %23 ]
  %5 = mul nuw nsw i64 %indvars.iv, 52
  %6 = getelementptr inbounds [2704 x double], ptr %2, i64 0, i64 %5
  store double 0.000000e+00, ptr %6, align 8, !tbaa !5
  %7 = getelementptr inbounds [2704 x double], ptr %0, i64 0, i64 %5
  store double 1.000000e+00, ptr %7, align 8, !tbaa !5
  %8 = add nuw nsw i64 %5, 50
  %9 = getelementptr inbounds [2704 x double], ptr %0, i64 0, i64 %8
  %10 = load double, ptr %9, align 8, !tbaa !5
  %11 = add nuw nsw i64 %5, 51
  %12 = getelementptr inbounds [2704 x double], ptr %0, i64 0, i64 %11
  store double %10, ptr %12, align 8, !tbaa !5
  %13 = trunc i64 %indvars.iv to i32
  %14 = add i32 %13, -13
  %or.cond = icmp ult i32 %14, 25
  br i1 %or.cond, label %15, label %23

15:                                               ; preds = %4
  %16 = add nuw nsw i64 %5, 16
  %17 = getelementptr inbounds [2704 x double], ptr %0, i64 0, i64 %16
  store double 0.000000e+00, ptr %17, align 8, !tbaa !5
  %18 = add nuw nsw i64 %5, 17
  %19 = getelementptr inbounds [2704 x double], ptr %2, i64 0, i64 %18
  %20 = load double, ptr %19, align 8, !tbaa !5
  %21 = fneg double %20
  %22 = getelementptr inbounds [2704 x double], ptr %2, i64 0, i64 %16
  store double %21, ptr %22, align 8, !tbaa !5
  br label %23

23:                                               ; preds = %15, %4
  %24 = add nuw nsw i64 %indvars.iv, 52
  %25 = getelementptr inbounds [2704 x double], ptr %0, i64 0, i64 %24
  %26 = load double, ptr %25, align 8, !tbaa !5
  %27 = fneg double %26
  %28 = getelementptr inbounds [2704 x double], ptr %0, i64 0, i64 %indvars.iv
  store double %27, ptr %28, align 8, !tbaa !5
  %29 = getelementptr inbounds [2704 x double], ptr %2, i64 0, i64 %indvars.iv
  store double 0.000000e+00, ptr %29, align 8, !tbaa !5
  %30 = add nuw nsw i64 %indvars.iv, 2600
  %31 = getelementptr inbounds [2704 x double], ptr %0, i64 0, i64 %30
  %32 = load double, ptr %31, align 8, !tbaa !5
  %33 = fneg double %32
  %34 = add nuw nsw i64 %indvars.iv, 2652
  %35 = getelementptr inbounds [2704 x double], ptr %0, i64 0, i64 %34
  store double %33, ptr %35, align 8, !tbaa !5
  %36 = getelementptr inbounds [2704 x double], ptr %2, i64 0, i64 %30
  store double 0.000000e+00, ptr %36, 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 %3, label %4, !llvm.loop !9
}

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


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass