; LLVM IR from mbheinen/bpa-ipf-tsp :: libgui (dmgr)

; 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.DBID = type { ptr, i64, i64, i64, i64, i64, i64, ptr, i64 }
%struct.schem = type { i8, i8, i64, i64, i64, ptr }

@.str.2 = external hidden unnamed_addr constant [68 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [15 x i8], align 1
@__PRETTY_FUNCTION__.ll_delete_list = external hidden unnamed_addr constant [52 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [32 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @db_resetlock(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @db_setlock(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: nounwind
declare void @free(ptr noundef) #2

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
define dso_local i32 @ll_delete_list(ptr noundef %0, ptr noundef %1, i64 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i64 %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = load ptr, ptr %10, align 8, !tbaa !5
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.DBID, ptr %12, i32 0, i32 0
  %14 = load ptr, ptr %13, align 8, !tbaa !11
  %15 = load i64, ptr %6, align 8, !tbaa !9
  %16 = getelementptr inbounds [0 x %struct.schem], ptr %14, i64 0, i64 %15
  %17 = getelementptr inbounds %struct.schem, ptr %16, i32 0, i32 3
  %18 = load i64, ptr %17, align 8, !tbaa !13
  %19 = mul nsw i64 %18, 3
  %20 = sub i64 0, %19
  %21 = getelementptr inbounds ptr, ptr %11, i64 %20
  store ptr %21, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = getelementptr inbounds ptr, ptr %22, i64 -1
  %24 = load ptr, ptr %23, align 8, !tbaa !5
  store ptr %24, ptr %9, align 8, !tbaa !5
  %25 = load i64, ptr %6, align 8, !tbaa !9
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.DBID, ptr %26, i32 0, i32 4
  %28 = load i64, ptr %27, align 8, !tbaa !15
  %29 = icmp sle i64 %25, %28
  br i1 %29, label %30, label %31

30:                                               ; preds = %3
  br label %32

31:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str.18, ptr noundef @.str.2, i32 noundef 1295, ptr noundef @__PRETTY_FUNCTION__.ll_delete_list) #5
  unreachable

32:                                               ; preds = %30
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.DBID, ptr %33, i32 0, i32 0
  %35 = load ptr, ptr %34, align 8, !tbaa !11
  %36 = load i64, ptr %6, align 8, !tbaa !9
  %37 = getelementptr inbounds [0 x %struct.schem], ptr %35, i64 0, i64 %36
  %38 = getelementptr inbounds %struct.schem, ptr %37, i32 0, i32 1
  %39 = load i8, ptr %38, align 1, !tbaa !16
  %40 = sext i8 %39 to i32
  %41 = icmp eq i32 %40, 108
  br i1 %41, label %42, label %43

42:                                               ; preds = %32
  br label %44

43:                                               ; preds = %32
  call void @__assert_fail(ptr noundef @.str.22, ptr noundef @.str.2, i32 noundef 1296, ptr noundef @__PRETTY_FUNCTION__.ll_delete_list) #5
  unreachable

44:                                               ; preds = %42
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = load ptr, ptr %45, align 8, !tbaa !5
  %47 = icmp ne ptr %46, null
  br i1 %47, label %48, label %49

48:                                               ; preds = %44
  br label %50

49:                                               ; preds = %44
  call void @__assert_fail(ptr noundef @.str.23, ptr noundef @.str.2, i32 noundef 1297, ptr noundef @__PRETTY_FUNCTION__.ll_delete_list) #5
  unreachable

50:                                               ; preds = %48
  %51 = load ptr, ptr %8, align 8, !tbaa !5
  %52 = getelementptr inbounds ptr, ptr %51, i64 -3
  %53 = load ptr, ptr %52, align 8, !tbaa !5
  %54 = ptrtoint ptr %53 to i64
  %55 = and i64 %54, 1
  %56 = icmp eq i64 %55, 1
  br i1 %56, label %57, label %58

57:                                               ; preds = %50
  br label %59

58:                                               ; preds = %50
  call void @__assert_fail(ptr noundef @.str.30, ptr noundef @.str.2, i32 noundef 1300, ptr noundef @__PRETTY_FUNCTION__.ll_delete_list) #5
  unreachable

59:                                               ; preds = %57
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  call void @db_setlock(ptr noundef %60)
  br label %61

61:                                               ; preds = %65, %59
  %62 = load ptr, ptr %9, align 8, !tbaa !5
  %63 = load ptr, ptr %8, align 8, !tbaa !5
  %64 = icmp ne ptr %62, %63
  br i1 %64, label %65, label %72

65:                                               ; preds = %61
  %66 = load ptr, ptr %9, align 8, !tbaa !5
  %67 = getelementptr inbounds ptr, ptr %66, i64 -3
  store ptr %67, ptr %7, align 8, !tbaa !5
  %68 = load ptr, ptr %9, align 8, !tbaa !5
  %69 = getelementptr inbounds ptr, ptr %68, i64 -1
  %70 = load ptr, ptr %69, align 8, !tbaa !5
  store ptr %70, ptr %9, align 8, !tbaa !5
  %71 = load ptr, ptr %7, align 8, !tbaa !5
  call void @free(ptr noundef %71) #4
  br label %61, !llvm.loop !17

72:                                               ; preds = %61
  %73 = load ptr, ptr %8, align 8, !tbaa !5
  %74 = load ptr, ptr %8, align 8, !tbaa !5
  %75 = getelementptr inbounds ptr, ptr %74, i64 -1
  store ptr %73, ptr %75, align 8, !tbaa !5
  %76 = load ptr, ptr %8, align 8, !tbaa !5
  %77 = load ptr, ptr %8, align 8, !tbaa !5
  %78 = getelementptr inbounds ptr, ptr %77, i64 -2
  store ptr %76, ptr %78, align 8, !tbaa !5
  %79 = load ptr, ptr %4, align 8, !tbaa !5
  call void @db_resetlock(ptr noundef %79)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  ret i32 0
}

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 = { 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 = { 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 #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 = !{!"long", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"", !6, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !6, i64 56, !10, i64 64}
!13 = !{!14, !10, i64 16}
!14 = !{!"schem", !7, i64 0, !7, i64 1, !10, i64 8, !10, i64 16, !10, i64 24, !6, i64 32}
!15 = !{!12, !10, i64 32}
!16 = !{!14, !7, i64 1}
!17 = distinct !{!17, !18}
!18 = !{!"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"

%struct.schem = type { i8, i8, i64, i64, i64, ptr }

@.str.2 = external hidden unnamed_addr constant [68 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [37 x i8], align 1
@__PRETTY_FUNCTION__.ll_delete_list = external hidden unnamed_addr constant [52 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [32 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @db_resetlock(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @db_setlock(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @ll_delete_list(ptr noundef %0, ptr nocapture noundef readonly %1, i64 noundef %2) local_unnamed_addr #0 {
  %4 = load ptr, ptr %1, align 8, !tbaa !5
  %5 = load ptr, ptr %0, align 8, !tbaa !9
  %6 = getelementptr inbounds [0 x %struct.schem], ptr %5, i64 0, i64 %2
  %7 = getelementptr inbounds i8, ptr %6, i64 16
  %8 = load i64, ptr %7, align 8, !tbaa !12
  %.idx = mul i64 %8, -24
  %9 = getelementptr inbounds i8, ptr %4, i64 %.idx
  %10 = getelementptr inbounds i8, ptr %9, i64 -8
  %11 = load ptr, ptr %10, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %0, i64 32
  %13 = load i64, ptr %12, align 8, !tbaa !14
  %.not = icmp slt i64 %13, %2
  br i1 %.not, label %14, label %15

14:                                               ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str.18, ptr noundef nonnull @.str.2, i32 noundef 1295, ptr noundef nonnull @__PRETTY_FUNCTION__.ll_delete_list) #3
  unreachable

15:                                               ; preds = %3
  %16 = getelementptr inbounds i8, ptr %6, i64 1
  %17 = load i8, ptr %16, align 1, !tbaa !15
  %18 = icmp eq i8 %17, 108
  br i1 %18, label %20, label %19

19:                                               ; preds = %15
  tail call void @__assert_fail(ptr noundef nonnull @.str.22, ptr noundef nonnull @.str.2, i32 noundef 1296, ptr noundef nonnull @__PRETTY_FUNCTION__.ll_delete_list) #3
  unreachable

20:                                               ; preds = %15
  %21 = getelementptr inbounds i8, ptr %9, i64 -24
  %22 = load ptr, ptr %21, align 8, !tbaa !5
  %23 = ptrtoint ptr %22 to i64
  %24 = and i64 %23, 1
  %.not22 = icmp eq i64 %24, 0
  br i1 %.not22, label %25, label %26

25:                                               ; preds = %20
  tail call void @__assert_fail(ptr noundef nonnull @.str.30, ptr noundef nonnull @.str.2, i32 noundef 1300, ptr noundef nonnull @__PRETTY_FUNCTION__.ll_delete_list) #3
  unreachable

26:                                               ; preds = %20
  tail call void @db_setlock(ptr noundef nonnull %0)
  %.not2324 = icmp eq ptr %11, %9
  br i1 %.not2324, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %26, %.lr.ph
  %.025 = phi ptr [ %29, %.lr.ph ], [ %11, %26 ]
  %27 = getelementptr inbounds i8, ptr %.025, i64 -24
  %28 = getelementptr inbounds i8, ptr %.025, i64 -8
  %29 = load ptr, ptr %28, align 8, !tbaa !5
  tail call void @free(ptr noundef nonnull %27) #4
  %.not23 = icmp eq ptr %29, %9
  br i1 %.not23, label %._crit_edge, label %.lr.ph, !llvm.loop !16

._crit_edge:                                      ; preds = %.lr.ph, %26
  store ptr %9, ptr %10, align 8, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %9, i64 -16
  store ptr %9, ptr %30, align 8, !tbaa !5
  tail call void @db_resetlock(ptr noundef nonnull %0)
  ret i32 0
}

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 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { 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 = { 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, !6, i64 0}
!10 = !{!"", !6, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !6, i64 56, !11, i64 64}
!11 = !{!"long", !7, i64 0}
!12 = !{!13, !11, i64 16}
!13 = !{!"schem", !7, i64 0, !7, i64 1, !11, i64 8, !11, i64 16, !11, i64 24, !6, i64 32}
!14 = !{!10, !11, i64 32}
!15 = !{!13, !7, i64 1}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass