; LLVM IR from erthink/libmdbx :: src (page-ops)

; 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.libmdbx_globals = type { %union.bin128, i32, i32, i8, i8, i8, i8, i32, %union.logger_union, %union.pthread_mutex_t, i64, ptr }
%union.bin128 = type { %struct.anon }
%struct.anon = type { i64, i64 }
%union.logger_union = type { ptr }
%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.page_get_result = type { ptr, i32 }
%struct.page = type <{ i64, i16, i16, %union.anon.10, i32, [0 x i16] }>
%union.anon.10 = type { i32 }
%struct.MDBX_cursor = type { i32, %union.anon, i8, i8, ptr, ptr, ptr, ptr, ptr, [32 x ptr], [32 x i16], ptr, ptr }
%union.anon = type { i16 }
%struct.MDBX_txn = type { i32, i32, i64, i64, ptr, ptr, %struct.geo, i64, i64, ptr, ptr, ptr, ptr, ptr, ptr, %struct.MDBX_canary, ptr, %union.anon.4 }
%struct.geo = type { i16, i16, i32, i32, %union.anon.2, %union.anon.3 }
%union.anon.2 = type { i32 }
%union.anon.3 = type { i32 }
%struct.MDBX_canary = type { i64, i64, i64, i64 }
%union.anon.4 = type { %struct.anon.6 }
%struct.anon.6 = type { %struct.troika, ptr, %struct.anon.7, i8, i32, i32, i64, ptr, ptr, ptr, i64, %union.anon.8 }
%struct.troika = type { i8, i8, i8, i8, i32, [3 x i64] }
%struct.anon.7 = type { %struct.MDBX_rkl, i64, %struct.MDBX_rkl }
%struct.MDBX_rkl = type { i64, i64, i32, i32, ptr, [12 x i64] }
%union.anon.8 = type { %struct.anon.9 }
%struct.anon.9 = type { i64, ptr }
%struct.MDBX_env = type { %union.mdbx_atomic_uint32_t, i32, i32, %struct.osal_mmap, i32, i32, %struct.osal_mmap, ptr, i16, i16, i16, i16, i16, i16, %union.mdbx_atomic_uint32_t, i8, i8, i16, i32, i32, i32, i32, %struct.anon.13, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, ptr, ptr, i64, %struct.anon.14, %struct.anon.18, i8, ptr, ptr, ptr, %struct.anon.19, %union.pthread_mutex_t, i32, i32, ptr, %struct.osal_ioring, %union.pthread_mutex_t, [71 x %union.mdbx_atomic_uint64_t] }
%struct.osal_mmap = type { %union.anon.12, i32, i64, i64, i64 }
%union.anon.12 = type { ptr }
%union.mdbx_atomic_uint32_t = type { i32 }
%struct.anon.13 = type { ptr, ptr, ptr, ptr }
%struct.anon.14 = type { i32, i32, i32, i32, i64, i8, i8, i8, i8, i32, i32, i8, i8, i8, %struct.anon.15, %union.anon.16 }
%struct.anon.15 = type { i16, i16, i16, i16 }
%union.anon.16 = type { i32 }
%struct.anon.18 = type { i64, i64, i64, i64, i64 }
%struct.anon.19 = type { i64 }
%struct.osal_ioring = type { i32, i32, i32, ptr, ptr, ptr }
%union.mdbx_atomic_uint64_t = type { i64 }
%struct.shared_lck = type { i64, i32, %union.mdbx_atomic_uint32_t, %union.mdbx_atomic_uint32_t, %union.mdbx_atomic_uint32_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, [2 x %union.mdbx_atomic_uint32_t], [16 x i8], %struct.pgops, [16 x i8], %union.pthread_mutex_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint32_t, i32, %struct.anon.22, %union.pthread_mutex_t, %union.mdbx_atomic_uint32_t, %union.mdbx_atomic_uint32_t, [16 x i8], [0 x %struct.reader_slot] }
%struct.pgops = type { %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint32_t, %union.mdbx_atomic_uint32_t, %struct.anon.20 }
%struct.anon.20 = type { %struct.gc_prof_stat, %struct.gc_prof_stat, i32, i32, i32, i32, i32 }
%struct.gc_prof_stat = type { i64, i64, i32, i32, i32, i32, %struct.anon.21 }
%struct.anon.21 = type { i64, i64, i32 }
%struct.anon.22 = type { [4 x i32], [4 x i64] }
%struct.reader_slot = type { %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint32_t, %union.mdbx_atomic_uint32_t, %union.mdbx_atomic_uint64_t }
%struct.tree = type { i16, i16, i32, i32, i32, i32, i32, i64, i64, i64 }
%struct.anon.1 = type { i8, i8 }

@globals = external global %struct.libmdbx_globals, align 8
@.str.2 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [32 x i8], align 1
@__func__.page_new_large = external hidden unnamed_addr constant [15 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [46 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [23 x i8], align 1

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

; Function Attrs: noreturn
declare void @mdbx_assert_fail(ptr noundef, ptr noundef, ptr noundef, i32 noundef) #1

declare { ptr, i32 } @gc_alloc_single(ptr noundef) #2

declare void @debug_log(i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) #2

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare hidden i64 @cursor_dbi(ptr noundef) #3

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare hidden ptr @cursor_dbi_state(ptr noundef) #3

; Function Attrs: nounwind uwtable
define dso_local { ptr, i32 } @page_new_large(ptr noundef %0, i64 noundef %1) #4 {
  %3 = alloca %struct.page_get_result, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  %6 = load i64, ptr %5, align 8, !tbaa !9
  %7 = icmp eq i64 %6, 1
  %8 = xor i1 %7, true
  %9 = xor i1 %8, true
  %10 = zext i1 %9 to i32
  %11 = sext i32 %10 to i64
  %12 = call i64 @llvm.expect.i64(i64 %11, i64 1)
  %13 = icmp ne i64 %12, 0
  br i1 %13, label %14, label %21

14:                                               ; preds = %2
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = call { ptr, i32 } @gc_alloc_single(ptr noundef %15)
  %17 = getelementptr inbounds { ptr, i32 }, ptr %3, i32 0, i32 0
  %18 = extractvalue { ptr, i32 } %16, 0
  store ptr %18, ptr %17, align 8
  %19 = getelementptr inbounds { ptr, i32 }, ptr %3, i32 0, i32 1
  %20 = extractvalue { ptr, i32 } %16, 1
  store i32 %20, ptr %19, align 8
  br label %29

21:                                               ; preds = %2
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = load i64, ptr %5, align 8, !tbaa !9
  %24 = call { ptr, i32 } @gc_alloc_ex(ptr noundef %22, i64 noundef %23, i8 noundef zeroext 0)
  %25 = getelementptr inbounds { ptr, i32 }, ptr %3, i32 0, i32 0
  %26 = extractvalue { ptr, i32 } %24, 0
  store ptr %26, ptr %25, align 8
  %27 = getelementptr inbounds { ptr, i32 }, ptr %3, i32 0, i32 1
  %28 = extractvalue { ptr, i32 } %24, 1
  store i32 %28, ptr %27, align 8
  br label %29

29:                                               ; preds = %21, %14
  %30 = getelementptr inbounds %struct.page_get_result, ptr %3, i32 0, i32 1
  %31 = load i32, ptr %30, align 8, !tbaa !11
  %32 = icmp ne i32 %31, 0
  %33 = xor i1 %32, true
  %34 = xor i1 %33, true
  %35 = zext i1 %34 to i32
  %36 = sext i32 %35 to i64
  %37 = call i64 @llvm.expect.i64(i64 %36, i64 0)
  %38 = icmp ne i64 %37, 0
  br i1 %38, label %39, label %40

39:                                               ; preds = %29
  br label %200

40:                                               ; preds = %29
  br label %41

41:                                               ; preds = %40
  %42 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !14
  %43 = zext i8 %42 to i32
  %44 = icmp sle i32 5, %43
  %45 = xor i1 %44, true
  %46 = xor i1 %45, true
  %47 = zext i1 %46 to i32
  %48 = sext i32 %47 to i64
  %49 = call i64 @llvm.expect.i64(i64 %48, i64 0)
  %50 = icmp ne i64 %49, 0
  br i1 %50, label %51, label %59

51:                                               ; preds = %41
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = call i64 @cursor_dbi(ptr noundef %52) #5
  %54 = getelementptr inbounds %struct.page_get_result, ptr %3, i32 0, i32 0
  %55 = load ptr, ptr %54, align 8, !tbaa !17
  %56 = getelementptr inbounds %struct.page, ptr %55, i32 0, i32 4
  %57 = load i32, ptr %56, align 1, !tbaa !18
  %58 = load i64, ptr %5, align 8, !tbaa !9
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef @__func__.page_new_large, i32 noundef 49, ptr noundef @.str.4, i64 noundef %53, i32 noundef %57, i64 noundef %58)
  br label %59

59:                                               ; preds = %51, %41
  br label %60

60:                                               ; preds = %59
  %61 = getelementptr inbounds %struct.page_get_result, ptr %3, i32 0, i32 0
  %62 = load ptr, ptr %61, align 8, !tbaa !17
  %63 = getelementptr inbounds %struct.page, ptr %62, i32 0, i32 2
  store i16 4, ptr %63, align 1, !tbaa !19
  br label %64

64:                                               ; preds = %60
  %65 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !21
  %66 = zext i8 %65 to i32
  %67 = and i32 %66, 1
  %68 = icmp ne i32 %67, 0
  %69 = xor i1 %68, true
  %70 = xor i1 %69, true
  %71 = zext i1 %70 to i32
  %72 = sext i32 %71 to i64
  %73 = call i64 @llvm.expect.i64(i64 %72, i64 1)
  %74 = icmp ne i64 %73, 0
  br i1 %74, label %75, label %98

75:                                               ; preds = %64
  br label %76

76:                                               ; preds = %75
  %77 = load ptr, ptr %4, align 8, !tbaa !5
  %78 = call ptr @cursor_dbi_state(ptr noundef %77) #5
  %79 = load i8, ptr %78, align 1, !tbaa !22
  %80 = zext i8 %79 to i32
  %81 = and i32 %80, 1
  %82 = icmp ne i32 %81, 0
  %83 = xor i1 %82, true
  %84 = xor i1 %83, true
  %85 = xor i1 %84, true
  %86 = zext i1 %85 to i32
  %87 = sext i32 %86 to i64
  %88 = call i64 @llvm.expect.i64(i64 %87, i64 0)
  %89 = icmp ne i64 %88, 0
  br i1 %89, label %90, label %96

90:                                               ; preds = %76
  %91 = load ptr, ptr %4, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.MDBX_cursor, ptr %91, i32 0, i32 5
  %93 = load ptr, ptr %92, align 8, !tbaa !23
  %94 = getelementptr inbounds %struct.MDBX_txn, ptr %93, i32 0, i32 9
  %95 = load ptr, ptr %94, align 8, !tbaa !25
  call void @mdbx_assert_fail(ptr noundef %95, ptr noundef @.str.2, ptr noundef @__func__.page_new_large, i32 noundef 51) #6
  unreachable

96:                                               ; preds = %76
  br label %97

97:                                               ; preds = %96
  br label %98

98:                                               ; preds = %97, %64
  br label %99

99:                                               ; preds = %98
  br label %100

100:                                              ; preds = %99
  %101 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !21
  %102 = zext i8 %101 to i32
  %103 = and i32 %102, 1
  %104 = icmp ne i32 %103, 0
  %105 = xor i1 %104, true
  %106 = xor i1 %105, true
  %107 = zext i1 %106 to i32
  %108 = sext i32 %107 to i64
  %109 = call i64 @llvm.expect.i64(i64 %108, i64 1)
  %110 = icmp ne i64 %109, 0
  br i1 %110, label %111, label %135

111:                                              ; preds = %100
  br label %112

112:                                              ; preds = %111
  %113 = load ptr, ptr %4, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.MDBX_cursor, ptr %113, i32 0, i32 5
  %115 = load ptr, ptr %114, align 8, !tbaa !23
  %116 = getelementptr inbounds %struct.MDBX_txn, ptr %115, i32 0, i32 1
  %117 = load i32, ptr %116, align 4, !tbaa !29
  %118 = and i32 %117, 4
  %119 = icmp ne i32 %118, 0
  %120 = xor i1 %119, true
  %121 = xor i1 %120, true
  %122 = xor i1 %121, true
  %123 = zext i1 %122 to i32
  %124 = sext i32 %123 to i64
  %125 = call i64 @llvm.expect.i64(i64 %124, i64 0)
  %126 = icmp ne i64 %125, 0
  br i1 %126, label %127, label %133

127:                                              ; preds = %112
  %128 = load ptr, ptr %4, align 8, !tbaa !5
  %129 = getelementptr inbounds %struct.MDBX_cursor, ptr %128, i32 0, i32 5
  %130 = load ptr, ptr %129, align 8, !tbaa !23
  %131 = getelementptr inbounds %struct.MDBX_txn, ptr %130, i32 0, i32 9
  %132 = load ptr, ptr %131, align 8, !tbaa !25
  call void @mdbx_assert_fail(ptr noundef %132, ptr noundef @.str.3, ptr noundef @__func__.page_new_large, i32 noundef 52) #6
  unreachable

133:                                              ; preds = %112
  br label %134

134:                                              ; preds = %133
  br label %135

135:                                              ; preds = %134, %100
  br label %136

136:                                              ; preds = %135
  %137 = load i64, ptr %5, align 8, !tbaa !9
  %138 = load ptr, ptr %4, align 8, !tbaa !5
  %139 = getelementptr inbounds %struct.MDBX_cursor, ptr %138, i32 0, i32 5
  %140 = load ptr, ptr %139, align 8, !tbaa !23
  %141 = getelementptr inbounds %struct.MDBX_txn, ptr %140, i32 0, i32 9
  %142 = load ptr, ptr %141, align 8, !tbaa !25
  %143 = getelementptr inbounds %struct.MDBX_env, ptr %142, i32 0, i32 7
  %144 = load ptr, ptr %143, align 8, !tbaa !30
  %145 = getelementptr inbounds %struct.shared_lck, ptr %144, i32 0, i32 9
  %146 = getelementptr inbounds %struct.pgops, ptr %145, i32 0, i32 0
  %147 = load volatile i64, ptr %146, align 64, !tbaa !22
  %148 = add i64 %147, %137
  store volatile i64 %148, ptr %146, align 64, !tbaa !22
  %149 = load i64, ptr %5, align 8, !tbaa !9
  %150 = trunc i64 %149 to i32
  %151 = load ptr, ptr %4, align 8, !tbaa !5
  %152 = getelementptr inbounds %struct.MDBX_cursor, ptr %151, i32 0, i32 6
  %153 = load ptr, ptr %152, align 8, !tbaa !39
  %154 = getelementptr inbounds %struct.tree, ptr %153, i32 0, i32 6
  %155 = load i32, ptr %154, align 4, !tbaa !40
  %156 = add i32 %155, %150
  store i32 %156, ptr %154, align 4, !tbaa !40
  %157 = load i64, ptr %5, align 8, !tbaa !9
  %158 = trunc i64 %157 to i32
  %159 = getelementptr inbounds %struct.page_get_result, ptr %3, i32 0, i32 0
  %160 = load ptr, ptr %159, align 8, !tbaa !17
  %161 = getelementptr inbounds %struct.page, ptr %160, i32 0, i32 3
  store i32 %158, ptr %161, align 1, !tbaa !22
  br label %162

162:                                              ; preds = %136
  %163 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !21
  %164 = zext i8 %163 to i32
  %165 = and i32 %164, 1
  %166 = icmp ne i32 %165, 0
  %167 = xor i1 %166, true
  %168 = xor i1 %167, true
  %169 = zext i1 %168 to i32
  %170 = sext i32 %169 to i64
  %171 = call i64 @llvm.expect.i64(i64 %170, i64 1)
  %172 = icmp ne i64 %171, 0
  br i1 %172, label %173, label %198

173:                                              ; preds = %162
  br label %174

174:                                              ; preds = %173
  %175 = load ptr, ptr %4, align 8, !tbaa !5
  %176 = getelementptr inbounds %struct.MDBX_cursor, ptr %175, i32 0, i32 1
  %177 = getelementptr inbounds %struct.anon.1, ptr %176, i32 0, i32 0
  %178 = load i8, ptr %177, align 4, !tbaa !22
  %179 = sext i8 %178 to i32
  %180 = and i32 %179, 1
  %181 = icmp ne i32 %180, 0
  %182 = xor i1 %181, true
  %183 = xor i1 %182, true
  %184 = xor i1 %183, true
  %185 = xor i1 %184, true
  %186 = zext i1 %185 to i32
  %187 = sext i32 %186 to i64
  %188 = call i64 @llvm.expect.i64(i64 %187, i64 0)
  %189 = icmp ne i64 %188, 0
  br i1 %189, label %190, label %196

190:                                              ; preds = %174
  %191 = load ptr, ptr %4, align 8, !tbaa !5
  %192 = getelementptr inbounds %struct.MDBX_cursor, ptr %191, i32 0, i32 5
  %193 = load ptr, ptr %192, align 8, !tbaa !23
  %194 = getelementptr inbounds %struct.MDBX_txn, ptr %193, i32 0, i32 9
  %195 = load ptr, ptr %194, align 8, !tbaa !25
  call void @mdbx_assert_fail(ptr noundef %195, ptr noundef @.str.5, ptr noundef @__func__.page_new_large, i32 noundef 59) #6
  unreachable

196:                                              ; preds = %174
  br label %197

197:                                              ; preds = %196
  br label %198

198:                                              ; preds = %197, %162
  br label %199

199:                                              ; preds = %198
  br label %200

200:                                              ; preds = %199, %39
  %201 = load { ptr, i32 }, ptr %3, align 8
  ret { ptr, i32 } %201
}

declare { ptr, i32 } @gc_alloc_ex(ptr noundef, i64 noundef, i8 noundef zeroext) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #1 = { noreturn "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 = { inlinehint nounwind willreturn memory(read) 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 = { 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 willreturn memory(read) }
attributes #6 = { noreturn }

!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, !13, i64 8}
!12 = !{!"page_get_result", !6, i64 0, !13, i64 8}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !7, i64 26}
!15 = !{!"libmdbx_globals", !7, i64 0, !13, i64 16, !13, i64 20, !7, i64 24, !7, i64 25, !7, i64 26, !16, i64 27, !13, i64 28, !7, i64 32, !7, i64 40, !10, i64 80, !6, i64 88}
!16 = !{!"_Bool", !7, i64 0}
!17 = !{!12, !6, i64 0}
!18 = !{!13, !13, i64 0}
!19 = !{!20, !20, i64 0}
!20 = !{!"short", !7, i64 0}
!21 = !{!15, !7, i64 25}
!22 = !{!7, !7, i64 0}
!23 = !{!24, !6, i64 16}
!24 = !{!"MDBX_cursor", !13, i64 0, !7, i64 4, !7, i64 6, !7, i64 7, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !7, i64 48, !7, i64 304, !6, i64 368, !6, i64 376}
!25 = !{!26, !6, i64 80}
!26 = !{!"MDBX_txn", !13, i64 0, !13, i64 4, !10, i64 8, !10, i64 16, !6, i64 24, !6, i64 32, !27, i64 40, !10, i64 64, !10, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !28, i64 128, !6, i64 160, !7, i64 168}
!27 = !{!"geo", !20, i64 0, !20, i64 2, !13, i64 4, !13, i64 8, !7, i64 12, !7, i64 16}
!28 = !{!"MDBX_canary", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24}
!29 = !{!26, !13, i64 4}
!30 = !{!31, !6, i64 104}
!31 = !{!"MDBX_env", !7, i64 0, !13, i64 4, !13, i64 8, !32, i64 16, !13, i64 56, !13, i64 60, !32, i64 64, !6, i64 104, !20, i64 112, !20, i64 114, !20, i64 116, !20, i64 118, !20, i64 120, !20, i64 122, !7, i64 124, !7, i64 128, !7, i64 129, !20, i64 130, !13, i64 132, !13, i64 136, !13, i64 140, !13, i64 144, !33, i64 152, !6, i64 184, !6, i64 192, !6, i64 200, !6, i64 208, !6, i64 216, !13, i64 224, !13, i64 228, !13, i64 232, !6, i64 240, !6, i64 248, !10, i64 256, !34, i64 264, !36, i64 320, !16, i64 360, !6, i64 368, !6, i64 376, !6, i64 384, !37, i64 392, !7, i64 400, !13, i64 440, !13, i64 444, !6, i64 448, !38, i64 456, !7, i64 496, !7, i64 536}
!32 = !{!"osal_mmap", !7, i64 0, !13, i64 8, !10, i64 16, !10, i64 24, !10, i64 32}
!33 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!34 = !{!"", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !10, i64 16, !7, i64 24, !7, i64 25, !7, i64 26, !7, i64 27, !13, i64 28, !13, i64 32, !16, i64 36, !16, i64 37, !16, i64 38, !35, i64 40, !7, i64 48}
!35 = !{!"", !20, i64 0, !20, i64 2, !20, i64 4, !20, i64 6}
!36 = !{!"", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32}
!37 = !{!"", !10, i64 0}
!38 = !{!"osal_ioring", !13, i64 0, !13, i64 4, !13, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!39 = !{!24, !6, i64 24}
!40 = !{!41, !13, i64 20}
!41 = !{!"tree", !20, i64 0, !20, i64 2, !13, i64 4, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20, !10, i64 24, !10, i64 32, !10, i64 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.libmdbx_globals = type { %union.bin128, i32, i32, i8, i8, i8, i8, i32, %union.logger_union, %union.pthread_mutex_t, i64, ptr }
%union.bin128 = type { %struct.anon }
%struct.anon = type { i64, i64 }
%union.logger_union = type { ptr }
%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 }

@globals = external local_unnamed_addr global %struct.libmdbx_globals, align 8
@.str.2 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [32 x i8], align 1
@__func__.page_new_large = external hidden unnamed_addr constant [15 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [46 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [23 x i8], align 1

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

declare { ptr, i32 } @gc_alloc_single(ptr noundef) local_unnamed_addr #1

declare void @debug_log(i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare hidden i64 @cursor_dbi(ptr noundef) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare hidden ptr @cursor_dbi_state(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local { ptr, i32 } @page_new_large(ptr noundef %0, i64 noundef %1) local_unnamed_addr #3 {
  %3 = icmp eq i64 %1, 1
  br i1 %3, label %4, label %6, !prof !5

4:                                                ; preds = %2
  %5 = tail call { ptr, i32 } @gc_alloc_single(ptr noundef %0) #4
  br label %8

6:                                                ; preds = %2
  %7 = tail call { ptr, i32 } @gc_alloc_ex(ptr noundef %0, i64 noundef %1, i8 noundef zeroext 0) #4
  br label %8

8:                                                ; preds = %6, %4
  %.pn = phi { ptr, i32 } [ %5, %4 ], [ %7, %6 ]
  %.sroa.6.0 = extractvalue { ptr, i32 } %.pn, 1
  %.sroa.0.0 = extractvalue { ptr, i32 } %.pn, 0
  %.not = icmp eq i32 %.sroa.6.0, 0
  br i1 %.not, label %9, label %62, !prof !5

9:                                                ; preds = %8
  %10 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !6
  %11 = icmp ugt i8 %10, 4
  br i1 %11, label %12, label %16, !prof !14

12:                                               ; preds = %9
  %13 = tail call i64 @cursor_dbi(ptr noundef %0) #5
  %14 = getelementptr inbounds i8, ptr %.sroa.0.0, i64 16
  %15 = load i32, ptr %14, align 1, !tbaa !15
  tail call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef nonnull @__func__.page_new_large, i32 noundef 49, ptr noundef nonnull @.str.4, i64 noundef %13, i32 noundef %15, i64 noundef %1) #4
  br label %16

16:                                               ; preds = %9, %12
  %17 = getelementptr inbounds i8, ptr %.sroa.0.0, i64 10
  store i16 4, ptr %17, align 1, !tbaa !16
  %18 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 25), align 1, !tbaa !18
  %19 = and i8 %18, 1
  %.not20 = icmp eq i8 %19, 0
  br i1 %.not20, label %..thread_crit_edge, label %20, !prof !14

..thread_crit_edge:                               ; preds = %16
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 16
  %.pre = load ptr, ptr %.phi.trans.insert, align 8, !tbaa !19
  br label %.thread

20:                                               ; preds = %16
  %21 = tail call ptr @cursor_dbi_state(ptr noundef %0) #5
  %22 = load i8, ptr %21, align 1, !tbaa !21
  %23 = and i8 %22, 1
  %.not21 = icmp eq i8 %23, 0
  %24 = getelementptr inbounds i8, ptr %0, i64 16
  %25 = load ptr, ptr %24, align 8, !tbaa !19
  br i1 %.not21, label %26, label %29, !prof !14

26:                                               ; preds = %20
  %27 = getelementptr inbounds i8, ptr %25, i64 80
  %28 = load ptr, ptr %27, align 8, !tbaa !22
  tail call void @mdbx_assert_fail(ptr noundef %28, ptr noundef nonnull @.str.2, ptr noundef nonnull @__func__.page_new_large, i32 noundef 51) #6
  unreachable

29:                                               ; preds = %20
  %30 = getelementptr inbounds i8, ptr %25, i64 4
  %31 = load i32, ptr %30, align 4, !tbaa !26
  %32 = and i32 %31, 4
  %.not23 = icmp eq i32 %32, 0
  br i1 %.not23, label %33, label %.thread, !prof !14

33:                                               ; preds = %29
  %34 = getelementptr inbounds i8, ptr %25, i64 80
  %35 = load ptr, ptr %34, align 8, !tbaa !22
  tail call void @mdbx_assert_fail(ptr noundef %35, ptr noundef nonnull @.str.3, ptr noundef nonnull @__func__.page_new_large, i32 noundef 52) #6
  unreachable

.thread:                                          ; preds = %..thread_crit_edge, %29
  %36 = phi ptr [ %.pre, %..thread_crit_edge ], [ %25, %29 ]
  %37 = getelementptr inbounds i8, ptr %36, i64 80
  %38 = load ptr, ptr %37, align 8, !tbaa !22
  %39 = getelementptr inbounds i8, ptr %38, i64 104
  %40 = load ptr, ptr %39, align 8, !tbaa !27
  %41 = getelementptr inbounds i8, ptr %40, i64 64
  %42 = load volatile i64, ptr %41, align 64, !tbaa !21
  %43 = add i64 %42, %1
  store volatile i64 %43, ptr %41, align 64, !tbaa !21
  %44 = trunc i64 %1 to i32
  %45 = getelementptr inbounds i8, ptr %0, i64 24
  %46 = load ptr, ptr %45, align 8, !tbaa !36
  %47 = getelementptr inbounds i8, ptr %46, i64 20
  %48 = load i32, ptr %47, align 4, !tbaa !37
  %49 = add i32 %48, %44
  store i32 %49, ptr %47, align 4, !tbaa !37
  %50 = getelementptr inbounds i8, ptr %.sroa.0.0, i64 12
  store i32 %44, ptr %50, align 1, !tbaa !21
  %51 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 25), align 1, !tbaa !18
  %52 = and i8 %51, 1
  %.not24 = icmp eq i8 %52, 0
  br i1 %.not24, label %62, label %53, !prof !14

53:                                               ; preds = %.thread
  %54 = getelementptr inbounds i8, ptr %0, i64 4
  %55 = load i8, ptr %54, align 4, !tbaa !21
  %56 = and i8 %55, 1
  %.not25 = icmp eq i8 %56, 0
  br i1 %.not25, label %62, label %57, !prof !5

57:                                               ; preds = %53
  %58 = getelementptr inbounds i8, ptr %0, i64 16
  %59 = load ptr, ptr %58, align 8, !tbaa !19
  %60 = getelementptr inbounds i8, ptr %59, i64 80
  %61 = load ptr, ptr %60, align 8, !tbaa !22
  tail call void @mdbx_assert_fail(ptr noundef %61, ptr noundef nonnull @.str.5, ptr noundef nonnull @__func__.page_new_large, i32 noundef 59) #6
  unreachable

62:                                               ; preds = %53, %.thread, %8
  ret { ptr, i32 } %.pn
}

declare { ptr, i32 } @gc_alloc_ex(ptr noundef, i64 noundef, i8 noundef zeroext) local_unnamed_addr #1

attributes #0 = { noreturn "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 = { inlinehint mustprogress nofree nounwind willreturn memory(read) 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 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 = { nounwind }
attributes #5 = { nounwind willreturn memory(read) }
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 = !{!"branch_weights", !"expected", i32 2000, i32 1}
!6 = !{!7, !8, i64 26}
!7 = !{!"libmdbx_globals", !8, i64 0, !10, i64 16, !10, i64 20, !8, i64 24, !8, i64 25, !8, i64 26, !11, i64 27, !10, i64 28, !8, i64 32, !8, i64 40, !12, i64 80, !13, i64 88}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"_Bool", !8, i64 0}
!12 = !{!"long", !8, i64 0}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!15 = !{!10, !10, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"short", !8, i64 0}
!18 = !{!7, !8, i64 25}
!19 = !{!20, !13, i64 16}
!20 = !{!"MDBX_cursor", !10, i64 0, !8, i64 4, !8, i64 6, !8, i64 7, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32, !13, i64 40, !8, i64 48, !8, i64 304, !13, i64 368, !13, i64 376}
!21 = !{!8, !8, i64 0}
!22 = !{!23, !13, i64 80}
!23 = !{!"MDBX_txn", !10, i64 0, !10, i64 4, !12, i64 8, !12, i64 16, !13, i64 24, !13, i64 32, !24, i64 40, !12, i64 64, !12, i64 72, !13, i64 80, !13, i64 88, !13, i64 96, !13, i64 104, !13, i64 112, !13, i64 120, !25, i64 128, !13, i64 160, !8, i64 168}
!24 = !{!"geo", !17, i64 0, !17, i64 2, !10, i64 4, !10, i64 8, !8, i64 12, !8, i64 16}
!25 = !{!"MDBX_canary", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24}
!26 = !{!23, !10, i64 4}
!27 = !{!28, !13, i64 104}
!28 = !{!"MDBX_env", !8, i64 0, !10, i64 4, !10, i64 8, !29, i64 16, !10, i64 56, !10, i64 60, !29, i64 64, !13, i64 104, !17, i64 112, !17, i64 114, !17, i64 116, !17, i64 118, !17, i64 120, !17, i64 122, !8, i64 124, !8, i64 128, !8, i64 129, !17, i64 130, !10, i64 132, !10, i64 136, !10, i64 140, !10, i64 144, !30, i64 152, !13, i64 184, !13, i64 192, !13, i64 200, !13, i64 208, !13, i64 216, !10, i64 224, !10, i64 228, !10, i64 232, !13, i64 240, !13, i64 248, !12, i64 256, !31, i64 264, !33, i64 320, !11, i64 360, !13, i64 368, !13, i64 376, !13, i64 384, !34, i64 392, !8, i64 400, !10, i64 440, !10, i64 444, !13, i64 448, !35, i64 456, !8, i64 496, !8, i64 536}
!29 = !{!"osal_mmap", !8, i64 0, !10, i64 8, !12, i64 16, !12, i64 24, !12, i64 32}
!30 = !{!"", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24}
!31 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !12, i64 16, !8, i64 24, !8, i64 25, !8, i64 26, !8, i64 27, !10, i64 28, !10, i64 32, !11, i64 36, !11, i64 37, !11, i64 38, !32, i64 40, !8, i64 48}
!32 = !{!"", !17, i64 0, !17, i64 2, !17, i64 4, !17, i64 6}
!33 = !{!"", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32}
!34 = !{!"", !12, i64 0}
!35 = !{!"osal_ioring", !10, i64 0, !10, i64 4, !10, i64 8, !13, i64 16, !13, i64 24, !13, i64 32}
!36 = !{!20, !13, i64 24}
!37 = !{!38, !10, i64 20}
!38 = !{!"tree", !17, i64 0, !17, i64 2, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !12, i64 24, !12, i64 32, !12, i64 40}


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