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

; 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 }
%struct.setT = type { i32, [1 x %union.setelemT] }
%union.setelemT = type { ptr }

@qhmem = external global %struct.qhmemT, align 8
@.str.1 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [71 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: nounwind uwtable
declare dso_local void @qh_setprint(ptr noundef, ptr noundef, ptr noundef) #2

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 ptr @qh_setdelnth(ptr noundef %0, i32 noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  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 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.setT, ptr %9, i32 0, i32 1
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.setT, ptr %11, i32 0, i32 0
  %13 = load i32, ptr %12, align 8, !tbaa !11
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [1 x %union.setelemT], ptr %10, i64 0, i64 %14
  store ptr %15, ptr %6, align 8, !tbaa !5
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = load i32, ptr %16, align 8, !tbaa !13
  %18 = add nsw i32 %17, -1
  store i32 %18, ptr %16, align 8, !tbaa !13
  %19 = icmp eq i32 %17, 0
  br i1 %19, label %20, label %25

20:                                               ; preds = %2
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.setT, ptr %21, i32 0, i32 0
  %23 = load i32, ptr %22, align 8, !tbaa !11
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  store i32 %23, ptr %24, align 8, !tbaa !13
  br label %25

25:                                               ; preds = %20, %2
  %26 = load i32, ptr %4, align 4, !tbaa !9
  %27 = icmp slt i32 %26, 0
  br i1 %27, label %33, label %28

28:                                               ; preds = %25
  %29 = load i32, ptr %4, align 4, !tbaa !9
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = load i32, ptr %30, align 8, !tbaa !13
  %32 = icmp sge i32 %29, %31
  br i1 %32, label %33, label %38

33:                                               ; preds = %28, %25
  %34 = load ptr, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 13), align 8, !tbaa !14
  %35 = load i32, ptr %4, align 4, !tbaa !9
  call void (ptr, i32, ptr, ...) @qh_fprintf(ptr noundef %34, i32 noundef 6174, ptr noundef @.str.5, i32 noundef %35)
  %36 = load ptr, ptr getelementptr inbounds (%struct.qhmemT, ptr @qhmem, i32 0, i32 13), align 8, !tbaa !14
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  call void @qh_setprint(ptr noundef %36, ptr noundef @.str.1, ptr noundef %37)
  call void @qh_errexit(i32 noundef 5, ptr noundef null, ptr noundef null)
  br label %38

38:                                               ; preds = %33, %28
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.setT, ptr %39, i32 0, i32 1
  %41 = load i32, ptr %4, align 4, !tbaa !9
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [1 x %union.setelemT], ptr %40, i64 0, i64 %42
  store ptr %43, ptr %7, align 8, !tbaa !5
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.setT, ptr %44, i32 0, i32 1
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = load i32, ptr %46, align 8, !tbaa !13
  %48 = sub nsw i32 %47, 1
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [1 x %union.setelemT], ptr %45, i64 0, i64 %49
  store ptr %50, ptr %8, align 8, !tbaa !5
  %51 = load ptr, ptr %7, align 8, !tbaa !5
  %52 = load ptr, ptr %51, align 8, !tbaa !13
  store ptr %52, ptr %5, align 8, !tbaa !5
  %53 = load ptr, ptr %8, align 8, !tbaa !5
  %54 = load ptr, ptr %53, align 8, !tbaa !13
  %55 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %54, ptr %55, align 8, !tbaa !13
  %56 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr null, ptr %56, align 8, !tbaa !13
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret ptr %57
}

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 0}
!12 = !{!"setT", !10, i64 0, !7, i64 8}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !6, i64 80}
!15 = !{!"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}


; 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 }
%union.setelemT = type { ptr }

@qhmem = external local_unnamed_addr global %struct.qhmemT, align 8
@.str.1 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [71 x i8], align 1

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

; Function Attrs: nounwind uwtable
declare dso_local void @qh_setprint(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local ptr @qh_setdelnth(ptr noundef %0, i32 noundef %1) local_unnamed_addr #1 {
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load i32, ptr %0, align 8, !tbaa !5
  %5 = sext i32 %4 to i64
  %6 = getelementptr inbounds [1 x %union.setelemT], ptr %3, i64 0, i64 %5
  %7 = load i32, ptr %6, align 8, !tbaa !10
  %8 = add nsw i32 %7, -1
  store i32 %8, ptr %6, align 8, !tbaa !10
  %9 = icmp eq i32 %7, 0
  br i1 %9, label %10, label %12

10:                                               ; preds = %2
  %11 = load i32, ptr %0, align 8, !tbaa !5
  store i32 %11, ptr %6, align 8, !tbaa !10
  br label %12

12:                                               ; preds = %10, %2
  %13 = phi i32 [ %11, %10 ], [ %8, %2 ]
  %14 = icmp sgt i32 %1, -1
  %.not = icmp sgt i32 %13, %1
  %or.cond = select i1 %14, i1 %.not, i1 false
  br i1 %or.cond, label %18, label %15

15:                                               ; preds = %12
  %16 = load ptr, ptr getelementptr inbounds (i8, ptr @qhmem, i64 80), align 8, !tbaa !11
  tail call void (ptr, i32, ptr, ...) @qh_fprintf(ptr noundef %16, i32 noundef 6174, ptr noundef nonnull @.str.5, i32 noundef %1) #2
  %17 = load ptr, ptr getelementptr inbounds (i8, ptr @qhmem, i64 80), align 8, !tbaa !11
  tail call void @qh_setprint(ptr noundef %17, ptr noundef nonnull @.str.1, ptr noundef nonnull %0)
  tail call void @qh_errexit(i32 noundef 5, ptr noundef null, ptr noundef null) #2
  %.pre = load i32, ptr %6, align 8, !tbaa !10
  br label %18

18:                                               ; preds = %12, %15
  %19 = phi i32 [ %.pre, %15 ], [ %13, %12 ]
  %20 = sext i32 %1 to i64
  %21 = getelementptr inbounds [1 x %union.setelemT], ptr %3, i64 0, i64 %20
  %22 = add nsw i32 %19, -1
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [1 x %union.setelemT], ptr %3, i64 0, i64 %23
  %25 = load ptr, ptr %21, align 8, !tbaa !10
  %26 = load ptr, ptr %24, align 8, !tbaa !10
  store ptr %26, ptr %21, align 8, !tbaa !10
  store ptr null, ptr %24, align 8, !tbaa !10
  ret ptr %25
}

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 0}
!6 = !{!"setT", !7, i64 0, !8, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!8, !8, i64 0}
!11 = !{!12, !13, i64 80}
!12 = !{!"qhmemT", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !13, i64 24, !13, i64 32, !13, i64 40, !13, i64 48, !13, i64 56, !7, i64 64, !13, i64 72, !13, 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}
!13 = !{!"any pointer", !8, i64 0}


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