; LLVM IR from SourangshuGhosh/Fluid-Simulation-for-Computer-Graphics :: src/polygonizer3d.ll (ZN13Polygonizer3dC2EP11ScalarField)

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

%class.Polygonizer3d = type <{ i32, i32, i32, [4 x i8], double, double, ptr, i8, [7 x i8], ptr, i8, [7 x i8] }>

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN13Polygonizer3dC2EP11ScalarField(ptr noundef nonnull align 8 dereferenceable(57) %0, ptr noundef %1) unnamed_addr #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %8 = load ptr, ptr %3, align 8
  %9 = getelementptr inbounds %class.Polygonizer3d, ptr %8, i32 0, i32 0
  store i32 0, ptr %9, align 8, !tbaa !9
  %10 = getelementptr inbounds %class.Polygonizer3d, ptr %8, i32 0, i32 1
  store i32 0, ptr %10, align 4, !tbaa !14
  %11 = getelementptr inbounds %class.Polygonizer3d, ptr %8, i32 0, i32 2
  store i32 0, ptr %11, align 8, !tbaa !15
  %12 = getelementptr inbounds %class.Polygonizer3d, ptr %8, i32 0, i32 4
  store double 0.000000e+00, ptr %12, align 8, !tbaa !16
  %13 = getelementptr inbounds %class.Polygonizer3d, ptr %8, i32 0, i32 5
  store double 5.000000e-01, ptr %13, align 8, !tbaa !17
  %14 = getelementptr inbounds %class.Polygonizer3d, ptr %8, i32 0, i32 7
  store i8 0, ptr %14, align 8, !tbaa !18
  %15 = getelementptr inbounds %class.Polygonizer3d, ptr %8, i32 0, i32 10
  store i8 0, ptr %15, align 8, !tbaa !19
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %class.Polygonizer3d, ptr %8, i32 0, i32 6
  store ptr %16, ptr %17, align 8, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN11ScalarField17getGridDimensionsEPiS0_S0_(ptr noundef nonnull align 8 dereferenceable(248) %18, ptr noundef %5, ptr noundef %6, ptr noundef %7)
  %19 = load i32, ptr %5, align 4, !tbaa !21
  %20 = sub nsw i32 %19, 1
  %21 = getelementptr inbounds %class.Polygonizer3d, ptr %8, i32 0, i32 0
  store i32 %20, ptr %21, align 8, !tbaa !9
  %22 = load i32, ptr %6, align 4, !tbaa !21
  %23 = sub nsw i32 %22, 1
  %24 = getelementptr inbounds %class.Polygonizer3d, ptr %8, i32 0, i32 1
  store i32 %23, ptr %24, align 4, !tbaa !14
  %25 = load i32, ptr %7, align 4, !tbaa !21
  %26 = sub nsw i32 %25, 1
  %27 = getelementptr inbounds %class.Polygonizer3d, ptr %8, i32 0, i32 2
  store i32 %26, ptr %27, align 8, !tbaa !15
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = call noundef double @_ZN11ScalarField11getCellSizeEv(ptr noundef nonnull align 8 dereferenceable(248) %28)
  %30 = getelementptr inbounds %class.Polygonizer3d, ptr %8, i32 0, i32 4
  store double %29, ptr %30, align 8, !tbaa !16
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = call noundef double @_ZN11ScalarField19getSurfaceThresholdEv(ptr noundef nonnull align 8 dereferenceable(248) %31)
  %33 = getelementptr inbounds %class.Polygonizer3d, ptr %8, i32 0, i32 5
  store double %32, ptr %33, align 8, !tbaa !17
  %34 = getelementptr inbounds %class.Polygonizer3d, ptr %8, i32 0, i32 7
  store i8 1, ptr %34, align 8, !tbaa !18
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #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: mustprogress nounwind uwtable
declare dso_local void @_ZN11ScalarField17getGridDimensionsEPiS0_S0_(ptr noundef nonnull align 8 dereferenceable(248), ptr noundef, ptr noundef, ptr noundef) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZN11ScalarField11getCellSizeEv(ptr noundef nonnull align 8 dereferenceable(248)) #2 align 2

declare noundef double @_ZN11ScalarField19getSurfaceThresholdEv(ptr noundef nonnull align 8 dereferenceable(248)) #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 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 = { 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 #3 = { "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 #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, !11, i64 0}
!10 = !{!"_ZTS13Polygonizer3d", !11, i64 0, !11, i64 4, !11, i64 8, !12, i64 16, !12, i64 24, !6, i64 32, !13, i64 40, !6, i64 48, !13, i64 56}
!11 = !{!"int", !7, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!"bool", !7, i64 0}
!14 = !{!10, !11, i64 4}
!15 = !{!10, !11, i64 8}
!16 = !{!10, !12, i64 16}
!17 = !{!10, !12, i64 24}
!18 = !{!10, !13, i64 40}
!19 = !{!10, !13, i64 56}
!20 = !{!10, !6, i64 32}
!21 = !{!11, !11, i64 0}


; 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 uwtable
define dso_local void @_ZN13Polygonizer3dC2EP11ScalarField(ptr nocapture noundef nonnull writeonly align 8 dereferenceable(57) %0, ptr noundef nonnull %1) unnamed_addr #0 align 2 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store i32 0, ptr %0, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 0, ptr %6, align 4, !tbaa !13
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 0, ptr %7, align 8, !tbaa !14
  %8 = getelementptr inbounds i8, ptr %0, i64 16
  %9 = getelementptr inbounds i8, ptr %0, i64 24
  store <2 x double> <double 0.000000e+00, double 5.000000e-01>, ptr %8, align 8, !tbaa !15
  %10 = getelementptr inbounds i8, ptr %0, i64 40
  store i8 0, ptr %10, align 8, !tbaa !16
  %11 = getelementptr inbounds i8, ptr %0, i64 56
  store i8 0, ptr %11, align 8, !tbaa !17
  %12 = getelementptr inbounds i8, ptr %0, i64 32
  store ptr %1, ptr %12, align 8, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #4
  call void @_ZN11ScalarField17getGridDimensionsEPiS0_S0_(ptr noundef nonnull align 8 dereferenceable(248) %1, ptr noundef nonnull %3, ptr noundef nonnull %4, ptr noundef nonnull %5)
  %13 = load i32, ptr %3, align 4, !tbaa !19
  %14 = add nsw i32 %13, -1
  store i32 %14, ptr %0, align 8, !tbaa !5
  %15 = load i32, ptr %4, align 4, !tbaa !19
  %16 = add nsw i32 %15, -1
  store i32 %16, ptr %6, align 4, !tbaa !13
  %17 = load i32, ptr %5, align 4, !tbaa !19
  %18 = add nsw i32 %17, -1
  store i32 %18, ptr %7, align 8, !tbaa !14
  %19 = call noundef double @_ZN11ScalarField11getCellSizeEv(ptr noundef nonnull align 8 dereferenceable(248) %1)
  store double %19, ptr %8, align 8, !tbaa !20
  %20 = call noundef double @_ZN11ScalarField19getSurfaceThresholdEv(ptr noundef nonnull align 8 dereferenceable(248) %1)
  store double %20, ptr %9, align 8, !tbaa !21
  store i8 1, ptr %10, align 8, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #4
  ret void
}

; 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 nounwind uwtable
declare dso_local void @_ZN11ScalarField17getGridDimensionsEPiS0_S0_(ptr noundef nonnull align 8 dereferenceable(248), ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZN11ScalarField11getCellSizeEv(ptr noundef nonnull align 8 dereferenceable(248)) local_unnamed_addr #2 align 2

declare noundef double @_ZN11ScalarField19getSurfaceThresholdEv(ptr noundef nonnull align 8 dereferenceable(248)) local_unnamed_addr #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 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 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 #3 = { "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 #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, !7, i64 0}
!6 = !{!"_ZTS13Polygonizer3d", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 16, !10, i64 24, !11, i64 32, !12, i64 40, !11, i64 48, !12, i64 56}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"double", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"bool", !8, i64 0}
!13 = !{!6, !7, i64 4}
!14 = !{!6, !7, i64 8}
!15 = !{!10, !10, i64 0}
!16 = !{!6, !12, i64 40}
!17 = !{!6, !12, i64 56}
!18 = !{!6, !11, i64 32}
!19 = !{!7, !7, i64 0}
!20 = !{!6, !10, i64 16}
!21 = !{!6, !10, i64 24}


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