; LLVM IR from doyubkim/fluid-engine-dev :: src/examples/hello_fluid_sim/main.ll (Z27accumulateWaveToHeightFielddddPSt5arrayIdLm80EE)

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z27accumulateWaveToHeightFielddddPSt5arrayIdLm80EE(double noundef %0, double noundef %1, double noundef %2, ptr noundef %3) #1 {
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca ptr, align 8
  %9 = alloca double, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  %16 = alloca double, align 8
  %17 = alloca double, align 8
  store double %0, ptr %5, align 8, !tbaa !5
  store double %1, ptr %6, align 8, !tbaa !5
  store double %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %18 = load double, ptr %6, align 8, !tbaa !5
  %19 = fmul double 2.500000e-01, %18
  store double %19, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  %20 = load double, ptr %5, align 8, !tbaa !5
  %21 = load double, ptr %9, align 8, !tbaa !5
  %22 = fsub double %20, %21
  %23 = fmul double %22, 8.000000e+01
  %24 = fptosi double %23 to i32
  store i32 %24, ptr %10, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  %25 = load double, ptr %5, align 8, !tbaa !5
  %26 = load double, ptr %9, align 8, !tbaa !5
  %27 = fadd double %25, %26
  %28 = fmul double %27, 8.000000e+01
  %29 = fptosi double %28 to i32
  store i32 %29, ptr %11, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  %30 = load i32, ptr %10, align 4, !tbaa !11
  store i32 %30, ptr %12, align 4, !tbaa !11
  br label %31

31:                                               ; preds = %80, %4
  %32 = load i32, ptr %12, align 4, !tbaa !11
  %33 = load i32, ptr %11, align 4, !tbaa !11
  %34 = icmp slt i32 %32, %33
  br i1 %34, label %36, label %35

35:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  br label %83

36:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  %37 = load i32, ptr %12, align 4, !tbaa !11
  store i32 %37, ptr %13, align 4, !tbaa !11
  %38 = load i32, ptr %12, align 4, !tbaa !11
  %39 = icmp slt i32 %38, 0
  br i1 %39, label %40, label %44

40:                                               ; preds = %36
  %41 = load i32, ptr %12, align 4, !tbaa !11
  %42 = sub nsw i32 0, %41
  %43 = sub nsw i32 %42, 1
  store i32 %43, ptr %13, align 4, !tbaa !11
  br label %54

44:                                               ; preds = %36
  %45 = load i32, ptr %12, align 4, !tbaa !11
  %46 = icmp sge i32 %45, 80
  br i1 %46, label %47, label %53

47:                                               ; preds = %44
  %48 = load i32, ptr %12, align 4, !tbaa !11
  %49 = sext i32 %48 to i64
  %50 = sub i64 160, %49
  %51 = sub i64 %50, 1
  %52 = trunc i64 %51 to i32
  store i32 %52, ptr %13, align 4, !tbaa !11
  br label %53

53:                                               ; preds = %47, %44
  br label %54

54:                                               ; preds = %53, %40
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  %55 = load i32, ptr %12, align 4, !tbaa !11
  %56 = sitofp i32 %55 to double
  %57 = fadd double %56, 5.000000e-01
  %58 = fdiv double %57, 8.000000e+01
  %59 = load double, ptr %5, align 8, !tbaa !5
  %60 = fsub double %58, %59
  %61 = call double @llvm.fabs.f64(double %60)
  store double %61, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  %62 = load double, ptr %7, align 8, !tbaa !5
  %63 = fmul double %62, 5.000000e-01
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  %64 = load double, ptr %14, align 8, !tbaa !5
  %65 = fmul double %64, 0x400921FB54442D18
  %66 = load double, ptr %9, align 8, !tbaa !5
  %67 = fdiv double %65, %66
  store double %67, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #6
  store double 0x400921FB54442D18, ptr %17, align 8, !tbaa !5
  %68 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %16, ptr noundef nonnull align 8 dereferenceable(8) %17)
  %69 = load double, ptr %68, align 8, !tbaa !5
  %70 = call double @cos(double noundef %69) #6
  %71 = fadd double %70, 1.000000e+00
  %72 = fmul double %63, %71
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  store double %72, ptr %15, align 8, !tbaa !5
  %73 = load double, ptr %15, align 8, !tbaa !5
  %74 = load ptr, ptr %8, align 8, !tbaa !9
  %75 = load i32, ptr %13, align 4, !tbaa !11
  %76 = sext i32 %75 to i64
  %77 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5arrayIdLm80EEixEm(ptr noundef nonnull align 8 dereferenceable(640) %74, i64 noundef %76) #6
  %78 = load double, ptr %77, align 8, !tbaa !5
  %79 = fadd double %78, %73
  store double %79, ptr %77, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  br label %80

80:                                               ; preds = %54
  %81 = load i32, ptr %12, align 4, !tbaa !11
  %82 = add nsw i32 %81, 1
  store i32 %82, ptr %12, align 4, !tbaa !11
  br label %31, !llvm.loop !13

83:                                               ; preds = %35
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  ret void
}

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

; Function Attrs: nounwind
declare double @cos(double noundef) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5arrayIdLm80EEixEm(ptr noundef nonnull align 8 dereferenceable(640), i64 noundef) #5 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 = { inlinehint 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 #5 = { 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 #6 = { 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 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z27accumulateWaveToHeightFielddddPSt5arrayIdLm80EE(double noundef %0, double noundef %1, double noundef %2, ptr noundef %3) local_unnamed_addr #1 {
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = fmul double %1, 2.500000e-01
  %8 = fsub double %0, %7
  %9 = fmul double %8, 8.000000e+01
  %10 = fptosi double %9 to i32
  %11 = fadd double %7, %0
  %12 = fmul double %11, 8.000000e+01
  %13 = fptosi double %12 to i32
  %14 = icmp slt i32 %10, %13
  br i1 %14, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %4
  %15 = fmul double %2, 5.000000e-01
  br label %16

._crit_edge:                                      ; preds = %16, %4
  ret void

16:                                               ; preds = %.lr.ph, %16
  %.022 = phi i32 [ %10, %.lr.ph ], [ %37, %16 ]
  %17 = icmp slt i32 %.022, 0
  %18 = xor i32 %.022, -1
  %19 = icmp sgt i32 %.022, 79
  %20 = sub nsw i32 159, %.022
  %spec.select = select i1 %19, i32 %20, i32 %.022
  %.021 = select i1 %17, i32 %18, i32 %spec.select
  %21 = sitofp i32 %.022 to double
  %22 = fadd double %21, 5.000000e-01
  %23 = fdiv double %22, 8.000000e+01
  %24 = fsub double %23, %0
  %25 = call double @llvm.fabs.f64(double %24)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #5
  %26 = fmul double %25, 0x400921FB54442D18
  %27 = fdiv double %26, %7
  store double %27, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #5
  store double 0x400921FB54442D18, ptr %6, align 8, !tbaa !5
  %28 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %6)
  %29 = load double, ptr %28, align 8, !tbaa !5
  %30 = call double @cos(double noundef %29) #5
  %31 = fadd double %30, 1.000000e+00
  %32 = fmul double %15, %31
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #5
  %33 = sext i32 %.021 to i64
  %34 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5arrayIdLm80EEixEm(ptr noundef nonnull align 8 dereferenceable(640) %3, i64 noundef %33) #5
  %35 = load double, ptr %34, align 8, !tbaa !5
  %36 = fadd double %32, %35
  store double %36, ptr %34, align 8, !tbaa !5
  %37 = add i32 %.022, 1
  %exitcond.not = icmp eq i32 %37, %13
  br i1 %exitcond.not, label %._crit_edge, label %16, !llvm.loop !9
}

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @cos(double noundef) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5arrayIdLm80EEixEm(ptr noundef nonnull align 8 dereferenceable(640), i64 noundef) local_unnamed_addr #1 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { mustprogress nofree nounwind willreturn memory(write) "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 = { inlinehint 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 #5 = { 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"}


; Effective O3 passes: GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass