; LLVM IR from jrl-umi3218/mc_rtc :: 3rd-party/qhull/src/testqset_r (testqset_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"

@stderr = external global ptr, align 8
@.str.30 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [51 x i8], align 1
@.str.38 = external hidden unnamed_addr constant [14 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @qh_fprintf(ptr noundef, ptr noundef, i32 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
define dso_local void @testSetcompactCopy(ptr noundef %0, i32 noundef %1, ptr noundef %2, i32 noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  store i32 %3, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = call ptr @qh_setnew(ptr noundef %14, i32 noundef 20)
  store ptr %15, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  store ptr null, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = load ptr, ptr @stderr, align 8, !tbaa !5
  %18 = load i32, ptr %6, align 4, !tbaa !9
  %19 = sub nsw i32 %18, 1
  call void (ptr, ptr, i32, ptr, ...) @qh_fprintf(ptr noundef %16, ptr noundef %17, i32 noundef 8149, ptr noundef @.str.37, i32 noundef %19)
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %20

20:                                               ; preds = %81, %4
  %21 = load i32, ptr %12, align 4, !tbaa !9
  %22 = load i32, ptr %6, align 4, !tbaa !9
  %23 = icmp slt i32 %21, %22
  br i1 %23, label %24, label %84

24:                                               ; preds = %20
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = load ptr, ptr %9, align 8, !tbaa !5
  %27 = load i32, ptr %12, align 4, !tbaa !9
  %28 = load i32, ptr %6, align 4, !tbaa !9
  %29 = load i32, ptr %8, align 4, !tbaa !9
  %30 = call i32 @log_i(ptr noundef %25, ptr noundef %26, ptr noundef @.str.30, i32 noundef %27, i32 noundef %28, i32 noundef %29)
  %31 = icmp ne i32 %30, 0
  br i1 %31, label %32, label %80

32:                                               ; preds = %24
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = call i32 @qh_setsize(ptr noundef %33, ptr noundef %34)
  store i32 %35, ptr %11, align 4, !tbaa !9
  br label %36

36:                                               ; preds = %57, %32
  %37 = load i32, ptr %11, align 4, !tbaa !9
  %38 = load i32, ptr %12, align 4, !tbaa !9
  %39 = icmp slt i32 %37, %38
  br i1 %39, label %40, label %60

40:                                               ; preds = %36
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %41

41:                                               ; preds = %48, %40
  %42 = load i32, ptr %13, align 4, !tbaa !9
  %43 = load i32, ptr %11, align 4, !tbaa !9
  %44 = srem i32 %43, 7
  %45 = icmp slt i32 %42, %44
  br i1 %45, label %46, label %51

46:                                               ; preds = %41
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  call void @qh_setappend(ptr noundef %47, ptr noundef %9, ptr noundef null)
  br label %48

48:                                               ; preds = %46
  %49 = load i32, ptr %13, align 4, !tbaa !9
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr %13, align 4, !tbaa !9
  br label %41, !llvm.loop !11

51:                                               ; preds = %41
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  %54 = load i32, ptr %11, align 4, !tbaa !9
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds i32, ptr %53, i64 %55
  call void @qh_setappend(ptr noundef %52, ptr noundef %9, ptr noundef %56)
  br label %57

57:                                               ; preds = %51
  %58 = load i32, ptr %11, align 4, !tbaa !9
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %11, align 4, !tbaa !9
  br label %36, !llvm.loop !13

60:                                               ; preds = %36
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  call void @qh_setfree(ptr noundef %61, ptr noundef %10)
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = load ptr, ptr %9, align 8, !tbaa !5
  %64 = call ptr @qh_setcopy(ptr noundef %62, ptr noundef %63, i32 noundef 0)
  store ptr %64, ptr %10, align 8, !tbaa !5
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = load ptr, ptr %9, align 8, !tbaa !5
  call void @qh_setcompact(ptr noundef %65, ptr noundef %66)
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = load ptr, ptr %10, align 8, !tbaa !5
  call void @qh_setcompact(ptr noundef %67, ptr noundef %68)
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = load ptr, ptr %9, align 8, !tbaa !5
  %71 = load i32, ptr %12, align 4, !tbaa !9
  call void @checkSetContents(ptr noundef %69, ptr noundef @.str.38, ptr noundef %70, i32 noundef %71, i32 noundef 0, i32 noundef 0, i32 noundef -1)
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  %73 = load ptr, ptr %10, align 8, !tbaa !5
  %74 = load i32, ptr %12, align 4, !tbaa !9
  call void @checkSetContents(ptr noundef %72, ptr noundef @.str.38, ptr noundef %73, i32 noundef %74, i32 noundef 0, i32 noundef 0, i32 noundef -1)
  %75 = load ptr, ptr %5, align 8, !tbaa !5
  %76 = load ptr, ptr %9, align 8, !tbaa !5
  call void @qh_setcompact(ptr noundef %75, ptr noundef %76)
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  %78 = load ptr, ptr %9, align 8, !tbaa !5
  %79 = load i32, ptr %12, align 4, !tbaa !9
  call void @checkSetContents(ptr noundef %77, ptr noundef @.str.38, ptr noundef %78, i32 noundef %79, i32 noundef 0, i32 noundef 0, i32 noundef -1)
  br label %80

80:                                               ; preds = %60, %24
  br label %81

81:                                               ; preds = %80
  %82 = load i32, ptr %12, align 4, !tbaa !9
  %83 = add nsw i32 %82, 1
  store i32 %83, ptr %12, align 4, !tbaa !9
  br label %20, !llvm.loop !14

84:                                               ; preds = %20
  %85 = load ptr, ptr %5, align 8, !tbaa !5
  call void @qh_setfree(ptr noundef %85, ptr noundef %9)
  %86 = load ptr, ptr %5, align 8, !tbaa !5
  call void @qh_setfree(ptr noundef %86, ptr noundef %10)
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, 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 void
}

declare ptr @qh_setnew(ptr noundef, i32 noundef) #2

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

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

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

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

declare i32 @qh_setsize(ptr noundef, ptr noundef) #2

declare ptr @qh_setcopy(ptr noundef, ptr noundef, i32 noundef) #2

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

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 = distinct !{!13, !12}
!14 = distinct !{!14, !12}


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

@stderr = external local_unnamed_addr global ptr, align 8
@.str.30 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [51 x i8], align 1
@.str.38 = external hidden unnamed_addr constant [14 x i8], align 1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @testSetcompactCopy(ptr noundef %0, i32 noundef %1, ptr noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  %7 = tail call ptr @qh_setnew(ptr noundef %0, i32 noundef 20) #3
  store ptr %7, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #3
  store ptr null, ptr %6, align 8, !tbaa !5
  %8 = load ptr, ptr @stderr, align 8, !tbaa !5
  %9 = add nsw i32 %1, -1
  tail call void (ptr, ptr, i32, ptr, ...) @qh_fprintf(ptr noundef %0, ptr noundef %8, i32 noundef 8149, ptr noundef nonnull @.str.37, i32 noundef %9)
  %10 = icmp sgt i32 %1, 0
  br i1 %10, label %.lr.ph41, label %._crit_edge42

.lr.ph41:                                         ; preds = %4, %31
  %.03339 = phi i32 [ %32, %31 ], [ 0, %4 ]
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = call i32 @log_i(ptr noundef %0, ptr noundef %11, ptr noundef nonnull @.str.30, i32 noundef %.03339, i32 noundef %1, i32 noundef %3)
  %.not = icmp eq i32 %12, 0
  br i1 %.not, label %31, label %13

13:                                               ; preds = %.lr.ph41
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = call i32 @qh_setsize(ptr noundef %0, ptr noundef %14) #3
  %16 = icmp slt i32 %15, %.03339
  br i1 %16, label %.preheader.preheader, label %._crit_edge38

.preheader.preheader:                             ; preds = %13
  %17 = sext i32 %15 to i64
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %._crit_edge
  %indvars.iv = phi i64 [ %17, %.preheader.preheader ], [ %indvars.iv.next, %._crit_edge ]
  %18 = trunc nsw i64 %indvars.iv to i32
  %19 = srem i32 %18, 7
  %20 = icmp sgt i32 %19, 0
  br i1 %20, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.036 = phi i32 [ %21, %.lr.ph ], [ 0, %.preheader ]
  call void @qh_setappend(ptr noundef %0, ptr noundef nonnull %5, ptr noundef null) #3
  %21 = add nuw nsw i32 %.036, 1
  %exitcond.not = icmp eq i32 %21, %19
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  %22 = getelementptr inbounds i32, ptr %2, i64 %indvars.iv
  call void @qh_setappend(ptr noundef %0, ptr noundef nonnull %5, ptr noundef %22) #3
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %lftr.wideiv = trunc i64 %indvars.iv.next to i32
  %exitcond44.not = icmp eq i32 %.03339, %lftr.wideiv
  br i1 %exitcond44.not, label %._crit_edge38, label %.preheader, !llvm.loop !11

._crit_edge38:                                    ; preds = %._crit_edge, %13
  call void @qh_setfree(ptr noundef %0, ptr noundef nonnull %6) #3
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = call ptr @qh_setcopy(ptr noundef %0, ptr noundef %23, i32 noundef 0) #3
  store ptr %24, ptr %6, align 8, !tbaa !5
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  call void @qh_setcompact(ptr noundef %0, ptr noundef %25) #3
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  call void @qh_setcompact(ptr noundef %0, ptr noundef %26) #3
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  call void @checkSetContents(ptr noundef %0, ptr noundef nonnull @.str.38, ptr noundef %27, i32 noundef %.03339, i32 noundef 0, i32 noundef 0, i32 noundef -1)
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  call void @checkSetContents(ptr noundef %0, ptr noundef nonnull @.str.38, ptr noundef %28, i32 noundef %.03339, i32 noundef 0, i32 noundef 0, i32 noundef -1)
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  call void @qh_setcompact(ptr noundef %0, ptr noundef %29) #3
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  call void @checkSetContents(ptr noundef %0, ptr noundef nonnull @.str.38, ptr noundef %30, i32 noundef %.03339, i32 noundef 0, i32 noundef 0, i32 noundef -1)
  br label %31

31:                                               ; preds = %.lr.ph41, %._crit_edge38
  %32 = add nuw nsw i32 %.03339, 1
  %exitcond45.not = icmp eq i32 %32, %1
  br i1 %exitcond45.not, label %._crit_edge42, label %.lr.ph41, !llvm.loop !12

._crit_edge42:                                    ; preds = %31, %4
  call void @qh_setfree(ptr noundef %0, ptr noundef nonnull %5) #3
  call void @qh_setfree(ptr noundef %0, ptr noundef nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  ret void
}

declare ptr @qh_setnew(ptr noundef, i32 noundef) local_unnamed_addr #2

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

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

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

declare void @qh_setfree(ptr noundef, ptr noundef) local_unnamed_addr #2

declare i32 @qh_setsize(ptr noundef, ptr noundef) local_unnamed_addr #2

declare ptr @qh_setcopy(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

declare void @qh_setcompact(ptr noundef, ptr noundef) local_unnamed_addr #2

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 = { mustprogress 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}


; Effective O3 passes: GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass