; LLVM IR from niessner/Matterport :: code/gaps/pkgs/R2Shapes/R2Arc.ll (ZN5R2Arc13SetStartAngleEd)

; 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.R2Arc = type { %class.R2Curve, %class.R2Circle, double, double }
%class.R2Curve = type { %class.R2Shape }
%class.R2Shape = type { ptr }
%class.R2Circle = type { %class.R2Solid, %class.R2Point, double }
%class.R2Solid = type { %class.R2Shape }
%class.R2Point = type { [2 x double] }

@.str = external hidden unnamed_addr constant [41 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [87 x i8], align 1
@RN_TWO_PI = external constant double, align 8
@.str.5 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [49 x i8], align 1

declare void @_Z7RNAbortPKcz(ptr noundef, ...) #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5R2Arc13SetStartAngleEd(ptr noundef nonnull align 8 dereferenceable(56) %0, double noundef %1) unnamed_addr #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca double, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store double %1, ptr %4, align 8, !tbaa !9
  %5 = load ptr, ptr %3, align 8
  %6 = load double, ptr %4, align 8, !tbaa !9
  %7 = getelementptr inbounds %class.R2Arc, ptr %5, i32 0, i32 2
  store double %6, ptr %7, align 8, !tbaa !11
  br label %8

8:                                                ; preds = %13, %2
  %9 = getelementptr inbounds %class.R2Arc, ptr %5, i32 0, i32 2
  %10 = load double, ptr %9, align 8, !tbaa !11
  %11 = load double, ptr @RN_TWO_PI, align 8, !tbaa !9
  %12 = fcmp oge double %10, %11
  br i1 %12, label %13, label %18

13:                                               ; preds = %8
  %14 = load double, ptr @RN_TWO_PI, align 8, !tbaa !9
  %15 = getelementptr inbounds %class.R2Arc, ptr %5, i32 0, i32 2
  %16 = load double, ptr %15, align 8, !tbaa !11
  %17 = fsub double %16, %14
  store double %17, ptr %15, align 8, !tbaa !11
  br label %8, !llvm.loop !18

18:                                               ; preds = %8
  br label %19

19:                                               ; preds = %23, %18
  %20 = getelementptr inbounds %class.R2Arc, ptr %5, i32 0, i32 2
  %21 = load double, ptr %20, align 8, !tbaa !11
  %22 = fcmp olt double %21, 0.000000e+00
  br i1 %22, label %23, label %28

23:                                               ; preds = %19
  %24 = load double, ptr @RN_TWO_PI, align 8, !tbaa !9
  %25 = getelementptr inbounds %class.R2Arc, ptr %5, i32 0, i32 2
  %26 = load double, ptr %25, align 8, !tbaa !11
  %27 = fadd double %26, %24
  store double %27, ptr %25, align 8, !tbaa !11
  br label %19, !llvm.loop !20

28:                                               ; preds = %19
  br label %29

29:                                               ; preds = %37, %28
  %30 = getelementptr inbounds %class.R2Arc, ptr %5, i32 0, i32 3
  %31 = load double, ptr %30, align 8, !tbaa !21
  %32 = getelementptr inbounds %class.R2Arc, ptr %5, i32 0, i32 2
  %33 = load double, ptr %32, align 8, !tbaa !11
  %34 = load double, ptr @RN_TWO_PI, align 8, !tbaa !9
  %35 = fadd double %33, %34
  %36 = fcmp oge double %31, %35
  br i1 %36, label %37, label %42

37:                                               ; preds = %29
  %38 = load double, ptr @RN_TWO_PI, align 8, !tbaa !9
  %39 = getelementptr inbounds %class.R2Arc, ptr %5, i32 0, i32 3
  %40 = load double, ptr %39, align 8, !tbaa !21
  %41 = fsub double %40, %38
  store double %41, ptr %39, align 8, !tbaa !21
  br label %29, !llvm.loop !22

42:                                               ; preds = %29
  br label %43

43:                                               ; preds = %49, %42
  %44 = getelementptr inbounds %class.R2Arc, ptr %5, i32 0, i32 3
  %45 = load double, ptr %44, align 8, !tbaa !21
  %46 = getelementptr inbounds %class.R2Arc, ptr %5, i32 0, i32 2
  %47 = load double, ptr %46, align 8, !tbaa !11
  %48 = fcmp olt double %45, %47
  br i1 %48, label %49, label %54

49:                                               ; preds = %43
  %50 = load double, ptr @RN_TWO_PI, align 8, !tbaa !9
  %51 = getelementptr inbounds %class.R2Arc, ptr %5, i32 0, i32 3
  %52 = load double, ptr %51, align 8, !tbaa !21
  %53 = fadd double %52, %50
  store double %53, ptr %51, align 8, !tbaa !21
  br label %43, !llvm.loop !23

54:                                               ; preds = %43
  %55 = getelementptr inbounds %class.R2Arc, ptr %5, i32 0, i32 2
  %56 = load double, ptr %55, align 8, !tbaa !11
  %57 = fcmp ole double 0.000000e+00, %56
  br i1 %57, label %58, label %63

58:                                               ; preds = %54
  %59 = getelementptr inbounds %class.R2Arc, ptr %5, i32 0, i32 2
  %60 = load double, ptr %59, align 8, !tbaa !11
  %61 = load double, ptr @RN_TWO_PI, align 8, !tbaa !9
  %62 = fcmp ole double %60, %61
  br i1 %62, label %64, label %63

63:                                               ; preds = %58, %54
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.5, i32 noundef 205, ptr noundef @.str.3)
  br label %64

64:                                               ; preds = %63, %58
  %65 = getelementptr inbounds %class.R2Arc, ptr %5, i32 0, i32 2
  %66 = load double, ptr %65, align 8, !tbaa !11
  %67 = getelementptr inbounds %class.R2Arc, ptr %5, i32 0, i32 3
  %68 = load double, ptr %67, align 8, !tbaa !21
  %69 = fcmp ole double %66, %68
  br i1 %69, label %70, label %78

70:                                               ; preds = %64
  %71 = getelementptr inbounds %class.R2Arc, ptr %5, i32 0, i32 3
  %72 = load double, ptr %71, align 8, !tbaa !21
  %73 = getelementptr inbounds %class.R2Arc, ptr %5, i32 0, i32 2
  %74 = load double, ptr %73, align 8, !tbaa !11
  %75 = load double, ptr @RN_TWO_PI, align 8, !tbaa !9
  %76 = fadd double %74, %75
  %77 = fcmp ole double %72, %76
  br i1 %77, label %79, label %78

78:                                               ; preds = %70, %64
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.6, i32 noundef 206, ptr noundef @.str.3)
  br label %79

79:                                               ; preds = %78, %70
  ret void
}

attributes #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 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 = !{!"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 40}
!12 = !{!"_ZTS5R2Arc", !13, i64 0, !15, i64 8, !10, i64 40, !10, i64 48}
!13 = !{!"_ZTS7R2Curve", !14, i64 0}
!14 = !{!"_ZTS7R2Shape"}
!15 = !{!"_ZTS8R2Circle", !16, i64 0, !17, i64 8, !10, i64 24}
!16 = !{!"_ZTS7R2Solid", !14, i64 0}
!17 = !{!"_ZTS7R2Point", !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}
!21 = !{!12, !10, i64 48}
!22 = distinct !{!22, !19}
!23 = distinct !{!23, !19}


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

