; 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
@__PRETTY_FUNCTION__.ll_delete_all_lists = external hidden unnamed_addr constant [48 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_all_lists(ptr noundef %0, i64 noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i64 %1, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.DBID, ptr %13, i32 0, i32 5
  %15 = load i64, ptr %14, align 8, !tbaa !11
  %16 = add i64 %15, 8
  store i64 %16, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.DBID, ptr %17, i32 0, i32 7
  %19 = load ptr, ptr %18, align 8, !tbaa !13
  store ptr %19, ptr %12, align 8, !tbaa !5
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  call void @db_setlock(ptr noundef %20)
  %21 = load i64, ptr %4, align 8, !tbaa !9
  %22 = icmp ne i64 %21, 0
  br i1 %22, label %23, label %52

23:                                               ; preds = %2
  %24 = load i64, ptr %4, align 8, !tbaa !9
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.DBID, ptr %25, i32 0, i32 4
  %27 = load i64, ptr %26, align 8, !tbaa !14
  %28 = icmp sle i64 %24, %27
  br i1 %28, label %29, label %30

29:                                               ; preds = %23
  br label %31

30:                                               ; preds = %23
  call void @__assert_fail(ptr noundef @.str.18, ptr noundef @.str.2, i32 noundef 1340, ptr noundef @__PRETTY_FUNCTION__.ll_delete_all_lists) #5
  unreachable

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

41:                                               ; preds = %31
  br label %43

42:                                               ; preds = %31
  call void @__assert_fail(ptr noundef @.str.22, ptr noundef @.str.2, i32 noundef 1341, ptr noundef @__PRETTY_FUNCTION__.ll_delete_all_lists) #5
  unreachable

43:                                               ; preds = %41
  store i64 1, ptr %7, align 8, !tbaa !9
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.DBID, ptr %44, i32 0, i32 0
  %46 = load ptr, ptr %45, align 8, !tbaa !15
  %47 = load i64, ptr %4, align 8, !tbaa !9
  %48 = getelementptr inbounds [0 x %struct.schem], ptr %46, i64 0, i64 %47
  %49 = getelementptr inbounds %struct.schem, ptr %48, i32 0, i32 3
  %50 = load i64, ptr %49, align 8, !tbaa !18
  %51 = mul nsw i64 %50, 3
  store i64 %51, ptr %8, align 8, !tbaa !9
  br label %56

52:                                               ; preds = %2
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.DBID, ptr %53, i32 0, i32 3
  %55 = load i64, ptr %54, align 8, !tbaa !19
  store i64 %55, ptr %7, align 8, !tbaa !9
  store i64 0, ptr %8, align 8, !tbaa !9
  br label %56

56:                                               ; preds = %52, %43
  br label %57

57:                                               ; preds = %92, %56
  %58 = load ptr, ptr %12, align 8, !tbaa !5
  %59 = load i64, ptr %8, align 8, !tbaa !9
  %60 = sub i64 0, %59
  %61 = getelementptr inbounds ptr, ptr %58, i64 %60
  store ptr %61, ptr %6, align 8, !tbaa !5
  %62 = load i64, ptr %7, align 8, !tbaa !9
  store i64 %62, ptr %5, align 8, !tbaa !9
  br label %63

63:                                               ; preds = %82, %57
  %64 = load i64, ptr %5, align 8, !tbaa !9
  %65 = add nsw i64 %64, -1
  store i64 %65, ptr %5, align 8, !tbaa !9
  %66 = icmp sge i64 %65, 0
  br i1 %66, label %67, label %91

67:                                               ; preds = %63
  %68 = load ptr, ptr %6, 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 %11, align 8, !tbaa !5
  br label %71

71:                                               ; preds = %75, %67
  %72 = load ptr, ptr %11, align 8, !tbaa !5
  %73 = load ptr, ptr %6, align 8, !tbaa !5
  %74 = icmp ne ptr %72, %73
  br i1 %74, label %75, label %82

75:                                               ; preds = %71
  %76 = load ptr, ptr %11, align 8, !tbaa !5
  %77 = getelementptr inbounds ptr, ptr %76, i64 -3
  store ptr %77, ptr %9, align 8, !tbaa !5
  %78 = load ptr, ptr %11, align 8, !tbaa !5
  %79 = getelementptr inbounds ptr, ptr %78, i64 -1
  %80 = load ptr, ptr %79, align 8, !tbaa !5
  store ptr %80, ptr %11, align 8, !tbaa !5
  %81 = load ptr, ptr %9, align 8, !tbaa !5
  call void @free(ptr noundef %81) #4
  br label %71, !llvm.loop !20

82:                                               ; preds = %71
  %83 = load ptr, ptr %6, align 8, !tbaa !5
  %84 = load ptr, ptr %6, align 8, !tbaa !5
  %85 = getelementptr inbounds ptr, ptr %84, i64 -1
  store ptr %83, ptr %85, align 8, !tbaa !5
  %86 = load ptr, ptr %6, align 8, !tbaa !5
  %87 = load ptr, ptr %6, align 8, !tbaa !5
  %88 = getelementptr inbounds ptr, ptr %87, i64 -2
  store ptr %86, ptr %88, align 8, !tbaa !5
  %89 = load ptr, ptr %6, align 8, !tbaa !5
  %90 = getelementptr inbounds ptr, ptr %89, i64 -3
  store ptr %90, ptr %6, align 8, !tbaa !5
  br label %63, !llvm.loop !22

91:                                               ; preds = %63
  br label %92

92:                                               ; preds = %91
  %93 = load ptr, ptr %12, align 8, !tbaa !5
  %94 = load i64, ptr %10, align 8, !tbaa !9
  %95 = getelementptr inbounds i8, ptr %93, i64 %94
  %96 = load ptr, ptr %95, align 8, !tbaa !5
  store ptr %96, ptr %12, align 8, !tbaa !5
  %97 = icmp ne ptr %96, null
  br i1 %97, label %57, label %98, !llvm.loop !23

98:                                               ; preds = %92
  %99 = load ptr, ptr %3, align 8, !tbaa !5
  call void @db_resetlock(ptr noundef %99)
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  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
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #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, !10, i64 40}
!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 = !{!12, !6, i64 56}
!14 = !{!12, !10, i64 32}
!15 = !{!12, !6, i64 0}
!16 = !{!17, !7, i64 1}
!17 = !{!"schem", !7, i64 0, !7, i64 1, !10, i64 8, !10, i64 16, !10, i64 24, !6, i64 32}
!18 = !{!17, !10, i64 16}
!19 = !{!12, !10, i64 24}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !21}
!23 = distinct !{!23, !21}


; 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_all_lists = external hidden unnamed_addr constant [48 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_all_lists(ptr noundef %0, i64 noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 40
  %4 = load i64, ptr %3, align 8, !tbaa !5
  %5 = add i64 %4, 8
  %6 = getelementptr inbounds i8, ptr %0, i64 56
  %7 = load ptr, ptr %6, align 8, !tbaa !11
  tail call void @db_setlock(ptr noundef %0)
  %.not = icmp eq i64 %1, 0
  br i1 %.not, label %21, label %8

8:                                                ; preds = %2
  %9 = getelementptr inbounds i8, ptr %0, i64 32
  %10 = load i64, ptr %9, align 8, !tbaa !12
  %.not36 = icmp slt i64 %10, %1
  br i1 %.not36, label %11, label %12

11:                                               ; preds = %8
  tail call void @__assert_fail(ptr noundef nonnull @.str.18, ptr noundef nonnull @.str.2, i32 noundef 1340, ptr noundef nonnull @__PRETTY_FUNCTION__.ll_delete_all_lists) #3
  unreachable

12:                                               ; preds = %8
  %13 = load ptr, ptr %0, align 8, !tbaa !13
  %14 = getelementptr inbounds [0 x %struct.schem], ptr %13, i64 0, i64 %1
  %15 = getelementptr inbounds i8, ptr %14, i64 1
  %16 = load i8, ptr %15, align 1, !tbaa !14
  %17 = icmp eq i8 %16, 108
  br i1 %17, label %.thread, label %18

18:                                               ; preds = %12
  tail call void @__assert_fail(ptr noundef nonnull @.str.22, ptr noundef nonnull @.str.2, i32 noundef 1341, ptr noundef nonnull @__PRETTY_FUNCTION__.ll_delete_all_lists) #3
  unreachable

.thread:                                          ; preds = %12
  %19 = getelementptr inbounds i8, ptr %14, i64 16
  %20 = load i64, ptr %19, align 8, !tbaa !16
  %.neg = mul i64 %20, -3
  br label %.lr.ph43.us.preheader

21:                                               ; preds = %2
  %22 = getelementptr inbounds i8, ptr %0, i64 24
  %23 = load i64, ptr %22, align 8, !tbaa !17
  %24 = icmp sgt i64 %23, 0
  br i1 %24, label %.lr.ph43.us.preheader, label %.split46.us

.lr.ph43.us.preheader:                            ; preds = %.thread, %21
  %.031.neg51 = phi i64 [ %.neg, %.thread ], [ 0, %21 ]
  %.03250 = phi i64 [ 1, %.thread ], [ %23, %21 ]
  br label %.lr.ph43.us

.lr.ph43.us:                                      ; preds = %.lr.ph43.us.preheader, %._crit_edge44.us
  %.0.us = phi ptr [ %37, %._crit_edge44.us ], [ %7, %.lr.ph43.us.preheader ]
  %25 = getelementptr inbounds ptr, ptr %.0.us, i64 %.031.neg51
  br label %26

26:                                               ; preds = %.lr.ph43.us, %._crit_edge.us
  %.in = phi i64 [ %.03250, %.lr.ph43.us ], [ %27, %._crit_edge.us ]
  %.03041.us = phi ptr [ %25, %.lr.ph43.us ], [ %34, %._crit_edge.us ]
  %27 = add nsw i64 %.in, -1
  %28 = getelementptr inbounds i8, ptr %.03041.us, i64 -8
  %29 = load ptr, ptr %28, align 8, !tbaa !18
  %.not3839.us = icmp eq ptr %29, %.03041.us
  br i1 %.not3839.us, label %._crit_edge.us, label %.lr.ph.us

.lr.ph.us:                                        ; preds = %26, %.lr.ph.us
  %.02840.us = phi ptr [ %32, %.lr.ph.us ], [ %29, %26 ]
  %30 = getelementptr inbounds i8, ptr %.02840.us, i64 -24
  %31 = getelementptr inbounds i8, ptr %.02840.us, i64 -8
  %32 = load ptr, ptr %31, align 8, !tbaa !18
  tail call void @free(ptr noundef nonnull %30) #4
  %.not38.us = icmp eq ptr %32, %.03041.us
  br i1 %.not38.us, label %._crit_edge.us, label %.lr.ph.us, !llvm.loop !19

._crit_edge.us:                                   ; preds = %.lr.ph.us, %26
  store ptr %.03041.us, ptr %28, align 8, !tbaa !18
  %33 = getelementptr inbounds i8, ptr %.03041.us, i64 -16
  store ptr %.03041.us, ptr %33, align 8, !tbaa !18
  %34 = getelementptr inbounds i8, ptr %.03041.us, i64 -24
  %35 = icmp sgt i64 %.in, 1
  br i1 %35, label %26, label %._crit_edge44.us, !llvm.loop !21

._crit_edge44.us:                                 ; preds = %._crit_edge.us
  %36 = getelementptr inbounds i8, ptr %.0.us, i64 %5
  %37 = load ptr, ptr %36, align 8, !tbaa !18
  %.not37.us = icmp eq ptr %37, null
  br i1 %.not37.us, label %.split46.us, label %.lr.ph43.us, !llvm.loop !22

.split46.us:                                      ; preds = %._crit_edge44.us, %21
  tail call void @db_resetlock(ptr noundef %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, !10, i64 40}
!6 = !{!"", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !7, i64 56, !10, i64 64}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!6, !7, i64 56}
!12 = !{!6, !10, i64 32}
!13 = !{!6, !7, i64 0}
!14 = !{!15, !8, i64 1}
!15 = !{!"schem", !8, i64 0, !8, i64 1, !10, i64 8, !10, i64 16, !10, i64 24, !7, i64 32}
!16 = !{!15, !10, i64 16}
!17 = !{!6, !10, i64 24}
!18 = !{!7, !7, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}
!22 = distinct !{!22, !20}


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