; LLVM IR from Discngine/fpocket :: src/qhull/src/libqhull (poly)

; 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) #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) #0

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

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

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

16:                                               ; preds = %32, %12
  %17 = load ptr, ptr %9, align 8, !tbaa !5
  %18 = getelementptr inbounds ptr, ptr %17, i32 1
  store ptr %18, ptr %9, align 8, !tbaa !5
  %19 = load ptr, ptr %17, align 8, !tbaa !5
  store ptr %19, ptr %8, align 8, !tbaa !5
  %20 = icmp ne ptr %19, null
  br i1 %20, label %21, label %33

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

29:                                               ; preds = %21
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  call void @qh_removevertex(ptr noundef %30)
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  call void @qh_appendvertex(ptr noundef %31)
  br label %32

32:                                               ; preds = %29, %21
  br label %16, !llvm.loop !11

33:                                               ; preds = %16
  br label %34

34:                                               ; preds = %33, %3
  %35 = call ptr @qh_newfacet()
  store ptr %35, ptr %7, align 8, !tbaa !5
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.facetT, ptr %37, i32 0, i32 8
  store ptr %36, ptr %38, align 8, !tbaa !13
  %39 = load i32, ptr %5, align 4, !tbaa !9
  %40 = trunc i32 %39 to i8
  %41 = zext i8 %40 to i32
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.facetT, ptr %42, i32 0, i32 15
  %44 = load i32, ptr %43, align 8
  %45 = and i32 %41, 1
  %46 = shl i32 %45, 12
  %47 = and i32 %44, -4097
  %48 = or i32 %47, %46
  store i32 %48, ptr %43, align 8
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = icmp ne ptr %49, null
  br i1 %50, label %51, label %55

51:                                               ; preds = %34
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.facetT, ptr %52, i32 0, i32 10
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  call void @qh_setappend(ptr noundef %53, ptr noundef %54)
  br label %55

55:                                               ; preds = %51, %34
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  call void @qh_appendfacet(ptr noundef %56)
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret ptr %57
}

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @qh_newfacet() #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) local_unnamed_addr #0

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

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

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

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

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

9:                                                ; preds = %.lr.ph
  tail call void @qh_removevertex(ptr noundef nonnull %5)
  tail call void @qh_appendvertex(ptr noundef nonnull %5)
  br label %10

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

.loopexit:                                        ; preds = %10, %.preheader, %3
  %12 = tail call ptr @qh_newfacet()
  %13 = getelementptr inbounds i8, ptr %12, i64 64
  store ptr %0, ptr %13, align 8, !tbaa !11
  %14 = getelementptr inbounds i8, ptr %12, i64 112
  %15 = load i32, ptr %14, align 8
  %16 = shl i32 %1, 12
  %17 = and i32 %16, 4096
  %18 = and i32 %15, -4097
  %19 = or disjoint i32 %18, %17
  store i32 %19, ptr %14, align 8
  %.not18 = icmp eq ptr %2, null
  br i1 %.not18, label %22, label %20

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

22:                                               ; preds = %20, %.loopexit
  tail call void @qh_appendfacet(ptr noundef nonnull %12)
  ret ptr %12
}

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @qh_newfacet() 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