; LLVM IR from jwerle/libhypercore-crypto :: deps/merkle (merkle)

; 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.merkle_node_list = type { i8, i64, ptr }
%struct.merkle = type { i8, %struct.merkle_node_list, i64, %struct.merkle_codec }
%struct.merkle_codec = type { ptr, ptr }
%struct.merkle_node = type { i8, i32, i64, i64, i64, i64, ptr, ptr }

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

declare ptr @merkle_alloc(i64 noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local ptr @merkle_next(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3) #3 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i64 %2, ptr %8, align 8, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = icmp eq ptr null, %17
  br i1 %18, label %19, label %21

19:                                               ; preds = %4
  %20 = call ptr @__errno_location() #6
  store i32 14, ptr %20, align 4, !tbaa !11
  store ptr null, ptr %5, align 8
  br label %237

21:                                               ; preds = %4
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = icmp eq ptr null, %22
  br i1 %23, label %27, label %24

24:                                               ; preds = %21
  %25 = load i64, ptr %8, align 8, !tbaa !9
  %26 = icmp eq i64 0, %25
  br i1 %26, label %27, label %29

27:                                               ; preds = %24, %21
  %28 = call ptr @__errno_location() #6
  store i32 22, ptr %28, align 4, !tbaa !11
  store ptr null, ptr %5, align 8
  br label %237

29:                                               ; preds = %24
  %30 = load ptr, ptr %9, align 8, !tbaa !5
  %31 = icmp eq ptr null, %30
  br i1 %31, label %32, label %42

32:                                               ; preds = %29
  %33 = call ptr @merkle_alloc(i64 noundef 24)
  store ptr %33, ptr %9, align 8, !tbaa !5
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.merkle_node_list, ptr %34, i32 0, i32 1
  store i64 0, ptr %35, align 8, !tbaa !13
  %36 = load ptr, ptr %9, align 8, !tbaa !5
  %37 = load i8, ptr %36, align 8
  %38 = and i8 %37, -2
  %39 = or i8 %38, 1
  store i8 %39, ptr %36, align 8
  %40 = load ptr, ptr %9, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.merkle_node_list, ptr %40, i32 0, i32 2
  store ptr null, ptr %41, align 8, !tbaa !15
  br label %42

42:                                               ; preds = %32, %29
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.merkle, ptr %43, i32 0, i32 2
  %45 = load i64, ptr %44, align 8, !tbaa !16
  %46 = add i64 %45, 1
  store i64 %46, ptr %44, align 8, !tbaa !16
  %47 = mul i64 2, %45
  %48 = trunc i64 %47 to i32
  store i32 %48, ptr %10, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  %49 = call ptr @merkle_alloc(i64 noundef 56)
  store ptr %49, ptr %11, align 8, !tbaa !5
  %50 = load ptr, ptr %11, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %50, i8 0, i64 56, i1 false)
  %51 = load ptr, ptr %11, align 8, !tbaa !5
  %52 = load i8, ptr %51, align 8
  %53 = and i8 %52, -2
  %54 = or i8 %53, 1
  store i8 %54, ptr %51, align 8
  %55 = load i32, ptr %10, align 4, !tbaa !11
  %56 = zext i32 %55 to i64
  %57 = call i64 @ft_parent(i64 noundef %56, i64 noundef 0)
  %58 = load ptr, ptr %11, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.merkle_node, ptr %58, i32 0, i32 3
  store i64 %57, ptr %59, align 8, !tbaa !19
  %60 = load i32, ptr %10, align 4, !tbaa !11
  %61 = zext i32 %60 to i64
  %62 = load ptr, ptr %11, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.merkle_node, ptr %62, i32 0, i32 2
  store i64 %61, ptr %63, align 8, !tbaa !21
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = load ptr, ptr %11, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.merkle_node, ptr %65, i32 0, i32 7
  store ptr %64, ptr %66, align 8, !tbaa !22
  %67 = load i64, ptr %8, align 8, !tbaa !9
  %68 = load ptr, ptr %11, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.merkle_node, ptr %68, i32 0, i32 4
  store i64 %67, ptr %69, align 8, !tbaa !23
  %70 = load ptr, ptr %6, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.merkle, ptr %70, i32 0, i32 3
  %72 = getelementptr inbounds %struct.merkle_codec, ptr %71, i32 0, i32 0
  %73 = load ptr, ptr %72, align 8, !tbaa !24
  %74 = load ptr, ptr %11, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.merkle_node, ptr %74, i32 0, i32 6
  %76 = load ptr, ptr %11, align 8, !tbaa !5
  %77 = load ptr, ptr %6, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.merkle, ptr %77, i32 0, i32 1
  %79 = call i64 %73(ptr noundef %75, ptr noundef %76, ptr noundef %78)
  %80 = load ptr, ptr %11, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.merkle_node, ptr %80, i32 0, i32 5
  store i64 %79, ptr %81, align 8, !tbaa !25
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  %82 = call ptr @merkle_alloc(i64 noundef 56)
  store ptr %82, ptr %12, align 8, !tbaa !5
  %83 = load ptr, ptr %12, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %83, i8 0, i64 56, i1 false)
  %84 = load ptr, ptr %12, align 8, !tbaa !5
  %85 = load ptr, ptr %11, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %84, ptr align 8 %85, i64 56, i1 false)
  %86 = load ptr, ptr %12, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.merkle_node, ptr %86, i32 0, i32 1
  store i32 0, ptr %87, align 4, !tbaa !26
  %88 = load ptr, ptr %11, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.merkle_node, ptr %88, i32 0, i32 5
  %90 = load i64, ptr %89, align 8, !tbaa !25
  %91 = call ptr @merkle_alloc(i64 noundef %90)
  %92 = load ptr, ptr %12, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.merkle_node, ptr %92, i32 0, i32 6
  store ptr %91, ptr %93, align 8, !tbaa !27
  %94 = load ptr, ptr %12, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.merkle_node, ptr %94, i32 0, i32 6
  %96 = load ptr, ptr %95, align 8, !tbaa !27
  %97 = load ptr, ptr %11, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.merkle_node, ptr %97, i32 0, i32 5
  %99 = load i64, ptr %98, align 8, !tbaa !25
  call void @llvm.memset.p0.i64(ptr align 1 %96, i8 0, i64 %99, i1 false)
  %100 = load ptr, ptr %12, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.merkle_node, ptr %100, i32 0, i32 6
  %102 = load ptr, ptr %101, align 8, !tbaa !27
  %103 = load ptr, ptr %11, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.merkle_node, ptr %103, i32 0, i32 6
  %105 = load ptr, ptr %104, align 8, !tbaa !27
  %106 = load ptr, ptr %11, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.merkle_node, ptr %106, i32 0, i32 5
  %108 = load i64, ptr %107, align 8, !tbaa !25
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %102, ptr align 1 %105, i64 %108, i1 false)
  %109 = load ptr, ptr %9, align 8, !tbaa !5
  %110 = load ptr, ptr %11, align 8, !tbaa !5
  %111 = call i64 @push(ptr noundef %109, ptr noundef %110)
  %112 = load ptr, ptr %6, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct.merkle, ptr %112, i32 0, i32 1
  %114 = load ptr, ptr %12, align 8, !tbaa !5
  %115 = call i64 @push(ptr noundef %113, ptr noundef %114)
  br label %116

116:                                              ; preds = %234, %42
  %117 = load ptr, ptr %6, align 8, !tbaa !5
  %118 = getelementptr inbounds %struct.merkle, ptr %117, i32 0, i32 1
  %119 = getelementptr inbounds %struct.merkle_node_list, ptr %118, i32 0, i32 1
  %120 = load i64, ptr %119, align 8, !tbaa !28
  %121 = icmp ugt i64 %120, 1
  br i1 %121, label %122, label %235

122:                                              ; preds = %116
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  %123 = load ptr, ptr %6, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.merkle, ptr %123, i32 0, i32 1
  %125 = getelementptr inbounds %struct.merkle_node_list, ptr %124, i32 0, i32 1
  %126 = load i64, ptr %125, align 8, !tbaa !28
  store i64 %126, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  %127 = load ptr, ptr %6, align 8, !tbaa !5
  %128 = getelementptr inbounds %struct.merkle, ptr %127, i32 0, i32 1
  %129 = getelementptr inbounds %struct.merkle_node_list, ptr %128, i32 0, i32 2
  %130 = load ptr, ptr %129, align 8, !tbaa !29
  %131 = load i64, ptr %13, align 8, !tbaa !9
  %132 = sub i64 %131, 2
  %133 = getelementptr inbounds ptr, ptr %130, i64 %132
  %134 = load ptr, ptr %133, align 8, !tbaa !5
  store ptr %134, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #7
  %135 = load ptr, ptr %6, align 8, !tbaa !5
  %136 = getelementptr inbounds %struct.merkle, ptr %135, i32 0, i32 1
  %137 = getelementptr inbounds %struct.merkle_node_list, ptr %136, i32 0, i32 2
  %138 = load ptr, ptr %137, align 8, !tbaa !29
  %139 = load i64, ptr %13, align 8, !tbaa !9
  %140 = sub i64 %139, 1
  %141 = getelementptr inbounds ptr, ptr %138, i64 %140
  %142 = load ptr, ptr %141, align 8, !tbaa !5
  store ptr %142, ptr %15, align 8, !tbaa !5
  %143 = load ptr, ptr %14, align 8, !tbaa !5
  %144 = getelementptr inbounds %struct.merkle_node, ptr %143, i32 0, i32 3
  %145 = load i64, ptr %144, align 8, !tbaa !19
  %146 = load ptr, ptr %15, align 8, !tbaa !5
  %147 = getelementptr inbounds %struct.merkle_node, ptr %146, i32 0, i32 3
  %148 = load i64, ptr %147, align 8, !tbaa !19
  %149 = icmp ne i64 %145, %148
  br i1 %149, label %150, label %151

150:                                              ; preds = %122
  store i32 3, ptr %16, align 4
  br label %232

151:                                              ; preds = %122
  %152 = load ptr, ptr %6, align 8, !tbaa !5
  %153 = getelementptr inbounds %struct.merkle, ptr %152, i32 0, i32 1
  %154 = call ptr @pop(ptr noundef %153)
  store ptr %154, ptr %12, align 8, !tbaa !5
  %155 = call ptr @merkle_alloc(i64 noundef 56)
  store ptr %155, ptr %11, align 8, !tbaa !5
  %156 = load ptr, ptr %11, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %156, i8 0, i64 56, i1 false)
  %157 = load ptr, ptr %11, align 8, !tbaa !5
  %158 = load i8, ptr %157, align 8
  %159 = and i8 %158, -2
  %160 = or i8 %159, 1
  store i8 %160, ptr %157, align 8
  %161 = load ptr, ptr %14, align 8, !tbaa !5
  %162 = getelementptr inbounds %struct.merkle_node, ptr %161, i32 0, i32 3
  %163 = load i64, ptr %162, align 8, !tbaa !19
  %164 = call i64 @ft_parent(i64 noundef %163, i64 noundef 0)
  %165 = load ptr, ptr %11, align 8, !tbaa !5
  %166 = getelementptr inbounds %struct.merkle_node, ptr %165, i32 0, i32 3
  store i64 %164, ptr %166, align 8, !tbaa !19
  %167 = load ptr, ptr %14, align 8, !tbaa !5
  %168 = getelementptr inbounds %struct.merkle_node, ptr %167, i32 0, i32 3
  %169 = load i64, ptr %168, align 8, !tbaa !19
  %170 = load ptr, ptr %11, align 8, !tbaa !5
  %171 = getelementptr inbounds %struct.merkle_node, ptr %170, i32 0, i32 2
  store i64 %169, ptr %171, align 8, !tbaa !21
  %172 = load ptr, ptr %14, align 8, !tbaa !5
  %173 = getelementptr inbounds %struct.merkle_node, ptr %172, i32 0, i32 4
  %174 = load i64, ptr %173, align 8, !tbaa !23
  %175 = load ptr, ptr %15, align 8, !tbaa !5
  %176 = getelementptr inbounds %struct.merkle_node, ptr %175, i32 0, i32 4
  %177 = load i64, ptr %176, align 8, !tbaa !23
  %178 = add i64 %174, %177
  %179 = load ptr, ptr %11, align 8, !tbaa !5
  %180 = getelementptr inbounds %struct.merkle_node, ptr %179, i32 0, i32 4
  store i64 %178, ptr %180, align 8, !tbaa !23
  %181 = load ptr, ptr %11, align 8, !tbaa !5
  %182 = getelementptr inbounds %struct.merkle_node, ptr %181, i32 0, i32 7
  store ptr null, ptr %182, align 8, !tbaa !22
  %183 = load ptr, ptr %6, align 8, !tbaa !5
  %184 = getelementptr inbounds %struct.merkle, ptr %183, i32 0, i32 3
  %185 = getelementptr inbounds %struct.merkle_codec, ptr %184, i32 0, i32 1
  %186 = load ptr, ptr %185, align 8, !tbaa !30
  %187 = load ptr, ptr %11, align 8, !tbaa !5
  %188 = getelementptr inbounds %struct.merkle_node, ptr %187, i32 0, i32 6
  %189 = load ptr, ptr %14, align 8, !tbaa !5
  %190 = load ptr, ptr %15, align 8, !tbaa !5
  %191 = call i64 %186(ptr noundef %188, ptr noundef %189, ptr noundef %190)
  %192 = load ptr, ptr %11, align 8, !tbaa !5
  %193 = getelementptr inbounds %struct.merkle_node, ptr %192, i32 0, i32 5
  store i64 %191, ptr %193, align 8, !tbaa !25
  %194 = load ptr, ptr %9, align 8, !tbaa !5
  %195 = load ptr, ptr %11, align 8, !tbaa !5
  %196 = call i64 @push(ptr noundef %194, ptr noundef %195)
  %197 = load ptr, ptr %12, align 8, !tbaa !5
  call void @merkle_node_destroy(ptr noundef %197)
  %198 = call ptr @merkle_alloc(i64 noundef 56)
  store ptr %198, ptr %12, align 8, !tbaa !5
  %199 = load ptr, ptr %12, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %199, i8 0, i64 56, i1 false)
  %200 = load ptr, ptr %12, align 8, !tbaa !5
  %201 = load ptr, ptr %11, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %200, ptr align 8 %201, i64 56, i1 false)
  %202 = load ptr, ptr %12, align 8, !tbaa !5
  %203 = getelementptr inbounds %struct.merkle_node, ptr %202, i32 0, i32 1
  store i32 0, ptr %203, align 4, !tbaa !26
  %204 = load ptr, ptr %11, align 8, !tbaa !5
  %205 = getelementptr inbounds %struct.merkle_node, ptr %204, i32 0, i32 5
  %206 = load i64, ptr %205, align 8, !tbaa !25
  %207 = call ptr @merkle_alloc(i64 noundef %206)
  %208 = load ptr, ptr %12, align 8, !tbaa !5
  %209 = getelementptr inbounds %struct.merkle_node, ptr %208, i32 0, i32 6
  store ptr %207, ptr %209, align 8, !tbaa !27
  %210 = load ptr, ptr %12, align 8, !tbaa !5
  %211 = getelementptr inbounds %struct.merkle_node, ptr %210, i32 0, i32 6
  %212 = load ptr, ptr %211, align 8, !tbaa !27
  %213 = load ptr, ptr %11, align 8, !tbaa !5
  %214 = getelementptr inbounds %struct.merkle_node, ptr %213, i32 0, i32 5
  %215 = load i64, ptr %214, align 8, !tbaa !25
  call void @llvm.memset.p0.i64(ptr align 1 %212, i8 0, i64 %215, i1 false)
  %216 = load ptr, ptr %12, align 8, !tbaa !5
  %217 = getelementptr inbounds %struct.merkle_node, ptr %216, i32 0, i32 6
  %218 = load ptr, ptr %217, align 8, !tbaa !27
  %219 = load ptr, ptr %11, align 8, !tbaa !5
  %220 = getelementptr inbounds %struct.merkle_node, ptr %219, i32 0, i32 6
  %221 = load ptr, ptr %220, align 8, !tbaa !27
  %222 = load ptr, ptr %11, align 8, !tbaa !5
  %223 = getelementptr inbounds %struct.merkle_node, ptr %222, i32 0, i32 5
  %224 = load i64, ptr %223, align 8, !tbaa !25
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %218, ptr align 1 %221, i64 %224, i1 false)
  %225 = load ptr, ptr %6, align 8, !tbaa !5
  %226 = getelementptr inbounds %struct.merkle, ptr %225, i32 0, i32 1
  %227 = call ptr @pop(ptr noundef %226)
  call void @merkle_node_destroy(ptr noundef %227)
  %228 = load ptr, ptr %6, align 8, !tbaa !5
  %229 = getelementptr inbounds %struct.merkle, ptr %228, i32 0, i32 1
  %230 = load ptr, ptr %12, align 8, !tbaa !5
  %231 = call i64 @push(ptr noundef %229, ptr noundef %230)
  store i32 0, ptr %16, align 4
  br label %232

232:                                              ; preds = %151, %150
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  %233 = load i32, ptr %16, align 4
  switch i32 %233, label %239 [
    i32 0, label %234
    i32 3, label %235
  ]

234:                                              ; preds = %232
  br label %116, !llvm.loop !31

235:                                              ; preds = %232, %116
  %236 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %236, ptr %5, align 8
  store i32 1, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  br label %237

237:                                              ; preds = %235, %27, %19
  %238 = load ptr, ptr %5, align 8
  ret ptr %238

239:                                              ; preds = %232
  unreachable
}

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__errno_location() #4

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

declare i64 @ft_parent(i64 noundef, i64 noundef) #1

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

; Function Attrs: nounwind uwtable
declare hidden ptr @pop(ptr noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local void @merkle_node_destroy(ptr noundef) #3

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

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 willreturn memory(none) "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { nounwind willreturn memory(none) }
attributes #7 = { 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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !10, i64 8}
!14 = !{!"merkle_node_list", !12, i64 0, !10, i64 8, !6, i64 16}
!15 = !{!14, !6, i64 16}
!16 = !{!17, !10, i64 32}
!17 = !{!"merkle", !12, i64 0, !14, i64 8, !10, i64 32, !18, i64 40}
!18 = !{!"merkle_codec", !6, i64 0, !6, i64 8}
!19 = !{!20, !10, i64 16}
!20 = !{!"merkle_node", !12, i64 0, !12, i64 4, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !6, i64 40, !6, i64 48}
!21 = !{!20, !10, i64 8}
!22 = !{!20, !6, i64 48}
!23 = !{!20, !10, i64 24}
!24 = !{!17, !6, i64 40}
!25 = !{!20, !10, i64 32}
!26 = !{!20, !12, i64 4}
!27 = !{!20, !6, i64 40}
!28 = !{!17, !10, i64 16}
!29 = !{!17, !6, i64 24}
!30 = !{!17, !6, i64 48}
!31 = distinct !{!31, !32}
!32 = !{!"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"

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

declare ptr @merkle_alloc(i64 noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @merkle_next(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3) local_unnamed_addr #3 {
  %5 = icmp eq ptr %0, null
  br i1 %5, label %.thread.sink.split, label %6

6:                                                ; preds = %4
  %7 = icmp eq ptr %1, null
  %8 = icmp eq i64 %2, 0
  %or.cond = or i1 %7, %8
  br i1 %or.cond, label %.thread.sink.split, label %9

9:                                                ; preds = %6
  %10 = icmp eq ptr %3, null
  br i1 %10, label %11, label %17

11:                                               ; preds = %9
  %12 = tail call ptr @merkle_alloc(i64 noundef 24) #5
  %13 = getelementptr inbounds i8, ptr %12, i64 8
  store i64 0, ptr %13, align 8, !tbaa !5
  %14 = load i8, ptr %12, align 8
  %15 = or i8 %14, 1
  store i8 %15, ptr %12, align 8
  %16 = getelementptr inbounds i8, ptr %12, i64 16
  store ptr null, ptr %16, align 8, !tbaa !12
  br label %17

17:                                               ; preds = %11, %9
  %.083 = phi ptr [ %12, %11 ], [ %3, %9 ]
  %18 = getelementptr inbounds i8, ptr %0, i64 32
  %19 = load i64, ptr %18, align 8, !tbaa !13
  %20 = add i64 %19, 1
  store i64 %20, ptr %18, align 8, !tbaa !13
  %21 = shl i64 %19, 1
  %22 = tail call ptr @merkle_alloc(i64 noundef 56) #5
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(56) %22, i8 0, i64 56, i1 false)
  store i8 1, ptr %22, align 8
  %23 = and i64 %21, 4294967294
  %24 = tail call i64 @ft_parent(i64 noundef %23, i64 noundef 0) #5
  %25 = getelementptr inbounds i8, ptr %22, i64 16
  store i64 %24, ptr %25, align 8, !tbaa !16
  %26 = getelementptr inbounds i8, ptr %22, i64 8
  store i64 %23, ptr %26, align 8, !tbaa !18
  %27 = getelementptr inbounds i8, ptr %22, i64 48
  store ptr %1, ptr %27, align 8, !tbaa !19
  %28 = getelementptr inbounds i8, ptr %22, i64 24
  store i64 %2, ptr %28, align 8, !tbaa !20
  %29 = getelementptr inbounds i8, ptr %0, i64 40
  %30 = load ptr, ptr %29, align 8, !tbaa !21
  %31 = getelementptr inbounds i8, ptr %22, i64 40
  %32 = getelementptr inbounds i8, ptr %0, i64 8
  %33 = tail call i64 %30(ptr noundef nonnull %31, ptr noundef nonnull %22, ptr noundef nonnull %32) #5
  %34 = getelementptr inbounds i8, ptr %22, i64 32
  store i64 %33, ptr %34, align 8, !tbaa !22
  %35 = tail call ptr @merkle_alloc(i64 noundef 56) #5
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(56) %35, i8 0, i64 56, i1 false)
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(56) %35, ptr noundef nonnull align 8 dereferenceable(56) %22, i64 56, i1 false)
  %36 = getelementptr inbounds i8, ptr %35, i64 4
  store i32 0, ptr %36, align 4, !tbaa !23
  %37 = load i64, ptr %34, align 8, !tbaa !22
  %38 = tail call ptr @merkle_alloc(i64 noundef %37) #5
  %39 = getelementptr inbounds i8, ptr %35, i64 40
  store ptr %38, ptr %39, align 8, !tbaa !24
  %40 = load i64, ptr %34, align 8, !tbaa !22
  tail call void @llvm.memset.p0.i64(ptr align 1 %38, i8 0, i64 %40, i1 false)
  %41 = load ptr, ptr %39, align 8, !tbaa !24
  %42 = load ptr, ptr %31, align 8, !tbaa !24
  %43 = load i64, ptr %34, align 8, !tbaa !22
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %41, ptr align 1 %42, i64 %43, i1 false)
  %44 = tail call i64 @push(ptr noundef nonnull %.083, ptr noundef nonnull %22)
  %45 = tail call i64 @push(ptr noundef nonnull %32, ptr noundef %35)
  %46 = getelementptr inbounds i8, ptr %0, i64 24
  %47 = getelementptr inbounds i8, ptr %0, i64 16
  %48 = load i64, ptr %47, align 8, !tbaa !25
  %49 = icmp ugt i64 %48, 1
  br i1 %49, label %.lr.ph, label %.thread

.lr.ph:                                           ; preds = %17
  %50 = getelementptr inbounds i8, ptr %0, i64 48
  br label %51

51:                                               ; preds = %.lr.ph, %63
  %52 = phi i64 [ %48, %.lr.ph ], [ %94, %63 ]
  %53 = load ptr, ptr %46, align 8, !tbaa !26
  %54 = getelementptr ptr, ptr %53, i64 %52
  %55 = getelementptr i8, ptr %54, i64 -16
  %56 = load ptr, ptr %55, align 8, !tbaa !27
  %57 = getelementptr i8, ptr %54, i64 -8
  %58 = load ptr, ptr %57, align 8, !tbaa !27
  %59 = getelementptr inbounds i8, ptr %56, i64 16
  %60 = load i64, ptr %59, align 8, !tbaa !16
  %61 = getelementptr inbounds i8, ptr %58, i64 16
  %62 = load i64, ptr %61, align 8, !tbaa !16
  %.not = icmp eq i64 %60, %62
  br i1 %.not, label %63, label %.thread

63:                                               ; preds = %51
  %64 = tail call ptr @pop(ptr noundef nonnull %32)
  %65 = tail call ptr @merkle_alloc(i64 noundef 56) #5
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(56) %65, i8 0, i64 56, i1 false)
  store i8 1, ptr %65, align 8
  %66 = load i64, ptr %59, align 8, !tbaa !16
  %67 = tail call i64 @ft_parent(i64 noundef %66, i64 noundef 0) #5
  %68 = getelementptr inbounds i8, ptr %65, i64 16
  store i64 %67, ptr %68, align 8, !tbaa !16
  %69 = load i64, ptr %59, align 8, !tbaa !16
  %70 = getelementptr inbounds i8, ptr %65, i64 8
  store i64 %69, ptr %70, align 8, !tbaa !18
  %71 = getelementptr inbounds i8, ptr %56, i64 24
  %72 = load i64, ptr %71, align 8, !tbaa !20
  %73 = getelementptr inbounds i8, ptr %58, i64 24
  %74 = load i64, ptr %73, align 8, !tbaa !20
  %75 = add i64 %74, %72
  %76 = getelementptr inbounds i8, ptr %65, i64 24
  store i64 %75, ptr %76, align 8, !tbaa !20
  %77 = getelementptr inbounds i8, ptr %65, i64 48
  store ptr null, ptr %77, align 8, !tbaa !19
  %78 = load ptr, ptr %50, align 8, !tbaa !28
  %79 = getelementptr inbounds i8, ptr %65, i64 40
  %80 = tail call i64 %78(ptr noundef nonnull %79, ptr noundef nonnull %56, ptr noundef nonnull %58) #5
  %81 = getelementptr inbounds i8, ptr %65, i64 32
  store i64 %80, ptr %81, align 8, !tbaa !22
  %82 = tail call i64 @push(ptr noundef nonnull %.083, ptr noundef nonnull %65)
  tail call void @merkle_node_destroy(ptr noundef %64)
  %83 = tail call ptr @merkle_alloc(i64 noundef 56) #5
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(56) %83, i8 0, i64 56, i1 false)
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(56) %83, ptr noundef nonnull align 8 dereferenceable(56) %65, i64 56, i1 false)
  %84 = getelementptr inbounds i8, ptr %83, i64 4
  store i32 0, ptr %84, align 4, !tbaa !23
  %85 = load i64, ptr %81, align 8, !tbaa !22
  %86 = tail call ptr @merkle_alloc(i64 noundef %85) #5
  %87 = getelementptr inbounds i8, ptr %83, i64 40
  store ptr %86, ptr %87, align 8, !tbaa !24
  %88 = load i64, ptr %81, align 8, !tbaa !22
  tail call void @llvm.memset.p0.i64(ptr align 1 %86, i8 0, i64 %88, i1 false)
  %89 = load ptr, ptr %87, align 8, !tbaa !24
  %90 = load ptr, ptr %79, align 8, !tbaa !24
  %91 = load i64, ptr %81, align 8, !tbaa !22
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %89, ptr align 1 %90, i64 %91, i1 false)
  %92 = tail call ptr @pop(ptr noundef nonnull %32)
  tail call void @merkle_node_destroy(ptr noundef %92)
  %93 = tail call i64 @push(ptr noundef nonnull %32, ptr noundef %83)
  %94 = load i64, ptr %47, align 8, !tbaa !25
  %95 = icmp ugt i64 %94, 1
  br i1 %95, label %51, label %.thread

.thread.sink.split:                               ; preds = %6, %4
  %.sink = phi i32 [ 14, %4 ], [ 22, %6 ]
  %96 = tail call ptr @__errno_location() #6
  store i32 %.sink, ptr %96, align 4, !tbaa !29
  br label %.thread

.thread:                                          ; preds = %63, %51, %.thread.sink.split, %17
  %.082 = phi ptr [ %.083, %17 ], [ null, %.thread.sink.split ], [ %.083, %51 ], [ %.083, %63 ]
  ret ptr %.082
}

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__errno_location() local_unnamed_addr #4

declare i64 @ft_parent(i64 noundef, i64 noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare hidden ptr @pop(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local void @merkle_node_destroy(ptr noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { mustprogress nofree nosync nounwind willreturn memory(none) "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 = { nounwind willreturn memory(none) }

!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 8}
!6 = !{!"merkle_node_list", !7, i64 0, !10, i64 8, !11, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!6, !11, i64 16}
!13 = !{!14, !10, i64 32}
!14 = !{!"merkle", !7, i64 0, !6, i64 8, !10, i64 32, !15, i64 40}
!15 = !{!"merkle_codec", !11, i64 0, !11, i64 8}
!16 = !{!17, !10, i64 16}
!17 = !{!"merkle_node", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !11, i64 40, !11, i64 48}
!18 = !{!17, !10, i64 8}
!19 = !{!17, !11, i64 48}
!20 = !{!17, !10, i64 24}
!21 = !{!14, !11, i64 40}
!22 = !{!17, !10, i64 32}
!23 = !{!17, !7, i64 4}
!24 = !{!17, !11, i64 40}
!25 = !{!14, !10, i64 16}
!26 = !{!14, !11, i64 24}
!27 = !{!11, !11, i64 0}
!28 = !{!14, !11, i64 48}
!29 = !{!7, !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass