; 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.13 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [44 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 @setupMemory(i32 noundef %0, i32 noundef %1, ptr noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %8 = load i32, ptr %5, align 4, !tbaa !5
  %9 = icmp slt i32 %8, 0
  br i1 %9, label %14, label %10

10:                                               ; preds = %3
  %11 = load i32, ptr %5, align 4, !tbaa !5
  %12 = mul nsw i32 %11, 4
  %13 = icmp slt i32 %12, 0
  br i1 %13, label %14, label %16

14:                                               ; preds = %10, %3
  %15 = load ptr, ptr @stderr, align 8, !tbaa !9
  call void (ptr, i32, ptr, ...) @qh_fprintf(ptr noundef %15, i32 noundef 6303, ptr noundef @.str.13)
  call void @exit(i32 noundef 1) #5
  unreachable

16:                                               ; preds = %10
  %17 = load i32, ptr %5, align 4, !tbaa !5
  %18 = zext i32 %17 to i64
  %19 = mul i64 %18, 4
  %20 = call ptr @qh_malloc(i64 noundef %19)
  %21 = load ptr, ptr %6, align 8, !tbaa !9
  store ptr %20, ptr %21, align 8, !tbaa !9
  %22 = load ptr, ptr %6, align 8, !tbaa !9
  %23 = load ptr, ptr %22, align 8, !tbaa !9
  %24 = icmp ne ptr %23, null
  br i1 %24, label %29, label %25

25:                                               ; preds = %16
  %26 = load ptr, ptr @stderr, align 8, !tbaa !9
  %27 = load i32, ptr %5, align 4, !tbaa !5
  %28 = mul nsw i32 %27, 4
  call void (ptr, i32, ptr, ...) @qh_fprintf(ptr noundef %26, i32 noundef 6304, ptr noundef @.str.14, i32 noundef %28)
  call void @exit(i32 noundef 4) #5
  unreachable

29:                                               ; preds = %16
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %41, %29
  %31 = load i32, ptr %7, align 4, !tbaa !5
  %32 = load i32, ptr %5, align 4, !tbaa !5
  %33 = icmp slt i32 %31, %32
  br i1 %33, label %34, label %44

34:                                               ; preds = %30
  %35 = load i32, ptr %7, align 4, !tbaa !5
  %36 = load ptr, ptr %6, align 8, !tbaa !9
  %37 = load ptr, ptr %36, align 8, !tbaa !9
  %38 = load i32, ptr %7, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds i32, ptr %37, i64 %39
  store i32 %35, ptr %40, align 4, !tbaa !5
  br label %41

41:                                               ; preds = %34
  %42 = load i32, ptr %7, align 4, !tbaa !5
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %7, align 4, !tbaa !5
  br label %30, !llvm.loop !11

44:                                               ; preds = %30
  %45 = load ptr, ptr @stderr, align 8, !tbaa !9
  call void @qh_meminit(ptr noundef %45)
  %46 = load i32, ptr %4, align 4, !tbaa !5
  call void @qh_meminitbuffers(i32 noundef %46, i32 noundef 8, i32 noundef 4, i32 noundef 65536, i32 noundef 131072)
  call void @qh_memsize(i32 noundef 10)
  call void @qh_memsize(i32 noundef 20)
  call void @qh_memsize(i32 noundef 30)
  call void @qh_memsize(i32 noundef 40)
  call void @qh_memsetup()
  %47 = load ptr, ptr @stderr, align 8, !tbaa !9
  call void (ptr, i32, ptr, ...) @qh_fprintf(ptr noundef %47, i32 noundef 8089, ptr noundef @.str.15, i32 noundef 8)
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  ret void
}

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #2

declare ptr @qh_malloc(i64 noundef) #3

declare void @qh_meminit(ptr noundef) #3

declare void @qh_meminitbuffers(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #3

declare void @qh_memsize(i32 noundef) #3

declare void @qh_memsetup() #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { noreturn nounwind "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 = { "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 #4 = { nounwind }
attributes #5 = { noreturn 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"}


; 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.13 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [44 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: nounwind uwtable
define dso_local void @setupMemory(i32 noundef %0, i32 noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #0 {
  %4 = icmp slt i32 %1, 0
  br i1 %4, label %5, label %7

5:                                                ; preds = %3
  %6 = load ptr, ptr @stderr, align 8, !tbaa !5
  tail call void (ptr, i32, ptr, ...) @qh_fprintf(ptr noundef %6, i32 noundef 6303, ptr noundef nonnull @.str.13)
  tail call void @exit(i32 noundef 1) #3
  unreachable

7:                                                ; preds = %3
  %8 = zext nneg i32 %1 to i64
  %9 = shl nuw nsw i64 %8, 2
  %10 = tail call ptr @qh_malloc(i64 noundef %9) #4
  store ptr %10, ptr %2, align 8, !tbaa !5
  %.not = icmp eq ptr %10, null
  br i1 %.not, label %14, label %.preheader

.preheader:                                       ; preds = %7
  %.not15 = icmp eq i32 %1, 0
  br i1 %.not15, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %.preheader
  %min.iters.check = icmp ult i32 %1, 8
  br i1 %min.iters.check, label %.lr.ph.preheader18, label %vector.ph

.lr.ph.preheader18:                               ; preds = %middle.block, %.lr.ph.preheader
  %indvars.iv.ph = phi i64 [ 0, %.lr.ph.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph

vector.ph:                                        ; preds = %.lr.ph.preheader
  %n.vec = and i64 %8, 2147483640
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.ind = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %vector.ph ], [ %vec.ind.next, %vector.body ]
  %step.add = add <4 x i32> %vec.ind, <i32 4, i32 4, i32 4, i32 4>
  %11 = getelementptr inbounds i32, ptr %10, i64 %index
  %12 = getelementptr inbounds i8, ptr %11, i64 16
  store <4 x i32> %vec.ind, ptr %11, align 4, !tbaa !9
  store <4 x i32> %step.add, ptr %12, align 4, !tbaa !9
  %index.next = add nuw i64 %index, 8
  %vec.ind.next = add <4 x i32> %vec.ind, <i32 8, i32 8, i32 8, i32 8>
  %13 = icmp eq i64 %index.next, %n.vec
  br i1 %13, label %middle.block, label %vector.body, !llvm.loop !11

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %8
  br i1 %cmp.n, label %._crit_edge, label %.lr.ph.preheader18

14:                                               ; preds = %7
  %15 = shl nsw i32 %1, 2
  %16 = load ptr, ptr @stderr, align 8, !tbaa !5
  tail call void (ptr, i32, ptr, ...) @qh_fprintf(ptr noundef %16, i32 noundef 6304, ptr noundef nonnull @.str.14, i32 noundef %15)
  tail call void @exit(i32 noundef 4) #3
  unreachable

.lr.ph:                                           ; preds = %.lr.ph.preheader18, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ %indvars.iv.ph, %.lr.ph.preheader18 ]
  %17 = getelementptr inbounds i32, ptr %10, i64 %indvars.iv
  %18 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %18, ptr %17, align 4, !tbaa !9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %8
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !15

._crit_edge:                                      ; preds = %.lr.ph, %middle.block, %.preheader
  %19 = load ptr, ptr @stderr, align 8, !tbaa !5
  tail call void @qh_meminit(ptr noundef %19) #4
  tail call void @qh_meminitbuffers(i32 noundef %0, i32 noundef 8, i32 noundef 4, i32 noundef 65536, i32 noundef 131072) #4
  tail call void @qh_memsize(i32 noundef 10) #4
  tail call void @qh_memsize(i32 noundef 20) #4
  tail call void @qh_memsize(i32 noundef 30) #4
  tail call void @qh_memsize(i32 noundef 40) #4
  tail call void @qh_memsetup() #4
  %20 = load ptr, ptr @stderr, align 8, !tbaa !5
  tail call void (ptr, i32, ptr, ...) @qh_fprintf(ptr noundef %20, i32 noundef 8089, ptr noundef nonnull @.str.15, i32 noundef 8)
  ret void
}

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #1

declare ptr @qh_malloc(i64 noundef) local_unnamed_addr #2

declare void @qh_meminit(ptr noundef) local_unnamed_addr #2

declare void @qh_meminitbuffers(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

declare void @qh_memsize(i32 noundef) local_unnamed_addr #2

declare void @qh_memsetup() 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 = { noreturn nounwind "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 = { "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 = { noreturn nounwind }
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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12, !13, !14}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!"llvm.loop.isvectorized", i32 1}
!14 = !{!"llvm.loop.unroll.runtime.disable"}
!15 = distinct !{!15, !12, !14, !13}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass