; LLVM IR from ImperialCollegeLondon/pnflow :: src/pnm/pnflow/polygon/polygon.ll (ZN8Triangle13setHalfAnglesEv)

; 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.VoidElem = type { %class.ElemModel, double, double, double, double }
%class.ElemModel = type { ptr, double, double, ptr, ptr, double, ptr, i8, i8, i8, i8, i32, double, double, double, double, double, double, double, %"struct.std::pair", %"struct.std::pair" }
%"struct.std::pair" = type { double, double }
%class.Polygon = type { %class.VoidElem, i32, %"class.std::vector.16", ptr, ptr, i16, i8, double }
%"class.std::vector.16" = type { %"struct.std::_Vector_base.17" }
%"struct.std::_Vector_base.17" = type { %"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl" }
%"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl" = type { %"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl_data" }
%"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@_ZN9ElemModel2PIE = external constant double, align 8

; 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN8Triangle13setHalfAnglesEv(ptr noundef nonnull align 8 dereferenceable(248) %0) #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %7 = call double @sqrt(double noundef 3.000000e+00) #4
  %8 = fdiv double 2.000000e+00, %7
  %9 = call double @sqrt(double noundef 3.000000e+00) #4
  %10 = fmul double -1.200000e+01, %9
  %11 = getelementptr inbounds %class.VoidElem, ptr %6, i32 0, i32 1
  %12 = load double, ptr %11, align 8, !tbaa !9
  %13 = fmul double %10, %12
  %14 = call double @acos(double noundef %13) #4
  %15 = fdiv double %14, 3.000000e+00
  %16 = load double, ptr @_ZN9ElemModel2PIE, align 8, !tbaa !16
  %17 = fmul double 4.000000e+00, %16
  %18 = fdiv double %17, 3.000000e+00
  %19 = fadd double %15, %18
  %20 = call double @cos(double noundef %19) #4
  %21 = fmul double %8, %20
  %22 = call double @atan(double noundef %21) #4
  store double %22, ptr %3, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %23 = call double @sqrt(double noundef 3.000000e+00) #4
  %24 = fdiv double 2.000000e+00, %23
  %25 = call double @sqrt(double noundef 3.000000e+00) #4
  %26 = fmul double -1.200000e+01, %25
  %27 = getelementptr inbounds %class.VoidElem, ptr %6, i32 0, i32 1
  %28 = load double, ptr %27, align 8, !tbaa !9
  %29 = fmul double %26, %28
  %30 = call double @acos(double noundef %29) #4
  %31 = fdiv double %30, 3.000000e+00
  %32 = call double @cos(double noundef %31) #4
  %33 = fmul double %24, %32
  %34 = call double @atan(double noundef %33) #4
  store double %34, ptr %4, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %35 = call i32 @rand() #4
  %36 = sitofp i32 %35 to double
  %37 = fdiv double %36, 0x41DFFFFFFFC00000
  store double %37, ptr %5, align 8, !tbaa !16
  %38 = load double, ptr %5, align 8, !tbaa !16
  %39 = fadd double %38, 5.000000e-01
  %40 = fmul double 5.000000e-01, %39
  store double %40, ptr %5, align 8, !tbaa !16
  %41 = load double, ptr %3, align 8, !tbaa !16
  %42 = load double, ptr %4, align 8, !tbaa !16
  %43 = load double, ptr %3, align 8, !tbaa !16
  %44 = fsub double %42, %43
  %45 = load double, ptr %5, align 8, !tbaa !16
  %46 = call double @llvm.fmuladd.f64(double %44, double %45, double %41)
  %47 = getelementptr inbounds %class.Polygon, ptr %6, i32 0, i32 2
  %48 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %47, i64 noundef 1) #4
  store double %46, ptr %48, align 8, !tbaa !16
  %49 = getelementptr inbounds %class.Polygon, ptr %6, i32 0, i32 2
  %50 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %49, i64 noundef 1) #4
  %51 = load double, ptr %50, align 8, !tbaa !16
  %52 = call double @tan(double noundef %51) #4
  %53 = getelementptr inbounds %class.VoidElem, ptr %6, i32 0, i32 1
  %54 = load double, ptr %53, align 8, !tbaa !9
  %55 = call double @llvm.fmuladd.f64(double 4.000000e+00, double %54, double %52)
  %56 = getelementptr inbounds %class.Polygon, ptr %6, i32 0, i32 2
  %57 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %56, i64 noundef 1) #4
  %58 = load double, ptr %57, align 8, !tbaa !16
  %59 = call double @sin(double noundef %58) #4
  %60 = fmul double %55, %59
  %61 = getelementptr inbounds %class.Polygon, ptr %6, i32 0, i32 2
  %62 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %61, i64 noundef 1) #4
  %63 = load double, ptr %62, align 8, !tbaa !16
  %64 = call double @tan(double noundef %63) #4
  %65 = getelementptr inbounds %class.VoidElem, ptr %6, i32 0, i32 1
  %66 = load double, ptr %65, align 8, !tbaa !9
  %67 = call double @llvm.fmuladd.f64(double -4.000000e+00, double %66, double %64)
  %68 = fdiv double %60, %67
  %69 = call double @asin(double noundef %68) #4
  %70 = getelementptr inbounds %class.Polygon, ptr %6, i32 0, i32 2
  %71 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %70, i64 noundef 1) #4
  %72 = load double, ptr %71, align 8, !tbaa !16
  %73 = fsub double %69, %72
  %74 = fmul double 5.000000e-01, %73
  %75 = getelementptr inbounds %class.Polygon, ptr %6, i32 0, i32 2
  %76 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %75, i64 noundef 0) #4
  store double %74, ptr %76, align 8, !tbaa !16
  %77 = load double, ptr @_ZN9ElemModel2PIE, align 8, !tbaa !16
  %78 = fdiv double %77, 2.000000e+00
  %79 = getelementptr inbounds %class.Polygon, ptr %6, i32 0, i32 2
  %80 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %79, i64 noundef 1) #4
  %81 = load double, ptr %80, align 8, !tbaa !16
  %82 = fsub double %78, %81
  %83 = getelementptr inbounds %class.Polygon, ptr %6, i32 0, i32 2
  %84 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %83, i64 noundef 0) #4
  %85 = load double, ptr %84, align 8, !tbaa !16
  %86 = fsub double %82, %85
  %87 = getelementptr inbounds %class.Polygon, ptr %6, i32 0, i32 2
  %88 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %87, i64 noundef 2) #4
  store double %86, ptr %88, align 8, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  ret void
}

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

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

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

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

; Function Attrs: nounwind
declare i32 @rand() #3

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

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

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #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 = { 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, !12, i64 152}
!10 = !{!"_ZTS8VoidElem", !11, i64 0, !12, i64 152, !12, i64 160, !12, i64 168, !12, i64 176}
!11 = !{!"_ZTS9ElemModel", !12, i64 8, !12, i64 16, !6, i64 24, !6, i64 32, !12, i64 40, !6, i64 48, !13, i64 56, !13, i64 57, !13, i64 58, !13, i64 59, !14, i64 60, !12, i64 64, !12, i64 72, !12, i64 80, !12, i64 88, !12, i64 96, !12, i64 104, !12, i64 112, !15, i64 120, !15, i64 136}
!12 = !{!"double", !7, i64 0}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!"_ZTSSt4pairIddE", !12, i64 0, !12, i64 8}
!16 = !{!12, !12, i64 0}


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

@_ZN9ElemModel2PIE = external local_unnamed_addr constant double, align 8

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN8Triangle13setHalfAnglesEv(ptr noundef nonnull align 8 dereferenceable(248) %0) local_unnamed_addr #1 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 152
  %3 = load double, ptr %2, align 8, !tbaa !5
  %4 = fmul double %3, 0xC034C8DC2E423980
  %5 = tail call double @acos(double noundef %4) #4
  %6 = load double, ptr @_ZN9ElemModel2PIE, align 8, !tbaa !15
  %7 = fmul double %6, 4.000000e+00
  %8 = insertelement <2 x double> poison, double %5, i64 0
  %9 = insertelement <2 x double> %8, double %7, i64 1
  %10 = fdiv <2 x double> %9, <double 3.000000e+00, double 3.000000e+00>
  %shift = shufflevector <2 x double> %10, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %11 = fadd <2 x double> %10, %shift
  %12 = extractelement <2 x double> %11, i64 0
  %13 = tail call double @cos(double noundef %12) #4
  %14 = fmul double %13, 0x3FF279A74590331D
  %15 = tail call double @atan(double noundef %14) #4
  %16 = load double, ptr %2, align 8, !tbaa !5
  %17 = fmul double %16, 0xC034C8DC2E423980
  %18 = tail call double @acos(double noundef %17) #4
  %19 = fdiv double %18, 3.000000e+00
  %20 = tail call double @cos(double noundef %19) #4
  %21 = fmul double %20, 0x3FF279A74590331D
  %22 = tail call double @atan(double noundef %21) #4
  %23 = tail call i32 @rand() #4
  %24 = sitofp i32 %23 to double
  %25 = fdiv double %24, 0x41DFFFFFFFC00000
  %26 = fadd double %25, 5.000000e-01
  %27 = fmul double %26, 5.000000e-01
  %28 = fsub double %22, %15
  %29 = tail call double @llvm.fmuladd.f64(double %28, double %27, double %15)
  %30 = getelementptr inbounds i8, ptr %0, i64 192
  %31 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %30, i64 noundef 1) #4
  store double %29, ptr %31, align 8, !tbaa !15
  %32 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %30, i64 noundef 1) #4
  %33 = load double, ptr %32, align 8, !tbaa !15
  %34 = tail call double @tan(double noundef %33) #4
  %35 = load double, ptr %2, align 8, !tbaa !5
  %36 = tail call double @llvm.fmuladd.f64(double %35, double 4.000000e+00, double %34)
  %37 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %30, i64 noundef 1) #4
  %38 = load double, ptr %37, align 8, !tbaa !15
  %39 = tail call double @sin(double noundef %38) #4
  %40 = fmul double %36, %39
  %41 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %30, i64 noundef 1) #4
  %42 = load double, ptr %41, align 8, !tbaa !15
  %43 = tail call double @tan(double noundef %42) #4
  %44 = load double, ptr %2, align 8, !tbaa !5
  %45 = tail call double @llvm.fmuladd.f64(double %44, double -4.000000e+00, double %43)
  %46 = fdiv double %40, %45
  %47 = tail call double @asin(double noundef %46) #4
  %48 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %30, i64 noundef 1) #4
  %49 = load double, ptr %48, align 8, !tbaa !15
  %50 = fsub double %47, %49
  %51 = fmul double %50, 5.000000e-01
  %52 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %30, i64 noundef 0) #4
  store double %51, ptr %52, align 8, !tbaa !15
  %53 = fmul double %6, 5.000000e-01
  %54 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %30, i64 noundef 1) #4
  %55 = load double, ptr %54, align 8, !tbaa !15
  %56 = fsub double %53, %55
  %57 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %30, i64 noundef 0) #4
  %58 = load double, ptr %57, align 8, !tbaa !15
  %59 = fsub double %56, %58
  %60 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %30, i64 noundef 2) #4
  store double %59, ptr %60, align 8, !tbaa !15
  ret void
}

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

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

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

; Function Attrs: nounwind
declare i32 @rand() local_unnamed_addr #3

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

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

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 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 #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 = { 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, !8, i64 152}
!6 = !{!"_ZTS8VoidElem", !7, i64 0, !8, i64 152, !8, i64 160, !8, i64 168, !8, i64 176}
!7 = !{!"_ZTS9ElemModel", !8, i64 8, !8, i64 16, !11, i64 24, !11, i64 32, !8, i64 40, !11, i64 48, !12, i64 56, !12, i64 57, !12, i64 58, !12, i64 59, !13, i64 60, !8, i64 64, !8, i64 72, !8, i64 80, !8, i64 88, !8, i64 96, !8, i64 104, !8, i64 112, !14, i64 120, !14, i64 136}
!8 = !{!"double", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!"bool", !9, i64 0}
!13 = !{!"int", !9, i64 0}
!14 = !{!"_ZTSSt4pairIddE", !8, i64 0, !8, i64 8}
!15 = !{!8, !8, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SLPVectorizerPass,SROAPass,TailCallElimPass,VectorCombinePass