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

; 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.obmap_struct = type { ptr, i8, ptr, ptr, i32 }

@.str.1 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [17 x i8], align 1
@stderr = external global ptr, align 8
@.str.15 = external hidden unnamed_addr constant [6 x i8], align 1
@__PRETTY_FUNCTION__.obmap_display = external hidden unnamed_addr constant [32 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [13 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

declare ptr @obdeque_head_iterator(ptr noundef) #2

declare ptr @obdeque_obj_at_iterator(ptr noundef, ptr noundef) #2

declare ptr @ob_release(ptr noundef) #2

declare zeroext i8 @obdeque_iterate_next(ptr noundef, ptr noundef) #2

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

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

declare void @ob_display(ptr noundef) #2

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

9:                                                ; preds = %1
  br label %11

10:                                               ; preds = %1
  call void @__assert_fail(ptr noundef @.str.9, ptr noundef @.str.1, i32 noundef 385, ptr noundef @__PRETTY_FUNCTION__.obmap_display) #6
  unreachable

11:                                               ; preds = %9
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = call zeroext i8 @ob_has_class(ptr noundef %12, ptr noundef @.str.15)
  %14 = icmp ne i8 %13, 0
  br i1 %14, label %15, label %16

15:                                               ; preds = %11
  br label %17

16:                                               ; preds = %11
  call void @__assert_fail(ptr noundef @.str.21, ptr noundef @.str.1, i32 noundef 386, ptr noundef @__PRETTY_FUNCTION__.obmap_display) #6
  unreachable

17:                                               ; preds = %15
  %18 = load ptr, ptr @stderr, align 8, !tbaa !5
  %19 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %18, ptr noundef @.str.22) #5
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.obmap_struct, ptr %20, i32 0, i32 3
  %22 = load ptr, ptr %21, align 8, !tbaa !9
  %23 = call ptr @obdeque_head_iterator(ptr noundef %22)
  store ptr %23, ptr %4, align 8, !tbaa !5
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = icmp ne ptr %24, null
  br i1 %25, label %27, label %26

26:                                               ; preds = %17
  store i32 1, ptr %5, align 4
  br label %46

27:                                               ; preds = %17
  br label %28

28:                                               ; preds = %34, %27
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.obmap_struct, ptr %29, i32 0, i32 3
  %31 = load ptr, ptr %30, align 8, !tbaa !9
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = call ptr @obdeque_obj_at_iterator(ptr noundef %31, ptr noundef %32)
  call void @ob_display(ptr noundef %33)
  br label %34

34:                                               ; preds = %28
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.obmap_struct, ptr %35, i32 0, i32 3
  %37 = load ptr, ptr %36, align 8, !tbaa !9
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = call zeroext i8 @obdeque_iterate_next(ptr noundef %37, ptr noundef %38)
  %40 = icmp ne i8 %39, 0
  br i1 %40, label %28, label %41, !llvm.loop !12

41:                                               ; preds = %34
  %42 = load ptr, ptr @stderr, align 8, !tbaa !5
  %43 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %42, ptr noundef @.str.23) #5
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = call ptr @ob_release(ptr noundef %44)
  store i32 1, ptr %5, align 4
  br label %46

46:                                               ; preds = %41, %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  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 = { "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 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 #5 = { nounwind }
attributes #6 = { 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 24}
!10 = !{!"obmap_struct", !6, i64 0, !7, i64 8, !6, i64 16, !6, i64 24, !11, i64 32}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"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 [74 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [17 x i8], align 1
@stderr = external local_unnamed_addr global ptr, align 8
@.str.15 = external hidden unnamed_addr constant [6 x i8], align 1
@__PRETTY_FUNCTION__.obmap_display = external hidden unnamed_addr constant [32 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [13 x i8], align 1

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

declare ptr @obdeque_head_iterator(ptr noundef) local_unnamed_addr #1

declare ptr @obdeque_obj_at_iterator(ptr noundef, ptr noundef) local_unnamed_addr #1

declare ptr @ob_release(ptr noundef) local_unnamed_addr #1

declare zeroext i8 @obdeque_iterate_next(ptr noundef, ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #2

declare void @ob_display(ptr noundef) local_unnamed_addr #1

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

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

3:                                                ; preds = %1
  %4 = tail call zeroext i8 @ob_has_class(ptr noundef nonnull %0, ptr noundef nonnull @.str.15) #5
  %.not10 = icmp eq i8 %4, 0
  br i1 %.not10, label %5, label %6

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

6:                                                ; preds = %3
  %7 = load ptr, ptr @stderr, align 8, !tbaa !5
  %8 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %7, ptr noundef nonnull @.str.22) #6
  %9 = getelementptr inbounds i8, ptr %0, i64 24
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  %11 = tail call ptr @obdeque_head_iterator(ptr noundef %10) #5
  %.not11 = icmp eq ptr %11, null
  br i1 %.not11, label %20, label %.preheader

.preheader:                                       ; preds = %6, %.preheader
  %12 = load ptr, ptr %9, align 8, !tbaa !9
  %13 = tail call ptr @obdeque_obj_at_iterator(ptr noundef %12, ptr noundef nonnull %11) #5
  tail call void @ob_display(ptr noundef %13) #5
  %14 = load ptr, ptr %9, align 8, !tbaa !9
  %15 = tail call zeroext i8 @obdeque_iterate_next(ptr noundef %14, ptr noundef nonnull %11) #5
  %.not12 = icmp eq i8 %15, 0
  br i1 %.not12, label %16, label %.preheader, !llvm.loop !12

16:                                               ; preds = %.preheader
  %17 = load ptr, ptr @stderr, align 8, !tbaa !5
  %18 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %17, ptr noundef nonnull @.str.23) #6
  %19 = tail call ptr @ob_release(ptr noundef nonnull %11) #5
  br label %20

20:                                               ; preds = %6, %16
  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 = { "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 = { 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 #3 = { 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 #4 = { noreturn nounwind }
attributes #5 = { nounwind }
attributes #6 = { cold 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 24}
!10 = !{!"obmap_struct", !6, i64 0, !7, i64 8, !6, i64 16, !6, i64 24, !11, i64 32}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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