; LLVM IR from bohanwang/libpgo :: src/core/perlinNoise/perlinWind.ll (ZN3pgo11PerlinNoise10PerlinWindC2EPdd)

; 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.pgo::PerlinNoise::PerlinWind" = type { ptr, double, [3 x double], [4 x ptr] }

@_ZTVN3pgo11PerlinNoise10PerlinWindE = external dso_local unnamed_addr constant { [4 x ptr] }, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3pgo11PerlinNoise10PerlinWindC2EPdd(ptr noundef nonnull align 8 dereferenceable(72) %0, ptr noundef %1, double noundef %2) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca double, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = 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
  %10 = load ptr, ptr %4, align 8
  store ptr getelementptr inbounds inrange(-16, 16) ({ [4 x ptr] }, ptr @_ZTVN3pgo11PerlinNoise10PerlinWindE, i32 0, i32 0, i32 2), ptr %10, align 8, !tbaa !11
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds double, ptr %11, i64 0
  %13 = load double, ptr %12, align 8, !tbaa !9
  %14 = getelementptr inbounds %"class.pgo::PerlinNoise::PerlinWind", ptr %10, i32 0, i32 2
  %15 = getelementptr inbounds [3 x double], ptr %14, i64 0, i64 0
  store double %13, ptr %15, align 8, !tbaa !9
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = getelementptr inbounds double, ptr %16, i64 1
  %18 = load double, ptr %17, align 8, !tbaa !9
  %19 = getelementptr inbounds %"class.pgo::PerlinNoise::PerlinWind", ptr %10, i32 0, i32 2
  %20 = getelementptr inbounds [3 x double], ptr %19, i64 0, i64 1
  store double %18, ptr %20, align 8, !tbaa !9
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds double, ptr %21, i64 2
  %23 = load double, ptr %22, align 8, !tbaa !9
  %24 = getelementptr inbounds %"class.pgo::PerlinNoise::PerlinWind", ptr %10, i32 0, i32 2
  %25 = getelementptr inbounds [3 x double], ptr %24, i64 0, i64 2
  store double %23, ptr %25, align 8, !tbaa !9
  %26 = load double, ptr %6, align 8, !tbaa !9
  %27 = getelementptr inbounds %"class.pgo::PerlinNoise::PerlinWind", ptr %10, i32 0, i32 1
  store double %26, ptr %27, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 0, ptr %7, align 4, !tbaa !15
  br label %28

28:                                               ; preds = %39, %3
  %29 = load i32, ptr %7, align 4, !tbaa !15
  %30 = icmp slt i32 %29, 4
  br i1 %30, label %32, label %31

31:                                               ; preds = %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %46

32:                                               ; preds = %28
  %33 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 2496) #6
  invoke void @_ZN3pgo11PerlinNoise11PerlinNoiseC1Ev(ptr noundef nonnull align 8 dereferenceable(2496) %33)
          to label %34 unwind label %42

34:                                               ; preds = %32
  %35 = getelementptr inbounds %"class.pgo::PerlinNoise::PerlinWind", ptr %10, i32 0, i32 3
  %36 = load i32, ptr %7, align 4, !tbaa !15
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [4 x ptr], ptr %35, i64 0, i64 %37
  store ptr %33, ptr %38, align 8, !tbaa !5
  br label %39

39:                                               ; preds = %34
  %40 = load i32, ptr %7, align 4, !tbaa !15
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %7, align 4, !tbaa !15
  br label %28, !llvm.loop !17

42:                                               ; preds = %32
  %43 = landingpad { ptr, i32 }
          cleanup
  %44 = extractvalue { ptr, i32 } %43, 0
  store ptr %44, ptr %8, align 8
  %45 = extractvalue { ptr, i32 } %43, 1
  store i32 %45, ptr %9, align 4
  call void @_ZdlPvm(ptr noundef %33, i64 noundef 2496) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %47

46:                                               ; preds = %31
  ret void

47:                                               ; preds = %42
  %48 = load ptr, ptr %8, align 8
  %49 = load i32, ptr %9, align 4
  %50 = insertvalue { ptr, i32 } poison, ptr %48, 0
  %51 = insertvalue { ptr, i32 } %50, i32 %49, 1
  resume { ptr, i32 } %51
}

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

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #2

declare void @_ZN3pgo11PerlinNoise11PerlinNoiseC1Ev(ptr noundef nonnull align 8 dereferenceable(2496)) unnamed_addr #3

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #4

