; 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"

@.str.2 = external hidden unnamed_addr constant [68 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [6 x i8], align 1
@__PRETTY_FUNCTION__.ll_insert_in = external hidden unnamed_addr constant [63 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [43 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

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

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

; Function Attrs: nounwind uwtable
declare hidden void @db_exit(ptr noundef) #2

; Function Attrs: nounwind
declare i32 @sprintf(ptr noundef, ptr noundef, ...) #3

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

; Function Attrs: nounwind uwtable
define dso_local i32 @ll_insert_in(ptr noundef %0, ptr noundef %1, i64 noundef %2, i8 noundef signext %3) #2 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i8, align 1
  %10 = alloca [80 x i8], align 16
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i64 %2, ptr %8, align 8, !tbaa !9
  store i8 %3, ptr %9, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 80, ptr %10) #4
  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 %6, align 8, !tbaa !5
  %18 = load ptr, ptr %17, align 8, !tbaa !5
  store ptr %18, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %19 = load ptr, ptr %12, align 8, !tbaa !5
  %20 = getelementptr inbounds ptr, ptr %19, i64 -1
  store ptr %20, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  %21 = load ptr, ptr %12, align 8, !tbaa !5
  %22 = icmp ne ptr %21, null
  br i1 %22, label %23, label %24

23:                                               ; preds = %4
  br label %25

24:                                               ; preds = %4
  call void @__assert_fail(ptr noundef @.str.17, ptr noundef @.str.2, i32 noundef 1157, ptr noundef @__PRETTY_FUNCTION__.ll_insert_in) #5
  unreachable

25:                                               ; preds = %23
  %26 = load i64, ptr %8, align 8, !tbaa !9
  %27 = call i32 @db_newlink(ptr noundef %11, i64 noundef 3, i64 noundef %26)
  store i32 %27, ptr %15, align 4, !tbaa !12
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %29, label %31

29:                                               ; preds = %25
  %30 = load i32, ptr %15, align 4, !tbaa !12
  store i32 %30, ptr %5, align 4
  store i32 1, ptr %16, align 4
  br label %79

31:                                               ; preds = %25
  %32 = load ptr, ptr %11, align 8, !tbaa !5
  %33 = getelementptr inbounds ptr, ptr %32, i64 -1
  store ptr %33, ptr %14, align 8, !tbaa !5
  %34 = load i8, ptr %9, align 1, !tbaa !11
  %35 = sext i8 %34 to i32
  switch i32 %35, label %70 [
    i32 65, label %36
    i32 97, label %36
    i32 66, label %53
    i32 98, label %53
  ]

36:                                               ; preds = %31, %31
  %37 = load ptr, ptr %13, align 8, !tbaa !5
  %38 = getelementptr inbounds ptr, ptr %37, i64 0
  %39 = load ptr, ptr %38, align 8, !tbaa !5
  %40 = load ptr, ptr %14, align 8, !tbaa !5
  %41 = getelementptr inbounds ptr, ptr %40, i64 0
  store ptr %39, ptr %41, align 8, !tbaa !5
  %42 = load ptr, ptr %11, align 8, !tbaa !5
  %43 = load ptr, ptr %13, align 8, !tbaa !5
  %44 = getelementptr inbounds ptr, ptr %43, i64 0
  %45 = load ptr, ptr %44, align 8, !tbaa !5
  %46 = getelementptr inbounds ptr, ptr %45, i64 -2
  store ptr %42, ptr %46, align 8, !tbaa !5
  %47 = load ptr, ptr %11, align 8, !tbaa !5
  %48 = load ptr, ptr %13, align 8, !tbaa !5
  %49 = getelementptr inbounds ptr, ptr %48, i64 0
  store ptr %47, ptr %49, align 8, !tbaa !5
  %50 = load ptr, ptr %12, align 8, !tbaa !5
  %51 = load ptr, ptr %14, align 8, !tbaa !5
  %52 = getelementptr inbounds ptr, ptr %51, i64 -1
  store ptr %50, ptr %52, align 8, !tbaa !5
  br label %76

53:                                               ; preds = %31, %31
  %54 = load ptr, ptr %13, align 8, !tbaa !5
  %55 = getelementptr inbounds ptr, ptr %54, i64 -1
  %56 = load ptr, ptr %55, align 8, !tbaa !5
  %57 = load ptr, ptr %14, align 8, !tbaa !5
  %58 = getelementptr inbounds ptr, ptr %57, i64 -1
  store ptr %56, ptr %58, align 8, !tbaa !5
  %59 = load ptr, ptr %11, align 8, !tbaa !5
  %60 = load ptr, ptr %13, align 8, !tbaa !5
  %61 = getelementptr inbounds ptr, ptr %60, i64 -1
  %62 = load ptr, ptr %61, align 8, !tbaa !5
  %63 = getelementptr inbounds ptr, ptr %62, i64 -1
  store ptr %59, ptr %63, align 8, !tbaa !5
  %64 = load ptr, ptr %11, align 8, !tbaa !5
  %65 = load ptr, ptr %13, align 8, !tbaa !5
  %66 = getelementptr inbounds ptr, ptr %65, i64 -1
  store ptr %64, ptr %66, align 8, !tbaa !5
  %67 = load ptr, ptr %12, align 8, !tbaa !5
  %68 = load ptr, ptr %14, align 8, !tbaa !5
  %69 = getelementptr inbounds ptr, ptr %68, i64 0
  store ptr %67, ptr %69, align 8, !tbaa !5
  br label %76

70:                                               ; preds = %31
  %71 = getelementptr inbounds [80 x i8], ptr %10, i64 0, i64 0
  %72 = load i8, ptr %9, align 1, !tbaa !11
  %73 = sext i8 %72 to i32
  %74 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %71, ptr noundef @.str.26, i32 noundef %73) #4
  %75 = getelementptr inbounds [80 x i8], ptr %10, i64 0, i64 0
  call void @db_exit(ptr noundef %75)
  br label %76

76:                                               ; preds = %70, %53, %36
  %77 = load ptr, ptr %11, align 8, !tbaa !5
  %78 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %77, ptr %78, align 8, !tbaa !5
  store i32 0, ptr %5, align 4
  store i32 1, ptr %16, align 4
  br label %79

79:                                               ; preds = %76, %29
  call void @llvm.lifetime.end.p0(i64 4, 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 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 80, ptr %10) #4
  %80 = load i32, ptr %5, align 4
  ret i32 %80
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 "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 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}


; 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"

@.str.2 = external hidden unnamed_addr constant [68 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [6 x i8], align 1
@__PRETTY_FUNCTION__.ll_insert_in = external hidden unnamed_addr constant [63 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [43 x i8], align 1

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

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

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

; Function Attrs: nounwind uwtable
declare hidden void @db_exit(ptr noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @sprintf(ptr noalias nocapture noundef writeonly, ptr nocapture noundef readonly, ...) local_unnamed_addr #3

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

; Function Attrs: nounwind uwtable
define dso_local i32 @ll_insert_in(ptr nocapture noundef readonly %0, ptr nocapture noundef writeonly %1, i64 noundef %2, i8 noundef signext %3) local_unnamed_addr #2 {
  %5 = alloca [80 x i8], align 16
  %6 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 80, ptr nonnull %5) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #4
  %7 = load ptr, ptr %0, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %7, i64 -8
  %.not = icmp eq ptr %7, null
  br i1 %.not, label %9, label %10

9:                                                ; preds = %4
  tail call void @__assert_fail(ptr noundef nonnull @.str.17, ptr noundef nonnull @.str.2, i32 noundef 1157, ptr noundef nonnull @__PRETTY_FUNCTION__.ll_insert_in) #5
  unreachable

10:                                               ; preds = %4
  %11 = call i32 @db_newlink(ptr noundef nonnull %6, i64 noundef 3, i64 noundef %2)
  %.not22 = icmp eq i32 %11, 0
  br i1 %.not22, label %12, label %31

12:                                               ; preds = %10
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %13, i64 -8
  switch i8 %3, label %26 [
    i8 65, label %15
    i8 97, label %15
    i8 66, label %20
    i8 98, label %20
  ]

15:                                               ; preds = %12, %12
  %16 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %16, ptr %14, align 8, !tbaa !5
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %16, i64 -16
  store ptr %17, ptr %18, align 8, !tbaa !5
  store ptr %17, ptr %8, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %13, i64 -16
  store ptr %7, ptr %19, align 8, !tbaa !5
  br label %29

20:                                               ; preds = %12, %12
  %21 = getelementptr inbounds i8, ptr %7, i64 -16
  %22 = load ptr, ptr %21, align 8, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %13, i64 -16
  store ptr %22, ptr %23, align 8, !tbaa !5
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %22, i64 -8
  store ptr %24, ptr %25, align 8, !tbaa !5
  store ptr %24, ptr %21, align 8, !tbaa !5
  store ptr %7, ptr %14, align 8, !tbaa !5
  br label %29

26:                                               ; preds = %12
  %27 = sext i8 %3 to i32
  %28 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %5, ptr noundef nonnull dereferenceable(1) @.str.26, i32 noundef %27) #4
  call void @db_exit(ptr noundef nonnull %5)
  br label %29

29:                                               ; preds = %26, %20, %15
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %30, ptr %1, align 8, !tbaa !5
  br label %31

31:                                               ; preds = %10, %29
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %5) #4
  ret i32 %11
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { nofree 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"}


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