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

; 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 @_ZN5R2Arc12SetStopAngleEd(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 3
  store double %6, ptr %7, align 8, !tbaa !11
  br label %8

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

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

21:                                               ; preds = %8
  br label %22

22:                                               ; preds = %28, %21
  %23 = getelementptr inbounds %class.R2Arc, ptr %5, i32 0, i32 3
  %24 = load double, ptr %23, align 8, !tbaa !11
  %25 = getelementptr inbounds %class.R2Arc, ptr %5, i32 0, i32 2
  %26 = load double, ptr %25, align 8, !tbaa !18
  %27 = fcmp olt double %24, %26
  br i1 %27, label %28, label %33

28:                                               ; preds = %22
  %29 = load double, ptr @RN_TWO_PI, align 8, !tbaa !9
  %30 = getelementptr inbounds %class.R2Arc, ptr %5, i32 0, i32 3
  %31 = load double, ptr %30, align 8, !tbaa !11
  %32 = fadd double %31, %29
  store double %32, ptr %30, align 8, !tbaa !11
  br label %22, !llvm.loop !21

33:                                               ; preds = %22
  %34 = getelementptr inbounds %class.R2Arc, ptr %5, i32 0, i32 2
  %35 = load double, ptr %34, align 8, !tbaa !18
  %36 = fcmp ole double 0.000000e+00, %35
  br i1 %36, label %37, label %42

37:                                               ; preds = %33
  %38 = getelementptr inbounds %class.R2Arc, ptr %5, i32 0, i32 2
  %39 = load double, ptr %38, align 8, !tbaa !18
  %40 = load double, ptr @RN_TWO_PI, align 8, !tbaa !9
  %41 = fcmp ole double %39, %40
  br i1 %41, label %43, label %42

42:                                               ; preds = %37, %33
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.5, i32 noundef 218, ptr noundef @.str.3)
  br label %43

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

49:                                               ; preds = %43
  %50 = getelementptr inbounds %class.R2Arc, ptr %5, i32 0, i32 3
  %51 = load double, ptr %50, align 8, !tbaa !11
  %52 = getelementptr inbounds %class.R2Arc, ptr %5, i32 0, i32 2
  %53 = load double, ptr %52, align 8, !tbaa !18
  %54 = load double, ptr @RN_TWO_PI, align 8, !tbaa !9
  %55 = fadd double %53, %54
  %56 = fcmp ole double %51, %55
  br i1 %56, label %58, label %57

57:                                               ; preds = %49, %43
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.6, i32 noundef 219, ptr noundef @.str.3)
  br label %58

58:                                               ; preds = %57, %49
  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 48}
!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 = !{!12, !10, i64 40}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}


; 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 @_ZN5R2Arc12SetStopAngleEd(ptr nocapture noundef nonnull align 8 dereferenceable(56) %0, double noundef %1) unnamed_addr #1 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 48
  %4 = getelementptr inbounds i8, ptr %0, i64 40
  %5 = load double, ptr %4, align 8, !tbaa !5
  %6 = load double, ptr @RN_TWO_PI, align 8
  %7 = fadd double %5, %6
  %8 = fcmp ugt double %7, %1
  br i1 %8, label %.preheader, label %.lr.ph

.preheader:                                       ; preds = %.lr.ph, %2
  %storemerge.lcssa = phi double [ %1, %2 ], [ %10, %.lr.ph ]
  store double %storemerge.lcssa, ptr %3, align 8, !tbaa !15
  %9 = fcmp olt double %storemerge.lcssa, %5
  br i1 %9, label %.lr.ph14, label %15

.lr.ph:                                           ; preds = %2, %.lr.ph
  %storemerge11 = phi double [ %10, %.lr.ph ], [ %1, %2 ]
  %10 = fsub double %storemerge11, %6
  %11 = fcmp ult double %10, %7
  br i1 %11, label %.preheader, label %.lr.ph, !llvm.loop !16

.lr.ph14:                                         ; preds = %.preheader, %.lr.ph14
  %12 = phi double [ %13, %.lr.ph14 ], [ %storemerge.lcssa, %.preheader ]
  %13 = fadd double %6, %12
  %14 = fcmp olt double %13, %5
  br i1 %14, label %.lr.ph14, label %._crit_edge, !llvm.loop !18

._crit_edge:                                      ; preds = %.lr.ph14
  store double %13, ptr %3, align 8, !tbaa !15
  br label %15

15:                                               ; preds = %._crit_edge, %.preheader
  %16 = phi double [ %13, %._crit_edge ], [ %storemerge.lcssa, %.preheader ]
  %17 = fcmp ult double %5, 0.000000e+00
  %18 = fcmp ugt double %5, %6
  %or.cond = or i1 %17, %18
  br i1 %or.cond, label %19, label %20

19:                                               ; preds = %15
  tail call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef nonnull @.str, ptr noundef nonnull @.str.5, i32 noundef 218, ptr noundef nonnull @.str.3)
  %.pre = load double, ptr %4, align 8, !tbaa !5
  %.pre17 = load double, ptr %3, align 8, !tbaa !15
  %.pre18 = fadd double %6, %.pre
  br label %20

20:                                               ; preds = %15, %19
  %.pre-phi = phi double [ %7, %15 ], [ %.pre18, %19 ]
  %21 = phi double [ %16, %15 ], [ %.pre17, %19 ]
  %22 = phi double [ %5, %15 ], [ %.pre, %19 ]
  %23 = fcmp ugt double %22, %21
  %24 = fcmp ugt double %21, %.pre-phi
  %or.cond8 = or i1 %23, %24
  br i1 %or.cond8, label %25, label %26

25:                                               ; preds = %20
  tail call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef nonnull @.str, ptr noundef nonnull @.str.6, i32 noundef 219, ptr noundef nonnull @.str.3)
  br label %26

26:                                               ; preds = %20, %25
  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 = !{!6, !14, i64 48}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}


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