; 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
@.str.28 = external hidden unnamed_addr constant [29 x i8], align 1
@__PRETTY_FUNCTION__.ll_first = external hidden unnamed_addr constant [67 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
define dso_local i32 @ll_first(ptr noundef %0, ptr noundef %1, ptr noundef %2, i64 noundef %3) #2 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i64 %3, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %12 = load ptr, ptr %7, align 8, !tbaa !5
  %13 = load ptr, ptr %12, align 8, !tbaa !5
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.DBID, ptr %14, i32 0, i32 0
  %16 = load ptr, ptr %15, align 8, !tbaa !11
  %17 = load i64, ptr %9, align 8, !tbaa !9
  %18 = getelementptr inbounds [0 x %struct.schem], ptr %16, i64 0, i64 %17
  %19 = getelementptr inbounds %struct.schem, ptr %18, i32 0, i32 3
  %20 = load i64, ptr %19, align 8, !tbaa !13
  %21 = mul nsw i64 %20, 3
  %22 = sub i64 0, %21
  %23 = getelementptr inbounds ptr, ptr %13, i64 %22
  store ptr %23, ptr %10, align 8, !tbaa !5
  %24 = load i64, ptr %9, align 8, !tbaa !9
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.DBID, ptr %25, i32 0, i32 4
  %27 = load i64, ptr %26, align 8, !tbaa !15
  %28 = icmp sle i64 %24, %27
  br i1 %28, label %29, label %30

29:                                               ; preds = %4
  br label %31

30:                                               ; preds = %4
  call void @__assert_fail(ptr noundef @.str.18, ptr noundef @.str.2, i32 noundef 1246, ptr noundef @__PRETTY_FUNCTION__.ll_first) #4
  unreachable

31:                                               ; preds = %29
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.DBID, ptr %32, i32 0, i32 0
  %34 = load ptr, ptr %33, align 8, !tbaa !11
  %35 = load i64, ptr %9, 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 1247, ptr noundef @__PRETTY_FUNCTION__.ll_first) #4
  unreachable

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

47:                                               ; preds = %43
  br label %49

48:                                               ; preds = %43
  call void @__assert_fail(ptr noundef @.str.23, ptr noundef @.str.2, i32 noundef 1248, ptr noundef @__PRETTY_FUNCTION__.ll_first) #4
  unreachable

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

56:                                               ; preds = %49
  br label %58

57:                                               ; preds = %49
  call void @__assert_fail(ptr noundef @.str.28, ptr noundef @.str.2, i32 noundef 1251, ptr noundef @__PRETTY_FUNCTION__.ll_first) #4
  unreachable

58:                                               ; preds = %56
  %59 = load ptr, ptr %10, align 8, !tbaa !5
  %60 = getelementptr inbounds ptr, ptr %59, i64 -1
  %61 = load ptr, ptr %60, align 8, !tbaa !5
  %62 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %61, ptr %62, align 8, !tbaa !5
  %63 = load ptr, ptr %10, align 8, !tbaa !5
  %64 = icmp ne ptr %61, %63
  br i1 %64, label %65, label %66

65:                                               ; preds = %58
  store i32 2, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %67

66:                                               ; preds = %58
  store i32 5, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %67

67:                                               ; preds = %66, %65
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %68 = load i32, ptr %5, align 4
  ret i32 %68
}

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 }
attributes #4 = { 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}


; 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
@.str.23 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [29 x i8], align 1
@__PRETTY_FUNCTION__.ll_first = external hidden unnamed_addr constant [67 x i8], align 1

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

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

13:                                               ; preds = %4
  tail call void @__assert_fail(ptr noundef nonnull @.str.18, ptr noundef nonnull @.str.2, i32 noundef 1246, ptr noundef nonnull @__PRETTY_FUNCTION__.ll_first) #2
  unreachable

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

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

19:                                               ; preds = %14
  %.not12 = icmp eq ptr %5, null
  br i1 %.not12, label %20, label %21

20:                                               ; preds = %19
  tail call void @__assert_fail(ptr noundef nonnull @.str.23, ptr noundef nonnull @.str.2, i32 noundef 1248, ptr noundef nonnull @__PRETTY_FUNCTION__.ll_first) #2
  unreachable

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

26:                                               ; preds = %21
  tail call void @__assert_fail(ptr noundef nonnull @.str.28, ptr noundef nonnull @.str.2, i32 noundef 1251, ptr noundef nonnull @__PRETTY_FUNCTION__.ll_first) #2
  unreachable

27:                                               ; preds = %21
  %28 = getelementptr inbounds i8, ptr %10, i64 -8
  %29 = load ptr, ptr %28, align 8, !tbaa !5
  store ptr %29, ptr %2, align 8, !tbaa !5
  %.not14 = icmp eq ptr %29, %10
  %. = select i1 %.not14, i32 5, i32 2
  ret i32 %.
}

attributes #0 = { 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 #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 = { 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, !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}


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