; 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.1 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [68 x i8], align 1
@__PRETTY_FUNCTION__.db_delete = external hidden unnamed_addr constant [35 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [41 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: nounwind uwtable
define dso_local i32 @db_delete(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.DBID, ptr %18, i32 0, i32 3
  %20 = load i64, ptr %19, align 8, !tbaa !9
  store i64 %20, ptr %7, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = load ptr, ptr %21, align 8, !tbaa !5
  store ptr %22, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.DBID, ptr %23, i32 0, i32 4
  %25 = load i64, ptr %24, align 8, !tbaa !13
  store i64 %25, ptr %12, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  store i64 0, ptr %13, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.DBID, ptr %26, i32 0, i32 5
  %28 = load i64, ptr %27, align 8, !tbaa !14
  store i64 %28, ptr %14, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %29 = load ptr, ptr %9, align 8, !tbaa !5
  %30 = load i64, ptr %14, align 8, !tbaa !12
  %31 = getelementptr inbounds i8, ptr %29, i64 %30
  %32 = load i64, ptr %31, align 8, !tbaa !12
  %33 = mul i64 %32, 8
  store i64 %33, ptr %15, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = load i64, ptr %14, align 8, !tbaa !12
  %36 = getelementptr inbounds i8, ptr %34, i64 %35
  %37 = getelementptr inbounds i8, ptr %36, i64 8
  store ptr %37, ptr %16, align 8, !tbaa !5
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  %39 = icmp ne ptr %38, null
  br i1 %39, label %40, label %41

40:                                               ; preds = %2
  br label %42

41:                                               ; preds = %2
  call void @__assert_fail(ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 378, ptr noundef @__PRETTY_FUNCTION__.db_delete) #5
  unreachable

42:                                               ; preds = %40
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  call void @db_setlock(ptr noundef %43)
  br label %44

44:                                               ; preds = %89, %42
  %45 = load i64, ptr %12, align 8, !tbaa !12
  %46 = icmp sgt i64 %45, 0
  br i1 %46, label %47, label %92

47:                                               ; preds = %44
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.DBID, ptr %48, i32 0, i32 0
  %50 = load ptr, ptr %49, align 8, !tbaa !15
  %51 = load i64, ptr %12, align 8, !tbaa !12
  %52 = getelementptr inbounds [0 x %struct.schem], ptr %50, i64 0, i64 %51
  %53 = getelementptr inbounds %struct.schem, ptr %52, i32 0, i32 0
  %54 = load i8, ptr %53, align 8, !tbaa !16
  %55 = sext i8 %54 to i32
  %56 = icmp eq i32 %55, 110
  br i1 %56, label %57, label %58

57:                                               ; preds = %47
  br label %89

58:                                               ; preds = %47
  %59 = load ptr, ptr %16, align 8, !tbaa !5
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.DBID, ptr %60, i32 0, i32 0
  %62 = load ptr, ptr %61, align 8, !tbaa !15
  %63 = load i64, ptr %12, align 8, !tbaa !12
  %64 = getelementptr inbounds [0 x %struct.schem], ptr %62, i64 0, i64 %63
  %65 = getelementptr inbounds %struct.schem, ptr %64, i32 0, i32 4
  %66 = load i64, ptr %65, align 8, !tbaa !18
  %67 = load i64, ptr %15, align 8, !tbaa !12
  %68 = mul nsw i64 %66, %67
  %69 = getelementptr inbounds i8, ptr %59, i64 %68
  %70 = load ptr, ptr %69, align 8, !tbaa !5
  %71 = load ptr, ptr %9, align 8, !tbaa !5
  %72 = icmp eq ptr %70, %71
  br i1 %72, label %73, label %74

73:                                               ; preds = %58
  br label %89

74:                                               ; preds = %58
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = load ptr, ptr %5, align 8, !tbaa !5
  %77 = load i64, ptr %12, align 8, !tbaa !12
  %78 = call i32 @xdelete(ptr noundef %75, ptr noundef %76, i64 noundef %77)
  store i32 %78, ptr %11, align 4, !tbaa !19
  %79 = load i32, ptr %11, align 4, !tbaa !19
  %80 = icmp ne i32 %79, 0
  br i1 %80, label %81, label %88

81:                                               ; preds = %74
  %82 = load i64, ptr %13, align 8, !tbaa !12
  %83 = icmp ne i64 %82, 0
  br i1 %83, label %84, label %85

84:                                               ; preds = %81
  call void @db_exit(ptr noundef @.str.3)
  br label %85

85:                                               ; preds = %84, %81
  %86 = load ptr, ptr %4, align 8, !tbaa !5
  call void @db_resetlock(ptr noundef %86)
  %87 = load i32, ptr %11, align 4, !tbaa !19
  store i32 %87, ptr %3, align 4
  store i32 1, ptr %17, align 4
  br label %121

88:                                               ; preds = %74
  store i64 1, ptr %13, align 8, !tbaa !12
  br label %89

89:                                               ; preds = %88, %73, %57
  %90 = load i64, ptr %12, align 8, !tbaa !12
  %91 = add nsw i64 %90, -1
  store i64 %91, ptr %12, align 8, !tbaa !12
  br label %44, !llvm.loop !21

92:                                               ; preds = %44
  %93 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %93, ptr %6, align 8, !tbaa !5
  %94 = load i64, ptr %7, align 8, !tbaa !12
  store i64 %94, ptr %12, align 8, !tbaa !12
  br label %95

95:                                               ; preds = %114, %92
  %96 = load i64, ptr %12, align 8, !tbaa !12
  %97 = add nsw i64 %96, -1
  store i64 %97, ptr %12, align 8, !tbaa !12
  %98 = icmp sge i64 %97, 0
  br i1 %98, label %99, label %117

99:                                               ; preds = %95
  %100 = load ptr, ptr %6, align 8, !tbaa !5
  %101 = getelementptr inbounds ptr, ptr %100, i64 -1
  %102 = load ptr, ptr %101, align 8, !tbaa !5
  store ptr %102, ptr %10, align 8, !tbaa !5
  br label %103

103:                                              ; preds = %107, %99
  %104 = load ptr, ptr %10, align 8, !tbaa !5
  %105 = load ptr, ptr %6, align 8, !tbaa !5
  %106 = icmp ne ptr %104, %105
  br i1 %106, label %107, label %114

107:                                              ; preds = %103
  %108 = load ptr, ptr %10, align 8, !tbaa !5
  %109 = getelementptr inbounds ptr, ptr %108, i64 -3
  store ptr %109, ptr %8, align 8, !tbaa !5
  %110 = load ptr, ptr %10, align 8, !tbaa !5
  %111 = getelementptr inbounds ptr, ptr %110, i64 -1
  %112 = load ptr, ptr %111, align 8, !tbaa !5
  store ptr %112, ptr %10, align 8, !tbaa !5
  %113 = load ptr, ptr %8, align 8, !tbaa !5
  call void @free(ptr noundef %113) #4
  br label %103, !llvm.loop !23

114:                                              ; preds = %103
  %115 = load ptr, ptr %6, align 8, !tbaa !5
  %116 = getelementptr inbounds ptr, ptr %115, i64 -3
  store ptr %116, ptr %6, align 8, !tbaa !5
  br label %95, !llvm.loop !24

117:                                              ; preds = %95
  %118 = load ptr, ptr %6, align 8, !tbaa !5
  call void @free(ptr noundef %118) #4
  %119 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr null, ptr %119, align 8, !tbaa !5
  %120 = load ptr, ptr %4, align 8, !tbaa !5
  call void @db_resetlock(ptr noundef %120)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %17, align 4
  br label %121

121:                                              ; preds = %117, %85
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, 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
  %122 = load i32, ptr %3, align 4
  ret i32 %122
}

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

; Function Attrs: nounwind uwtable
declare hidden i32 @xdelete(ptr noundef, ptr noundef, i64 noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @db_exit(ptr noundef) #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, !11, i64 24}
!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 = !{!11, !11, i64 0}
!13 = !{!10, !11, i64 32}
!14 = !{!10, !11, i64 40}
!15 = !{!10, !6, i64 0}
!16 = !{!17, !7, i64 0}
!17 = !{!"schem", !7, i64 0, !7, i64 1, !11, i64 8, !11, i64 16, !11, i64 24, !6, i64 32}
!18 = !{!17, !11, i64 24}
!19 = !{!20, !20, i64 0}
!20 = !{!"int", !7, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = distinct !{!23, !22}
!24 = distinct !{!24, !22}


; 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.3 = external hidden unnamed_addr constant [41 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: nounwind uwtable
define dso_local i32 @db_delete(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 24
  %4 = load i64, ptr %3, align 8, !tbaa !5
  %5 = load ptr, ptr %1, align 8, !tbaa !11
  %6 = getelementptr inbounds i8, ptr %0, i64 40
  %7 = load i64, ptr %6, align 8, !tbaa !12
  %8 = getelementptr inbounds i8, ptr %5, i64 %7
  %9 = load i64, ptr %8, align 8, !tbaa !13
  %10 = shl i64 %9, 3
  %11 = getelementptr inbounds i8, ptr %8, i64 8
  %12 = getelementptr inbounds i8, ptr %0, i64 32
  %13 = load i64, ptr %12, align 8, !tbaa !14
  tail call void @db_setlock(ptr noundef %0)
  %14 = icmp sgt i64 %13, 0
  br i1 %14, label %.lr.ph, label %.preheader

.preheader:                                       ; preds = %32, %2
  %15 = icmp sgt i64 %4, 0
  br i1 %15, label %.lr.ph57, label %._crit_edge58

.lr.ph:                                           ; preds = %2, %32
  %.04152 = phi i64 [ %.1, %32 ], [ 0, %2 ]
  %.04251 = phi i64 [ %33, %32 ], [ %13, %2 ]
  %16 = load ptr, ptr %0, align 8, !tbaa !15
  %17 = getelementptr inbounds [0 x %struct.schem], ptr %16, i64 0, i64 %.04251
  %18 = load i8, ptr %17, align 8, !tbaa !16
  %19 = icmp eq i8 %18, 110
  br i1 %19, label %32, label %20

20:                                               ; preds = %.lr.ph
  %21 = getelementptr inbounds i8, ptr %17, i64 24
  %22 = load i64, ptr %21, align 8, !tbaa !18
  %23 = mul nsw i64 %10, %22
  %24 = getelementptr inbounds i8, ptr %11, i64 %23
  %25 = load ptr, ptr %24, align 8, !tbaa !11
  %26 = icmp eq ptr %25, %5
  br i1 %26, label %32, label %27

27:                                               ; preds = %20
  %28 = tail call i32 @xdelete(ptr noundef nonnull %0, ptr noundef nonnull %1, i64 noundef %.04251)
  %.not48 = icmp eq i32 %28, 0
  br i1 %.not48, label %32, label %29

29:                                               ; preds = %27
  %.not49 = icmp eq i64 %.04152, 0
  br i1 %.not49, label %31, label %30

30:                                               ; preds = %29
  tail call void @db_exit(ptr noundef nonnull @.str.3)
  br label %31

31:                                               ; preds = %30, %29
  tail call void @db_resetlock(ptr noundef nonnull %0)
  br label %43

32:                                               ; preds = %27, %20, %.lr.ph
  %.1 = phi i64 [ %.04152, %.lr.ph ], [ %.04152, %20 ], [ 1, %27 ]
  %33 = add nsw i64 %.04251, -1
  %34 = icmp sgt i64 %.04251, 1
  br i1 %34, label %.lr.ph, label %.preheader, !llvm.loop !19

.lr.ph57:                                         ; preds = %.preheader, %._crit_edge
  %.in = phi i64 [ %35, %._crit_edge ], [ %4, %.preheader ]
  %.03956 = phi ptr [ %41, %._crit_edge ], [ %5, %.preheader ]
  %35 = add nsw i64 %.in, -1
  %36 = getelementptr inbounds i8, ptr %.03956, i64 -8
  %37 = load ptr, ptr %36, align 8, !tbaa !11
  %.not4753 = icmp eq ptr %37, %.03956
  br i1 %.not4753, label %._crit_edge, label %.lr.ph55

.lr.ph55:                                         ; preds = %.lr.ph57, %.lr.ph55
  %.04054 = phi ptr [ %40, %.lr.ph55 ], [ %37, %.lr.ph57 ]
  %38 = getelementptr inbounds i8, ptr %.04054, i64 -24
  %39 = getelementptr inbounds i8, ptr %.04054, i64 -8
  %40 = load ptr, ptr %39, align 8, !tbaa !11
  tail call void @free(ptr noundef nonnull %38) #2
  %.not47 = icmp eq ptr %40, %.03956
  br i1 %.not47, label %._crit_edge, label %.lr.ph55, !llvm.loop !21

._crit_edge:                                      ; preds = %.lr.ph55, %.lr.ph57
  %41 = getelementptr inbounds i8, ptr %.03956, i64 -24
  %42 = icmp sgt i64 %.in, 1
  br i1 %42, label %.lr.ph57, label %._crit_edge58, !llvm.loop !22

._crit_edge58:                                    ; preds = %._crit_edge, %.preheader
  %.039.lcssa = phi ptr [ %5, %.preheader ], [ %41, %._crit_edge ]
  tail call void @free(ptr noundef %.039.lcssa) #2
  store ptr null, ptr %1, align 8, !tbaa !11
  tail call void @db_resetlock(ptr noundef %0)
  br label %43

43:                                               ; preds = %._crit_edge58, %31
  %.0 = phi i32 [ %28, %31 ], [ 0, %._crit_edge58 ]
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare hidden i32 @xdelete(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @db_exit(ptr noundef) local_unnamed_addr #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 = { 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 24}
!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 = !{!7, !7, i64 0}
!12 = !{!6, !10, i64 40}
!13 = !{!10, !10, i64 0}
!14 = !{!6, !10, i64 32}
!15 = !{!6, !7, i64 0}
!16 = !{!17, !8, i64 0}
!17 = !{!"schem", !8, i64 0, !8, i64 1, !10, i64 8, !10, i64 16, !10, i64 24, !7, i64 32}
!18 = !{!17, !10, i64 24}
!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,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass