; 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 }

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @canonical_subgraph_template(ptr dead_on_unwind noalias writable sret(%struct.subgraph_t) align 8 %0, ptr noundef %1) #3 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  store ptr %1, ptr %3, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %0, i8 0, i64 120, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  %5 = load ptr, ptr %3, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.subgraph_t, ptr %5, i32 0, i32 18
  %7 = load i16, ptr %6, align 8, !tbaa !9
  %8 = zext i16 %7 to i32
  %9 = add nsw i32 %8, 1
  store i32 %9, ptr %4, align 4, !tbaa !13
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.subgraph_t, ptr %10, i32 0, i32 14
  %12 = load i32, ptr %11, align 8, !tbaa !14
  %13 = getelementptr inbounds %struct.subgraph_t, ptr %0, i32 0, i32 14
  store i32 %12, ptr %13, align 8, !tbaa !14
  %14 = getelementptr inbounds %struct.subgraph_t, ptr %0, i32 0, i32 14
  %15 = load i32, ptr %14, align 8, !tbaa !14
  %16 = zext i32 %15 to i64
  %17 = mul i64 %16, 24
  %18 = call noalias ptr @malloc(i64 noundef %17) #5
  %19 = getelementptr inbounds %struct.subgraph_t, ptr %0, i32 0, i32 0
  store ptr %18, ptr %19, align 8, !tbaa !15
  %20 = load i32, ptr %4, align 4, !tbaa !13
  %21 = zext i32 %20 to i64
  %22 = mul i64 %21, 2
  %23 = call noalias ptr @malloc(i64 noundef %22) #5
  %24 = getelementptr inbounds %struct.subgraph_t, ptr %0, i32 0, i32 2
  store ptr %23, ptr %24, align 8, !tbaa !16
  %25 = load i32, ptr %4, align 4, !tbaa !13
  %26 = zext i32 %25 to i64
  %27 = mul i64 %26, 4
  %28 = call noalias ptr @malloc(i64 noundef %27) #5
  %29 = getelementptr inbounds %struct.subgraph_t, ptr %0, i32 0, i32 1
  store ptr %28, ptr %29, align 8, !tbaa !17
  %30 = getelementptr inbounds %struct.subgraph_t, ptr %0, i32 0, i32 10
  store i32 1, ptr %30, align 8, !tbaa !18
  %31 = call noalias ptr @malloc(i64 noundef 4) #5
  %32 = getelementptr inbounds %struct.subgraph_t, ptr %0, i32 0, i32 5
  store ptr %31, ptr %32, align 8, !tbaa !19
  %33 = getelementptr inbounds %struct.subgraph_t, ptr %0, i32 0, i32 5
  %34 = load ptr, ptr %33, align 8, !tbaa !19
  %35 = getelementptr inbounds i32, ptr %34, i64 0
  store i32 1, ptr %35, align 4, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  ret void
}

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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(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, !12, i64 104}
!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 = !{!11, !11, i64 0}
!14 = !{!10, !11, i64 88}
!15 = !{!10, !6, i64 0}
!16 = !{!10, !6, i64 16}
!17 = !{!10, !6, i64 8}
!18 = !{!10, !11, i64 72}
!19 = !{!10, !6, 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.subgraph_t = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i16, i32, ptr }

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

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write, argmem: readwrite, inaccessiblemem: readwrite) uwtable
define dso_local void @canonical_subgraph_template(ptr dead_on_unwind noalias nocapture writable writeonly sret(%struct.subgraph_t) align 8 %0, ptr nocapture noundef readonly %1) local_unnamed_addr #2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 24
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(120) %3, i8 0, i64 96, i1 false)
  %4 = getelementptr inbounds i8, ptr %1, i64 104
  %5 = load i16, ptr %4, align 8, !tbaa !5
  %6 = zext i16 %5 to i64
  %7 = add nuw nsw i64 %6, 1
  %8 = getelementptr inbounds i8, ptr %1, i64 88
  %9 = load i32, ptr %8, align 8, !tbaa !12
  %10 = getelementptr inbounds i8, ptr %0, i64 88
  store i32 %9, ptr %10, align 8, !tbaa !12
  %11 = zext i32 %9 to i64
  %12 = mul nuw nsw i64 %11, 24
  %13 = tail call noalias ptr @malloc(i64 noundef %12) #3
  store ptr %13, ptr %0, align 8, !tbaa !13
  %14 = shl nuw nsw i64 %7, 1
  %15 = tail call noalias ptr @malloc(i64 noundef %14) #3
  %16 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr %15, ptr %16, align 8, !tbaa !14
  %17 = shl nuw nsw i64 %7, 2
  %18 = tail call noalias ptr @malloc(i64 noundef %17) #3
  %19 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %18, ptr %19, align 8, !tbaa !15
  %20 = getelementptr inbounds i8, ptr %0, i64 72
  store i32 1, ptr %20, align 8, !tbaa !16
  %21 = tail call noalias dereferenceable_or_null(4) ptr @malloc(i64 noundef 4) #3
  %22 = getelementptr inbounds i8, ptr %0, i64 40
  store ptr %21, ptr %22, align 8, !tbaa !17
  store i32 1, ptr %21, align 4, !tbaa !18
  ret void
}

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #1 = { 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 #2 = { mustprogress nofree nounwind willreturn memory(write, argmem: readwrite, inaccessiblemem: readwrite) 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(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, !11, i64 104}
!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 = !{!6, !7, i64 0}
!14 = !{!6, !7, i64 16}
!15 = !{!6, !7, i64 8}
!16 = !{!6, !10, i64 72}
!17 = !{!6, !7, i64 40}
!18 = !{!10, !10, i64 0}


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