; LLVM IR from jrl-umi3218/mc_rtc :: 3rd-party/qhull/src/libqhull_r (poly_r)

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

%struct.setT = type { i32, [1 x %union.setelemT] }
%union.setelemT = type { ptr }
%struct.vertexT = type { ptr, ptr, ptr, ptr, i32, i32, i8 }
%struct.facetT = type { double, double, double, ptr, %union.anon, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i32 }
%union.anon = type { double }

; Function Attrs: nounwind uwtable
declare dso_local void @qh_appendfacet(ptr noundef, ptr noundef) #0

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @qh_appendvertex(ptr noundef, ptr noundef) #0

declare void @qh_setappend(ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local ptr @qh_makenewfacet(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  store ptr null, ptr %10, align 8, !tbaa !5
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  %13 = icmp ne ptr %12, null
  br i1 %13, label %14, label %38

14:                                               ; preds = %4
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.setT, ptr %15, i32 0, i32 1
  %17 = getelementptr inbounds [1 x %union.setelemT], ptr %16, i64 0, i64 0
  store ptr %17, ptr %11, align 8, !tbaa !5
  br label %18

18:                                               ; preds = %36, %14
  %19 = load ptr, ptr %11, align 8, !tbaa !5
  %20 = getelementptr inbounds ptr, ptr %19, i32 1
  store ptr %20, ptr %11, align 8, !tbaa !5
  %21 = load ptr, ptr %19, align 8, !tbaa !5
  store ptr %21, ptr %10, align 8, !tbaa !5
  %22 = icmp ne ptr %21, null
  br i1 %22, label %23, label %37

23:                                               ; preds = %18
  %24 = load ptr, ptr %10, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.vertexT, ptr %24, i32 0, i32 6
  %26 = load i8, ptr %25, align 8
  %27 = lshr i8 %26, 4
  %28 = and i8 %27, 1
  %29 = zext i8 %28 to i32
  %30 = icmp ne i32 %29, 0
  br i1 %30, label %36, label %31

31:                                               ; preds = %23
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = load ptr, ptr %10, align 8, !tbaa !5
  call void @qh_removevertex(ptr noundef %32, ptr noundef %33)
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = load ptr, ptr %10, align 8, !tbaa !5
  call void @qh_appendvertex(ptr noundef %34, ptr noundef %35)
  br label %36

36:                                               ; preds = %31, %23
  br label %18, !llvm.loop !11

37:                                               ; preds = %18
  br label %38

38:                                               ; preds = %37, %4
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = call ptr @qh_newfacet(ptr noundef %39)
  store ptr %40, ptr %9, align 8, !tbaa !5
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = load ptr, ptr %9, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.facetT, ptr %42, i32 0, i32 8
  store ptr %41, ptr %43, align 8, !tbaa !13
  %44 = load i32, ptr %7, align 4, !tbaa !9
  %45 = icmp ne i32 %44, 0
  br i1 %45, label %46, label %52

46:                                               ; preds = %38
  %47 = load ptr, ptr %9, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.facetT, ptr %47, i32 0, i32 15
  %49 = load i32, ptr %48, align 8
  %50 = and i32 %49, -4097
  %51 = or i32 %50, 4096
  store i32 %51, ptr %48, align 8
  br label %52

52:                                               ; preds = %46, %38
  %53 = load ptr, ptr %8, align 8, !tbaa !5
  %54 = icmp ne ptr %53, null
  br i1 %54, label %55, label %60

55:                                               ; preds = %52
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = load ptr, ptr %9, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.facetT, ptr %57, i32 0, i32 10
  %59 = load ptr, ptr %8, align 8, !tbaa !5
  call void @qh_setappend(ptr noundef %56, ptr noundef %58, ptr noundef %59)
  br label %60

60:                                               ; preds = %55, %52
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = load ptr, ptr %9, align 8, !tbaa !5
  call void @qh_appendfacet(ptr noundef %61, ptr noundef %62)
  %63 = load ptr, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  ret ptr %63
}

; Function Attrs: nounwind uwtable
declare dso_local void @qh_removevertex(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @qh_newfacet(ptr noundef) #0

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

!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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !6, i64 64}
!14 = !{!"facetT", !15, i64 0, !15, i64 8, !15, i64 16, !6, i64 24, !7, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !10, i64 104, !10, i64 108, !10, i64 112, !10, i64 113, !10, i64 113, !10, i64 113, !10, i64 113, !10, i64 113, !10, i64 113, !10, i64 113, !10, i64 114, !10, i64 114, !10, i64 114, !10, i64 114, !10, i64 114, !10, i64 114, !10, i64 114, !10, i64 114, !10, i64 115, !10, i64 115, !10, i64 115, !10, i64 115, !10, i64 115, !10, i64 115, !10, i64 115, !10, i64 115}
!15 = !{!"double", !7, 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"

; Function Attrs: nounwind uwtable
declare dso_local void @qh_appendfacet(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @qh_appendvertex(ptr noundef, ptr noundef) local_unnamed_addr #0

declare void @qh_setappend(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local ptr @qh_makenewfacet(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3) local_unnamed_addr #0 {
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %4
  %.026 = getelementptr inbounds i8, ptr %1, i64 8
  %5 = load ptr, ptr %.026, align 8, !tbaa !5
  %.not2227 = icmp eq ptr %5, null
  br i1 %.not2227, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %11
  %6 = phi ptr [ %12, %11 ], [ %5, %.preheader ]
  %.028 = phi ptr [ %.0, %11 ], [ %.026, %.preheader ]
  %7 = getelementptr inbounds i8, ptr %6, i64 40
  %8 = load i8, ptr %7, align 8
  %9 = and i8 %8, 16
  %.not25 = icmp eq i8 %9, 0
  br i1 %.not25, label %10, label %11

10:                                               ; preds = %.lr.ph
  tail call void @qh_removevertex(ptr noundef %0, ptr noundef nonnull %6)
  tail call void @qh_appendvertex(ptr noundef %0, ptr noundef nonnull %6)
  br label %11

11:                                               ; preds = %10, %.lr.ph
  %.0 = getelementptr inbounds i8, ptr %.028, i64 8
  %12 = load ptr, ptr %.0, align 8, !tbaa !5
  %.not22 = icmp eq ptr %12, null
  br i1 %.not22, label %.loopexit, label %.lr.ph, !llvm.loop !9

.loopexit:                                        ; preds = %11, %.preheader, %4
  %13 = tail call ptr @qh_newfacet(ptr noundef %0)
  %14 = getelementptr inbounds i8, ptr %13, i64 64
  store ptr %1, ptr %14, align 8, !tbaa !11
  %.not23 = icmp eq i32 %2, 0
  br i1 %.not23, label %19, label %15

15:                                               ; preds = %.loopexit
  %16 = getelementptr inbounds i8, ptr %13, i64 112
  %17 = load i32, ptr %16, align 8
  %18 = or i32 %17, 4096
  store i32 %18, ptr %16, align 8
  br label %19

19:                                               ; preds = %15, %.loopexit
  %.not24 = icmp eq ptr %3, null
  br i1 %.not24, label %22, label %20

20:                                               ; preds = %19
  %21 = getelementptr inbounds i8, ptr %13, i64 80
  tail call void @qh_setappend(ptr noundef %0, ptr noundef nonnull %21, ptr noundef nonnull %3) #2
  br label %22

22:                                               ; preds = %20, %19
  tail call void @qh_appendfacet(ptr noundef %0, ptr noundef nonnull %13)
  ret ptr %13
}

; Function Attrs: nounwind uwtable
declare dso_local void @qh_removevertex(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @qh_newfacet(ptr noundef) local_unnamed_addr #0

attributes #0 = { 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 #1 = { "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/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !6, i64 64}
!12 = !{!"facetT", !13, i64 0, !13, i64 8, !13, i64 16, !6, i64 24, !7, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !14, i64 104, !14, i64 108, !14, i64 112, !14, i64 113, !14, i64 113, !14, i64 113, !14, i64 113, !14, i64 113, !14, i64 113, !14, i64 113, !14, i64 114, !14, i64 114, !14, i64 114, !14, i64 114, !14, i64 114, !14, i64 114, !14, i64 114, !14, i64 114, !14, i64 115, !14, i64 115, !14, i64 115, !14, i64 115, !14, i64 115, !14, i64 115, !14, i64 115, !14, i64 115}
!13 = !{!"double", !7, i64 0}
!14 = !{!"int", !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass