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

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

; 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: nounwind uwtable
define dso_local void @qh_newvertices(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  store ptr null, ptr %3, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = icmp ne ptr %5, null
  br i1 %6, label %7, label %29

7:                                                ; preds = %1
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.setT, ptr %8, i32 0, i32 1
  %10 = getelementptr inbounds [1 x %union.setelemT], ptr %9, i64 0, i64 0
  store ptr %10, ptr %4, align 8, !tbaa !5
  br label %11

11:                                               ; preds = %27, %7
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds ptr, ptr %12, i32 1
  store ptr %13, ptr %4, align 8, !tbaa !5
  %14 = load ptr, ptr %12, align 8, !tbaa !5
  store ptr %14, ptr %3, align 8, !tbaa !5
  %15 = icmp ne ptr %14, null
  br i1 %15, label %16, label %28

16:                                               ; preds = %11
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.vertexT, ptr %17, i32 0, i32 6
  %19 = load i8, ptr %18, align 8
  %20 = lshr i8 %19, 4
  %21 = and i8 %20, 1
  %22 = zext i8 %21 to i32
  %23 = icmp ne i32 %22, 0
  br i1 %23, label %27, label %24

24:                                               ; preds = %16
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  call void @qh_removevertex(ptr noundef %25)
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  call void @qh_appendvertex(ptr noundef %26)
  br label %27

27:                                               ; preds = %24, %16
  br label %11, !llvm.loop !9

28:                                               ; preds = %11
  br label %29

29:                                               ; preds = %28, %1
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret void
}

declare void @qh_removevertex(ptr noundef) #2

declare void @qh_appendvertex(ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { "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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; 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
define dso_local void @qh_newvertices(ptr noundef readonly %0) local_unnamed_addr #0 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %.loopexit, label %.preheader

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

.lr.ph:                                           ; preds = %.preheader, %8
  %3 = phi ptr [ %9, %8 ], [ %2, %.preheader ]
  %.012 = phi ptr [ %.0, %8 ], [ %.010, %.preheader ]
  %4 = getelementptr inbounds i8, ptr %3, i64 40
  %5 = load i8, ptr %4, align 8
  %6 = and i8 %5, 16
  %.not9 = icmp eq i8 %6, 0
  br i1 %.not9, label %7, label %8

7:                                                ; preds = %.lr.ph
  tail call void @qh_removevertex(ptr noundef nonnull %3) #2
  tail call void @qh_appendvertex(ptr noundef nonnull %3) #2
  br label %8

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

.loopexit:                                        ; preds = %8, %.preheader, %1
  ret void
}

declare void @qh_removevertex(ptr noundef) local_unnamed_addr #1

declare void @qh_appendvertex(ptr noundef) local_unnamed_addr #1

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


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