@.str = external hidden unnamed_addr constant [41 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [87 x i8], align 1
@RN_TWO_PI = external local_unnamed_addr constant double, align 8
@.str.5 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [49 x i8], align 1

declare void @_Z7RNAbortPKcz(ptr noundef, ...) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5R2Arc13SetStartAngleEd(ptr nocapture noundef nonnull align 8 dereferenceable(56) %0, double noundef %1) unnamed_addr #1 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 40
  %4 = load double, ptr @RN_TWO_PI, align 8
  %5 = fcmp ugt double %4, %1
  br i1 %5, label %.preheader13, label %.lr.ph

.preheader13:                                     ; preds = %.lr.ph, %2
  %storemerge.lcssa16 = phi double [ %1, %2 ], [ %7, %.lr.ph ]
  store double %storemerge.lcssa16, ptr %3, align 8, !tbaa !5
  %6 = fcmp olt double %storemerge.lcssa16, 0.000000e+00
  br i1 %6, label %.lr.ph20, label %.preheader12

.lr.ph:                                           ; preds = %2, %.lr.ph
  %storemerge17 = phi double [ %7, %.lr.ph ], [ %1, %2 ]
  %7 = fsub double %storemerge17, %4
  %8 = fcmp ult double %7, %4
  br i1 %8, label %.preheader13, label %.lr.ph, !llvm.loop !15

..preheader12_crit_edge:                          ; preds = %.lr.ph20
  store double %13, ptr %3, align 8, !tbaa !5
  br label %.preheader12

.preheader12:                                     ; preds = %..preheader12_crit_edge, %.preheader13
  %.lcssa14 = phi double [ %13, %..preheader12_crit_edge ], [ %storemerge.lcssa16, %.preheader13 ]
  %9 = getelementptr inbounds i8, ptr %0, i64 48
  %10 = fadd double %4, %.lcssa14
  %.promoted = load double, ptr %9, align 8, !tbaa !17
  %11 = fcmp ult double %.promoted, %10
  br i1 %11, label %.preheader, label %.lr.ph23

.lr.ph20:                                         ; preds = %.preheader13, %.lr.ph20
  %12 = phi double [ %13, %.lr.ph20 ], [ %storemerge.lcssa16, %.preheader13 ]
  %13 = fadd double %4, %12
  %14 = fcmp olt double %13, 0.000000e+00
  br i1 %14, label %.lr.ph20, label %..preheader12_crit_edge, !llvm.loop !18

..preheader_crit_edge:                            ; preds = %.lr.ph23
  store double %17, ptr %9, align 8, !tbaa !17
  br label %.preheader

.preheader:                                       ; preds = %..preheader_crit_edge, %.preheader12
  %.lcssa.promoted = phi double [ %17, %..preheader_crit_edge ], [ %.promoted, %.preheader12 ]
  %15 = fcmp olt double %.lcssa.promoted, %.lcssa14
  br i1 %15, label %.lr.ph26, label %22

.lr.ph23:                                         ; preds = %.preheader12, %.lr.ph23
  %16 = phi double [ %17, %.lr.ph23 ], [ %.promoted, %.preheader12 ]
  %17 = fsub double %16, %4
  %18 = fcmp ult double %17, %10
  br i1 %18, label %..preheader_crit_edge, label %.lr.ph23, !llvm.loop !19

.lr.ph26:                                         ; preds = %.preheader, %.lr.ph26
  %19 = phi double [ %20, %.lr.ph26 ], [ %.lcssa.promoted, %.preheader ]
  %20 = fadd double %4, %19
  %21 = fcmp olt double %20, %.lcssa14
  br i1 %21, label %.lr.ph26, label %._crit_edge, !llvm.loop !20

._crit_edge:                                      ; preds = %.lr.ph26
  store double %20, ptr %9, align 8, !tbaa !17
  br label %22

22:                                               ; preds = %._crit_edge, %.preheader
  %23 = phi double [ %20, %._crit_edge ], [ %.lcssa.promoted, %.preheader ]
  %24 = fcmp ult double %.lcssa14, 0.000000e+00
  %25 = fcmp ugt double %.lcssa14, %4
  %or.cond = or i1 %24, %25
  br i1 %or.cond, label %26, label %27

26:                                               ; preds = %22
  tail call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef nonnull @.str, ptr noundef nonnull @.str.5, i32 noundef 205, ptr noundef nonnull @.str.3)
  %.pre = load double, ptr %3, align 8, !tbaa !5
  %.pre32 = load double, ptr %9, align 8, !tbaa !17
  %.pre33 = fadd double %4, %.pre
  br label %27

27:                                               ; preds = %22, %26
  %.pre-phi = phi double [ %10, %22 ], [ %.pre33, %26 ]
  %28 = phi double [ %23, %22 ], [ %.pre32, %26 ]
  %29 = phi double [ %.lcssa14, %22 ], [ %.pre, %26 ]
  %30 = fcmp ugt double %29, %28
  %31 = fcmp ugt double %28, %.pre-phi
  %or.cond11 = or i1 %30, %31
  br i1 %or.cond11, label %32, label %33

32:                                               ; preds = %27
  tail call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef nonnull @.str, ptr noundef nonnull @.str.6, i32 noundef 206, ptr noundef nonnull @.str.3)
  br label %33

33:                                               ; preds = %27, %32
  ret void
}

attributes #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 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, !14, i64 40}
!6 = !{!"_ZTS5R2Arc", !7, i64 0, !9, i64 8, !14, i64 40, !14, i64 48}
!7 = !{!"_ZTS7R2Curve", !8, i64 0}
!8 = !{!"_ZTS7R2Shape"}
!9 = !{!"_ZTS8R2Circle", !10, i64 0, !11, i64 8, !14, i64 24}
!10 = !{!"_ZTS7R2Solid", !8, i64 0}
!11 = !{!"_ZTS7R2Point", !12, i64 0}
!12 = !{!"omnipotent char", !13, i64 0}
!13 = !{!"Simple C++ TBAA"}
!14 = !{!"double", !12, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!6, !14, i64 48}
!18 = distinct !{!18, !16}
!19 = distinct !{!19, !16}
!20 = distinct !{!20, !16}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass