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

@error_count = external dso_local global i32, align 4
@stderr = external global ptr, align 8
@.str.30 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.86 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.87 = external hidden unnamed_addr constant [49 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 @testSettemp(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 ptr, align 8
  %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
  store ptr null, 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 8, ptr %11) #3
  store ptr null, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = load ptr, ptr @stderr, align 8, !tbaa !5
  %16 = load i32, ptr %6, align 4, !tbaa !9
  %17 = sub nsw i32 %16, 1
  call void (ptr, ptr, i32, ptr, ...) @qh_fprintf(ptr noundef %14, ptr noundef %15, i32 noundef 8153, ptr noundef @.str.86, i32 noundef %17)
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %18

18:                                               ; preds = %87, %4
  %19 = load i32, ptr %13, align 4, !tbaa !9
  %20 = load i32, ptr %6, align 4, !tbaa !9
  %21 = icmp slt i32 %19, %20
  br i1 %21, label %22, label %90

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

30:                                               ; preds = %22
  %31 = load i32, ptr %13, align 4, !tbaa !9
  %32 = icmp slt i32 %31, 20
  br i1 %32, label %33, label %47

33:                                               ; preds = %30
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %34

34:                                               ; preds = %42, %33
  %35 = load i32, ptr %12, align 4, !tbaa !9
  %36 = load i32, ptr %13, align 4, !tbaa !9
  %37 = icmp slt i32 %35, %36
  br i1 %37, label %38, label %45

38:                                               ; preds = %34
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = load i32, ptr %13, align 4, !tbaa !9
  %41 = call ptr @qh_settemp(ptr noundef %39, i32 noundef %40)
  store ptr %41, ptr %10, align 8, !tbaa !5
  br label %42

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

45:                                               ; preds = %34
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  call void @qh_settempfree_all(ptr noundef %46)
  br label %47

47:                                               ; preds = %45, %30
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = load ptr, ptr %9, align 8, !tbaa !5
  %50 = call i32 @qh_setsize(ptr noundef %48, ptr noundef %49)
  store i32 %50, ptr %12, align 4, !tbaa !9
  br label %51

51:                                               ; preds = %61, %47
  %52 = load i32, ptr %12, align 4, !tbaa !9
  %53 = load i32, ptr %13, align 4, !tbaa !9
  %54 = icmp slt i32 %52, %53
  br i1 %54, label %55, label %64

55:                                               ; preds = %51
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  %58 = load i32, ptr %12, align 4, !tbaa !9
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds i32, ptr %57, i64 %59
  call void @qh_setappend(ptr noundef %56, ptr noundef %9, ptr noundef %60)
  br label %61

61:                                               ; preds = %55
  %62 = load i32, ptr %12, align 4, !tbaa !9
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %12, align 4, !tbaa !9
  br label %51, !llvm.loop !13

64:                                               ; preds = %51
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = load i32, ptr %13, align 4, !tbaa !9
  %67 = call ptr @qh_settemp(ptr noundef %65, i32 noundef %66)
  store ptr %67, ptr %10, align 8, !tbaa !5
  %68 = load i32, ptr %13, align 4, !tbaa !9
  %69 = icmp sgt i32 %68, 0
  br i1 %69, label %70, label %84

70:                                               ; preds = %64
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = load ptr, ptr %9, align 8, !tbaa !5
  call void @qh_settemppush(ptr noundef %71, ptr noundef %72)
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = call ptr @qh_settemppop(ptr noundef %73)
  store ptr %74, ptr %11, align 8, !tbaa !5
  %75 = load ptr, ptr %9, align 8, !tbaa !5
  %76 = load ptr, ptr %11, align 8, !tbaa !5
  %77 = icmp ne ptr %75, %76
  br i1 %77, label %78, label %83

78:                                               ; preds = %70
  %79 = load ptr, ptr %5, align 8, !tbaa !5
  %80 = load ptr, ptr @stderr, align 8, !tbaa !5
  call void (ptr, ptr, i32, ptr, ...) @qh_fprintf(ptr noundef %79, ptr noundef %80, i32 noundef 6343, ptr noundef @.str.87)
  %81 = load i32, ptr @error_count, align 4, !tbaa !9
  %82 = add nsw i32 %81, 1
  store i32 %82, ptr @error_count, align 4, !tbaa !9
  br label %83

83:                                               ; preds = %78, %70
  br label %84

84:                                               ; preds = %83, %64
  %85 = load ptr, ptr %5, align 8, !tbaa !5
  call void @qh_settempfree(ptr noundef %85, ptr noundef %10)
  br label %86

86:                                               ; preds = %84, %22
  br label %87

87:                                               ; preds = %86
  %88 = load i32, ptr %13, align 4, !tbaa !9
  %89 = add nsw i32 %88, 1
  store i32 %89, ptr %13, align 4, !tbaa !9
  br label %18, !llvm.loop !14

90:                                               ; preds = %18
  %91 = load ptr, ptr %5, align 8, !tbaa !5
  call void @qh_setfreelong(ptr noundef %91, ptr noundef %9)
  %92 = load ptr, ptr %9, align 8, !tbaa !5
  %93 = icmp ne ptr %92, null
  br i1 %93, label %94, label %96

94:                                               ; preds = %90
  %95 = load ptr, ptr %5, align 8, !tbaa !5
  call void @qh_setfree(ptr noundef %95, ptr noundef %9)
  br label %96

96:                                               ; preds = %94, %90
  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 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
  ret void
}

; 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

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

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

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

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

declare void @qh_settempfree_all(ptr noundef) #2

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

declare ptr @qh_settemppop(ptr noundef) #2

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

@error_count = external dso_local local_unnamed_addr global i32, align 4
@stderr = external local_unnamed_addr global ptr, align 8
@.str.30 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.86 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.87 = external hidden unnamed_addr constant [49 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 @testSettemp(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
  store ptr null, 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
  %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 8153, ptr noundef nonnull @.str.86, i32 noundef %8)
  %9 = icmp sgt i32 %1, 0
  br i1 %9, label %.lr.ph44, label %._crit_edge45

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

12:                                               ; preds = %.lr.ph44
  %13 = icmp ult i32 %.042, 20
  br i1 %13, label %.preheader, label %16

.preheader:                                       ; preds = %12
  %.not46 = icmp eq i32 %.042, 0
  br i1 %.not46, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.03237 = phi i32 [ %15, %.lr.ph ], [ 0, %.preheader ]
  %14 = call ptr @qh_settemp(ptr noundef %0, i32 noundef %.042) #3
  store ptr %14, ptr %6, align 8, !tbaa !5
  %15 = add nuw nsw i32 %.03237, 1
  %exitcond.not = icmp eq i32 %15, %.042
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  call void @qh_settempfree_all(ptr noundef %0) #3
  br label %16

16:                                               ; preds = %._crit_edge, %12
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = call i32 @qh_setsize(ptr noundef %0, ptr noundef %17) #3
  %19 = icmp slt i32 %18, %.042
  br i1 %19, label %.lr.ph40.preheader, label %._crit_edge41

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

.lr.ph40:                                         ; preds = %.lr.ph40.preheader, %.lr.ph40
  %indvars.iv = phi i64 [ %20, %.lr.ph40.preheader ], [ %indvars.iv.next, %.lr.ph40 ]
  %21 = getelementptr inbounds i32, ptr %2, i64 %indvars.iv
  call void @qh_setappend(ptr noundef %0, ptr noundef nonnull %5, ptr noundef %21) #3
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %lftr.wideiv = trunc i64 %indvars.iv.next to i32
  %exitcond48.not = icmp eq i32 %.042, %lftr.wideiv
  br i1 %exitcond48.not, label %._crit_edge41, label %.lr.ph40, !llvm.loop !11

._crit_edge41:                                    ; preds = %.lr.ph40, %16
  %22 = call ptr @qh_settemp(ptr noundef %0, i32 noundef %.042) #3
  store ptr %22, ptr %6, align 8, !tbaa !5
  %.not35 = icmp eq i32 %.042, 0
  br i1 %.not35, label %31, label %23

23:                                               ; preds = %._crit_edge41
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  call void @qh_settemppush(ptr noundef %0, ptr noundef %24) #3
  %25 = call ptr @qh_settemppop(ptr noundef %0) #3
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %.not36 = icmp eq ptr %26, %25
  br i1 %.not36, label %31, label %27

27:                                               ; preds = %23
  %28 = load ptr, ptr @stderr, align 8, !tbaa !5
  call void (ptr, ptr, i32, ptr, ...) @qh_fprintf(ptr noundef %0, ptr noundef %28, i32 noundef 6343, ptr noundef nonnull @.str.87)
  %29 = load i32, ptr @error_count, align 4, !tbaa !12
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr @error_count, align 4, !tbaa !12
  br label %31

31:                                               ; preds = %23, %27, %._crit_edge41
  call void @qh_settempfree(ptr noundef %0, ptr noundef nonnull %6) #3
  br label %32

32:                                               ; preds = %.lr.ph44, %31
  %33 = add nuw nsw i32 %.042, 1
  %exitcond49.not = icmp eq i32 %33, %1
  br i1 %exitcond49.not, label %._crit_edge45, label %.lr.ph44, !llvm.loop !14

._crit_edge45:                                    ; preds = %32, %4
  call void @qh_setfreelong(ptr noundef %0, ptr noundef nonnull %5) #3
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %.not = icmp eq ptr %34, null
  br i1 %.not, label %36, label %35

35:                                               ; preds = %._crit_edge45
  call void @qh_setfree(ptr noundef %0, ptr noundef nonnull %5) #3
  br label %36

36:                                               ; preds = %35, %._crit_edge45
  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
}

; 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

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 void @qh_setfreelong(ptr noundef, ptr noundef) local_unnamed_addr #2

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

declare void @qh_settempfree_all(ptr noundef) local_unnamed_addr #2

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

declare ptr @qh_settemppop(ptr noundef) local_unnamed_addr #2

declare void @qh_settempfree(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 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = distinct !{!14, !10}


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