; 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_struct = type { ptr, ptr, ptr, i64 }

@.str.1 = external hidden unnamed_addr constant [76 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [2 x i8], align 1
@__PRETTY_FUNCTION__.obdeque_compare = external hidden unnamed_addr constant [49 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [27 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 ptr @obdeque_head_iterator(ptr noundef) #2

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

; 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

declare signext i8 @ob_compare(ptr noundef, ptr noundef) #3

declare zeroext i8 @ob_has_class(ptr noundef, ptr noundef) #3

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

16:                                               ; preds = %2
  br label %18

17:                                               ; preds = %2
  call void @__assert_fail(ptr noundef @.str.23, ptr noundef @.str.1, i32 noundef 656, ptr noundef @__PRETTY_FUNCTION__.obdeque_compare) #5
  unreachable

18:                                               ; preds = %16
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = icmp ne ptr %19, null
  br i1 %20, label %21, label %22

21:                                               ; preds = %18
  br label %23

22:                                               ; preds = %18
  call void @__assert_fail(ptr noundef @.str.24, ptr noundef @.str.1, i32 noundef 657, ptr noundef @__PRETTY_FUNCTION__.obdeque_compare) #5
  unreachable

23:                                               ; preds = %21
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = call zeroext i8 @ob_has_class(ptr noundef %24, ptr noundef @.str.21)
  %26 = icmp ne i8 %25, 0
  br i1 %26, label %27, label %28

27:                                               ; preds = %23
  br label %29

28:                                               ; preds = %23
  call void @__assert_fail(ptr noundef @.str.25, ptr noundef @.str.1, i32 noundef 658, ptr noundef @__PRETTY_FUNCTION__.obdeque_compare) #5
  unreachable

29:                                               ; preds = %27
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = call zeroext i8 @ob_has_class(ptr noundef %30, ptr noundef @.str.21)
  %32 = icmp ne i8 %31, 0
  br i1 %32, label %33, label %34

33:                                               ; preds = %29
  br label %35

34:                                               ; preds = %29
  call void @__assert_fail(ptr noundef @.str.26, ptr noundef @.str.1, i32 noundef 659, ptr noundef @__PRETTY_FUNCTION__.obdeque_compare) #5
  unreachable

35:                                               ; preds = %33
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.obdeque_struct, ptr %36, i32 0, i32 3
  %38 = load i64, ptr %37, align 8, !tbaa !10
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.obdeque_struct, ptr %39, i32 0, i32 3
  %41 = load i64, ptr %40, align 8, !tbaa !10
  %42 = icmp ne i64 %38, %41
  br i1 %42, label %43, label %44

43:                                               ; preds = %35
  store i8 2, ptr %3, align 1
  store i32 1, ptr %11, align 4
  br label %96

44:                                               ; preds = %35
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  %46 = call ptr @obdeque_head_iterator(ptr noundef %45)
  store ptr %46, ptr %9, align 8, !tbaa !5
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  %48 = call ptr @obdeque_head_iterator(ptr noundef %47)
  store ptr %48, ptr %10, align 8, !tbaa !5
  %49 = load ptr, ptr %9, align 8, !tbaa !5
  %50 = icmp ne ptr %49, null
  br i1 %50, label %55, label %51

51:                                               ; preds = %44
  %52 = load ptr, ptr %10, align 8, !tbaa !5
  %53 = icmp ne ptr %52, null
  br i1 %53, label %55, label %54

54:                                               ; preds = %51
  store i8 0, ptr %3, align 1
  store i32 1, ptr %11, align 4
  br label %96

55:                                               ; preds = %51, %44
  %56 = load ptr, ptr %9, align 8, !tbaa !5
  %57 = icmp ne ptr %56, null
  br i1 %57, label %58, label %89

58:                                               ; preds = %55
  %59 = load ptr, ptr %10, align 8, !tbaa !5
  %60 = icmp ne ptr %59, null
  br i1 %60, label %61, label %89

61:                                               ; preds = %58
  br label %62

62:                                               ; preds = %86, %61
  %63 = load ptr, ptr %7, align 8, !tbaa !5
  %64 = load ptr, ptr %9, align 8, !tbaa !5
  %65 = call ptr @obdeque_obj_at_iterator(ptr noundef %63, ptr noundef %64)
  %66 = load ptr, ptr %8, align 8, !tbaa !5
  %67 = load ptr, ptr %10, align 8, !tbaa !5
  %68 = call ptr @obdeque_obj_at_iterator(ptr noundef %66, ptr noundef %67)
  %69 = call signext i8 @ob_compare(ptr noundef %65, ptr noundef %68)
  %70 = sext i8 %69 to i32
  %71 = icmp ne i32 %70, 0
  br i1 %71, label %72, label %73

72:                                               ; preds = %62
  store i8 2, ptr %6, align 1, !tbaa !9
  br label %88

73:                                               ; preds = %62
  br label %74

74:                                               ; preds = %73
  %75 = load ptr, ptr %7, align 8, !tbaa !5
  %76 = load ptr, ptr %9, align 8, !tbaa !5
  %77 = call zeroext i8 @obdeque_iterate_next(ptr noundef %75, ptr noundef %76)
  %78 = zext i8 %77 to i32
  %79 = icmp ne i32 %78, 0
  br i1 %79, label %80, label %86

80:                                               ; preds = %74
  %81 = load ptr, ptr %8, align 8, !tbaa !5
  %82 = load ptr, ptr %10, align 8, !tbaa !5
  %83 = call zeroext i8 @obdeque_iterate_next(ptr noundef %81, ptr noundef %82)
  %84 = zext i8 %83 to i32
  %85 = icmp ne i32 %84, 0
  br label %86

86:                                               ; preds = %80, %74
  %87 = phi i1 [ false, %74 ], [ %85, %80 ]
  br i1 %87, label %62, label %88, !llvm.loop !13

88:                                               ; preds = %86, %72
  br label %90

89:                                               ; preds = %58, %55
  store i8 2, ptr %6, align 1, !tbaa !9
  br label %90

90:                                               ; preds = %89, %88
  %91 = load ptr, ptr %9, align 8, !tbaa !5
  %92 = call ptr @ob_release(ptr noundef %91)
  %93 = load ptr, ptr %10, align 8, !tbaa !5
  %94 = call ptr @ob_release(ptr noundef %93)
  %95 = load i8, ptr %6, align 1, !tbaa !9
  store i8 %95, ptr %3, align 1
  store i32 1, ptr %11, align 4
  br label %96

96:                                               ; preds = %90, %54, %43
  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 1, ptr %6) #4
  %97 = load i8, ptr %3, align 1
  ret i8 %97
}

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 = !{!7, !7, i64 0}
!10 = !{!11, !12, i64 24}
!11 = !{!"obdeque_struct", !6, i64 0, !6, i64 8, !6, i64 16, !12, i64 24}
!12 = !{!"long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; 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.21 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [2 x i8], align 1
@__PRETTY_FUNCTION__.obdeque_compare = external hidden unnamed_addr constant [49 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [27 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 ptr @obdeque_head_iterator(ptr noundef) local_unnamed_addr #1

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

; 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

declare signext i8 @ob_compare(ptr noundef, ptr noundef) local_unnamed_addr #2

declare zeroext i8 @ob_has_class(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local signext range(i8 0, 3) i8 @obdeque_compare(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.23, ptr noundef nonnull @.str.1, i32 noundef 656, ptr noundef nonnull @__PRETTY_FUNCTION__.obdeque_compare) #3
  unreachable

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

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

6:                                                ; preds = %4
  %7 = tail call zeroext i8 @ob_has_class(ptr noundef nonnull %0, ptr noundef nonnull @.str.21) #4
  %.not32 = icmp eq i8 %7, 0
  br i1 %.not32, label %8, label %9

8:                                                ; preds = %6
  tail call void @__assert_fail(ptr noundef nonnull @.str.25, ptr noundef nonnull @.str.1, i32 noundef 658, ptr noundef nonnull @__PRETTY_FUNCTION__.obdeque_compare) #3
  unreachable

9:                                                ; preds = %6
  %10 = tail call zeroext i8 @ob_has_class(ptr noundef nonnull %1, ptr noundef nonnull @.str.21) #4
  %.not33 = icmp eq i8 %10, 0
  br i1 %.not33, label %11, label %12

11:                                               ; preds = %9
  tail call void @__assert_fail(ptr noundef nonnull @.str.26, ptr noundef nonnull @.str.1, i32 noundef 659, ptr noundef nonnull @__PRETTY_FUNCTION__.obdeque_compare) #3
  unreachable

12:                                               ; preds = %9
  %13 = getelementptr inbounds i8, ptr %0, i64 24
  %14 = load i64, ptr %13, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %1, i64 24
  %16 = load i64, ptr %15, align 8, !tbaa !5
  %.not34 = icmp eq i64 %14, %16
  br i1 %.not34, label %17, label %32

17:                                               ; preds = %12
  %18 = tail call ptr @obdeque_head_iterator(ptr noundef nonnull %0)
  %19 = tail call ptr @obdeque_head_iterator(ptr noundef nonnull %1)
  %20 = icmp ne ptr %18, null
  %21 = icmp ne ptr %19, null
  %or.cond = select i1 %20, i1 true, i1 %21
  br i1 %or.cond, label %22, label %32

22:                                               ; preds = %17
  %or.cond3 = select i1 %20, i1 %21, i1 false
  br i1 %or.cond3, label %.preheader, label %.critedge

.preheader:                                       ; preds = %22, %28
  %23 = tail call ptr @obdeque_obj_at_iterator(ptr noundef nonnull %0, ptr noundef nonnull %18)
  %24 = tail call ptr @obdeque_obj_at_iterator(ptr noundef nonnull %1, ptr noundef nonnull %19)
  %25 = tail call signext i8 @ob_compare(ptr noundef %23, ptr noundef %24) #4
  %.not35 = icmp eq i8 %25, 0
  br i1 %.not35, label %26, label %.critedge

26:                                               ; preds = %.preheader
  %27 = tail call zeroext i8 @obdeque_iterate_next(ptr noundef nonnull %0, ptr noundef nonnull %18)
  %.not36 = icmp eq i8 %27, 0
  br i1 %.not36, label %.critedge, label %28

28:                                               ; preds = %26
  %29 = tail call zeroext i8 @obdeque_iterate_next(ptr noundef nonnull %1, ptr noundef nonnull %19)
  %.not37 = icmp eq i8 %29, 0
  br i1 %.not37, label %.critedge, label %.preheader, !llvm.loop !11

.critedge:                                        ; preds = %.preheader, %26, %28, %22
  %.028 = phi i8 [ 2, %22 ], [ 2, %.preheader ], [ 0, %26 ], [ 0, %28 ]
  %30 = tail call ptr @ob_release(ptr noundef %18) #4
  %31 = tail call ptr @ob_release(ptr noundef %19) #4
  br label %32

32:                                               ; preds = %17, %12, %.critedge
  %.0 = phi i8 [ %.028, %.critedge ], [ 2, %12 ], [ 0, %17 ]
  ret i8 %.0
}

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 = { noreturn nounwind }
attributes #4 = { 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 = !{!"obdeque_struct", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass