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

; 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.qhmemT = type { i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, i32, ptr, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.setT = type { i32, [1 x %union.setelemT] }
%union.setelemT = type { ptr }

@qhmem = external global %struct.qhmemT, 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: nounwind uwtable
define dso_local void @qh_setlarger(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 1, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  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
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = load ptr, ptr %12, align 8, !tbaa !5
  %14 = icmp ne ptr %13, null
  br i1 %14, label %15, label %91

15:                                               ; preds = %1
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = load ptr, ptr %16, align 8, !tbaa !5
  store ptr %17, ptr %8, align 8, !tbaa !5
  %18 = load ptr, ptr %8, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.setT, ptr %18, i32 0, i32 1
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.setT, ptr %20, i32 0, i32 0
  %22 = load i32, ptr %21, align 8, !tbaa !11
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [1 x %union.setelemT], ptr %19, i64 0, i64 %23
  %25 = load i32, ptr %24, align 8, !tbaa !13
  store i32 %25, ptr %3, align 4, !tbaa !9
  %26 = icmp ne i32 %25, 0
  br i1 %26, label %27, label %30

27:                                               ; preds = %15
  %28 = load i32, ptr %3, align 4, !tbaa !9
  %29 = add nsw i32 %28, -1
  store i32 %29, ptr %3, align 4, !tbaa !9
  br label %34

30:                                               ; preds = %15
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.setT, ptr %31, i32 0, i32 0
  %33 = load i32, ptr %32, align 8, !tbaa !11
  store i32 %33, ptr %3, align 4, !tbaa !9
  br label %34

34:                                               ; preds = %30, %27
  %35 = phi i32 [ %29, %27 ], [ %33, %30 ]
  %36 = load i32, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 27), align 4, !tbaa !14
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 27), align 4, !tbaa !14
  %38 = load i32, ptr %3, align 4, !tbaa !9
  %39 = add nsw i32 %38, 1
  %40 = load i32, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 28), align 8, !tbaa !16
  %41 = add nsw i32 %40, %39
  store i32 %41, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 28), align 8, !tbaa !16
  %42 = load i32, ptr %3, align 4, !tbaa !9
  %43 = call i32 @qh_setlarger_quick(i32 noundef %42, ptr noundef %4)
  %44 = load i32, ptr %4, align 4, !tbaa !9
  %45 = call ptr @qh_setnew(i32 noundef %44)
  store ptr %45, ptr %5, align 8, !tbaa !5
  %46 = load ptr, ptr %8, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.setT, ptr %46, i32 0, i32 1
  %48 = getelementptr inbounds [1 x %union.setelemT], ptr %47, i64 0, i64 0
  store ptr %48, ptr %11, align 8, !tbaa !5
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.setT, ptr %49, i32 0, i32 1
  %51 = getelementptr inbounds [1 x %union.setelemT], ptr %50, i64 0, i64 0
  store ptr %51, ptr %10, align 8, !tbaa !5
  %52 = load ptr, ptr %10, align 8, !tbaa !5
  %53 = load ptr, ptr %11, align 8, !tbaa !5
  %54 = load i32, ptr %3, align 4, !tbaa !9
  %55 = add nsw i32 %54, 1
  %56 = sext i32 %55 to i64
  %57 = mul i64 %56, 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %52, ptr align 1 %53, i64 %57, i1 false)
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.setT, ptr %58, i32 0, i32 1
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.setT, ptr %60, i32 0, i32 0
  %62 = load i32, ptr %61, align 8, !tbaa !11
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [1 x %union.setelemT], ptr %59, i64 0, i64 %63
  store ptr %64, ptr %9, align 8, !tbaa !5
  %65 = load i32, ptr %3, align 4, !tbaa !9
  %66 = add nsw i32 %65, 1
  %67 = load ptr, ptr %9, align 8, !tbaa !5
  store i32 %66, ptr %67, align 8, !tbaa !13
  store ptr null, ptr %6, align 8, !tbaa !5
  %68 = load ptr, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 12), align 8, !tbaa !17
  %69 = icmp ne ptr %68, null
  br i1 %69, label %70, label %89

70:                                               ; preds = %34
  %71 = load ptr, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 12), align 8, !tbaa !17
  %72 = getelementptr inbounds %struct.setT, ptr %71, i32 0, i32 1
  %73 = getelementptr inbounds [1 x %union.setelemT], ptr %72, i64 0, i64 0
  store ptr %73, ptr %7, align 8, !tbaa !5
  br label %74

74:                                               ; preds = %87, %70
  %75 = load ptr, ptr %7, align 8, !tbaa !5
  %76 = getelementptr inbounds ptr, ptr %75, i32 1
  store ptr %76, ptr %7, align 8, !tbaa !5
  %77 = load ptr, ptr %75, align 8, !tbaa !5
  store ptr %77, ptr %6, align 8, !tbaa !5
  %78 = icmp ne ptr %77, null
  br i1 %78, label %79, label %88

79:                                               ; preds = %74
  %80 = load ptr, ptr %6, align 8, !tbaa !5
  %81 = load ptr, ptr %8, align 8, !tbaa !5
  %82 = icmp eq ptr %80, %81
  br i1 %82, label %83, label %87

83:                                               ; preds = %79
  %84 = load ptr, ptr %5, align 8, !tbaa !5
  %85 = load ptr, ptr %7, align 8, !tbaa !5
  %86 = getelementptr inbounds ptr, ptr %85, i64 -1
  store ptr %84, ptr %86, align 8, !tbaa !5
  br label %87

87:                                               ; preds = %83, %79
  br label %74, !llvm.loop !18

88:                                               ; preds = %74
  br label %89

89:                                               ; preds = %88, %34
  %90 = load ptr, ptr %2, align 8, !tbaa !5
  call void @qh_setfree(ptr noundef %90)
  br label %93

91:                                               ; preds = %1
  %92 = call ptr @qh_setnew(i32 noundef 3)
  store ptr %92, ptr %5, align 8, !tbaa !5
  br label %93

93:                                               ; preds = %91, %89
  %94 = load ptr, ptr %5, align 8, !tbaa !5
  %95 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %94, ptr %95, 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
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret void
}

; 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
declare dso_local ptr @qh_setnew(i32 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @qh_setfree(ptr noundef) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @qh_setlarger_quick(i32 noundef, ptr noundef) #1

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!12, !10, i64 0}
!12 = !{!"setT", !10, i64 0, !7, i64 8}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !10, i64 140}
!15 = !{!"qhmemT", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !10, i64 64, !6, i64 72, !6, i64 80, !10, i64 88, !10, i64 92, !10, i64 96, !10, i64 100, !10, i64 104, !10, i64 108, !10, i64 112, !10, i64 116, !10, i64 120, !10, i64 124, !10, i64 128, !10, i64 132, !10, i64 136, !10, i64 140, !10, i64 144}
!16 = !{!15, !10, i64 144}
!17 = !{!15, !6, i64 72}
!18 = distinct !{!18, !19}
!19 = !{!"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"

%struct.qhmemT = type { i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, i32, ptr, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%union.setelemT = type { ptr }

@qhmem = external local_unnamed_addr global %struct.qhmemT, align 8

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

; Function Attrs: nounwind uwtable
define dso_local void @qh_setlarger(ptr noundef %0) local_unnamed_addr #1 {
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #3
  %3 = load ptr, ptr %0, align 8, !tbaa !5
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %31, label %4

4:                                                ; preds = %1
  %5 = getelementptr inbounds i8, ptr %3, i64 8
  %6 = load i32, ptr %3, align 8, !tbaa !9
  %7 = sext i32 %6 to i64
  %8 = getelementptr inbounds [1 x %union.setelemT], ptr %5, i64 0, i64 %7
  %9 = load i32, ptr %8, align 8, !tbaa !12
  %.not30 = icmp eq i32 %9, 0
  %10 = add nsw i32 %9, -1
  %.0 = select i1 %.not30, i32 %6, i32 %10
  %11 = add nsw i32 %.0, 1
  %12 = load <2 x i32>, ptr getelementptr inbounds (i8, ptr @qhmem, i64 140), align 4, !tbaa !13
  %13 = insertelement <2 x i32> <i32 1, i32 poison>, i32 %11, i64 1
  %14 = add nsw <2 x i32> %12, %13
  store <2 x i32> %14, ptr getelementptr inbounds (i8, ptr @qhmem, i64 140), align 4, !tbaa !13
  %15 = call i32 @qh_setlarger_quick(i32 noundef %.0, ptr noundef nonnull %2)
  %16 = load i32, ptr %2, align 4, !tbaa !13
  %17 = call ptr @qh_setnew(i32 noundef %16)
  %18 = getelementptr inbounds i8, ptr %17, i64 8
  %19 = sext i32 %11 to i64
  %20 = shl nsw i64 %19, 3
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %18, ptr nonnull align 1 %5, i64 %20, i1 false)
  %21 = load i32, ptr %17, align 8, !tbaa !9
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [1 x %union.setelemT], ptr %18, i64 0, i64 %22
  store i32 %11, ptr %23, align 8, !tbaa !12
  %24 = load ptr, ptr getelementptr inbounds (i8, ptr @qhmem, i64 72), align 8, !tbaa !14
  %.not31 = icmp eq ptr %24, null
  br i1 %.not31, label %.loopexit, label %.preheader

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

.lr.ph:                                           ; preds = %.preheader, %29
  %26 = phi ptr [ %30, %29 ], [ %25, %.preheader ]
  %.02535 = phi ptr [ %.025, %29 ], [ %.02533, %.preheader ]
  %27 = icmp eq ptr %26, %3
  br i1 %27, label %28, label %29

28:                                               ; preds = %.lr.ph
  store ptr %17, ptr %.02535, align 8, !tbaa !5
  br label %29

29:                                               ; preds = %28, %.lr.ph
  %.025 = getelementptr inbounds i8, ptr %.02535, i64 8
  %30 = load ptr, ptr %.025, align 8, !tbaa !5
  %.not32 = icmp eq ptr %30, null
  br i1 %.not32, label %.loopexit, label %.lr.ph, !llvm.loop !16

.loopexit:                                        ; preds = %29, %.preheader, %4
  call void @qh_setfree(ptr noundef nonnull %0)
  br label %33

31:                                               ; preds = %1
  %32 = tail call ptr @qh_setnew(i32 noundef 3)
  br label %33

33:                                               ; preds = %31, %.loopexit
  %.024 = phi ptr [ %17, %.loopexit ], [ %32, %31 ]
  store ptr %.024, ptr %0, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #3
  ret void
}

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @qh_setnew(i32 noundef) local_unnamed_addr #1

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @qh_setlarger_quick(i32 noundef, ptr noundef) local_unnamed_addr #1

attributes #0 = { mustprogress 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !11, i64 0}
!10 = !{!"setT", !11, i64 0, !7, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!7, !7, i64 0}
!13 = !{!11, !11, i64 0}
!14 = !{!15, !6, i64 72}
!15 = !{!"qhmemT", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !11, i64 64, !6, i64 72, !6, i64 80, !11, i64 88, !11, i64 92, !11, i64 96, !11, i64 100, !11, i64 104, !11, i64 108, !11, i64 112, !11, i64 116, !11, i64 120, !11, i64 124, !11, i64 128, !11, i64 132, !11, i64 136, !11, i64 140, !11, i64 144}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


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