; 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 = { nobuiltin allocsize(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 = { nobuiltin 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 = { nounwind }
attributes #6 = { builtin allocsize(0) }
attributes #7 = { builtin 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 = !{!"vtable pointer", !8, i64 0}
!13 = !{!14, !10, i64 8}
!14 = !{!"_ZTSN3pgo11PerlinNoise10PerlinWindE", !10, i64 8, !7, i64 16, !7, i64 40}
!15 = !{!16, !16, i64 0}
!16 = !{!"int", !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"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"

@_ZTVN3pgo11PerlinNoise10PerlinWindE = external dso_local unnamed_addr constant { [4 x ptr] }, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3pgo11PerlinNoise10PerlinWindC2EPdd(ptr nocapture noundef nonnull writeonly align 8 dereferenceable(72) %0, ptr nocapture noundef readonly %1, double noundef %2) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  store ptr getelementptr inbounds inrange(-16, 16) (i8, ptr @_ZTVN3pgo11PerlinNoise10PerlinWindE, i64 16), ptr %0, align 8, !tbaa !5
  %4 = load double, ptr %1, align 8, !tbaa !8
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  store double %4, ptr %5, align 8, !tbaa !8
  %6 = getelementptr inbounds i8, ptr %1, i64 8
  %7 = load double, ptr %6, align 8, !tbaa !8
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  store double %7, ptr %8, align 8, !tbaa !8
  %9 = getelementptr inbounds i8, ptr %1, i64 16
  %10 = load double, ptr %9, align 8, !tbaa !8
  %11 = getelementptr inbounds i8, ptr %0, i64 32
  store double %10, ptr %11, align 8, !tbaa !8
  %12 = getelementptr inbounds i8, ptr %0, i64 8
  store double %2, ptr %12, align 8, !tbaa !11
  %13 = tail call noalias noundef nonnull dereferenceable(2496) ptr @_Znwm(i64 noundef 2496) #4
  invoke void @_ZN3pgo11PerlinNoise11PerlinNoiseC1Ev(ptr noundef nonnull align 8 dereferenceable(2496) %13)
          to label %14 unwind label %25

14:                                               ; preds = %3
  %15 = getelementptr inbounds i8, ptr %0, i64 40
  store ptr %13, ptr %15, align 8, !tbaa !13
  %16 = tail call noalias noundef nonnull dereferenceable(2496) ptr @_Znwm(i64 noundef 2496) #4
  invoke void @_ZN3pgo11PerlinNoise11PerlinNoiseC1Ev(ptr noundef nonnull align 8 dereferenceable(2496) %16)
          to label %17 unwind label %25

17:                                               ; preds = %14
  %18 = getelementptr inbounds i8, ptr %0, i64 48
  store ptr %16, ptr %18, align 8, !tbaa !13
  %19 = tail call noalias noundef nonnull dereferenceable(2496) ptr @_Znwm(i64 noundef 2496) #4
  invoke void @_ZN3pgo11PerlinNoise11PerlinNoiseC1Ev(ptr noundef nonnull align 8 dereferenceable(2496) %19)
          to label %20 unwind label %25

20:                                               ; preds = %17
  %21 = getelementptr inbounds i8, ptr %0, i64 56
  store ptr %19, ptr %21, align 8, !tbaa !13
  %22 = tail call noalias noundef nonnull dereferenceable(2496) ptr @_Znwm(i64 noundef 2496) #4
  invoke void @_ZN3pgo11PerlinNoise11PerlinNoiseC1Ev(ptr noundef nonnull align 8 dereferenceable(2496) %22)
          to label %23 unwind label %25

23:                                               ; preds = %20
  %24 = getelementptr inbounds i8, ptr %0, i64 64
  store ptr %22, ptr %24, align 8, !tbaa !13
  ret void

25:                                               ; preds = %20, %17, %14, %3
  %.lcssa = phi ptr [ %13, %3 ], [ %16, %14 ], [ %19, %17 ], [ %22, %20 ]
  %26 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %.lcssa, i64 noundef 2496) #5
  resume { ptr, i32 } %26
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #1

declare void @_ZN3pgo11PerlinNoise11PerlinNoiseC1Ev(ptr noundef nonnull align 8 dereferenceable(2496)) unnamed_addr #2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #3

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 = { nobuiltin allocsize(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 #2 = { "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 = { nobuiltin 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 #4 = { builtin allocsize(0) }
attributes #5 = { builtin 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"double", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = !{!12, !9, i64 8}
!12 = !{!"_ZTSN3pgo11PerlinNoise10PerlinWindE", !9, i64 8, !10, i64 16, !10, i64 40}
!13 = !{!14, !14, i64 0}
!14 = !{!"any pointer", !10, i64 0}


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