; LLVM IR from Discngine/fpocket :: src/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.14 = external hidden unnamed_addr constant [64 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [44 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 @setupMemory(ptr noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %10 = load i32, ptr %7, align 4, !tbaa !9
  %11 = icmp slt i32 %10, 0
  br i1 %11, label %16, label %12

12:                                               ; preds = %4
  %13 = load i32, ptr %7, align 4, !tbaa !9
  %14 = mul nsw i32 %13, 4
  %15 = icmp slt i32 %14, 0
  br i1 %15, label %16, label %19

16:                                               ; preds = %12, %4
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = load ptr, ptr @stderr, align 8, !tbaa !5
  call void (ptr, ptr, i32, ptr, ...) @qh_fprintf(ptr noundef %17, ptr noundef %18, i32 noundef 6303, ptr noundef @.str.14)
  call void @exit(i32 noundef 1) #5
  unreachable

19:                                               ; preds = %12
  %20 = load i32, ptr %7, align 4, !tbaa !9
  %21 = sext i32 %20 to i64
  %22 = mul i64 %21, 4
  %23 = call ptr @qh_malloc(i64 noundef %22)
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %23, ptr %24, align 8, !tbaa !5
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = load ptr, ptr %25, align 8, !tbaa !5
  %27 = icmp ne ptr %26, null
  br i1 %27, label %34, label %28

28:                                               ; preds = %19
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = load ptr, ptr @stderr, align 8, !tbaa !5
  %31 = load i32, ptr %7, align 4, !tbaa !9
  %32 = sext i32 %31 to i64
  %33 = mul i64 %32, 4
  call void (ptr, ptr, i32, ptr, ...) @qh_fprintf(ptr noundef %29, ptr noundef %30, i32 noundef 6304, ptr noundef @.str.15, i64 noundef %33)
  call void @exit(i32 noundef 1) #5
  unreachable

34:                                               ; preds = %19
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %35

35:                                               ; preds = %46, %34
  %36 = load i32, ptr %9, align 4, !tbaa !9
  %37 = load i32, ptr %7, align 4, !tbaa !9
  %38 = icmp slt i32 %36, %37
  br i1 %38, label %39, label %49

39:                                               ; preds = %35
  %40 = load i32, ptr %9, align 4, !tbaa !9
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = load ptr, ptr %41, align 8, !tbaa !5
  %43 = load i32, ptr %9, align 4, !tbaa !9
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds i32, ptr %42, i64 %44
  store i32 %40, ptr %45, align 4, !tbaa !9
  br label %46

46:                                               ; preds = %39
  %47 = load i32, ptr %9, align 4, !tbaa !9
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr %9, align 4, !tbaa !9
  br label %35, !llvm.loop !11

49:                                               ; preds = %35
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = load ptr, ptr @stderr, align 8, !tbaa !5
  call void @qh_meminit(ptr noundef %50, ptr noundef %51)
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = load i32, ptr %6, align 4, !tbaa !9
  call void @qh_meminitbuffers(ptr noundef %52, i32 noundef %53, i32 noundef 8, i32 noundef 4, i32 noundef 65536, i32 noundef 131072)
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  call void @qh_memsize(ptr noundef %54, i32 noundef 10)
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  call void @qh_memsize(ptr noundef %55, i32 noundef 20)
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  call void @qh_memsize(ptr noundef %56, i32 noundef 30)
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  call void @qh_memsize(ptr noundef %57, i32 noundef 40)
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  call void @qh_memsetup(ptr noundef %58)
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = load ptr, ptr @stderr, align 8, !tbaa !5
  call void (ptr, ptr, i32, ptr, ...) @qh_fprintf(ptr noundef %59, ptr noundef %60, i32 noundef 8001, ptr noundef @.str.16, i32 noundef 8)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #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, ptr noundef) #3

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

declare void @qh_memsize(ptr noundef, i32 noundef) #3

declare void @qh_memsetup(ptr noundef) #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 = !{!"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"}


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

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

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

.preheader:                                       ; preds = %8
  %.not24 = icmp eq i32 %2, 0
  br i1 %.not24, label %._crit_edge, label %.lr.ph.preheader

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

.lr.ph.preheader27:                               ; 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 %9, 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>
  %12 = getelementptr inbounds i32, ptr %11, i64 %index
  %13 = getelementptr inbounds i8, ptr %12, i64 16
  store <4 x i32> %vec.ind, ptr %12, align 4, !tbaa !9
  store <4 x i32> %step.add, ptr %13, 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>
  %14 = icmp eq i64 %index.next, %n.vec
  br i1 %14, label %middle.block, label %vector.body, !llvm.loop !11

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

15:                                               ; preds = %8
  %16 = load ptr, ptr @stderr, align 8, !tbaa !5
  tail call void (ptr, ptr, i32, ptr, ...) @qh_fprintf(ptr noundef %0, ptr noundef %16, i32 noundef 6304, ptr noundef nonnull @.str.15, i64 noundef %10)
  tail call void @exit(i32 noundef 1) #3
  unreachable

.lr.ph:                                           ; preds = %.lr.ph.preheader27, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ %indvars.iv.ph, %.lr.ph.preheader27 ]
  %17 = getelementptr inbounds i32, ptr %11, 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, %9
  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 %0, ptr noundef %19) #4
  tail call void @qh_meminitbuffers(ptr noundef %0, i32 noundef %1, i32 noundef 8, i32 noundef 4, i32 noundef 65536, i32 noundef 131072) #4
  tail call void @qh_memsize(ptr noundef %0, i32 noundef 10) #4
  tail call void @qh_memsize(ptr noundef %0, i32 noundef 20) #4
  tail call void @qh_memsize(ptr noundef %0, i32 noundef 30) #4
  tail call void @qh_memsize(ptr noundef %0, i32 noundef 40) #4
  tail call void @qh_memsetup(ptr noundef %0) #4
  %20 = load ptr, ptr @stderr, align 8, !tbaa !5
  tail call void (ptr, ptr, i32, ptr, ...) @qh_fprintf(ptr noundef %0, ptr noundef %20, i32 noundef 8001, ptr noundef nonnull @.str.16, 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, ptr noundef) local_unnamed_addr #2

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

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

declare void @qh_memsetup(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 = { 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