; 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
@__PRETTY_FUNCTION__.obdeque_remove_at_iterator = external hidden unnamed_addr constant [63 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [19 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: nounwind uwtable
declare dso_local zeroext i8 @obdeque_iterate_next(ptr noundef, ptr noundef) #2

declare ptr @ob_release(ptr noundef) #3

; 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
define dso_local void @obdeque_remove_at_iterator(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = icmp ne ptr %7, null
  br i1 %8, label %9, label %10

9:                                                ; preds = %2
  br label %11

10:                                               ; preds = %2
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 363, ptr noundef @__PRETTY_FUNCTION__.obdeque_remove_at_iterator) #5
  unreachable

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

14:                                               ; preds = %11
  br label %16

15:                                               ; preds = %11
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 364, ptr noundef @__PRETTY_FUNCTION__.obdeque_remove_at_iterator) #5
  unreachable

16:                                               ; preds = %14
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = load ptr, ptr %4, 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 = icmp eq ptr %17, %20
  br i1 %21, label %22, label %23

22:                                               ; preds = %16
  br label %24

23:                                               ; preds = %16
  call void @__assert_fail(ptr noundef @.str.12, ptr noundef @.str.1, i32 noundef 365, ptr noundef @__PRETTY_FUNCTION__.obdeque_remove_at_iterator) #5
  unreachable

24:                                               ; preds = %22
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.obdeque_iterator_struct, ptr %25, i32 0, i32 2
  %27 = load ptr, ptr %26, align 8, !tbaa !11
  %28 = icmp ne ptr %27, null
  br i1 %28, label %30, label %29

29:                                               ; preds = %24
  store i32 1, ptr %6, align 4
  br label %127

30:                                               ; preds = %24
  %31 = load ptr, ptr %4, 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 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.obdeque_struct, ptr %34, i32 0, i32 1
  %36 = load ptr, ptr %35, align 8, !tbaa !12
  %37 = icmp eq ptr %33, %36
  br i1 %37, label %38, label %46

38:                                               ; preds = %30
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.obdeque_iterator_struct, ptr %39, i32 0, i32 2
  %41 = load ptr, ptr %40, align 8, !tbaa !11
  %42 = getelementptr inbounds %struct.obdeque_node_struct, ptr %41, i32 0, i32 2
  %43 = load ptr, ptr %42, align 8, !tbaa !15
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.obdeque_struct, ptr %44, i32 0, i32 1
  store ptr %43, ptr %45, align 8, !tbaa !12
  br label %46

46:                                               ; preds = %38, %30
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.obdeque_iterator_struct, ptr %47, i32 0, i32 2
  %49 = load ptr, ptr %48, align 8, !tbaa !11
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.obdeque_struct, ptr %50, i32 0, i32 2
  %52 = load ptr, ptr %51, align 8, !tbaa !17
  %53 = icmp eq ptr %49, %52
  br i1 %53, label %54, label %62

54:                                               ; preds = %46
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.obdeque_iterator_struct, ptr %55, i32 0, i32 2
  %57 = load ptr, ptr %56, align 8, !tbaa !11
  %58 = getelementptr inbounds %struct.obdeque_node_struct, ptr %57, i32 0, i32 3
  %59 = load ptr, ptr %58, align 8, !tbaa !18
  %60 = load ptr, ptr %3, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.obdeque_struct, ptr %60, i32 0, i32 2
  store ptr %59, ptr %61, align 8, !tbaa !17
  br label %62

62:                                               ; preds = %54, %46
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.obdeque_iterator_struct, ptr %63, i32 0, i32 2
  %65 = load ptr, ptr %64, align 8, !tbaa !11
  %66 = getelementptr inbounds %struct.obdeque_node_struct, ptr %65, i32 0, i32 3
  %67 = load ptr, ptr %66, align 8, !tbaa !18
  %68 = icmp ne ptr %67, null
  br i1 %68, label %69, label %81

69:                                               ; preds = %62
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.obdeque_iterator_struct, ptr %70, i32 0, i32 2
  %72 = load ptr, ptr %71, align 8, !tbaa !11
  %73 = getelementptr inbounds %struct.obdeque_node_struct, ptr %72, i32 0, i32 2
  %74 = load ptr, ptr %73, align 8, !tbaa !15
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.obdeque_iterator_struct, ptr %75, i32 0, i32 2
  %77 = load ptr, ptr %76, align 8, !tbaa !11
  %78 = getelementptr inbounds %struct.obdeque_node_struct, ptr %77, i32 0, i32 3
  %79 = load ptr, ptr %78, align 8, !tbaa !18
  %80 = getelementptr inbounds %struct.obdeque_node_struct, ptr %79, i32 0, i32 2
  store ptr %74, ptr %80, align 8, !tbaa !15
  br label %81

81:                                               ; preds = %69, %62
  %82 = load ptr, ptr %4, 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 = getelementptr inbounds %struct.obdeque_node_struct, ptr %84, i32 0, i32 2
  %86 = load ptr, ptr %85, align 8, !tbaa !15
  %87 = icmp ne ptr %86, null
  br i1 %87, label %88, label %100

88:                                               ; preds = %81
  %89 = load ptr, ptr %4, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.obdeque_iterator_struct, ptr %89, i32 0, i32 2
  %91 = load ptr, ptr %90, align 8, !tbaa !11
  %92 = getelementptr inbounds %struct.obdeque_node_struct, ptr %91, i32 0, i32 3
  %93 = load ptr, ptr %92, align 8, !tbaa !18
  %94 = load ptr, ptr %4, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.obdeque_iterator_struct, ptr %94, i32 0, i32 2
  %96 = load ptr, ptr %95, align 8, !tbaa !11
  %97 = getelementptr inbounds %struct.obdeque_node_struct, ptr %96, i32 0, i32 2
  %98 = load ptr, ptr %97, align 8, !tbaa !15
  %99 = getelementptr inbounds %struct.obdeque_node_struct, ptr %98, i32 0, i32 3
  store ptr %93, ptr %99, align 8, !tbaa !18
  br label %100

100:                                              ; preds = %88, %81
  %101 = load ptr, ptr %3, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.obdeque_struct, ptr %101, i32 0, i32 3
  %103 = load i64, ptr %102, align 8, !tbaa !19
  %104 = add i64 %103, -1
  store i64 %104, ptr %102, align 8, !tbaa !19
  %105 = load ptr, ptr %4, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.obdeque_iterator_struct, ptr %105, i32 0, i32 2
  %107 = load ptr, ptr %106, align 8, !tbaa !11
  store ptr %107, ptr %5, align 8, !tbaa !5
  %108 = load ptr, ptr %3, align 8, !tbaa !5
  %109 = load ptr, ptr %4, align 8, !tbaa !5
  %110 = call zeroext i8 @obdeque_iterate_next(ptr noundef %108, ptr noundef %109)
  %111 = icmp ne i8 %110, 0
  br i1 %111, label %120, label %112

112:                                              ; preds = %100
  %113 = load ptr, ptr %3, align 8, !tbaa !5
  %114 = load ptr, ptr %4, align 8, !tbaa !5
  %115 = call zeroext i8 @obdeque_iterate_prev(ptr noundef %113, ptr noundef %114)
  %116 = icmp ne i8 %115, 0
  br i1 %116, label %120, label %117

117:                                              ; preds = %112
  %118 = load ptr, ptr %4, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.obdeque_iterator_struct, ptr %118, i32 0, i32 2
  store ptr null, ptr %119, align 8, !tbaa !11
  br label %120

120:                                              ; preds = %117, %112, %100
  %121 = load ptr, ptr %5, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct.obdeque_node_struct, ptr %121, i32 0, i32 2
  store ptr null, ptr %122, align 8, !tbaa !15
  %123 = load ptr, ptr %5, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.obdeque_node_struct, ptr %123, i32 0, i32 3
  store ptr null, ptr %124, align 8, !tbaa !18
  %125 = load ptr, ptr %5, align 8, !tbaa !5
  %126 = call ptr @ob_release(ptr noundef %125)
  store i32 1, ptr %6, align 4
  br label %127

127:                                              ; preds = %120, %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  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 = { "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, !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 16}
!16 = !{!"obdeque_node_struct", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!17 = !{!13, !6, i64 16}
!18 = !{!16, !6, i64 24}
!19 = !{!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
@__PRETTY_FUNCTION__.obdeque_remove_at_iterator = external hidden unnamed_addr constant [63 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [19 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_next(ptr noundef, ptr noundef) local_unnamed_addr #1

declare ptr @ob_release(ptr noundef) local_unnamed_addr #2

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

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

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

4:                                                ; preds = %2
  %.not34 = icmp eq ptr %1, null
  br i1 %.not34, label %5, label %6

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

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

10:                                               ; preds = %6
  tail call void @__assert_fail(ptr noundef nonnull @.str.12, ptr noundef nonnull @.str.1, i32 noundef 365, ptr noundef nonnull @__PRETTY_FUNCTION__.obdeque_remove_at_iterator) #4
  unreachable

11:                                               ; preds = %6
  %12 = getelementptr inbounds i8, ptr %1, i64 16
  %13 = load ptr, ptr %12, align 8, !tbaa !10
  %.not35 = icmp eq ptr %13, null
  br i1 %.not35, label %43, label %14

14:                                               ; preds = %11
  %15 = getelementptr inbounds i8, ptr %0, i64 8
  %16 = load ptr, ptr %15, align 8, !tbaa !11
  %17 = icmp eq ptr %13, %16
  br i1 %17, label %18, label %21

18:                                               ; preds = %14
  %19 = getelementptr inbounds i8, ptr %13, i64 16
  %20 = load ptr, ptr %19, align 8, !tbaa !14
  store ptr %20, ptr %15, align 8, !tbaa !11
  br label %21

21:                                               ; preds = %18, %14
  %22 = getelementptr inbounds i8, ptr %0, i64 16
  %23 = load ptr, ptr %22, align 8, !tbaa !16
  %24 = icmp eq ptr %13, %23
  %25 = getelementptr inbounds i8, ptr %13, i64 24
  %26 = load ptr, ptr %25, align 8, !tbaa !17
  br i1 %24, label %27, label %._crit_edge

27:                                               ; preds = %21
  store ptr %26, ptr %22, align 8, !tbaa !16
  br label %._crit_edge

._crit_edge:                                      ; preds = %21, %27
  %.not36 = icmp eq ptr %26, null
  %.phi.trans.insert41 = getelementptr inbounds i8, ptr %13, i64 16
  %.pre42 = load ptr, ptr %.phi.trans.insert41, align 8, !tbaa !14
  br i1 %.not36, label %._crit_edge40, label %28

28:                                               ; preds = %._crit_edge
  %29 = getelementptr inbounds i8, ptr %26, i64 16
  store ptr %.pre42, ptr %29, align 8, !tbaa !14
  br label %._crit_edge40

._crit_edge40:                                    ; preds = %._crit_edge, %28
  %30 = getelementptr inbounds i8, ptr %13, i64 16
  %.not37 = icmp eq ptr %.pre42, null
  br i1 %.not37, label %33, label %31

31:                                               ; preds = %._crit_edge40
  %32 = getelementptr inbounds i8, ptr %.pre42, i64 24
  store ptr %26, ptr %32, align 8, !tbaa !17
  br label %33

33:                                               ; preds = %31, %._crit_edge40
  %34 = getelementptr inbounds i8, ptr %0, i64 24
  %35 = load i64, ptr %34, align 8, !tbaa !18
  %36 = add i64 %35, -1
  store i64 %36, ptr %34, align 8, !tbaa !18
  %37 = tail call zeroext i8 @obdeque_iterate_next(ptr noundef nonnull %0, ptr noundef nonnull %1)
  %.not38 = icmp eq i8 %37, 0
  br i1 %.not38, label %38, label %41

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

40:                                               ; preds = %38
  store ptr null, ptr %12, align 8, !tbaa !10
  br label %41

41:                                               ; preds = %40, %38, %33
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %30, i8 0, i64 16, i1 false)
  %42 = tail call ptr @ob_release(ptr noundef nonnull %13) #5
  br label %43

43:                                               ; preds = %11, %41
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { noreturn nounwind }
attributes #5 = { 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 16}
!15 = !{!"obdeque_node_struct", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!16 = !{!12, !7, i64 16}
!17 = !{!15, !7, i64 24}
!18 = !{!12, !13, i64 24}


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