; LLVM IR from pmwkaa/monotone :: monotone/engine/engine (op)

; 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.Runtime = type { %struct.ExceptionMgr, %struct.Error, ptr }
%struct.ExceptionMgr = type { ptr }
%struct.Error = type { [256 x i8], i32, ptr, ptr, i32, ptr, ptr }
%struct.Buf = type { ptr, ptr, ptr }
%struct.Guard = type { ptr, ptr, ptr }
%struct.Id = type { i64, i64 }
%struct.Engine = type { %struct.Mutex, %struct.CondVar, %struct.Mapping, %struct.Pipeline, %struct.StorageMgr, ptr, ptr, ptr }
%struct.Mutex = type { %union.pthread_mutex_t }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%struct.CondVar = type { %union.pthread_cond_t }
%union.pthread_cond_t = type { %struct.__pthread_cond_s }
%struct.__pthread_cond_s = type { %union.__atomic_wide_counter, %union.__atomic_wide_counter, [2 x i32], [2 x i32], i32, i32, [2 x i32] }
%union.__atomic_wide_counter = type { i64 }
%struct.Mapping = type { %struct.Rbtree, i32 }
%struct.Rbtree = type { ptr }
%struct.Pipeline = type { %struct.List, i32, ptr }
%struct.List = type { ptr, ptr }
%struct.StorageMgr = type { %struct.List, i32, ptr }
%struct.Exception = type { ptr, i8, ptr, [1 x %struct.__jmp_buf_tag] }
%struct.__jmp_buf_tag = type { [8 x i64], i32, %struct.__sigset_t }
%struct.__sigset_t = type { [16 x i64] }
%struct.Slice = type { i64, i64, %struct.RbtreeNode }
%struct.RbtreeNode = type { ptr, ptr, ptr, i8 }

@mn_runtime = external thread_local global %struct.Runtime, align 8
@.str = external hidden unnamed_addr constant [77 x i8], align 1
@__func__.engine_fill_nolock = external hidden unnamed_addr constant [19 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [33 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @engine_fill_nolock(ptr noundef %0, i64 noundef %1, i64 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca %struct.Buf, align 8
  %8 = alloca %struct.Guard, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca %struct.Id, align 1
  %14 = alloca %struct.Id, align 1
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  store i64 %2, ptr %6, align 8, !tbaa !9
  %17 = load i64, ptr %5, align 8, !tbaa !9
  %18 = load i64, ptr %6, align 8, !tbaa !9
  %19 = icmp ugt i64 %17, %18
  %20 = xor i1 %19, true
  %21 = xor i1 %20, true
  %22 = zext i1 %21 to i32
  %23 = sext i32 %22 to i64
  %24 = call i64 @llvm.expect.i64(i64 %23, i64 0)
  %25 = icmp ne i64 %24, 0
  br i1 %25, label %26, label %31

26:                                               ; preds = %3
  %27 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %28 = getelementptr inbounds %struct.Runtime, ptr %27, i32 0, i32 1
  %29 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %30 = getelementptr inbounds %struct.Runtime, ptr %29, i32 0, i32 0
  call void (ptr, ptr, ptr, ptr, i32, ptr, ...) @error_throw_as(ptr noundef %28, ptr noundef %30, ptr noundef @.str, ptr noundef @__func__.engine_fill_nolock, i32 noundef 71, ptr noundef @.str.1) #8
  unreachable

31:                                               ; preds = %3
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.Engine, ptr %32, i32 0, i32 2
  %34 = getelementptr inbounds %struct.Mapping, ptr %33, i32 0, i32 1
  %35 = load i32, ptr %34, align 8, !tbaa !11
  %36 = icmp eq i32 %35, 0
  %37 = xor i1 %36, true
  %38 = xor i1 %37, true
  %39 = zext i1 %38 to i32
  %40 = sext i32 %39 to i64
  %41 = call i64 @llvm.expect.i64(i64 %40, i64 0)
  %42 = icmp ne i64 %41, 0
  br i1 %42, label %43, label %48

43:                                               ; preds = %31
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = load i64, ptr %5, align 8, !tbaa !9
  %46 = load i64, ptr %6, align 8, !tbaa !9
  %47 = call ptr @engine_create(ptr noundef %44, i64 noundef %45, i64 noundef %46)
  br label %144

48:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 24, ptr %7) #9
  call void @buf_init(ptr noundef %7)
  call void @llvm.lifetime.start.p0(i64 24, ptr %8) #9
  %49 = getelementptr inbounds %struct.Guard, ptr %8, i32 0, i32 0
  store ptr @buf_free, ptr %49, align 8, !tbaa !21
  %50 = getelementptr inbounds %struct.Guard, ptr %8, i32 0, i32 1
  store ptr %7, ptr %50, align 8, !tbaa !23
  %51 = getelementptr inbounds %struct.Guard, ptr %8, i32 0, i32 2
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #9
  %52 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %53 = getelementptr inbounds %struct.Runtime, ptr %52, i32 0, i32 0
  %54 = getelementptr inbounds %struct.ExceptionMgr, ptr %53, i32 0, i32 0
  %55 = load ptr, ptr %54, align 8, !tbaa !24
  store ptr %55, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #9
  %56 = load ptr, ptr %9, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.Exception, ptr %56, i32 0, i32 2
  %58 = load ptr, ptr %57, align 8, !tbaa !28
  store ptr %58, ptr %10, align 8, !tbaa !5
  %59 = load ptr, ptr %9, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.Exception, ptr %59, i32 0, i32 2
  store ptr %8, ptr %60, align 8, !tbaa !28
  %61 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %61, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #9
  %62 = load ptr, ptr %11, align 8, !tbaa !5
  store ptr %62, ptr %51, align 8, !tbaa !31
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #9
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.Engine, ptr %63, i32 0, i32 2
  %65 = load i64, ptr %5, align 8, !tbaa !9
  %66 = call ptr @mapping_seek(ptr noundef %64, i64 noundef %65) #10
  store ptr %66, ptr %12, align 8, !tbaa !5
  br label %67

67:                                               ; preds = %112, %48
  %68 = load i64, ptr %5, align 8, !tbaa !9
  %69 = load i64, ptr %6, align 8, !tbaa !9
  %70 = icmp ule i64 %68, %69
  br i1 %70, label %71, label %122

71:                                               ; preds = %67
  %72 = load ptr, ptr %12, align 8, !tbaa !5
  %73 = icmp ne ptr %72, null
  br i1 %73, label %74, label %117

74:                                               ; preds = %71
  %75 = load i64, ptr %5, align 8, !tbaa !9
  %76 = load ptr, ptr %12, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.Slice, ptr %76, i32 0, i32 0
  %78 = load i64, ptr %77, align 8, !tbaa !32
  %79 = icmp ult i64 %75, %78
  br i1 %79, label %80, label %102

80:                                               ; preds = %74
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #9
  %81 = load i64, ptr %5, align 8, !tbaa !9
  %82 = getelementptr inbounds %struct.Id, ptr %13, i32 0, i32 0
  store i64 %81, ptr %82, align 1, !tbaa !35
  %83 = load i64, ptr %6, align 8, !tbaa !9
  %84 = load ptr, ptr %12, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.Slice, ptr %84, i32 0, i32 0
  %86 = load i64, ptr %85, align 8, !tbaa !32
  %87 = icmp ult i64 %83, %86
  br i1 %87, label %88, label %91

88:                                               ; preds = %80
  %89 = load i64, ptr %6, align 8, !tbaa !9
  %90 = getelementptr inbounds %struct.Id, ptr %13, i32 0, i32 1
  store i64 %89, ptr %90, align 1, !tbaa !37
  br label %97

91:                                               ; preds = %80
  %92 = load ptr, ptr %12, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.Slice, ptr %92, i32 0, i32 0
  %94 = load i64, ptr %93, align 8, !tbaa !32
  %95 = sub i64 %94, 1
  %96 = getelementptr inbounds %struct.Id, ptr %13, i32 0, i32 1
  store i64 %95, ptr %96, align 1, !tbaa !37
  br label %97

97:                                               ; preds = %91, %88
  call void @buf_write(ptr noundef %7, ptr noundef %13, i32 noundef 16)
  %98 = load ptr, ptr %12, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.Slice, ptr %98, i32 0, i32 1
  %100 = load i64, ptr %99, align 8, !tbaa !38
  %101 = add i64 %100, 1
  store i64 %101, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #9
  br label %112

102:                                              ; preds = %74
  %103 = load ptr, ptr %12, align 8, !tbaa !5
  %104 = load i64, ptr %5, align 8, !tbaa !9
  %105 = call zeroext i1 @slice_in(ptr noundef %103, i64 noundef %104)
  br i1 %105, label %106, label %111

106:                                              ; preds = %102
  %107 = load ptr, ptr %12, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.Slice, ptr %107, i32 0, i32 1
  %109 = load i64, ptr %108, align 8, !tbaa !38
  %110 = add i64 %109, 1
  store i64 %110, ptr %5, align 8, !tbaa !9
  br label %111

111:                                              ; preds = %106, %102
  br label %112

112:                                              ; preds = %111, %97
  %113 = load ptr, ptr %4, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.Engine, ptr %113, i32 0, i32 2
  %115 = load ptr, ptr %12, align 8, !tbaa !5
  %116 = call ptr @mapping_next(ptr noundef %114, ptr noundef %115)
  store ptr %116, ptr %12, align 8, !tbaa !5
  br label %67, !llvm.loop !39

117:                                              ; preds = %71
  call void @llvm.lifetime.start.p0(i64 16, ptr %14) #9
  %118 = getelementptr inbounds %struct.Id, ptr %14, i32 0, i32 0
  %119 = load i64, ptr %5, align 8, !tbaa !9
  store i64 %119, ptr %118, align 1, !tbaa !35
  %120 = getelementptr inbounds %struct.Id, ptr %14, i32 0, i32 1
  %121 = load i64, ptr %6, align 8, !tbaa !9
  store i64 %121, ptr %120, align 1, !tbaa !37
  call void @buf_write(ptr noundef %7, ptr noundef %14, i32 noundef 16)
  call void @llvm.lifetime.end.p0(i64 16, ptr %14) #9
  br label %122

122:                                              ; preds = %117, %67
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #9
  %123 = getelementptr inbounds %struct.Buf, ptr %7, i32 0, i32 0
  %124 = load ptr, ptr %123, align 8, !tbaa !41
  store ptr %124, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #9
  %125 = getelementptr inbounds %struct.Buf, ptr %7, i32 0, i32 1
  %126 = load ptr, ptr %125, align 8, !tbaa !43
  store ptr %126, ptr %16, align 8, !tbaa !5
  br label %127

127:                                              ; preds = %140, %122
  %128 = load ptr, ptr %15, align 8, !tbaa !5
  %129 = load ptr, ptr %16, align 8, !tbaa !5
  %130 = icmp ult ptr %128, %129
  br i1 %130, label %131, label %143

131:                                              ; preds = %127
  %132 = load ptr, ptr %4, align 8, !tbaa !5
  %133 = load ptr, ptr %15, align 8, !tbaa !5
  %134 = getelementptr inbounds %struct.Id, ptr %133, i32 0, i32 0
  %135 = load i64, ptr %134, align 1, !tbaa !35
  %136 = load ptr, ptr %15, align 8, !tbaa !5
  %137 = getelementptr inbounds %struct.Id, ptr %136, i32 0, i32 1
  %138 = load i64, ptr %137, align 1, !tbaa !37
  %139 = call ptr @engine_create(ptr noundef %132, i64 noundef %135, i64 noundef %138)
  br label %140

140:                                              ; preds = %131
  %141 = load ptr, ptr %15, align 8, !tbaa !5
  %142 = getelementptr inbounds %struct.Id, ptr %141, i32 1
  store ptr %142, ptr %15, align 8, !tbaa !5
  br label %127, !llvm.loop !44

143:                                              ; preds = %127
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #9
  call void @guard_runner(ptr noundef %8)
  call void @llvm.lifetime.end.p0(i64 24, ptr %8) #9
  call void @llvm.lifetime.end.p0(i64 24, ptr %7) #9
  br label %144

144:                                              ; preds = %143, %43
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare i64 @llvm.expect.i64(i64, i64) #1

; Function Attrs: inlinehint noreturn nounwind uwtable
declare hidden void @error_throw_as(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, ...) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare nonnull ptr @llvm.threadlocal.address.p0(ptr nonnull) #3

; Function Attrs: nounwind uwtable
declare hidden ptr @engine_create(ptr noundef, i64 noundef, i64 noundef) #0

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @buf_init(ptr noundef) #5

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @buf_free(ptr noundef) #5

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

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @guard_runner(ptr noundef) #6

; Function Attrs: hot inlinehint nounwind uwtable
declare hidden ptr @mapping_seek(ptr noundef, i64 noundef) #7

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @buf_write(ptr noundef, ptr noundef, i32 noundef) #5

; Function Attrs: alwaysinline nounwind uwtable
declare hidden zeroext i1 @slice_in(ptr noundef, i64 noundef) #6

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @mapping_next(ptr noundef, ptr noundef) #5

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #2 = { inlinehint noreturn 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { inlinehint 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 #6 = { alwaysinline 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 #7 = { hot inlinehint 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 #8 = { noreturn }
attributes #9 = { nounwind }
attributes #10 = { hot }

!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, !17, i64 96}
!12 = !{!"Engine", !13, i64 0, !14, i64 40, !15, i64 88, !18, i64 104, !20, i64 136, !6, i64 168, !6, i64 176, !6, i64 184}
!13 = !{!"Mutex", !7, i64 0}
!14 = !{!"CondVar", !7, i64 0}
!15 = !{!"Mapping", !16, i64 0, !17, i64 8}
!16 = !{!"Rbtree", !6, i64 0}
!17 = !{!"int", !7, i64 0}
!18 = !{!"Pipeline", !19, i64 0, !17, i64 16, !6, i64 24}
!19 = !{!"List", !6, i64 0, !6, i64 8}
!20 = !{!"StorageMgr", !19, i64 0, !17, i64 16, !6, i64 24}
!21 = !{!22, !6, i64 0}
!22 = !{!"Guard", !6, i64 0, !6, i64 8, !6, i64 16}
!23 = !{!22, !6, i64 8}
!24 = !{!25, !6, i64 0}
!25 = !{!"Runtime", !26, i64 0, !27, i64 8, !6, i64 312}
!26 = !{!"ExceptionMgr", !6, i64 0}
!27 = !{!"Error", !7, i64 0, !17, i64 256, !6, i64 264, !6, i64 272, !17, i64 280, !6, i64 288, !6, i64 296}
!28 = !{!29, !6, i64 16}
!29 = !{!"Exception", !6, i64 0, !30, i64 8, !6, i64 16, !7, i64 24}
!30 = !{!"_Bool", !7, i64 0}
!31 = !{!22, !6, i64 16}
!32 = !{!33, !10, i64 0}
!33 = !{!"Slice", !10, i64 0, !10, i64 8, !34, i64 16}
!34 = !{!"RbtreeNode", !6, i64 0, !6, i64 8, !6, i64 16, !7, i64 24}
!35 = !{!36, !10, i64 0}
!36 = !{!"Id", !10, i64 0, !10, i64 8}
!37 = !{!36, !10, i64 8}
!38 = !{!33, !10, i64 8}
!39 = distinct !{!39, !40}
!40 = !{!"llvm.loop.mustprogress"}
!41 = !{!42, !6, i64 0}
!42 = !{!"Buf", !6, i64 0, !6, i64 8, !6, i64 16}
!43 = !{!42, !6, i64 8}
!44 = distinct !{!44, !40}


; 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.Runtime = type { %struct.ExceptionMgr, %struct.Error, ptr }
%struct.ExceptionMgr = type { ptr }
%struct.Error = type { [256 x i8], i32, ptr, ptr, i32, ptr, ptr }
%struct.Buf = type { ptr, ptr, ptr }
%struct.Guard = type { ptr, ptr, ptr }
%struct.Id = type { i64, i64 }

@mn_runtime = external thread_local global %struct.Runtime, align 8
@.str = external hidden unnamed_addr constant [77 x i8], align 1
@__func__.engine_fill_nolock = external hidden unnamed_addr constant [19 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [33 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @engine_fill_nolock(ptr noundef %0, i64 noundef %1, i64 noundef %2) local_unnamed_addr #0 {
  %4 = alloca %struct.Buf, align 8
  %5 = alloca %struct.Guard, align 8
  %6 = alloca %struct.Id, align 8
  %7 = alloca %struct.Id, align 8
  %8 = icmp ugt i64 %1, %2
  br i1 %8, label %9, label %12, !prof !5

9:                                                ; preds = %3
  %10 = tail call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %11 = getelementptr inbounds i8, ptr %10, i64 8
  tail call void (ptr, ptr, ptr, ptr, i32, ptr, ...) @error_throw_as(ptr noundef nonnull %11, ptr noundef nonnull %10, ptr noundef nonnull @.str, ptr noundef nonnull @__func__.engine_fill_nolock, i32 noundef 71, ptr noundef nonnull @.str.1) #7
  unreachable

12:                                               ; preds = %3
  %13 = getelementptr inbounds i8, ptr %0, i64 88
  %14 = getelementptr inbounds i8, ptr %0, i64 96
  %15 = load i32, ptr %14, align 8, !tbaa !6
  %16 = icmp eq i32 %15, 0
  br i1 %16, label %17, label %.lr.ph, !prof !5

17:                                               ; preds = %12
  %18 = tail call ptr @engine_create(ptr noundef nonnull %0, i64 noundef %1, i64 noundef %2)
  br label %57

.lr.ph:                                           ; preds = %12
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #8
  call void @buf_init(ptr noundef nonnull %4)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #8
  store ptr @buf_free, ptr %5, align 8, !tbaa !19
  %19 = getelementptr inbounds i8, ptr %5, i64 8
  store ptr %4, ptr %19, align 8, !tbaa !21
  %20 = getelementptr inbounds i8, ptr %5, i64 16
  %21 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %22 = load ptr, ptr %21, align 8, !tbaa !22
  %23 = getelementptr inbounds i8, ptr %22, i64 16
  %24 = load ptr, ptr %23, align 8, !tbaa !26
  store ptr %5, ptr %23, align 8, !tbaa !26
  store ptr %24, ptr %20, align 8, !tbaa !29
  %25 = call ptr @mapping_seek(ptr noundef nonnull %13, i64 noundef %1) #9
  %26 = getelementptr inbounds i8, ptr %6, i64 8
  br label %27

27:                                               ; preds = %.lr.ph, %43
  %.044 = phi i64 [ %1, %.lr.ph ], [ %.1, %43 ]
  %.03643 = phi ptr [ %25, %.lr.ph ], [ %44, %43 ]
  %.not40 = icmp eq ptr %.03643, null
  br i1 %.not40, label %45, label %28

28:                                               ; preds = %27
  %29 = load i64, ptr %.03643, align 8, !tbaa !30
  %30 = icmp ult i64 %.044, %29
  br i1 %30, label %31, label %37

31:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #8
  store i64 %.044, ptr %6, align 8, !tbaa !34
  %32 = icmp ugt i64 %29, %2
  %33 = add i64 %29, -1
  %spec.select = select i1 %32, i64 %2, i64 %33
  store i64 %spec.select, ptr %26, align 8, !tbaa !36
  call void @buf_write(ptr noundef nonnull %4, ptr noundef nonnull %6, i32 noundef 16)
  %34 = getelementptr inbounds i8, ptr %.03643, i64 8
  %35 = load i64, ptr %34, align 8, !tbaa !37
  %36 = add i64 %35, 1
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #8
  br label %43

37:                                               ; preds = %28
  %38 = call zeroext i1 @slice_in(ptr noundef nonnull %.03643, i64 noundef %.044)
  br i1 %38, label %39, label %43

39:                                               ; preds = %37
  %40 = getelementptr inbounds i8, ptr %.03643, i64 8
  %41 = load i64, ptr %40, align 8, !tbaa !37
  %42 = add i64 %41, 1
  br label %43

43:                                               ; preds = %37, %39, %31
  %.1 = phi i64 [ %36, %31 ], [ %42, %39 ], [ %.044, %37 ]
  %44 = call ptr @mapping_next(ptr noundef nonnull %13, ptr noundef nonnull %.03643)
  %.not = icmp ugt i64 %.1, %2
  br i1 %.not, label %.loopexit, label %27, !llvm.loop !38

45:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %7) #8
  store i64 %.044, ptr %7, align 8, !tbaa !34
  %46 = getelementptr inbounds i8, ptr %7, i64 8
  store i64 %2, ptr %46, align 8, !tbaa !36
  call void @buf_write(ptr noundef nonnull %4, ptr noundef nonnull %7, i32 noundef 16)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #8
  br label %.loopexit

.loopexit:                                        ; preds = %43, %45
  %47 = load ptr, ptr %4, align 8, !tbaa !40
  %48 = getelementptr inbounds i8, ptr %4, i64 8
  %49 = load ptr, ptr %48, align 8, !tbaa !42
  %50 = icmp ult ptr %47, %49
  br i1 %50, label %.lr.ph46, label %._crit_edge

.lr.ph46:                                         ; preds = %.loopexit, %.lr.ph46
  %.03545 = phi ptr [ %55, %.lr.ph46 ], [ %47, %.loopexit ]
  %51 = load i64, ptr %.03545, align 1, !tbaa !34
  %52 = getelementptr inbounds i8, ptr %.03545, i64 8
  %53 = load i64, ptr %52, align 1, !tbaa !36
  %54 = call ptr @engine_create(ptr noundef %0, i64 noundef %51, i64 noundef %53)
  %55 = getelementptr inbounds i8, ptr %.03545, i64 16
  %56 = icmp ult ptr %55, %49
  br i1 %56, label %.lr.ph46, label %._crit_edge, !llvm.loop !43

._crit_edge:                                      ; preds = %.lr.ph46, %.loopexit
  call void @guard_runner(ptr noundef nonnull %5)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #8
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #8
  br label %57

57:                                               ; preds = %._crit_edge, %17
  ret void
}

; Function Attrs: inlinehint noreturn nounwind uwtable
declare hidden void @error_throw_as(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare nonnull ptr @llvm.threadlocal.address.p0(ptr nonnull) #2

; Function Attrs: nounwind uwtable
declare hidden ptr @engine_create(ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #0

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @buf_init(ptr noundef) local_unnamed_addr #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @buf_free(ptr noundef) #4

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

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @guard_runner(ptr noundef) local_unnamed_addr #5

; Function Attrs: hot inlinehint nounwind uwtable
declare hidden ptr @mapping_seek(ptr noundef, i64 noundef) local_unnamed_addr #6

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @buf_write(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #4

; Function Attrs: alwaysinline nounwind uwtable
declare hidden zeroext i1 @slice_in(ptr noundef, i64 noundef) local_unnamed_addr #5

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @mapping_next(ptr noundef, ptr noundef) local_unnamed_addr #4

attributes #0 = { 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 #1 = { inlinehint noreturn 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { inlinehint 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 = { alwaysinline 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 #6 = { hot inlinehint 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 #7 = { noreturn }
attributes #8 = { nounwind }
attributes #9 = { hot }

!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 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!6 = !{!7, !15, i64 96}
!7 = !{!"Engine", !8, i64 0, !11, i64 40, !12, i64 88, !16, i64 104, !18, i64 136, !14, i64 168, !14, i64 176, !14, i64 184}
!8 = !{!"Mutex", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"CondVar", !9, i64 0}
!12 = !{!"Mapping", !13, i64 0, !15, i64 8}
!13 = !{!"Rbtree", !14, i64 0}
!14 = !{!"any pointer", !9, i64 0}
!15 = !{!"int", !9, i64 0}
!16 = !{!"Pipeline", !17, i64 0, !15, i64 16, !14, i64 24}
!17 = !{!"List", !14, i64 0, !14, i64 8}
!18 = !{!"StorageMgr", !17, i64 0, !15, i64 16, !14, i64 24}
!19 = !{!20, !14, i64 0}
!20 = !{!"Guard", !14, i64 0, !14, i64 8, !14, i64 16}
!21 = !{!20, !14, i64 8}
!22 = !{!23, !14, i64 0}
!23 = !{!"Runtime", !24, i64 0, !25, i64 8, !14, i64 312}
!24 = !{!"ExceptionMgr", !14, i64 0}
!25 = !{!"Error", !9, i64 0, !15, i64 256, !14, i64 264, !14, i64 272, !15, i64 280, !14, i64 288, !14, i64 296}
!26 = !{!27, !14, i64 16}
!27 = !{!"Exception", !14, i64 0, !28, i64 8, !14, i64 16, !9, i64 24}
!28 = !{!"_Bool", !9, i64 0}
!29 = !{!20, !14, i64 16}
!30 = !{!31, !32, i64 0}
!31 = !{!"Slice", !32, i64 0, !32, i64 8, !33, i64 16}
!32 = !{!"long", !9, i64 0}
!33 = !{!"RbtreeNode", !14, i64 0, !14, i64 8, !14, i64 16, !9, i64 24}
!34 = !{!35, !32, i64 0}
!35 = !{!"Id", !32, i64 0, !32, i64 8}
!36 = !{!35, !32, i64 8}
!37 = !{!31, !32, i64 8}
!38 = distinct !{!38, !39}
!39 = !{!"llvm.loop.mustprogress"}
!40 = !{!41, !14, i64 0}
!41 = !{!"Buf", !14, i64 0, !14, i64 8, !14, i64 16}
!42 = !{!41, !14, i64 8}
!43 = distinct !{!43, !39}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LowerExpectIntrinsicPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass