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

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

%struct.qhmemT = type { i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, i32, ptr, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }

@qhmem = external dso_local global %struct.qhmemT, align 8
@.str.19 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [72 x i8], align 1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

declare void @qh_fprintf(ptr noundef, i32 noundef, ptr noundef, ...) #1

declare void @qh_errexit(i32 noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local void @qh_memsize(i32 noundef %0) #2 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store i32 %0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  %5 = load i32, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 4), align 8, !tbaa !9
  %6 = icmp ne i32 %5, 0
  br i1 %6, label %7, label %9

7:                                                ; preds = %1
  %8 = load ptr, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 13), align 8, !tbaa !12
  call void (ptr, i32, ptr, ...) @qh_fprintf(ptr noundef %8, i32 noundef 6089, ptr noundef @.str.19)
  call void @qh_errexit(i32 noundef 5, ptr noundef null, ptr noundef null)
  br label %9

9:                                                ; preds = %7, %1
  %10 = load i32, ptr %2, align 4, !tbaa !5
  %11 = load i32, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 5), align 4, !tbaa !13
  %12 = add nsw i32 %10, %11
  %13 = load i32, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 5), align 4, !tbaa !13
  %14 = xor i32 %13, -1
  %15 = and i32 %12, %14
  store i32 %15, ptr %2, align 4, !tbaa !5
  %16 = load i32, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 14), align 8, !tbaa !14
  %17 = icmp sge i32 %16, 3
  br i1 %17, label %18, label %21

18:                                               ; preds = %9
  %19 = load ptr, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 13), align 8, !tbaa !12
  %20 = load i32, ptr %2, align 4, !tbaa !5
  call void (ptr, i32, ptr, ...) @qh_fprintf(ptr noundef %19, i32 noundef 3078, ptr noundef @.str.20, i32 noundef %20)
  br label %21

21:                                               ; preds = %18, %9
  %22 = load i32, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 2), align 8, !tbaa !15
  store i32 %22, ptr %3, align 4, !tbaa !5
  br label %23

23:                                               ; preds = %36, %21
  %24 = load i32, ptr %3, align 4, !tbaa !5
  %25 = add nsw i32 %24, -1
  store i32 %25, ptr %3, align 4, !tbaa !5
  %26 = icmp ne i32 %24, 0
  br i1 %26, label %27, label %37

27:                                               ; preds = %23
  %28 = load ptr, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 7), align 8, !tbaa !16
  %29 = load i32, ptr %3, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds i32, ptr %28, i64 %30
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %33 = load i32, ptr %2, align 4, !tbaa !5
  %34 = icmp eq i32 %32, %33
  br i1 %34, label %35, label %36

35:                                               ; preds = %27
  store i32 1, ptr %4, align 4
  br label %52

36:                                               ; preds = %27
  br label %23, !llvm.loop !17

37:                                               ; preds = %23
  %38 = load i32, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 2), align 8, !tbaa !15
  %39 = load i32, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 3), align 4, !tbaa !19
  %40 = icmp slt i32 %38, %39
  br i1 %40, label %41, label %48

41:                                               ; preds = %37
  %42 = load i32, ptr %2, align 4, !tbaa !5
  %43 = load ptr, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 7), align 8, !tbaa !16
  %44 = load i32, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 2), align 8, !tbaa !15
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 2), align 8, !tbaa !15
  %46 = sext i32 %44 to i64
  %47 = getelementptr inbounds i32, ptr %43, i64 %46
  store i32 %42, ptr %47, align 4, !tbaa !5
  br label %51

48:                                               ; preds = %37
  %49 = load ptr, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 13), align 8, !tbaa !12
  %50 = load i32, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 3), align 4, !tbaa !19
  call void (ptr, i32, ptr, ...) @qh_fprintf(ptr noundef %49, i32 noundef 7060, ptr noundef @.str.21, i32 noundef %50)
  br label %51

51:                                               ; preds = %48, %41
  store i32 0, ptr %4, align 4
  br label %52

52:                                               ; preds = %51, %35
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  %53 = load i32, ptr %4, align 4
  switch i32 %53, label %55 [
    i32 0, label %54
    i32 1, label %54
  ]

54:                                               ; preds = %52, %52
  ret void

55:                                               ; preds = %52
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { 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 #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, !6, i64 16}
!10 = !{!"qhmemT", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !6, i64 64, !11, i64 72, !11, i64 80, !6, i64 88, !6, i64 92, !6, i64 96, !6, i64 100, !6, i64 104, !6, i64 108, !6, i64 112, !6, i64 116, !6, i64 120, !6, i64 124, !6, i64 128, !6, i64 132, !6, i64 136, !6, i64 140, !6, i64 144}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!10, !11, i64 80}
!13 = !{!10, !6, i64 20}
!14 = !{!10, !6, i64 88}
!15 = !{!10, !6, i64 8}
!16 = !{!10, !11, i64 32}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!10, !6, i64 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"

%struct.qhmemT = type { i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, i32, ptr, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }

@qhmem = external dso_local local_unnamed_addr global %struct.qhmemT, align 8
@.str.19 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [72 x i8], align 1

declare void @qh_fprintf(ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #0

declare void @qh_errexit(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @qh_memsize(i32 noundef %0) local_unnamed_addr #1 {
  %2 = load i32, ptr getelementptr inbounds (i8, ptr @qhmem, i64 16), align 8, !tbaa !5
  %.not = icmp eq i32 %2, 0
  br i1 %.not, label %5, label %3

3:                                                ; preds = %1
  %4 = load ptr, ptr getelementptr inbounds (i8, ptr @qhmem, i64 80), align 8, !tbaa !11
  tail call void (ptr, i32, ptr, ...) @qh_fprintf(ptr noundef %4, i32 noundef 6089, ptr noundef nonnull @.str.19) #2
  tail call void @qh_errexit(i32 noundef 5, ptr noundef null, ptr noundef null) #2
  br label %5

5:                                                ; preds = %3, %1
  %6 = load i32, ptr getelementptr inbounds (i8, ptr @qhmem, i64 20), align 4, !tbaa !12
  %7 = add nsw i32 %6, %0
  %8 = xor i32 %6, -1
  %9 = and i32 %7, %8
  %10 = load i32, ptr getelementptr inbounds (i8, ptr @qhmem, i64 88), align 8, !tbaa !13
  %11 = icmp sgt i32 %10, 2
  br i1 %11, label %12, label %14

12:                                               ; preds = %5
  %13 = load ptr, ptr getelementptr inbounds (i8, ptr @qhmem, i64 80), align 8, !tbaa !11
  tail call void (ptr, i32, ptr, ...) @qh_fprintf(ptr noundef %13, i32 noundef 3078, ptr noundef nonnull @.str.20, i32 noundef %9) #2
  br label %14

14:                                               ; preds = %12, %5
  %15 = load i32, ptr getelementptr inbounds (i8, ptr @qhmem, i64 8), align 8, !tbaa !14
  %16 = load ptr, ptr getelementptr inbounds (i8, ptr @qhmem, i64 32), align 8
  %17 = sext i32 %15 to i64
  br label %18

18:                                               ; preds = %20, %14
  %indvars.iv = phi i64 [ %indvars.iv.next, %20 ], [ %17, %14 ]
  %19 = icmp eq i64 %indvars.iv, 0
  br i1 %19, label %24, label %20

20:                                               ; preds = %18
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %21 = getelementptr inbounds i32, ptr %16, i64 %indvars.iv.next
  %22 = load i32, ptr %21, align 4, !tbaa !15
  %23 = icmp eq i32 %22, %9
  br i1 %23, label %.loopexit, label %18, !llvm.loop !16

24:                                               ; preds = %18
  %25 = load i32, ptr getelementptr inbounds (i8, ptr @qhmem, i64 12), align 4, !tbaa !18
  %26 = icmp slt i32 %15, %25
  br i1 %26, label %27, label %30

27:                                               ; preds = %24
  %28 = add nsw i32 %15, 1
  store i32 %28, ptr getelementptr inbounds (i8, ptr @qhmem, i64 8), align 8, !tbaa !14
  %29 = getelementptr inbounds i32, ptr %16, i64 %17
  store i32 %9, ptr %29, align 4, !tbaa !15
  br label %.loopexit

30:                                               ; preds = %24
  %31 = load ptr, ptr getelementptr inbounds (i8, ptr @qhmem, i64 80), align 8, !tbaa !11
  tail call void (ptr, i32, ptr, ...) @qh_fprintf(ptr noundef %31, i32 noundef 7060, ptr noundef nonnull @.str.21, i32 noundef %25) #2
  br label %.loopexit

.loopexit:                                        ; preds = %20, %27, %30
  ret void
}

attributes #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 = { 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 #2 = { 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, !7, i64 16}
!6 = !{!"qhmemT", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !7, i64 64, !10, i64 72, !10, i64 80, !7, i64 88, !7, i64 92, !7, i64 96, !7, i64 100, !7, i64 104, !7, i64 108, !7, i64 112, !7, i64 116, !7, i64 120, !7, i64 124, !7, i64 128, !7, i64 132, !7, i64 136, !7, i64 140, !7, i64 144}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 80}
!12 = !{!6, !7, i64 20}
!13 = !{!6, !7, i64 88}
!14 = !{!6, !7, i64 8}
!15 = !{!7, !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!6, !7, i64 12}


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