; LLVM IR from kalininalab/rinminer :: rinminer (rinminer)

; 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.embedding_store_t = type { ptr, ptr, ptr, ptr, i32, i32, i32, i32, i32, i32 }
%struct.mapped_vertex_t = type { ptr, i32, i16 }

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #1

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

; Function Attrs: nounwind allocsize(1)
declare ptr @realloc(ptr noundef, i64 noundef) #2

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

9:                                                ; preds = %2
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.embedding_store_t, ptr %10, i32 0, i32 0
  %12 = load ptr, ptr %11, align 8, !tbaa !11
  %13 = icmp ne ptr %12, null
  br i1 %13, label %14, label %23

14:                                               ; preds = %9
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.embedding_store_t, ptr %15, i32 0, i32 0
  %17 = load ptr, ptr %16, align 8, !tbaa !11
  store ptr %17, ptr %5, align 8, !tbaa !5
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.mapped_vertex_t, ptr %18, i32 0, i32 0
  %20 = load ptr, ptr %19, align 8, !tbaa !13
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.embedding_store_t, ptr %21, i32 0, i32 0
  store ptr %20, ptr %22, align 8, !tbaa !11
  br label %89

23:                                               ; preds = %9, %2
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.embedding_store_t, ptr %24, i32 0, i32 5
  %26 = load i32, ptr %25, align 4, !tbaa !16
  %27 = icmp eq i32 %26, 0
  br i1 %27, label %28, label %68

28:                                               ; preds = %23
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.embedding_store_t, ptr %29, i32 0, i32 6
  %31 = load i32, ptr %30, align 8, !tbaa !17
  %32 = add i32 %31, 1
  store i32 %32, ptr %30, align 8, !tbaa !17
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.embedding_store_t, ptr %33, i32 0, i32 5
  store i32 1048576, ptr %34, align 4, !tbaa !16
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.embedding_store_t, ptr %35, i32 0, i32 6
  %37 = load i32, ptr %36, align 8, !tbaa !17
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.embedding_store_t, ptr %38, i32 0, i32 4
  %40 = load i32, ptr %39, align 8, !tbaa !18
  %41 = icmp eq i32 %37, %40
  br i1 %41, label %42, label %67

42:                                               ; preds = %28
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.embedding_store_t, ptr %43, i32 0, i32 4
  %45 = load i32, ptr %44, align 8, !tbaa !18
  %46 = add i32 %45, 1
  store i32 %46, ptr %44, align 8, !tbaa !18
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.embedding_store_t, ptr %47, i32 0, i32 1
  %49 = load ptr, ptr %48, align 8, !tbaa !19
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.embedding_store_t, ptr %50, i32 0, i32 4
  %52 = load i32, ptr %51, align 8, !tbaa !18
  %53 = zext i32 %52 to i64
  %54 = mul i64 %53, 8
  %55 = call ptr @realloc(ptr noundef %49, i64 noundef %54) #5
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.embedding_store_t, ptr %56, i32 0, i32 1
  store ptr %55, ptr %57, align 8, !tbaa !19
  %58 = call noalias ptr @malloc(i64 noundef 16777216) #6
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.embedding_store_t, ptr %59, i32 0, i32 1
  %61 = load ptr, ptr %60, align 8, !tbaa !19
  %62 = load ptr, ptr %3, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.embedding_store_t, ptr %62, i32 0, i32 6
  %64 = load i32, ptr %63, align 8, !tbaa !17
  %65 = zext i32 %64 to i64
  %66 = getelementptr inbounds ptr, ptr %61, i64 %65
  store ptr %58, ptr %66, align 8, !tbaa !5
  br label %67

67:                                               ; preds = %42, %28
  br label %68

68:                                               ; preds = %67, %23
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %69 = load ptr, ptr %3, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.embedding_store_t, ptr %69, i32 0, i32 1
  %71 = load ptr, ptr %70, align 8, !tbaa !19
  %72 = load ptr, ptr %3, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.embedding_store_t, ptr %72, i32 0, i32 6
  %74 = load i32, ptr %73, align 8, !tbaa !17
  %75 = zext i32 %74 to i64
  %76 = getelementptr inbounds ptr, ptr %71, i64 %75
  %77 = load ptr, ptr %76, align 8, !tbaa !5
  store ptr %77, ptr %6, align 8, !tbaa !5
  %78 = load ptr, ptr %6, align 8, !tbaa !5
  %79 = load ptr, ptr %3, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.embedding_store_t, ptr %79, i32 0, i32 5
  %81 = load i32, ptr %80, align 4, !tbaa !16
  %82 = sub i32 1048576, %81
  %83 = zext i32 %82 to i64
  %84 = getelementptr inbounds %struct.mapped_vertex_t, ptr %78, i64 %83
  store ptr %84, ptr %5, align 8, !tbaa !5
  %85 = load ptr, ptr %3, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.embedding_store_t, ptr %85, i32 0, i32 5
  %87 = load i32, ptr %86, align 4, !tbaa !16
  %88 = add i32 %87, -1
  store i32 %88, ptr %86, align 4, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  br label %89

89:                                               ; preds = %68, %14
  %90 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret ptr %90
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind allocsize(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 = { nounwind allocsize(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 #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 allocsize(1) }
attributes #6 = { nounwind allocsize(0) }

!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 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"embedding_store_t", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52}
!13 = !{!14, !6, i64 0}
!14 = !{!"mapped_vertex_t", !6, i64 0, !10, i64 8, !15, i64 12}
!15 = !{!"short", !7, i64 0}
!16 = !{!12, !10, i64 36}
!17 = !{!12, !10, i64 40}
!18 = !{!12, !10, i64 32}
!19 = !{!12, !6, i64 8}


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

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind willreturn allockind("realloc") allocsize(1) memory(argmem: readwrite, inaccessiblemem: readwrite)
declare noalias noundef ptr @realloc(ptr allocptr nocapture noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind willreturn uwtable
define dso_local ptr @request_mapped_vertex(ptr nocapture noundef %0, i32 noundef %1) local_unnamed_addr #2 {
  %.not = icmp eq i32 %1, 0
  br i1 %.not, label %7, label %3

3:                                                ; preds = %2
  %4 = load ptr, ptr %0, align 8, !tbaa !5
  %.not23 = icmp eq ptr %4, null
  br i1 %.not23, label %7, label %5

5:                                                ; preds = %3
  %6 = load ptr, ptr %4, align 8, !tbaa !11
  store ptr %6, ptr %0, align 8, !tbaa !5
  br label %40

7:                                                ; preds = %3, %2
  %8 = getelementptr inbounds i8, ptr %0, i64 36
  %9 = load i32, ptr %8, align 4, !tbaa !14
  %10 = icmp eq i32 %9, 0
  %11 = getelementptr inbounds i8, ptr %0, i64 40
  %12 = load i32, ptr %11, align 8, !tbaa !15
  br i1 %10, label %13, label %._crit_edge

13:                                               ; preds = %7
  %14 = add i32 %12, 1
  store i32 %14, ptr %11, align 8, !tbaa !15
  store i32 1048576, ptr %8, align 4, !tbaa !14
  %15 = getelementptr inbounds i8, ptr %0, i64 32
  %16 = load i32, ptr %15, align 8, !tbaa !16
  %17 = icmp eq i32 %14, %16
  br i1 %17, label %18, label %._crit_edge

18:                                               ; preds = %13
  %19 = add i32 %12, 2
  store i32 %19, ptr %15, align 8, !tbaa !16
  %20 = getelementptr inbounds i8, ptr %0, i64 8
  %21 = load ptr, ptr %20, align 8, !tbaa !17
  %22 = zext i32 %19 to i64
  %23 = shl nuw nsw i64 %22, 3
  %24 = tail call ptr @realloc(ptr noundef %21, i64 noundef %23) #3
  store ptr %24, ptr %20, align 8, !tbaa !17
  %25 = tail call noalias dereferenceable_or_null(16777216) ptr @malloc(i64 noundef 16777216) #4
  %26 = load i32, ptr %11, align 8, !tbaa !15
  %27 = zext i32 %26 to i64
  %28 = getelementptr inbounds ptr, ptr %24, i64 %27
  store ptr %25, ptr %28, align 8, !tbaa !18
  %.pre24 = load i32, ptr %8, align 4, !tbaa !14
  br label %._crit_edge

._crit_edge:                                      ; preds = %7, %13, %18
  %29 = phi i32 [ 1048576, %13 ], [ %.pre24, %18 ], [ %9, %7 ]
  %30 = phi i32 [ %14, %13 ], [ %26, %18 ], [ %12, %7 ]
  %31 = getelementptr inbounds i8, ptr %0, i64 8
  %32 = load ptr, ptr %31, align 8, !tbaa !17
  %33 = zext i32 %30 to i64
  %34 = getelementptr inbounds ptr, ptr %32, i64 %33
  %35 = load ptr, ptr %34, align 8, !tbaa !18
  %36 = sub i32 1048576, %29
  %37 = zext i32 %36 to i64
  %38 = getelementptr inbounds %struct.mapped_vertex_t, ptr %35, i64 %37
  %39 = add i32 %29, -1
  store i32 %39, ptr %8, align 4, !tbaa !14
  br label %40

40:                                               ; preds = %._crit_edge, %5
  %.0 = phi ptr [ %4, %5 ], [ %38, %._crit_edge ]
  ret ptr %.0
}

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { mustprogress nounwind willreturn allockind("realloc") allocsize(1) memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 nounwind willreturn 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 allocsize(1) }
attributes #4 = { nounwind allocsize(0) }

!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, !7, i64 0}
!6 = !{!"embedding_store_t", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!12, !7, i64 0}
!12 = !{!"mapped_vertex_t", !7, i64 0, !10, i64 8, !13, i64 12}
!13 = !{!"short", !8, i64 0}
!14 = !{!6, !10, i64 36}
!15 = !{!6, !10, i64 40}
!16 = !{!6, !10, i64 32}
!17 = !{!6, !7, i64 8}
!18 = !{!7, !7, i64 0}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass