; 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.19 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [34 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 @testSetdelSetadd(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 i32, align 4
  %11 = alloca i32, align 4
  %12 = 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
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = call ptr @qh_setnew(ptr noundef %13, i32 noundef 1)
  store ptr %14, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = load ptr, ptr @stderr, align 8, !tbaa !5
  %17 = load i32, ptr %6, align 4, !tbaa !9
  %18 = sub nsw i32 %17, 1
  call void (ptr, ptr, i32, ptr, ...) @qh_fprintf(ptr noundef %15, ptr noundef %16, i32 noundef 8147, ptr noundef @.str.29, i32 noundef %18)
  store i32 1, ptr %11, align 4, !tbaa !9
  br label %19

19:                                               ; preds = %93, %4
  %20 = load i32, ptr %11, align 4, !tbaa !9
  %21 = load i32, ptr %6, align 4, !tbaa !9
  %22 = icmp slt i32 %20, %21
  br i1 %22, label %23, label %96

23:                                               ; preds = %19
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = load ptr, ptr %9, align 8, !tbaa !5
  %26 = load i32, ptr %11, align 4, !tbaa !9
  %27 = load i32, ptr %6, align 4, !tbaa !9
  %28 = call i32 @log_i(ptr noundef %24, ptr noundef %25, ptr noundef @.str.30, i32 noundef %26, i32 noundef %27, i32 noundef 2147483647)
  %29 = icmp ne i32 %28, 0
  br i1 %29, label %30, label %92

30:                                               ; preds = %23
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = load ptr, ptr %9, align 8, !tbaa !5
  %33 = call i32 @qh_setsize(ptr noundef %31, ptr noundef %32)
  store i32 %33, ptr %10, align 4, !tbaa !9
  br label %34

34:                                               ; preds = %44, %30
  %35 = load i32, ptr %10, align 4, !tbaa !9
  %36 = load i32, ptr %11, align 4, !tbaa !9
  %37 = icmp slt i32 %35, %36
  br i1 %37, label %38, label %47

38:                                               ; preds = %34
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = load i32, ptr %10, align 4, !tbaa !9
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds i32, ptr %40, i64 %42
  call void @qh_setappend(ptr noundef %39, ptr noundef %9, ptr noundef %43)
  br label %44

44:                                               ; preds = %38
  %45 = load i32, ptr %10, align 4, !tbaa !9
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr %10, align 4, !tbaa !9
  br label %34, !llvm.loop !11

47:                                               ; preds = %34
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = load ptr, ptr %9, align 8, !tbaa !5
  %50 = load i32, ptr %11, align 4, !tbaa !9
  call void @checkSetContents(ptr noundef %48, ptr noundef @.str.19, ptr noundef %49, i32 noundef %50, i32 noundef 0, i32 noundef -1, i32 noundef -1)
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %51

51:                                               ; preds = %85, %47
  %52 = load i32, ptr %10, align 4, !tbaa !9
  %53 = load i32, ptr %11, align 4, !tbaa !9
  %54 = icmp slt i32 %52, %53
  br i1 %54, label %55, label %58

55:                                               ; preds = %51
  %56 = load i32, ptr %10, align 4, !tbaa !9
  %57 = icmp slt i32 %56, 100
  br label %58

58:                                               ; preds = %55, %51
  %59 = phi i1 [ false, %51 ], [ %57, %55 ]
  br i1 %59, label %60, label %88

60:                                               ; preds = %58
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = load ptr, ptr %9, align 8, !tbaa !5
  %63 = load i32, ptr %10, align 4, !tbaa !9
  %64 = load i32, ptr %6, align 4, !tbaa !9
  %65 = load i32, ptr %8, align 4, !tbaa !9
  %66 = call i32 @log_i(ptr noundef %61, ptr noundef %62, ptr noundef @.str.31, i32 noundef %63, i32 noundef %64, i32 noundef %65)
  store i32 %66, ptr %12, align 4, !tbaa !9
  %67 = load i32, ptr %12, align 4, !tbaa !9
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = load ptr, ptr %9, align 8, !tbaa !5
  %70 = load i32, ptr %10, align 4, !tbaa !9
  %71 = call ptr @qh_setdelnthsorted(ptr noundef %68, ptr noundef %69, i32 noundef %70)
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  %73 = load i32, ptr %10, align 4, !tbaa !9
  %74 = load ptr, ptr %7, align 8, !tbaa !5
  %75 = load i32, ptr %10, align 4, !tbaa !9
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds i32, ptr %74, i64 %76
  call void @qh_setaddnth(ptr noundef %72, ptr noundef %9, i32 noundef %73, ptr noundef %77)
  %78 = load i32, ptr %8, align 4, !tbaa !9
  %79 = icmp eq i32 %78, 1
  br i1 %79, label %80, label %84

80:                                               ; preds = %60
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  %82 = load ptr, ptr %9, align 8, !tbaa !5
  %83 = load i32, ptr %11, align 4, !tbaa !9
  call void @checkSetContents(ptr noundef %81, ptr noundef @.str.32, ptr noundef %82, i32 noundef %83, i32 noundef 0, i32 noundef -1, i32 noundef -1)
  br label %84

84:                                               ; preds = %80, %60
  br label %85

85:                                               ; preds = %84
  %86 = load i32, ptr %10, align 4, !tbaa !9
  %87 = add nsw i32 %86, 1
  store i32 %87, ptr %10, align 4, !tbaa !9
  br label %51, !llvm.loop !13

88:                                               ; preds = %58
  %89 = load ptr, ptr %5, align 8, !tbaa !5
  %90 = load ptr, ptr %9, align 8, !tbaa !5
  %91 = load i32, ptr %11, align 4, !tbaa !9
  call void @checkSetContents(ptr noundef %89, ptr noundef @.str.33, ptr noundef %90, i32 noundef %91, i32 noundef 0, i32 noundef -1, i32 noundef -1)
  br label %92

92:                                               ; preds = %88, %23
  br label %93

93:                                               ; preds = %92
  %94 = load i32, ptr %11, align 4, !tbaa !9
  %95 = add nsw i32 %94, 1
  store i32 %95, ptr %11, align 4, !tbaa !9
  br label %19, !llvm.loop !14

96:                                               ; preds = %19
  %97 = load ptr, ptr %5, align 8, !tbaa !5
  call void @qh_setfree(ptr noundef %97, ptr noundef %9)
  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 4, 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_setdelnthsorted(ptr noundef, ptr noundef, i32 noundef) #2

declare void @qh_setaddnth(ptr noundef, ptr noundef, i32 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.19 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [34 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 @testSetdelSetadd(ptr noundef %0, i32 noundef %1, ptr noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  %6 = tail call ptr @qh_setnew(ptr noundef %0, i32 noundef 1) #4
  store ptr %6, ptr %5, align 8, !tbaa !5
  %7 = load ptr, ptr @stderr, align 8, !tbaa !5
  %8 = add nsw i32 %1, -1
  tail call void (ptr, ptr, i32, ptr, ...) @qh_fprintf(ptr noundef %0, ptr noundef %7, i32 noundef 8147, ptr noundef nonnull @.str.29, i32 noundef %8)
  %9 = icmp sgt i32 %1, 1
  br i1 %9, label %.lr.ph46, label %._crit_edge47

.lr.ph46:                                         ; preds = %4
  %10 = icmp eq i32 %3, 1
  br label %11

11:                                               ; preds = %.lr.ph46, %35
  %.03844 = phi i32 [ 1, %.lr.ph46 ], [ %36, %35 ]
  %umin57 = call i32 @llvm.umin.i32(i32 %.03844, i32 100)
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = call i32 @log_i(ptr noundef %0, ptr noundef %12, ptr noundef nonnull @.str.30, i32 noundef %.03844, i32 noundef %1, i32 noundef 2147483647)
  %.not = icmp eq i32 %13, 0
  br i1 %.not, label %35, label %14

14:                                               ; preds = %11
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = call i32 @qh_setsize(ptr noundef %0, ptr noundef %15) #4
  %17 = icmp slt i32 %16, %.03844
  br i1 %17, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %14
  %18 = sext i32 %16 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %18, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %19 = getelementptr inbounds i32, ptr %2, i64 %indvars.iv
  call void @qh_setappend(ptr noundef %0, ptr noundef nonnull %5, ptr noundef %19) #4
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %lftr.wideiv = trunc i64 %indvars.iv.next to i32
  %exitcond.not = icmp eq i32 %.03844, %lftr.wideiv
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph, %14
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  call void @checkSetContents(ptr noundef %0, ptr noundef nonnull @.str.19, ptr noundef %20, i32 noundef %.03844, i32 noundef 0, i32 noundef -1, i32 noundef -1)
  %wide.trip.count58 = zext nneg i32 %umin57 to i64
  br i1 %10, label %.split.us, label %.split

.split.us:                                        ; preds = %._crit_edge, %.split.us
  %indvars.iv54 = phi i64 [ %indvars.iv.next55, %.split.us ], [ 0, %._crit_edge ]
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = trunc nuw nsw i64 %indvars.iv54 to i32
  %23 = call i32 @log_i(ptr noundef %0, ptr noundef %21, ptr noundef nonnull @.str.31, i32 noundef %22, i32 noundef %1, i32 noundef 1)
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = call ptr @qh_setdelnthsorted(ptr noundef %0, ptr noundef %24, i32 noundef %22) #4
  %26 = getelementptr inbounds i32, ptr %2, i64 %indvars.iv54
  call void @qh_setaddnth(ptr noundef %0, ptr noundef nonnull %5, i32 noundef %22, ptr noundef %26) #4
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  call void @checkSetContents(ptr noundef %0, ptr noundef nonnull @.str.32, ptr noundef %27, i32 noundef %.03844, i32 noundef 0, i32 noundef -1, i32 noundef -1)
  %indvars.iv.next55 = add nuw nsw i64 %indvars.iv54, 1
  %exitcond59.not = icmp eq i64 %indvars.iv.next55, %wide.trip.count58
  br i1 %exitcond59.not, label %.split43.us, label %.split.us, !llvm.loop !11

.split:                                           ; preds = %._crit_edge, %.split
  %indvars.iv50 = phi i64 [ %indvars.iv.next51, %.split ], [ 0, %._crit_edge ]
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = trunc nuw nsw i64 %indvars.iv50 to i32
  %30 = call i32 @log_i(ptr noundef %0, ptr noundef %28, ptr noundef nonnull @.str.31, i32 noundef %29, i32 noundef %1, i32 noundef %3)
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = call ptr @qh_setdelnthsorted(ptr noundef %0, ptr noundef %31, i32 noundef %29) #4
  %33 = getelementptr inbounds i32, ptr %2, i64 %indvars.iv50
  call void @qh_setaddnth(ptr noundef %0, ptr noundef nonnull %5, i32 noundef %29, ptr noundef %33) #4
  %indvars.iv.next51 = add nuw nsw i64 %indvars.iv50, 1
  %exitcond53.not = icmp eq i64 %indvars.iv.next51, %wide.trip.count58
  br i1 %exitcond53.not, label %.split43.us, label %.split, !llvm.loop !11

.split43.us:                                      ; preds = %.split, %.split.us
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  call void @checkSetContents(ptr noundef %0, ptr noundef nonnull @.str.33, ptr noundef %34, i32 noundef %.03844, i32 noundef 0, i32 noundef -1, i32 noundef -1)
  br label %35

35:                                               ; preds = %11, %.split43.us
  %36 = add nuw nsw i32 %.03844, 1
  %exitcond60.not = icmp eq i32 %36, %1
  br i1 %exitcond60.not, label %._crit_edge47, label %11, !llvm.loop !12

._crit_edge47:                                    ; preds = %35, %4
  call void @qh_setfree(ptr noundef %0, ptr noundef nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  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_setdelnthsorted(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

declare void @qh_setaddnth(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umin.i32(i32, i32) #3

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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: GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass