; LLVM IR from tryingfly/nabo :: nabo_core/src/robot/cpg.ll (ZN3Cpg8cpgClass12getNextEventEd)

; 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.Cpg::cpgClass" = type { i8, i8, double, double, [2 x double], [2 x double], [2 x double], [2 x double], [2 x double], [2 x double], [2 x double], [2 x double], [2 x i8], i8, [2 x i8], double, double, [2 x double], [2 x double], %struct.anon }
%struct.anon = type { double, [2 x double], [2 x double] }

; 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 nounwind uwtable
define dso_local noundef double @_ZN3Cpg8cpgClass12getNextEventEd(ptr noundef nonnull align 8 dereferenceable(248) %0, double noundef %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca i32, align 4
  %8 = alloca double, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store double %1, ptr %4, align 8, !tbaa !9
  %9 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  %10 = load double, ptr %4, align 8, !tbaa !9
  %11 = getelementptr inbounds %"class.Cpg::cpgClass", ptr %9, i32 0, i32 16
  %12 = load double, ptr %11, align 8, !tbaa !11
  %13 = fdiv double %10, %12
  store double %13, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  store double 1.000000e+00, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  store i32 0, ptr %7, align 4, !tbaa !15
  br label %14

14:                                               ; preds = %60, %2
  %15 = load i32, ptr %7, align 4, !tbaa !15
  %16 = icmp ne i32 %15, 2
  br i1 %16, label %18, label %17

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

18:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %19 = getelementptr inbounds %"class.Cpg::cpgClass", ptr %9, i32 0, i32 17
  %20 = load i32, ptr %7, align 4, !tbaa !15
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [2 x double], ptr %19, i64 0, i64 %21
  %23 = load double, ptr %22, align 8, !tbaa !9
  %24 = getelementptr inbounds %"class.Cpg::cpgClass", ptr %9, i32 0, i32 2
  %25 = load double, ptr %24, align 8, !tbaa !17
  %26 = fsub double %23, %25
  %27 = load double, ptr %5, align 8, !tbaa !9
  %28 = fsub double %26, %27
  %29 = fadd double %28, 1.000000e+02
  store double %29, ptr %8, align 8, !tbaa !9
  %30 = load double, ptr %8, align 8, !tbaa !9
  %31 = fptosi double %30 to i32
  %32 = sitofp i32 %31 to double
  %33 = load double, ptr %8, align 8, !tbaa !9
  %34 = fsub double %33, %32
  store double %34, ptr %8, align 8, !tbaa !9
  %35 = load double, ptr %8, align 8, !tbaa !9
  %36 = load double, ptr %6, align 8, !tbaa !9
  %37 = fcmp olt double %35, %36
  br i1 %37, label %38, label %40

38:                                               ; preds = %18
  %39 = load double, ptr %8, align 8, !tbaa !9
  store double %39, ptr %6, align 8, !tbaa !9
  br label %40

40:                                               ; preds = %38, %18
  %41 = getelementptr inbounds %"class.Cpg::cpgClass", ptr %9, i32 0, i32 18
  %42 = load i32, ptr %7, align 4, !tbaa !15
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [2 x double], ptr %41, i64 0, i64 %43
  %45 = load double, ptr %44, align 8, !tbaa !9
  %46 = fsub double 1.000000e+02, %45
  %47 = load double, ptr %8, align 8, !tbaa !9
  %48 = fadd double %47, %46
  store double %48, ptr %8, align 8, !tbaa !9
  %49 = load double, ptr %8, align 8, !tbaa !9
  %50 = fptosi double %49 to i32
  %51 = sitofp i32 %50 to double
  %52 = load double, ptr %8, align 8, !tbaa !9
  %53 = fsub double %52, %51
  store double %53, ptr %8, align 8, !tbaa !9
  %54 = load double, ptr %8, align 8, !tbaa !9
  %55 = load double, ptr %6, align 8, !tbaa !9
  %56 = fcmp olt double %54, %55
  br i1 %56, label %57, label %59

57:                                               ; preds = %40
  %58 = load double, ptr %8, align 8, !tbaa !9
  store double %58, ptr %6, align 8, !tbaa !9
  br label %59

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

60:                                               ; preds = %59
  %61 = load i32, ptr %7, align 4, !tbaa !15
  %62 = add nsw i32 %61, 1
  store i32 %62, ptr %7, align 4, !tbaa !15
  br label %14, !llvm.loop !18

63:                                               ; preds = %17
  %64 = load double, ptr %6, align 8, !tbaa !9
  %65 = getelementptr inbounds %"class.Cpg::cpgClass", ptr %9, i32 0, i32 16
  %66 = load double, ptr %65, align 8, !tbaa !11
  %67 = fmul double %64, %66
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  ret double %67
}

attributes #0 = { 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 = { 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, !10, i64 168}
!12 = !{!"_ZTSN3Cpg8cpgClassE", !13, i64 0, !13, i64 1, !10, i64 8, !10, i64 16, !7, i64 24, !7, i64 40, !7, i64 56, !7, i64 72, !7, i64 88, !7, i64 104, !7, i64 120, !7, i64 136, !7, i64 152, !13, i64 154, !7, i64 155, !10, i64 160, !10, i64 168, !7, i64 176, !7, i64 192, !14, i64 208}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"_ZTSN3Cpg8cpgClassUt_E", !10, i64 0, !7, i64 8, !7, i64 24}
!15 = !{!16, !16, i64 0}
!16 = !{!"int", !7, i64 0}
!17 = !{!12, !10, i64 8}
!18 = distinct !{!18, !19}
!19 = !{!"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 willreturn memory(argmem: read) uwtable
define dso_local noundef double @_ZN3Cpg8cpgClass12getNextEventEd(ptr nocapture noundef nonnull readonly align 8 dereferenceable(248) %0, double noundef %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 168
  %4 = load double, ptr %3, align 8, !tbaa !5
  %5 = fdiv double %1, %4
  %6 = getelementptr inbounds i8, ptr %0, i64 176
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %8 = load double, ptr %7, align 8, !tbaa !12
  %9 = getelementptr inbounds i8, ptr %0, i64 192
  %10 = load double, ptr %6, align 8, !tbaa !13
  %11 = fsub double %10, %8
  %12 = fsub double %11, %5
  %13 = fadd double %12, 1.000000e+02
  %14 = fptosi double %13 to i32
  %15 = sitofp i32 %14 to double
  %16 = fsub double %13, %15
  %17 = fcmp olt double %16, 1.000000e+00
  %.1 = select i1 %17, double %16, double 1.000000e+00
  %18 = load double, ptr %9, align 8, !tbaa !13
  %19 = fsub double 1.000000e+02, %18
  %20 = fadd double %19, %16
  %21 = fptosi double %20 to i32
  %22 = sitofp i32 %21 to double
  %23 = fsub double %20, %22
  %24 = fcmp olt double %23, %.1
  %.2 = select i1 %24, double %23, double %.1
  %25 = getelementptr inbounds i8, ptr %0, i64 184
  %26 = load double, ptr %25, align 8, !tbaa !13
  %27 = fsub double %26, %8
  %28 = fsub double %27, %5
  %29 = fadd double %28, 1.000000e+02
  %30 = fptosi double %29 to i32
  %31 = sitofp i32 %30 to double
  %32 = fsub double %29, %31
  %33 = fcmp olt double %32, %.2
  %.1.1 = select i1 %33, double %32, double %.2
  %34 = getelementptr inbounds i8, ptr %0, i64 200
  %35 = load double, ptr %34, align 8, !tbaa !13
  %36 = fsub double 1.000000e+02, %35
  %37 = fadd double %36, %32
  %38 = fptosi double %37 to i32
  %39 = sitofp i32 %38 to double
  %40 = fsub double %37, %39
  %41 = fcmp olt double %40, %.1.1
  %.2.1 = select i1 %41, double %40, double %.1.1
  %42 = fmul double %4, %.2.1
  ret double %42
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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, !10, i64 168}
!6 = !{!"_ZTSN3Cpg8cpgClassE", !7, i64 0, !7, i64 1, !10, i64 8, !10, i64 16, !8, i64 24, !8, i64 40, !8, i64 56, !8, i64 72, !8, i64 88, !8, i64 104, !8, i64 120, !8, i64 136, !8, i64 152, !7, i64 154, !8, i64 155, !10, i64 160, !10, i64 168, !8, i64 176, !8, i64 192, !11, i64 208}
!7 = !{!"bool", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"double", !8, i64 0}
!11 = !{!"_ZTSN3Cpg8cpgClassUt_E", !10, i64 0, !8, i64 8, !8, i64 24}
!12 = !{!6, !10, i64 8}
!13 = !{!10, !10, i64 0}


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