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

; 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.18 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [34 x i8], align 1

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

15:                                               ; preds = %80, %3
  %16 = load i32, ptr %9, align 4, !tbaa !5
  %17 = load i32, ptr %4, align 4, !tbaa !5
  %18 = icmp slt i32 %16, %17
  br i1 %18, label %19, label %83

19:                                               ; preds = %15
  %20 = load ptr, ptr %7, align 8, !tbaa !9
  %21 = load i32, ptr %9, align 4, !tbaa !5
  %22 = load i32, ptr %4, align 4, !tbaa !5
  %23 = call i32 @log_i(ptr noundef %20, ptr noundef @.str.29, i32 noundef %21, i32 noundef %22, i32 noundef 2147483647)
  %24 = icmp ne i32 %23, 0
  br i1 %24, label %25, label %79

25:                                               ; preds = %19
  %26 = load ptr, ptr %7, align 8, !tbaa !9
  %27 = call i32 @qh_setsize(ptr noundef %26)
  store i32 %27, ptr %8, align 4, !tbaa !5
  br label %28

28:                                               ; preds = %37, %25
  %29 = load i32, ptr %8, align 4, !tbaa !5
  %30 = load i32, ptr %9, align 4, !tbaa !5
  %31 = icmp slt i32 %29, %30
  br i1 %31, label %32, label %40

32:                                               ; preds = %28
  %33 = load ptr, ptr %5, align 8, !tbaa !9
  %34 = load i32, ptr %8, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds i32, ptr %33, i64 %35
  call void @qh_setappend(ptr noundef %7, ptr noundef %36)
  br label %37

37:                                               ; preds = %32
  %38 = load i32, ptr %8, align 4, !tbaa !5
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %8, align 4, !tbaa !5
  br label %28, !llvm.loop !11

40:                                               ; preds = %28
  %41 = load ptr, ptr %7, align 8, !tbaa !9
  %42 = load i32, ptr %9, align 4, !tbaa !5
  call void @checkSetContents(ptr noundef @.str.18, ptr noundef %41, i32 noundef %42, i32 noundef 0, i32 noundef -1, i32 noundef -1)
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %43

43:                                               ; preds = %73, %40
  %44 = load i32, ptr %8, align 4, !tbaa !5
  %45 = load i32, ptr %9, align 4, !tbaa !5
  %46 = icmp slt i32 %44, %45
  br i1 %46, label %47, label %50

47:                                               ; preds = %43
  %48 = load i32, ptr %8, align 4, !tbaa !5
  %49 = icmp slt i32 %48, 100
  br label %50

50:                                               ; preds = %47, %43
  %51 = phi i1 [ false, %43 ], [ %49, %47 ]
  br i1 %51, label %52, label %76

52:                                               ; preds = %50
  %53 = load ptr, ptr %7, align 8, !tbaa !9
  %54 = load i32, ptr %8, align 4, !tbaa !5
  %55 = load i32, ptr %4, align 4, !tbaa !5
  %56 = load i32, ptr %6, align 4, !tbaa !5
  %57 = call i32 @log_i(ptr noundef %53, ptr noundef @.str.30, i32 noundef %54, i32 noundef %55, i32 noundef %56)
  store i32 %57, ptr %10, align 4, !tbaa !5
  %58 = load i32, ptr %10, align 4, !tbaa !5
  %59 = load ptr, ptr %7, align 8, !tbaa !9
  %60 = load i32, ptr %8, align 4, !tbaa !5
  %61 = call ptr @qh_setdelnthsorted(ptr noundef %59, i32 noundef %60)
  %62 = load i32, ptr %8, align 4, !tbaa !5
  %63 = load ptr, ptr %5, align 8, !tbaa !9
  %64 = load i32, ptr %8, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds i32, ptr %63, i64 %65
  call void @qh_setaddnth(ptr noundef %7, i32 noundef %62, ptr noundef %66)
  %67 = load i32, ptr %6, align 4, !tbaa !5
  %68 = icmp eq i32 %67, 1
  br i1 %68, label %69, label %72

69:                                               ; preds = %52
  %70 = load ptr, ptr %7, align 8, !tbaa !9
  %71 = load i32, ptr %9, align 4, !tbaa !5
  call void @checkSetContents(ptr noundef @.str.31, ptr noundef %70, i32 noundef %71, i32 noundef 0, i32 noundef -1, i32 noundef -1)
  br label %72

72:                                               ; preds = %69, %52
  br label %73

73:                                               ; preds = %72
  %74 = load i32, ptr %8, align 4, !tbaa !5
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr %8, align 4, !tbaa !5
  br label %43, !llvm.loop !13

76:                                               ; preds = %50
  %77 = load ptr, ptr %7, align 8, !tbaa !9
  %78 = load i32, ptr %9, align 4, !tbaa !5
  call void @checkSetContents(ptr noundef @.str.32, ptr noundef %77, i32 noundef %78, i32 noundef 0, i32 noundef -1, i32 noundef -1)
  br label %79

79:                                               ; preds = %76, %19
  br label %80

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

83:                                               ; preds = %15
  call void @qh_setfree(ptr noundef %7)
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret void
}

declare ptr @qh_setnew(i32 noundef) #2

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

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

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

declare void @qh_setfree(ptr noundef) #2

declare i32 @qh_setsize(ptr noundef) #2

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

declare void @qh_setaddnth(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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !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.18 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [34 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @qh_fprintf(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(i32 noundef %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  %5 = tail call ptr @qh_setnew(i32 noundef 1) #4
  store ptr %5, ptr %4, align 8, !tbaa !5
  %6 = load ptr, ptr @stderr, align 8, !tbaa !5
  %7 = add nsw i32 %0, -1
  tail call void (ptr, i32, ptr, ...) @qh_fprintf(ptr noundef %6, i32 noundef 8147, ptr noundef nonnull @.str.28, i32 noundef %7)
  %8 = icmp sgt i32 %0, 1
  br i1 %8, label %.lr.ph34, label %._crit_edge35

.lr.ph34:                                         ; preds = %3
  %9 = icmp eq i32 %2, 1
  br i1 %9, label %.lr.ph34.split.us, label %.lr.ph34.split

.lr.ph34.split.us:                                ; preds = %.lr.ph34, %19
  %.02632.us = phi i32 [ %20, %19 ], [ 1, %.lr.ph34 ]
  %umin51 = call i32 @llvm.umin.i32(i32 %.02632.us, i32 100)
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = call i32 @log_i(ptr noundef %10, ptr noundef nonnull @.str.29, i32 noundef %.02632.us, i32 noundef %0, i32 noundef 2147483647)
  %.not.us = icmp eq i32 %11, 0
  br i1 %.not.us, label %19, label %12

12:                                               ; preds = %.lr.ph34.split.us
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = call i32 @qh_setsize(ptr noundef %13) #4
  %15 = icmp slt i32 %14, %.02632.us
  br i1 %15, label %.lr.ph.us.preheader, label %.split.us.us

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

.split.us.us:                                     ; preds = %.lr.ph.us, %12
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  call void @checkSetContents(ptr noundef nonnull @.str.18, ptr noundef %17, i32 noundef %.02632.us, i32 noundef 0, i32 noundef -1, i32 noundef -1)
  %wide.trip.count52 = zext nneg i32 %umin51 to i64
  br label %21

.lr.ph.us:                                        ; preds = %.lr.ph.us.preheader, %.lr.ph.us
  %indvars.iv43 = phi i64 [ %16, %.lr.ph.us.preheader ], [ %indvars.iv.next44, %.lr.ph.us ]
  %18 = getelementptr inbounds i32, ptr %1, i64 %indvars.iv43
  call void @qh_setappend(ptr noundef nonnull %4, ptr noundef %18) #4
  %indvars.iv.next44 = add nsw i64 %indvars.iv43, 1
  %lftr.wideiv46 = trunc i64 %indvars.iv.next44 to i32
  %exitcond47.not = icmp eq i32 %.02632.us, %lftr.wideiv46
  br i1 %exitcond47.not, label %.split.us.us, label %.lr.ph.us, !llvm.loop !9

19:                                               ; preds = %.split31.us.us, %.lr.ph34.split.us
  %20 = add nuw nsw i32 %.02632.us, 1
  %exitcond54.not = icmp eq i32 %20, %0
  br i1 %exitcond54.not, label %._crit_edge35, label %.lr.ph34.split.us, !llvm.loop !11

21:                                               ; preds = %21, %.split.us.us
  %indvars.iv48 = phi i64 [ %indvars.iv.next49, %21 ], [ 0, %.split.us.us ]
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = trunc nuw nsw i64 %indvars.iv48 to i32
  %24 = call i32 @log_i(ptr noundef %22, ptr noundef nonnull @.str.30, i32 noundef %23, i32 noundef %0, i32 noundef 1)
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = call ptr @qh_setdelnthsorted(ptr noundef %25, i32 noundef %23) #4
  %27 = getelementptr inbounds i32, ptr %1, i64 %indvars.iv48
  call void @qh_setaddnth(ptr noundef nonnull %4, i32 noundef %23, ptr noundef %27) #4
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  call void @checkSetContents(ptr noundef nonnull @.str.31, ptr noundef %28, i32 noundef %.02632.us, i32 noundef 0, i32 noundef -1, i32 noundef -1)
  %indvars.iv.next49 = add nuw nsw i64 %indvars.iv48, 1
  %exitcond53.not = icmp eq i64 %indvars.iv.next49, %wide.trip.count52
  br i1 %exitcond53.not, label %.split31.us.us, label %21, !llvm.loop !12

.split31.us.us:                                   ; preds = %21
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  call void @checkSetContents(ptr noundef nonnull @.str.32, ptr noundef %29, i32 noundef %.02632.us, i32 noundef 0, i32 noundef -1, i32 noundef -1)
  br label %19

.lr.ph34.split:                                   ; preds = %.lr.ph34, %47
  %.02632 = phi i32 [ %48, %47 ], [ 1, %.lr.ph34 ]
  %umin = call i32 @llvm.umin.i32(i32 %.02632, i32 100)
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = call i32 @log_i(ptr noundef %30, ptr noundef nonnull @.str.29, i32 noundef %.02632, i32 noundef %0, i32 noundef 2147483647)
  %.not = icmp eq i32 %31, 0
  br i1 %.not, label %47, label %32

32:                                               ; preds = %.lr.ph34.split
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = call i32 @qh_setsize(ptr noundef %33) #4
  %35 = icmp slt i32 %34, %.02632
  br i1 %35, label %.lr.ph.preheader, label %.split

.lr.ph.preheader:                                 ; preds = %32
  %36 = sext i32 %34 to i64
  br label %.lr.ph

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

.split:                                           ; preds = %.lr.ph, %32
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  call void @checkSetContents(ptr noundef nonnull @.str.18, ptr noundef %38, i32 noundef %.02632, i32 noundef 0, i32 noundef -1, i32 noundef -1)
  %wide.trip.count = zext nneg i32 %umin to i64
  br label %39

39:                                               ; preds = %.split, %39
  %indvars.iv38 = phi i64 [ 0, %.split ], [ %indvars.iv.next39, %39 ]
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = trunc nuw nsw i64 %indvars.iv38 to i32
  %42 = call i32 @log_i(ptr noundef %40, ptr noundef nonnull @.str.30, i32 noundef %41, i32 noundef %0, i32 noundef %2)
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = call ptr @qh_setdelnthsorted(ptr noundef %43, i32 noundef %41) #4
  %45 = getelementptr inbounds i32, ptr %1, i64 %indvars.iv38
  call void @qh_setaddnth(ptr noundef nonnull %4, i32 noundef %41, ptr noundef %45) #4
  %indvars.iv.next39 = add nuw nsw i64 %indvars.iv38, 1
  %exitcond41.not = icmp eq i64 %indvars.iv.next39, %wide.trip.count
  br i1 %exitcond41.not, label %.split31, label %39, !llvm.loop !12

.split31:                                         ; preds = %39
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  call void @checkSetContents(ptr noundef nonnull @.str.32, ptr noundef %46, i32 noundef %.02632, i32 noundef 0, i32 noundef -1, i32 noundef -1)
  br label %47

47:                                               ; preds = %.lr.ph34.split, %.split31
  %48 = add nuw nsw i32 %.02632, 1
  %exitcond42.not = icmp eq i32 %48, %0
  br i1 %exitcond42.not, label %._crit_edge35, label %.lr.ph34.split, !llvm.loop !11

._crit_edge35:                                    ; preds = %47, %19, %3
  call void @qh_setfree(ptr noundef nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  ret void
}

declare ptr @qh_setnew(i32 noundef) local_unnamed_addr #2

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

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

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

declare void @qh_setfree(ptr noundef) local_unnamed_addr #2

declare i32 @qh_setsize(ptr noundef) local_unnamed_addr #2

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

declare void @qh_setaddnth(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