; 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.subgraph_t = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i16, i32, ptr }
%struct.dfs_code_t = type { i16, i16, i32, i32, %struct.edge_label_t, i32 }
%struct.edge_label_t = type { i32, i32 }
%struct.extension_t = type { ptr, ptr, i32, %struct.dfs_code_t }

; 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: inlinehint nounwind uwtable
declare hidden i32 @rightmost_path_search(ptr noundef, i32 noundef, i16 noundef zeroext) #1

; 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) #2

; Function Attrs: nounwind uwtable
define dso_local void @update_canonical_subgraph_template(ptr noundef %0, ptr noundef %1) #3 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.subgraph_t, ptr %6, i32 0, i32 0
  %8 = load ptr, ptr %7, align 8, !tbaa !9
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.subgraph_t, ptr %9, i32 0, i32 14
  %11 = load i32, ptr %10, align 8, !tbaa !13
  %12 = zext i32 %11 to i64
  %13 = getelementptr inbounds %struct.dfs_code_t, ptr %8, i64 %12
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.extension_t, ptr %14, i32 0, i32 3
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %13, ptr align 4 %15, i64 24, i1 false), !tbaa.struct !14
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.subgraph_t, ptr %16, i32 0, i32 14
  %18 = load i32, ptr %17, align 8, !tbaa !13
  %19 = add i32 %18, 1
  store i32 %19, ptr %17, align 8, !tbaa !13
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.extension_t, ptr %20, i32 0, i32 3
  %22 = getelementptr inbounds %struct.dfs_code_t, ptr %21, i32 0, i32 1
  %23 = load i16, ptr %22, align 2, !tbaa !17
  %24 = zext i16 %23 to i32
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.extension_t, ptr %25, i32 0, i32 3
  %27 = getelementptr inbounds %struct.dfs_code_t, ptr %26, i32 0, i32 0
  %28 = load i16, ptr %27, align 4, !tbaa !21
  %29 = zext i16 %28 to i32
  %30 = icmp sgt i32 %24, %29
  br i1 %30, label %31, label %77

31:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.subgraph_t, ptr %32, i32 0, i32 2
  %34 = load ptr, ptr %33, align 8, !tbaa !22
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.subgraph_t, ptr %35, i32 0, i32 13
  %37 = load i32, ptr %36, align 4, !tbaa !23
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.extension_t, ptr %38, i32 0, i32 3
  %40 = getelementptr inbounds %struct.dfs_code_t, ptr %39, i32 0, i32 0
  %41 = load i16, ptr %40, align 4, !tbaa !21
  %42 = call i32 @rightmost_path_search(ptr noundef %34, i32 noundef %37, i16 noundef zeroext %41)
  store i32 %42, ptr %5, align 4, !tbaa !16
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.extension_t, ptr %43, i32 0, i32 3
  %45 = getelementptr inbounds %struct.dfs_code_t, ptr %44, i32 0, i32 1
  %46 = load i16, ptr %45, align 2, !tbaa !17
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.subgraph_t, ptr %47, i32 0, i32 2
  %49 = load ptr, ptr %48, align 8, !tbaa !22
  %50 = load i32, ptr %5, align 4, !tbaa !16
  %51 = add nsw i32 %50, 1
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds i16, ptr %49, i64 %52
  store i16 %46, ptr %53, align 2, !tbaa !15
  %54 = load i32, ptr %5, align 4, !tbaa !16
  %55 = add nsw i32 %54, 2
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.subgraph_t, ptr %56, i32 0, i32 13
  store i32 %55, ptr %57, align 4, !tbaa !23
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.extension_t, ptr %58, i32 0, i32 3
  %60 = getelementptr inbounds %struct.dfs_code_t, ptr %59, i32 0, i32 1
  %61 = load i16, ptr %60, align 2, !tbaa !17
  %62 = load ptr, ptr %3, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.subgraph_t, ptr %62, i32 0, i32 18
  store i16 %61, ptr %63, align 8, !tbaa !24
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.extension_t, ptr %64, i32 0, i32 3
  %66 = getelementptr inbounds %struct.dfs_code_t, ptr %65, i32 0, i32 3
  %67 = load i32, ptr %66, align 4, !tbaa !25
  %68 = load ptr, ptr %3, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.subgraph_t, ptr %68, i32 0, i32 1
  %70 = load ptr, ptr %69, align 8, !tbaa !26
  %71 = load ptr, ptr %4, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.extension_t, ptr %71, i32 0, i32 3
  %73 = getelementptr inbounds %struct.dfs_code_t, ptr %72, i32 0, i32 1
  %74 = load i16, ptr %73, align 2, !tbaa !17
  %75 = zext i16 %74 to i64
  %76 = getelementptr inbounds i32, ptr %70, i64 %75
  store i32 %67, ptr %76, align 4, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %77

77:                                               ; preds = %31, %2
  ret void
}

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

!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, !6, i64 0}
!10 = !{!"subgraph_t", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !11, i64 64, !11, i64 68, !11, i64 72, !11, i64 76, !11, i64 80, !11, i64 84, !11, i64 88, !11, i64 92, !11, i64 96, !11, i64 100, !12, i64 104, !11, i64 108, !6, i64 112}
!11 = !{!"int", !7, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = !{!10, !11, i64 88}
!14 = !{i64 0, i64 2, !15, i64 2, i64 2, !15, i64 4, i64 4, !16, i64 8, i64 4, !16, i64 12, i64 4, !16, i64 16, i64 4, !16, i64 20, i64 4, !16}
!15 = !{!12, !12, i64 0}
!16 = !{!11, !11, i64 0}
!17 = !{!18, !12, i64 22}
!18 = !{!"extension_t", !6, i64 0, !6, i64 8, !11, i64 16, !19, i64 20}
!19 = !{!"dfs_code_t", !12, i64 0, !12, i64 2, !11, i64 4, !11, i64 8, !20, i64 12, !11, i64 20}
!20 = !{!"edge_label_t", !11, i64 0, !11, i64 4}
!21 = !{!18, !12, i64 20}
!22 = !{!10, !6, i64 16}
!23 = !{!10, !11, i64 84}
!24 = !{!10, !12, i64 104}
!25 = !{!18, !11, i64 28}
!26 = !{!10, !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.dfs_code_t = type { i16, i16, i32, i32, %struct.edge_label_t, i32 }
%struct.edge_label_t = type { i32, i32 }

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @rightmost_path_search(ptr noundef, i32 noundef, i16 noundef zeroext) local_unnamed_addr #0

; 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) #1

; Function Attrs: nounwind uwtable
define dso_local void @update_canonical_subgraph_template(ptr nocapture noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #2 {
  %3 = load ptr, ptr %0, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 88
  %5 = load i32, ptr %4, align 8, !tbaa !12
  %6 = zext i32 %5 to i64
  %7 = getelementptr inbounds %struct.dfs_code_t, ptr %3, i64 %6
  %8 = getelementptr inbounds i8, ptr %1, i64 20
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(24) %7, ptr noundef nonnull align 4 dereferenceable(24) %8, i64 24, i1 false), !tbaa.struct !13
  %9 = load i32, ptr %4, align 8, !tbaa !12
  %10 = add i32 %9, 1
  store i32 %10, ptr %4, align 8, !tbaa !12
  %11 = getelementptr inbounds i8, ptr %1, i64 22
  %12 = load i16, ptr %11, align 2, !tbaa !16
  %13 = load i16, ptr %8, align 4, !tbaa !20
  %14 = icmp ugt i16 %12, %13
  br i1 %14, label %15, label %34

15:                                               ; preds = %2
  %16 = getelementptr inbounds i8, ptr %0, i64 16
  %17 = load ptr, ptr %16, align 8, !tbaa !21
  %18 = getelementptr inbounds i8, ptr %0, i64 84
  %19 = load i32, ptr %18, align 4, !tbaa !22
  %20 = tail call i32 @rightmost_path_search(ptr noundef %17, i32 noundef %19, i16 noundef zeroext %13)
  %21 = load i16, ptr %11, align 2, !tbaa !16
  %22 = load ptr, ptr %16, align 8, !tbaa !21
  %23 = sext i32 %20 to i64
  %24 = getelementptr i16, ptr %22, i64 %23
  %25 = getelementptr i8, ptr %24, i64 2
  store i16 %21, ptr %25, align 2, !tbaa !14
  %26 = add nsw i32 %20, 2
  store i32 %26, ptr %18, align 4, !tbaa !22
  %27 = getelementptr inbounds i8, ptr %0, i64 104
  store i16 %21, ptr %27, align 8, !tbaa !23
  %28 = getelementptr inbounds i8, ptr %1, i64 28
  %29 = load i32, ptr %28, align 4, !tbaa !24
  %30 = getelementptr inbounds i8, ptr %0, i64 8
  %31 = load ptr, ptr %30, align 8, !tbaa !25
  %32 = zext i16 %21 to i64
  %33 = getelementptr inbounds i32, ptr %31, i64 %32
  store i32 %29, ptr %33, align 4, !tbaa !15
  br label %34

34:                                               ; preds = %15, %2
  ret void
}

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

!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 = !{!"subgraph_t", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !10, i64 64, !10, i64 68, !10, i64 72, !10, i64 76, !10, i64 80, !10, i64 84, !10, i64 88, !10, i64 92, !10, i64 96, !10, i64 100, !11, i64 104, !10, i64 108, !7, i64 112}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"short", !8, i64 0}
!12 = !{!6, !10, i64 88}
!13 = !{i64 0, i64 2, !14, i64 2, i64 2, !14, i64 4, i64 4, !15, i64 8, i64 4, !15, i64 12, i64 4, !15, i64 16, i64 4, !15, i64 20, i64 4, !15}
!14 = !{!11, !11, i64 0}
!15 = !{!10, !10, i64 0}
!16 = !{!17, !11, i64 22}
!17 = !{!"extension_t", !7, i64 0, !7, i64 8, !10, i64 16, !18, i64 20}
!18 = !{!"dfs_code_t", !11, i64 0, !11, i64 2, !10, i64 4, !10, i64 8, !19, i64 12, !10, i64 20}
!19 = !{!"edge_label_t", !10, i64 0, !10, i64 4}
!20 = !{!17, !11, i64 20}
!21 = !{!6, !7, i64 16}
!22 = !{!6, !10, i64 84}
!23 = !{!6, !11, i64 104}
!24 = !{!17, !10, i64 28}
!25 = !{!6, !7, i64 8}


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