; LLVM IR from theck01/offbrand_lib :: src/classes (obdeque)

; 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.obdeque_iterator_struct = type { ptr, ptr, ptr }
%struct.obdeque_struct = type { ptr, ptr, ptr, i64 }
%struct.obdeque_node_struct = type { ptr, ptr, ptr, ptr }

@.str.1 = external hidden unnamed_addr constant [76 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [7 x i8], align 1
@__PRETTY_FUNCTION__.obdeque_add_at_iterator = external hidden unnamed_addr constant [67 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [32 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

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

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @obdeque_iterate_prev(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @obdeque_add_at_head(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local ptr @obdeque_new_node(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @obdeque_add_at_iterator(ptr noundef %0, ptr noundef %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = icmp ne ptr %8, null
  br i1 %9, label %10, label %11

10:                                               ; preds = %3
  br label %12

11:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 172, ptr noundef @__PRETTY_FUNCTION__.obdeque_add_at_iterator) #4
  unreachable

12:                                               ; preds = %10
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = icmp ne ptr %13, null
  br i1 %14, label %15, label %16

15:                                               ; preds = %12
  br label %17

16:                                               ; preds = %12
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 173, ptr noundef @__PRETTY_FUNCTION__.obdeque_add_at_iterator) #4
  unreachable

17:                                               ; preds = %15
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.obdeque_iterator_struct, ptr %18, i32 0, i32 1
  %20 = load ptr, ptr %19, align 8, !tbaa !9
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = icmp eq ptr %20, %21
  br i1 %22, label %23, label %24

23:                                               ; preds = %17
  br label %25

24:                                               ; preds = %17
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 174, ptr noundef @__PRETTY_FUNCTION__.obdeque_add_at_iterator) #4
  unreachable

25:                                               ; preds = %23
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = icmp ne ptr %26, null
  br i1 %27, label %28, label %29

28:                                               ; preds = %25
  br label %30

29:                                               ; preds = %25
  call void @__assert_fail(ptr noundef @.str.5, ptr noundef @.str.1, i32 noundef 175, ptr noundef @__PRETTY_FUNCTION__.obdeque_add_at_iterator) #4
  unreachable

30:                                               ; preds = %28
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.obdeque_iterator_struct, ptr %31, i32 0, i32 2
  %33 = load ptr, ptr %32, align 8, !tbaa !11
  %34 = icmp ne ptr %33, null
  br i1 %34, label %43, label %35

35:                                               ; preds = %30
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  call void @obdeque_add_at_head(ptr noundef %36, ptr noundef %37)
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.obdeque_struct, ptr %38, i32 0, i32 1
  %40 = load ptr, ptr %39, align 8, !tbaa !12
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.obdeque_iterator_struct, ptr %41, i32 0, i32 2
  store ptr %40, ptr %42, align 8, !tbaa !11
  br label %43

43:                                               ; preds = %35, %30
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = call ptr @obdeque_new_node(ptr noundef %44)
  store ptr %45, ptr %7, align 8, !tbaa !5
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.obdeque_iterator_struct, ptr %46, i32 0, i32 2
  %48 = load ptr, ptr %47, align 8, !tbaa !11
  %49 = getelementptr inbounds %struct.obdeque_node_struct, ptr %48, i32 0, i32 3
  %50 = load ptr, ptr %49, align 8, !tbaa !15
  %51 = load ptr, ptr %7, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.obdeque_node_struct, ptr %51, i32 0, i32 3
  store ptr %50, ptr %52, align 8, !tbaa !15
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.obdeque_iterator_struct, ptr %53, i32 0, i32 2
  %55 = load ptr, ptr %54, align 8, !tbaa !11
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.obdeque_node_struct, ptr %56, i32 0, i32 2
  store ptr %55, ptr %57, align 8, !tbaa !17
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.obdeque_iterator_struct, ptr %58, i32 0, i32 2
  %60 = load ptr, ptr %59, align 8, !tbaa !11
  %61 = getelementptr inbounds %struct.obdeque_node_struct, ptr %60, i32 0, i32 3
  %62 = load ptr, ptr %61, align 8, !tbaa !15
  %63 = icmp ne ptr %62, null
  br i1 %63, label %64, label %72

64:                                               ; preds = %43
  %65 = load ptr, ptr %7, align 8, !tbaa !5
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.obdeque_iterator_struct, ptr %66, i32 0, i32 2
  %68 = load ptr, ptr %67, align 8, !tbaa !11
  %69 = getelementptr inbounds %struct.obdeque_node_struct, ptr %68, i32 0, i32 3
  %70 = load ptr, ptr %69, align 8, !tbaa !15
  %71 = getelementptr inbounds %struct.obdeque_node_struct, ptr %70, i32 0, i32 2
  store ptr %65, ptr %71, align 8, !tbaa !17
  br label %72

72:                                               ; preds = %64, %43
  %73 = load ptr, ptr %7, align 8, !tbaa !5
  %74 = load ptr, ptr %5, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.obdeque_iterator_struct, ptr %74, i32 0, i32 2
  %76 = load ptr, ptr %75, align 8, !tbaa !11
  %77 = getelementptr inbounds %struct.obdeque_node_struct, ptr %76, i32 0, i32 3
  store ptr %73, ptr %77, align 8, !tbaa !15
  %78 = load ptr, ptr %4, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.obdeque_struct, ptr %78, i32 0, i32 3
  %80 = load i64, ptr %79, align 8, !tbaa !18
  %81 = add i64 %80, 1
  store i64 %81, ptr %79, align 8, !tbaa !18
  %82 = load ptr, ptr %5, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.obdeque_iterator_struct, ptr %82, i32 0, i32 2
  %84 = load ptr, ptr %83, align 8, !tbaa !11
  %85 = load ptr, ptr %4, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.obdeque_struct, ptr %85, i32 0, i32 1
  %87 = load ptr, ptr %86, align 8, !tbaa !12
  %88 = icmp eq ptr %84, %87
  br i1 %88, label %89, label %93

89:                                               ; preds = %72
  %90 = load ptr, ptr %7, align 8, !tbaa !5
  %91 = load ptr, ptr %4, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.obdeque_struct, ptr %91, i32 0, i32 1
  store ptr %90, ptr %92, align 8, !tbaa !12
  br label %93

93:                                               ; preds = %89, %72
  %94 = load ptr, ptr %4, align 8, !tbaa !5
  %95 = load ptr, ptr %5, align 8, !tbaa !5
  %96 = call zeroext i8 @obdeque_iterate_prev(ptr noundef %94, ptr noundef %95)
  %97 = icmp ne i8 %96, 0
  br i1 %97, label %98, label %99

98:                                               ; preds = %93
  br label %100

99:                                               ; preds = %93
  call void @__assert_fail(ptr noundef @.str.6, ptr noundef @.str.1, i32 noundef 199, ptr noundef @__PRETTY_FUNCTION__.obdeque_add_at_iterator) #4
  unreachable

100:                                              ; preds = %98
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret void
}

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, !6, i64 8}
!10 = !{!"obdeque_iterator_struct", !6, i64 0, !6, i64 8, !6, i64 16}
!11 = !{!10, !6, i64 16}
!12 = !{!13, !6, i64 8}
!13 = !{!"obdeque_struct", !6, i64 0, !6, i64 8, !6, i64 16, !14, i64 24}
!14 = !{!"long", !7, i64 0}
!15 = !{!16, !6, i64 24}
!16 = !{!"obdeque_node_struct", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!17 = !{!16, !6, i64 16}
!18 = !{!13, !14, i64 24}


; 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.1 = external hidden unnamed_addr constant [76 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [7 x i8], align 1
@__PRETTY_FUNCTION__.obdeque_add_at_iterator = external hidden unnamed_addr constant [67 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [32 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
declare dso_local zeroext i8 @obdeque_iterate_prev(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @obdeque_add_at_head(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @obdeque_new_node(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @obdeque_add_at_iterator(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #1 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %4, label %5

4:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 172, ptr noundef nonnull @__PRETTY_FUNCTION__.obdeque_add_at_iterator) #2
  unreachable

5:                                                ; preds = %3
  %.not30 = icmp eq ptr %1, null
  br i1 %.not30, label %6, label %7

6:                                                ; preds = %5
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 173, ptr noundef nonnull @__PRETTY_FUNCTION__.obdeque_add_at_iterator) #2
  unreachable

7:                                                ; preds = %5
  %8 = getelementptr inbounds i8, ptr %1, i64 8
  %9 = load ptr, ptr %8, align 8, !tbaa !5
  %10 = icmp eq ptr %9, %0
  br i1 %10, label %12, label %11

11:                                               ; preds = %7
  tail call void @__assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 174, ptr noundef nonnull @__PRETTY_FUNCTION__.obdeque_add_at_iterator) #2
  unreachable

12:                                               ; preds = %7
  %.not31 = icmp eq ptr %2, null
  br i1 %.not31, label %13, label %14

13:                                               ; preds = %12
  tail call void @__assert_fail(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.1, i32 noundef 175, ptr noundef nonnull @__PRETTY_FUNCTION__.obdeque_add_at_iterator) #2
  unreachable

14:                                               ; preds = %12
  %15 = getelementptr inbounds i8, ptr %1, i64 16
  %16 = load ptr, ptr %15, align 8, !tbaa !10
  %.not32 = icmp eq ptr %16, null
  br i1 %.not32, label %17, label %20

17:                                               ; preds = %14
  tail call void @obdeque_add_at_head(ptr noundef nonnull %0, ptr noundef nonnull %2)
  %18 = getelementptr inbounds i8, ptr %0, i64 8
  %19 = load ptr, ptr %18, align 8, !tbaa !11
  store ptr %19, ptr %15, align 8, !tbaa !10
  br label %20

20:                                               ; preds = %17, %14
  %21 = tail call ptr @obdeque_new_node(ptr noundef nonnull %2)
  %22 = load ptr, ptr %15, align 8, !tbaa !10
  %23 = getelementptr inbounds i8, ptr %22, i64 24
  %24 = load ptr, ptr %23, align 8, !tbaa !14
  %25 = getelementptr inbounds i8, ptr %21, i64 24
  store ptr %24, ptr %25, align 8, !tbaa !14
  %26 = getelementptr inbounds i8, ptr %21, i64 16
  store ptr %22, ptr %26, align 8, !tbaa !16
  %.not33 = icmp eq ptr %24, null
  br i1 %.not33, label %29, label %27

27:                                               ; preds = %20
  %28 = getelementptr inbounds i8, ptr %24, i64 16
  store ptr %21, ptr %28, align 8, !tbaa !16
  br label %29

29:                                               ; preds = %27, %20
  store ptr %21, ptr %23, align 8, !tbaa !14
  %30 = getelementptr inbounds i8, ptr %0, i64 24
  %31 = load i64, ptr %30, align 8, !tbaa !17
  %32 = add i64 %31, 1
  store i64 %32, ptr %30, align 8, !tbaa !17
  %33 = getelementptr inbounds i8, ptr %0, i64 8
  %34 = load ptr, ptr %33, align 8, !tbaa !11
  %35 = icmp eq ptr %22, %34
  br i1 %35, label %36, label %37

36:                                               ; preds = %29
  store ptr %21, ptr %33, align 8, !tbaa !11
  br label %37

37:                                               ; preds = %36, %29
  %38 = tail call zeroext i8 @obdeque_iterate_prev(ptr noundef nonnull %0, ptr noundef nonnull %1)
  %.not34 = icmp eq i8 %38, 0
  br i1 %.not34, label %39, label %40

39:                                               ; preds = %37
  tail call void @__assert_fail(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.1, i32 noundef 199, ptr noundef nonnull @__PRETTY_FUNCTION__.obdeque_add_at_iterator) #2
  unreachable

40:                                               ; preds = %37
  ret void
}

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, !7, i64 8}
!6 = !{!"obdeque_iterator_struct", !7, i64 0, !7, i64 8, !7, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 16}
!11 = !{!12, !7, i64 8}
!12 = !{!"obdeque_struct", !7, i64 0, !7, i64 8, !7, i64 16, !13, i64 24}
!13 = !{!"long", !8, i64 0}
!14 = !{!15, !7, i64 24}
!15 = !{!"obdeque_node_struct", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!16 = !{!15, !7, i64 16}
!17 = !{!12, !13, i64 24}


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