; LLVM IR from keroro824/HashingDeepLearning :: SLIDE/Node.ll (ZN4Node23backPropagateFirstLayerEPiPfifi)

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

%class.Node = type <{ i32, i32, ptr, i32, [4 x i8], i64, i64, i64, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, float, float, float, float, float, [4 x i8] }>
%struct.train = type { float, float, float, i32, [48 x i8] }

@.str.1 = external hidden unnamed_addr constant [83 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [78 x i8], align 1
@__PRETTY_FUNCTION__._ZN4Node23backPropagateFirstLayerEPiPfifi = external hidden unnamed_addr constant [68 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4Node23backPropagateFirstLayerEPiPfifi(ptr noundef nonnull align 8 dereferenceable(132) %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, float noundef %4, i32 noundef %5) #2 align 2 {
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca float, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca float, align 4
  %15 = alloca float, align 4
  %16 = alloca float, align 4
  %17 = alloca float, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store i32 %3, ptr %10, align 4, !tbaa !9
  store float %4, ptr %11, align 4, !tbaa !11
  store i32 %5, ptr %12, align 4, !tbaa !9
  %18 = load ptr, ptr %7, align 8
  %19 = getelementptr inbounds %class.Node, ptr %18, i32 0, i32 2
  %20 = load ptr, ptr %19, align 8, !tbaa !13
  %21 = load i32, ptr %12, align 4, !tbaa !9
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds %struct.train, ptr %20, i64 %22
  %24 = getelementptr inbounds %struct.train, ptr %23, i32 0, i32 3
  %25 = load i32, ptr %24, align 4, !tbaa !17
  %26 = icmp eq i32 %25, 1
  br i1 %26, label %27, label %28

27:                                               ; preds = %6
  br label %30

28:                                               ; preds = %6
  call void @__assert_fail(ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 188, ptr noundef @__PRETTY_FUNCTION__._ZN4Node23backPropagateFirstLayerEPiPfifi) #3
  unreachable

29:                                               ; No predecessors!
  br label %30

30:                                               ; preds = %29, %27
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %31

31:                                               ; preds = %65, %30
  %32 = load i32, ptr %13, align 4, !tbaa !9
  %33 = load i32, ptr %10, align 4, !tbaa !9
  %34 = icmp slt i32 %32, %33
  br i1 %34, label %36, label %35

35:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  br label %68

36:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %37 = getelementptr inbounds %class.Node, ptr %18, i32 0, i32 2
  %38 = load ptr, ptr %37, align 8, !tbaa !13
  %39 = load i32, ptr %12, align 4, !tbaa !9
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds %struct.train, ptr %38, i64 %40
  %42 = getelementptr inbounds %struct.train, ptr %41, i32 0, i32 0
  %43 = load float, ptr %42, align 64, !tbaa !19
  %44 = load ptr, ptr %9, align 8, !tbaa !5
  %45 = load i32, ptr %13, align 4, !tbaa !9
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds float, ptr %44, i64 %46
  %48 = load float, ptr %47, align 4, !tbaa !11
  %49 = fmul float %43, %48
  store float %49, ptr %14, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  %50 = load float, ptr %14, align 4, !tbaa !11
  %51 = load float, ptr %14, align 4, !tbaa !11
  %52 = fmul float %50, %51
  store float %52, ptr %15, align 4, !tbaa !11
  %53 = load float, ptr %14, align 4, !tbaa !11
  %54 = getelementptr inbounds %class.Node, ptr %18, i32 0, i32 14
  %55 = load ptr, ptr %54, align 8, !tbaa !20
  %56 = load ptr, ptr %8, align 8, !tbaa !5
  %57 = load i32, ptr %13, align 4, !tbaa !9
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds i32, ptr %56, i64 %58
  %60 = load i32, ptr %59, align 4, !tbaa !9
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds float, ptr %55, i64 %61
  %63 = load float, ptr %62, align 4, !tbaa !11
  %64 = fadd float %63, %53
  store float %64, ptr %62, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  br label %65

65:                                               ; preds = %36
  %66 = load i32, ptr %13, align 4, !tbaa !9
  %67 = add nsw i32 %66, 1
  store i32 %67, ptr %13, align 4, !tbaa !9
  br label %31, !llvm.loop !21

68:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  %69 = getelementptr inbounds %class.Node, ptr %18, i32 0, i32 2
  %70 = load ptr, ptr %69, align 8, !tbaa !13
  %71 = load i32, ptr %12, align 4, !tbaa !9
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds %struct.train, ptr %70, i64 %72
  %74 = getelementptr inbounds %struct.train, ptr %73, i32 0, i32 0
  %75 = load float, ptr %74, align 64, !tbaa !19
  store float %75, ptr %16, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  %76 = load float, ptr %16, align 4, !tbaa !11
  %77 = load float, ptr %16, align 4, !tbaa !11
  %78 = fmul float %76, %77
  store float %78, ptr %17, align 4, !tbaa !11
  %79 = load float, ptr %16, align 4, !tbaa !11
  %80 = getelementptr inbounds %class.Node, ptr %18, i32 0, i32 17
  %81 = load float, ptr %80, align 4, !tbaa !23
  %82 = fadd float %81, %79
  store float %82, ptr %80, align 4, !tbaa !23
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  %83 = getelementptr inbounds %class.Node, ptr %18, i32 0, i32 2
  %84 = load ptr, ptr %83, align 8, !tbaa !13
  %85 = load i32, ptr %12, align 4, !tbaa !9
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds %struct.train, ptr %84, i64 %86
  %88 = getelementptr inbounds %struct.train, ptr %87, i32 0, i32 3
  store i32 0, ptr %88, align 4, !tbaa !17
  %89 = getelementptr inbounds %class.Node, ptr %18, i32 0, i32 2
  %90 = load ptr, ptr %89, align 8, !tbaa !13
  %91 = load i32, ptr %12, align 4, !tbaa !9
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds %struct.train, ptr %90, i64 %92
  %94 = getelementptr inbounds %struct.train, ptr %93, i32 0, i32 0
  store float 0.000000e+00, ptr %94, align 64, !tbaa !19
  %95 = getelementptr inbounds %class.Node, ptr %18, i32 0, i32 2
  %96 = load ptr, ptr %95, align 8, !tbaa !13
  %97 = load i32, ptr %12, align 4, !tbaa !9
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds %struct.train, ptr %96, i64 %98
  %100 = getelementptr inbounds %struct.train, ptr %99, i32 0, i32 1
  store float 0.000000e+00, ptr %100, align 4, !tbaa !24
  %101 = getelementptr inbounds %class.Node, ptr %18, i32 0, i32 0
  %102 = load i32, ptr %101, align 8, !tbaa !25
  %103 = add nsw i32 %102, -1
  store i32 %103, ptr %101, align 8, !tbaa !25
  ret void
}

attributes #0 = { noreturn 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress 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 = { noreturn nounwind }
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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!14, !6, i64 8}
!14 = !{!"_ZTS4Node", !10, i64 0, !15, i64 4, !6, i64 8, !10, i64 16, !16, i64 24, !16, i64 32, !16, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !12, i64 112, !12, i64 116, !12, i64 120, !12, i64 124, !12, i64 128}
!15 = !{!"_ZTS8NodeType", !7, i64 0}
!16 = !{!"long", !7, i64 0}
!17 = !{!18, !10, i64 12}
!18 = !{!"_ZTS5train", !12, i64 0, !12, i64 4, !12, i64 8, !10, i64 12}
!19 = !{!18, !12, i64 0}
!20 = !{!14, !6, i64 96}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!14, !12, i64 116}
!24 = !{!18, !12, i64 4}
!25 = !{!14, !10, i64 0}


; 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.train = type { float, float, float, i32, [48 x i8] }

@.str.1 = external hidden unnamed_addr constant [83 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [78 x i8], align 1
@__PRETTY_FUNCTION__._ZN4Node23backPropagateFirstLayerEPiPfifi = external hidden unnamed_addr constant [68 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4Node23backPropagateFirstLayerEPiPfifi(ptr nocapture noundef nonnull align 8 dereferenceable(132) %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, i32 noundef %3, float noundef %4, i32 noundef %5) local_unnamed_addr #1 align 2 {
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %9 = sext i32 %5 to i64
  %10 = getelementptr inbounds %struct.train, ptr %8, i64 %9, i32 3
  %11 = load i32, ptr %10, align 4, !tbaa !14
  %12 = icmp eq i32 %11, 1
  br i1 %12, label %.preheader, label %18

.preheader:                                       ; preds = %6
  %13 = icmp sgt i32 %3, 0
  br i1 %13, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader
  %14 = getelementptr inbounds %struct.train, ptr %8, i64 %9
  %15 = getelementptr inbounds i8, ptr %0, i64 96
  %16 = load ptr, ptr %15, align 8, !tbaa !16
  %wide.trip.count = zext nneg i32 %3 to i64
  %xtraiter = and i64 %wide.trip.count, 1
  %17 = icmp eq i32 %3, 1
  br i1 %17, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i64 %wide.trip.count, 2147483646
  br label %36

18:                                               ; preds = %6
  tail call void @__assert_fail(ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 188, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN4Node23backPropagateFirstLayerEPiPfifi) #2
  unreachable

._crit_edge.loopexit.unr-lcssa:                   ; preds = %36, %.lr.ph
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next.1, %36 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %._crit_edge.loopexit.epilog-lcssa

._crit_edge.loopexit.epilog-lcssa:                ; preds = %._crit_edge.loopexit.unr-lcssa
  %19 = load float, ptr %14, align 64, !tbaa !17
  %20 = getelementptr inbounds float, ptr %2, i64 %indvars.iv.unr
  %21 = load float, ptr %20, align 4, !tbaa !18
  %22 = fmul float %19, %21
  %23 = getelementptr inbounds i32, ptr %1, i64 %indvars.iv.unr
  %24 = load i32, ptr %23, align 4, !tbaa !19
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds float, ptr %16, i64 %25
  %27 = load float, ptr %26, align 4, !tbaa !18
  %28 = fadd float %22, %27
  store float %28, ptr %26, align 4, !tbaa !18
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit.epilog-lcssa, %._crit_edge.loopexit.unr-lcssa, %.preheader
  %29 = getelementptr inbounds %struct.train, ptr %8, i64 %9
  %30 = load float, ptr %29, align 64, !tbaa !17
  %31 = getelementptr inbounds i8, ptr %0, i64 116
  %32 = load float, ptr %31, align 4, !tbaa !20
  %33 = fadd float %30, %32
  store float %33, ptr %31, align 4, !tbaa !20
  store i32 0, ptr %10, align 4, !tbaa !14
  store <2 x float> zeroinitializer, ptr %29, align 64, !tbaa !18
  %34 = load i32, ptr %0, align 8, !tbaa !21
  %35 = add nsw i32 %34, -1
  store i32 %35, ptr %0, align 8, !tbaa !21
  ret void

36:                                               ; preds = %36, %.lr.ph.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.new ], [ %indvars.iv.next.1, %36 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.1, %36 ]
  %37 = load float, ptr %14, align 64, !tbaa !17
  %38 = getelementptr inbounds float, ptr %2, i64 %indvars.iv
  %39 = load float, ptr %38, align 4, !tbaa !18
  %40 = fmul float %37, %39
  %41 = getelementptr inbounds i32, ptr %1, i64 %indvars.iv
  %42 = load i32, ptr %41, align 4, !tbaa !19
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds float, ptr %16, i64 %43
  %45 = load float, ptr %44, align 4, !tbaa !18
  %46 = fadd float %40, %45
  store float %46, ptr %44, align 4, !tbaa !18
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %47 = load float, ptr %14, align 64, !tbaa !17
  %48 = getelementptr inbounds float, ptr %2, i64 %indvars.iv.next
  %49 = load float, ptr %48, align 4, !tbaa !18
  %50 = fmul float %47, %49
  %51 = getelementptr inbounds i32, ptr %1, i64 %indvars.iv.next
  %52 = load i32, ptr %51, align 4, !tbaa !19
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds float, ptr %16, i64 %53
  %55 = load float, ptr %54, align 4, !tbaa !18
  %56 = fadd float %50, %55
  store float %56, ptr %54, align 4, !tbaa !18
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.loopexit.unr-lcssa, label %36, !llvm.loop !22
}

attributes #0 = { noreturn 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 #1 = { mustprogress 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 = { noreturn 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, !11, i64 8}
!6 = !{!"_ZTS4Node", !7, i64 0, !10, i64 4, !11, i64 8, !7, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !11, i64 80, !11, i64 88, !11, i64 96, !11, i64 104, !13, i64 112, !13, i64 116, !13, i64 120, !13, i64 124, !13, i64 128}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTS8NodeType", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"long", !8, i64 0}
!13 = !{!"float", !8, i64 0}
!14 = !{!15, !7, i64 12}
!15 = !{!"_ZTS5train", !13, i64 0, !13, i64 4, !13, i64 8, !7, i64 12}
!16 = !{!6, !11, i64 96}
!17 = !{!15, !13, i64 0}
!18 = !{!13, !13, i64 0}
!19 = !{!7, !7, i64 0}
!20 = !{!6, !13, i64 116}
!21 = !{!6, !7, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass