; 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.thread_data_t = type { ptr, ptr, ptr, ptr, ptr, %struct.embedding_store_t, %struct.embedding_store_t, %struct.embedding_store_t, %struct.extension_store_t, ptr, %struct.rem_edge_store_t, ptr, ptr, i32, %struct.subgraph_store_t, i32 }
%struct.embedding_store_t = type { ptr, ptr, ptr, ptr, i32, i32, i32, i32, i32, i32 }
%struct.extension_store_t = type { ptr, ptr, ptr, i32, i32, i32 }
%struct.rem_edge_store_t = type { ptr, ptr, ptr }
%struct.subgraph_store_t = type { ptr, ptr, i32, i32 }

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

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

; Function Attrs: nounwind
declare void @free(ptr noundef) #1

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

8:                                                ; preds = %49, %3
  %9 = load i32, ptr %7, align 4, !tbaa !9
  %10 = load i32, ptr %5, align 4, !tbaa !9
  %11 = icmp ult i32 %9, %10
  br i1 %11, label %13, label %12

12:                                               ; preds = %8
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %52

13:                                               ; preds = %8
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = load i32, ptr %7, align 4, !tbaa !9
  %16 = zext i32 %15 to i64
  %17 = getelementptr inbounds %struct.thread_data_t, ptr %14, i64 %16
  %18 = getelementptr inbounds %struct.thread_data_t, ptr %17, i32 0, i32 5
  call void @free_embedding_store(ptr noundef %18)
  %19 = load i32, ptr %6, align 4, !tbaa !9
  %20 = icmp ne i32 %19, 0
  br i1 %20, label %21, label %27

21:                                               ; preds = %13
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = load i32, ptr %7, align 4, !tbaa !9
  %24 = zext i32 %23 to i64
  %25 = getelementptr inbounds %struct.thread_data_t, ptr %22, i64 %24
  %26 = getelementptr inbounds %struct.thread_data_t, ptr %25, i32 0, i32 6
  call void @free_embedding_store(ptr noundef %26)
  br label %27

27:                                               ; preds = %21, %13
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = load i32, ptr %7, align 4, !tbaa !9
  %30 = zext i32 %29 to i64
  %31 = getelementptr inbounds %struct.thread_data_t, ptr %28, i64 %30
  %32 = getelementptr inbounds %struct.thread_data_t, ptr %31, i32 0, i32 7
  call void @free_embedding_store(ptr noundef %32)
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = load i32, ptr %7, align 4, !tbaa !9
  %35 = zext i32 %34 to i64
  %36 = getelementptr inbounds %struct.thread_data_t, ptr %33, i64 %35
  %37 = getelementptr inbounds %struct.thread_data_t, ptr %36, i32 0, i32 8
  call void @free_extension_store(ptr noundef %37)
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = load i32, ptr %7, align 4, !tbaa !9
  %40 = zext i32 %39 to i64
  %41 = getelementptr inbounds %struct.thread_data_t, ptr %38, i64 %40
  %42 = getelementptr inbounds %struct.thread_data_t, ptr %41, i32 0, i32 10
  call void @free_rem_edge_store(ptr noundef %42)
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = load i32, ptr %7, align 4, !tbaa !9
  %45 = zext i32 %44 to i64
  %46 = getelementptr inbounds %struct.thread_data_t, ptr %43, i64 %45
  %47 = getelementptr inbounds %struct.thread_data_t, ptr %46, i32 0, i32 12
  %48 = load ptr, ptr %47, align 8, !tbaa !11
  call void @free(ptr noundef %48) #4
  br label %49

49:                                               ; preds = %27
  %50 = load i32, ptr %7, align 4, !tbaa !9
  %51 = add i32 %50, 1
  store i32 %51, ptr %7, align 4, !tbaa !9
  br label %8, !llvm.loop !17

52:                                               ; preds = %12
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  call void @free(ptr noundef %53) #4
  ret void
}

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

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { 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 = { 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 #4 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 288}
!12 = !{!"thread_data_t", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !13, i64 40, !13, i64 96, !13, i64 152, !14, i64 208, !6, i64 248, !15, i64 256, !6, i64 280, !6, i64 288, !10, i64 296, !16, i64 304, !10, i64 328}
!13 = !{!"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}
!14 = !{!"extension_store_t", !6, i64 0, !6, i64 8, !6, i64 16, !10, i64 24, !10, i64 28, !10, i64 32}
!15 = !{!"rem_edge_store_t", !6, i64 0, !6, i64 8, !6, i64 16}
!16 = !{!"subgraph_store_t", !6, i64 0, !6, i64 8, !10, i64 16, !10, i64 20}
!17 = distinct !{!17, !18}
!18 = !{!"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"

%struct.thread_data_t = type { ptr, ptr, ptr, ptr, ptr, %struct.embedding_store_t, %struct.embedding_store_t, %struct.embedding_store_t, %struct.extension_store_t, ptr, %struct.rem_edge_store_t, ptr, ptr, i32, %struct.subgraph_store_t, i32 }
%struct.embedding_store_t = type { ptr, ptr, ptr, ptr, i32, i32, i32, i32, i32, i32 }
%struct.extension_store_t = type { ptr, ptr, ptr, i32, i32, i32 }
%struct.rem_edge_store_t = type { ptr, ptr, ptr }
%struct.subgraph_store_t = type { ptr, ptr, i32, i32 }

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @free_thread_data(ptr noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #1 {
  %.not17 = icmp eq i32 %1, 0
  br i1 %.not17, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3
  %.not = icmp eq i32 %2, 0
  %wide.trip.count23 = zext i32 %1 to i64
  br i1 %.not, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph, %.lr.ph.split.us
  %indvars.iv20 = phi i64 [ %indvars.iv.next21, %.lr.ph.split.us ], [ 0, %.lr.ph ]
  %4 = getelementptr inbounds %struct.thread_data_t, ptr %0, i64 %indvars.iv20
  %5 = getelementptr inbounds i8, ptr %4, i64 40
  tail call void @free_embedding_store(ptr noundef nonnull %5)
  %6 = getelementptr inbounds i8, ptr %4, i64 152
  tail call void @free_embedding_store(ptr noundef nonnull %6)
  %7 = getelementptr inbounds i8, ptr %4, i64 208
  tail call void @free_extension_store(ptr noundef nonnull %7)
  %8 = getelementptr inbounds i8, ptr %4, i64 256
  tail call void @free_rem_edge_store(ptr noundef nonnull %8)
  %9 = getelementptr inbounds i8, ptr %4, i64 288
  %10 = load ptr, ptr %9, align 8, !tbaa !5
  tail call void @free(ptr noundef %10) #3
  %indvars.iv.next21 = add nuw nsw i64 %indvars.iv20, 1
  %exitcond24.not = icmp eq i64 %indvars.iv.next21, %wide.trip.count23
  br i1 %exitcond24.not, label %._crit_edge, label %.lr.ph.split.us, !llvm.loop !15

._crit_edge:                                      ; preds = %.lr.ph.split, %.lr.ph.split.us, %3
  tail call void @free(ptr noundef %0) #3
  ret void

.lr.ph.split:                                     ; preds = %.lr.ph, %.lr.ph.split
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph.split ], [ 0, %.lr.ph ]
  %11 = getelementptr inbounds %struct.thread_data_t, ptr %0, i64 %indvars.iv
  %12 = getelementptr inbounds i8, ptr %11, i64 40
  tail call void @free_embedding_store(ptr noundef nonnull %12)
  %13 = getelementptr inbounds i8, ptr %11, i64 96
  tail call void @free_embedding_store(ptr noundef nonnull %13)
  %14 = getelementptr inbounds i8, ptr %11, i64 152
  tail call void @free_embedding_store(ptr noundef nonnull %14)
  %15 = getelementptr inbounds i8, ptr %11, i64 208
  tail call void @free_extension_store(ptr noundef nonnull %15)
  %16 = getelementptr inbounds i8, ptr %11, i64 256
  tail call void @free_rem_edge_store(ptr noundef nonnull %16)
  %17 = getelementptr inbounds i8, ptr %11, i64 288
  %18 = load ptr, ptr %17, align 8, !tbaa !5
  tail call void @free(ptr noundef %18) #3
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count23
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph.split, !llvm.loop !15
}

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

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

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

attributes #0 = { mustprogress nounwind willreturn allockind("free") 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 #1 = { 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 = { 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 #3 = { 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, !7, i64 288}
!6 = !{!"thread_data_t", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !10, i64 40, !10, i64 96, !10, i64 152, !12, i64 208, !7, i64 248, !13, i64 256, !7, i64 280, !7, i64 288, !11, i64 296, !14, i64 304, !11, i64 328}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"embedding_store_t", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !11, i64 48, !11, i64 52}
!11 = !{!"int", !8, i64 0}
!12 = !{!"extension_store_t", !7, i64 0, !7, i64 8, !7, i64 16, !11, i64 24, !11, i64 28, !11, i64 32}
!13 = !{!"rem_edge_store_t", !7, i64 0, !7, i64 8, !7, i64 16}
!14 = !{!"subgraph_store_t", !7, i64 0, !7, i64 8, !11, i64 16, !11, i64 20}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass