; 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.12 = external hidden unnamed_addr constant [54 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [53 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

; 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_memfree(ptr noundef %0, i32 noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = icmp ne ptr %9, null
  br i1 %10, label %12, label %11

11:                                               ; preds = %2
  store i32 1, ptr %8, align 4
  br label %85

12:                                               ; preds = %2
  %13 = load i32, ptr %4, align 4, !tbaa !9
  %14 = load i32, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 4), align 8, !tbaa !11
  %15 = icmp sle i32 %13, %14
  br i1 %15, label %16, label %63

16:                                               ; preds = %12
  %17 = load i32, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 18), align 8, !tbaa !13
  %18 = add nsw i32 %17, 1
  store i32 %18, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 18), align 8, !tbaa !13
  %19 = load ptr, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 8), align 8, !tbaa !14
  %20 = load i32, ptr %4, align 4, !tbaa !9
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds i32, ptr %19, i64 %21
  %23 = load i32, ptr %22, align 4, !tbaa !9
  store i32 %23, ptr %6, align 4, !tbaa !9
  %24 = load ptr, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 7), align 8, !tbaa !15
  %25 = load i32, ptr %6, align 4, !tbaa !9
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds i32, ptr %24, i64 %26
  %28 = load i32, ptr %27, align 4, !tbaa !9
  store i32 %28, ptr %7, align 4, !tbaa !9
  %29 = load i32, ptr %7, align 4, !tbaa !9
  %30 = load i32, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 22), align 8, !tbaa !16
  %31 = add nsw i32 %30, %29
  store i32 %31, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 22), align 8, !tbaa !16
  %32 = load i32, ptr %7, align 4, !tbaa !9
  %33 = load i32, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 25), align 4, !tbaa !17
  %34 = sub nsw i32 %33, %32
  store i32 %34, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 25), align 4, !tbaa !17
  %35 = load ptr, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 6), align 8, !tbaa !18
  %36 = load i32, ptr %6, align 4, !tbaa !9
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds ptr, ptr %35, i64 %37
  store ptr %38, ptr %5, align 8, !tbaa !5
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = load ptr, ptr %39, align 8, !tbaa !5
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %40, ptr %41, align 8, !tbaa !5
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %42, ptr %43, align 8, !tbaa !5
  %44 = load i32, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 16), align 8, !tbaa !19
  %45 = load i32, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 15), align 4, !tbaa !20
  %46 = add nsw i32 %44, %45
  %47 = load i32, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 18), align 8, !tbaa !13
  %48 = add nsw i32 %46, %47
  store i32 %48, ptr %6, align 4, !tbaa !9
  %49 = load i32, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 14), align 8, !tbaa !21
  %50 = icmp sge i32 %49, 5
  br i1 %50, label %51, label %62

51:                                               ; preds = %16
  %52 = load ptr, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 13), align 8, !tbaa !22
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = load i32, ptr %6, align 4, !tbaa !9
  %55 = load i32, ptr %7, align 4, !tbaa !9
  %56 = load i32, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 25), align 4, !tbaa !17
  %57 = load i32, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 16), align 8, !tbaa !19
  %58 = load i32, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 15), align 4, !tbaa !20
  %59 = add nsw i32 %57, %58
  %60 = load i32, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 18), align 8, !tbaa !13
  %61 = sub nsw i32 %59, %60
  call void (ptr, i32, ptr, ...) @qh_fprintf(ptr noundef %52, i32 noundef 8142, ptr noundef @.str.12, ptr noundef %53, i32 noundef %54, i32 noundef %55, i32 noundef %56, i32 noundef %61)
  br label %62

62:                                               ; preds = %51, %16
  br label %84

63:                                               ; preds = %12
  %64 = load i32, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 19), align 4, !tbaa !23
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 19), align 4, !tbaa !23
  %66 = load i32, ptr %4, align 4, !tbaa !9
  %67 = load i32, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 23), align 4, !tbaa !24
  %68 = sub nsw i32 %67, %66
  store i32 %68, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 23), align 4, !tbaa !24
  %69 = load i32, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 14), align 8, !tbaa !21
  %70 = icmp sge i32 %69, 5
  br i1 %70, label %71, label %82

71:                                               ; preds = %63
  %72 = load ptr, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 13), align 8, !tbaa !22
  %73 = load ptr, ptr %3, align 8, !tbaa !5
  %74 = load i32, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 17), align 4, !tbaa !25
  %75 = load i32, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 19), align 4, !tbaa !23
  %76 = add nsw i32 %74, %75
  %77 = load i32, ptr %4, align 4, !tbaa !9
  %78 = load i32, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 23), align 4, !tbaa !24
  %79 = load i32, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 17), align 4, !tbaa !25
  %80 = load i32, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 19), align 4, !tbaa !23
  %81 = sub nsw i32 %79, %80
  call void (ptr, i32, ptr, ...) @qh_fprintf(ptr noundef %72, i32 noundef 8058, ptr noundef @.str.13, ptr noundef %73, i32 noundef %76, i32 noundef %77, i32 noundef %78, i32 noundef %81)
  br label %82

82:                                               ; preds = %71, %63
  %83 = load ptr, ptr %3, align 8, !tbaa !5
  call void @qh_free(ptr noundef %83)
  br label %84

84:                                               ; preds = %82, %62
  store i32 0, ptr %8, align 4
  br label %85

85:                                               ; preds = %84, %11
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  %86 = load i32, ptr %8, align 4
  switch i32 %86, label %88 [
    i32 0, label %87
    i32 1, label %87
  ]

87:                                               ; preds = %85, %85
  ret void

88:                                               ; preds = %85
  unreachable
}

declare void @qh_free(ptr noundef) #1

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 = !{!"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 = !{!12, !10, i64 16}
!12 = !{!"qhmemT", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !10, i64 64, !6, i64 72, !6, i64 80, !10, i64 88, !10, i64 92, !10, i64 96, !10, i64 100, !10, i64 104, !10, i64 108, !10, i64 112, !10, i64 116, !10, i64 120, !10, i64 124, !10, i64 128, !10, i64 132, !10, i64 136, !10, i64 140, !10, i64 144}
!13 = !{!12, !10, i64 104}
!14 = !{!12, !6, i64 40}
!15 = !{!12, !6, i64 32}
!16 = !{!12, !10, i64 120}
!17 = !{!12, !10, i64 132}
!18 = !{!12, !6, i64 24}
!19 = !{!12, !10, i64 96}
!20 = !{!12, !10, i64 92}
!21 = !{!12, !10, i64 88}
!22 = !{!12, !6, i64 80}
!23 = !{!12, !10, i64 108}
!24 = !{!12, !10, i64 124}
!25 = !{!12, !10, i64 100}


; 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.12 = external hidden unnamed_addr constant [54 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [53 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local void @qh_memfree(ptr noundef %0, i32 noundef %1) local_unnamed_addr #1 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %45, label %3

3:                                                ; preds = %2
  %4 = load i32, ptr getelementptr inbounds (i8, ptr @qhmem, i64 16), align 8, !tbaa !5
  %.not18 = icmp slt i32 %4, %1
  br i1 %.not18, label %32, label %5

5:                                                ; preds = %3
  %6 = load i32, ptr getelementptr inbounds (i8, ptr @qhmem, i64 104), align 8, !tbaa !11
  %7 = add nsw i32 %6, 1
  store i32 %7, ptr getelementptr inbounds (i8, ptr @qhmem, i64 104), align 8, !tbaa !11
  %8 = load ptr, ptr getelementptr inbounds (i8, ptr @qhmem, i64 40), align 8, !tbaa !12
  %9 = sext i32 %1 to i64
  %10 = getelementptr inbounds i32, ptr %8, i64 %9
  %11 = load i32, ptr %10, align 4, !tbaa !13
  %12 = load ptr, ptr getelementptr inbounds (i8, ptr @qhmem, i64 32), align 8, !tbaa !14
  %13 = sext i32 %11 to i64
  %14 = getelementptr inbounds i32, ptr %12, i64 %13
  %15 = load i32, ptr %14, align 4, !tbaa !13
  %16 = load i32, ptr getelementptr inbounds (i8, ptr @qhmem, i64 120), align 8, !tbaa !15
  %17 = add nsw i32 %16, %15
  store i32 %17, ptr getelementptr inbounds (i8, ptr @qhmem, i64 120), align 8, !tbaa !15
  %18 = load i32, ptr getelementptr inbounds (i8, ptr @qhmem, i64 132), align 4, !tbaa !16
  %19 = sub nsw i32 %18, %15
  store i32 %19, ptr getelementptr inbounds (i8, ptr @qhmem, i64 132), align 4, !tbaa !16
  %20 = load ptr, ptr getelementptr inbounds (i8, ptr @qhmem, i64 24), align 8, !tbaa !17
  %21 = getelementptr inbounds ptr, ptr %20, i64 %13
  %22 = load ptr, ptr %21, align 8, !tbaa !18
  store ptr %22, ptr %0, align 8, !tbaa !18
  store ptr %0, ptr %21, align 8, !tbaa !18
  %23 = load i32, ptr getelementptr inbounds (i8, ptr @qhmem, i64 88), align 8, !tbaa !19
  %24 = icmp sgt i32 %23, 4
  br i1 %24, label %25, label %45

25:                                               ; preds = %5
  %26 = load i32, ptr getelementptr inbounds (i8, ptr @qhmem, i64 96), align 8, !tbaa !20
  %27 = load i32, ptr getelementptr inbounds (i8, ptr @qhmem, i64 92), align 4, !tbaa !21
  %28 = add nsw i32 %27, %26
  %29 = add nsw i32 %28, %7
  %30 = load ptr, ptr getelementptr inbounds (i8, ptr @qhmem, i64 80), align 8, !tbaa !22
  %31 = sub nsw i32 %28, %7
  tail call void (ptr, i32, ptr, ...) @qh_fprintf(ptr noundef %30, i32 noundef 8142, ptr noundef nonnull @.str.12, ptr noundef nonnull %0, i32 noundef %29, i32 noundef %15, i32 noundef %19, i32 noundef %31) #2
  br label %45

32:                                               ; preds = %3
  %33 = load i32, ptr getelementptr inbounds (i8, ptr @qhmem, i64 108), align 4, !tbaa !23
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr getelementptr inbounds (i8, ptr @qhmem, i64 108), align 4, !tbaa !23
  %35 = load i32, ptr getelementptr inbounds (i8, ptr @qhmem, i64 124), align 4, !tbaa !24
  %36 = sub nsw i32 %35, %1
  store i32 %36, ptr getelementptr inbounds (i8, ptr @qhmem, i64 124), align 4, !tbaa !24
  %37 = load i32, ptr getelementptr inbounds (i8, ptr @qhmem, i64 88), align 8, !tbaa !19
  %38 = icmp sgt i32 %37, 4
  br i1 %38, label %39, label %44

39:                                               ; preds = %32
  %40 = load ptr, ptr getelementptr inbounds (i8, ptr @qhmem, i64 80), align 8, !tbaa !22
  %41 = load i32, ptr getelementptr inbounds (i8, ptr @qhmem, i64 100), align 4, !tbaa !25
  %42 = add nsw i32 %41, %34
  %43 = sub nsw i32 %41, %34
  tail call void (ptr, i32, ptr, ...) @qh_fprintf(ptr noundef %40, i32 noundef 8058, ptr noundef nonnull @.str.13, ptr noundef nonnull %0, i32 noundef %42, i32 noundef %1, i32 noundef %36, i32 noundef %43) #2
  br label %44

44:                                               ; preds = %39, %32
  tail call void @qh_free(ptr noundef nonnull %0) #2
  br label %45

45:                                               ; preds = %44, %25, %5, %2
  ret void
}

declare void @qh_free(ptr noundef) local_unnamed_addr #0

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, !7, i64 104}
!12 = !{!6, !10, i64 40}
!13 = !{!7, !7, i64 0}
!14 = !{!6, !10, i64 32}
!15 = !{!6, !7, i64 120}
!16 = !{!6, !7, i64 132}
!17 = !{!6, !10, i64 24}
!18 = !{!10, !10, i64 0}
!19 = !{!6, !7, i64 88}
!20 = !{!6, !7, i64 96}
!21 = !{!6, !7, i64 92}
!22 = !{!6, !10, i64 80}
!23 = !{!6, !7, i64 108}
!24 = !{!6, !7, i64 124}
!25 = !{!6, !7, i64 100}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass