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

; 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__._ZN4Node13backPropagateEPS_Piifi = external hidden unnamed_addr constant [57 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_ZN4Node17getLastActivationEi(ptr noundef nonnull align 8 dereferenceable(132), i32 noundef) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4Node14incrementDeltaEif(ptr noundef nonnull align 8 dereferenceable(132), i32 noundef, float noundef) #0 align 2

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

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4Node13backPropagateEPS_Piifi(ptr noundef nonnull align 8 dereferenceable(132) %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, float noundef %4, i32 noundef %5) #0 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 ptr, align 8
  %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 148, ptr noundef @__PRETTY_FUNCTION__._ZN4Node13backPropagateEPS_Piifi) #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 = %88, %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 %91

36:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  %39 = load i32, ptr %13, align 4, !tbaa !9
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds i32, ptr %38, i64 %40
  %42 = load i32, ptr %41, align 4, !tbaa !9
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds %class.Node, ptr %37, i64 %43
  store ptr %44, ptr %14, align 8, !tbaa !5
  %45 = load ptr, ptr %14, align 8, !tbaa !5
  %46 = load i32, ptr %12, align 4, !tbaa !9
  %47 = getelementptr inbounds %class.Node, ptr %18, i32 0, i32 2
  %48 = load ptr, ptr %47, align 8, !tbaa !13
  %49 = load i32, ptr %12, align 4, !tbaa !9
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds %struct.train, ptr %48, i64 %50
  %52 = getelementptr inbounds %struct.train, ptr %51, i32 0, i32 0
  %53 = load float, ptr %52, align 64, !tbaa !19
  %54 = getelementptr inbounds %class.Node, ptr %18, i32 0, i32 10
  %55 = load ptr, ptr %54, align 8, !tbaa !20
  %56 = load ptr, ptr %9, 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 = fmul float %53, %63
  call void @_ZN4Node14incrementDeltaEif(ptr noundef nonnull align 8 dereferenceable(132) %45, i32 noundef %46, float noundef %64)
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  %65 = getelementptr inbounds %class.Node, ptr %18, i32 0, i32 2
  %66 = load ptr, ptr %65, align 8, !tbaa !13
  %67 = load i32, ptr %12, align 4, !tbaa !9
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds %struct.train, ptr %66, i64 %68
  %70 = getelementptr inbounds %struct.train, ptr %69, i32 0, i32 0
  %71 = load float, ptr %70, align 64, !tbaa !19
  %72 = load ptr, ptr %14, align 8, !tbaa !5
  %73 = load i32, ptr %12, align 4, !tbaa !9
  %74 = call noundef float @_ZN4Node17getLastActivationEi(ptr noundef nonnull align 8 dereferenceable(132) %72, i32 noundef %73)
  %75 = fmul float %71, %74
  store float %75, ptr %15, align 4, !tbaa !11
  %76 = load float, ptr %15, align 4, !tbaa !11
  %77 = getelementptr inbounds %class.Node, ptr %18, i32 0, i32 14
  %78 = load ptr, ptr %77, align 8, !tbaa !21
  %79 = load ptr, ptr %9, align 8, !tbaa !5
  %80 = load i32, ptr %13, align 4, !tbaa !9
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds i32, ptr %79, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !9
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds float, ptr %78, i64 %84
  %86 = load float, ptr %85, align 4, !tbaa !11
  %87 = fadd float %86, %76
  store float %87, ptr %85, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  br label %88

88:                                               ; preds = %36
  %89 = load i32, ptr %13, align 4, !tbaa !9
  %90 = add nsw i32 %89, 1
  store i32 %90, ptr %13, align 4, !tbaa !9
  br label %31, !llvm.loop !22

91:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  %92 = getelementptr inbounds %class.Node, ptr %18, i32 0, i32 2
  %93 = load ptr, ptr %92, align 8, !tbaa !13
  %94 = load i32, ptr %12, align 4, !tbaa !9
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds %struct.train, ptr %93, i64 %95
  %97 = getelementptr inbounds %struct.train, ptr %96, i32 0, i32 0
  %98 = load float, ptr %97, align 64, !tbaa !19
  store float %98, ptr %16, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  %99 = load float, ptr %16, align 4, !tbaa !11
  %100 = load float, ptr %16, align 4, !tbaa !11
  %101 = fmul float %99, %100
  store float %101, ptr %17, align 4, !tbaa !11
  %102 = load float, ptr %16, align 4, !tbaa !11
  %103 = getelementptr inbounds %class.Node, ptr %18, i32 0, i32 17
  %104 = load float, ptr %103, align 4, !tbaa !24
  %105 = fadd float %104, %102
  store float %105, ptr %103, align 4, !tbaa !24
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  %106 = getelementptr inbounds %class.Node, ptr %18, i32 0, i32 2
  %107 = load ptr, ptr %106, align 8, !tbaa !13
  %108 = load i32, ptr %12, align 4, !tbaa !9
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds %struct.train, ptr %107, i64 %109
  %111 = getelementptr inbounds %struct.train, ptr %110, i32 0, i32 3
  store i32 0, ptr %111, align 4, !tbaa !17
  %112 = getelementptr inbounds %class.Node, ptr %18, i32 0, i32 2
  %113 = load ptr, ptr %112, align 8, !tbaa !13
  %114 = load i32, ptr %12, align 4, !tbaa !9
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds %struct.train, ptr %113, i64 %115
  %117 = getelementptr inbounds %struct.train, ptr %116, i32 0, i32 0
  store float 0.000000e+00, ptr %117, align 64, !tbaa !19
  %118 = getelementptr inbounds %class.Node, ptr %18, i32 0, i32 2
  %119 = load ptr, ptr %118, align 8, !tbaa !13
  %120 = load i32, ptr %12, align 4, !tbaa !9
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds %struct.train, ptr %119, i64 %121
  %123 = getelementptr inbounds %struct.train, ptr %122, i32 0, i32 1
  store float 0.000000e+00, ptr %123, align 4, !tbaa !25
  %124 = getelementptr inbounds %class.Node, ptr %18, i32 0, i32 0
  %125 = load i32, ptr %124, align 8, !tbaa !26
  %126 = add nsw i32 %125, -1
  store i32 %126, ptr %124, align 8, !tbaa !26
  ret void
}

attributes #0 = { 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 #1 = { 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 64}
!21 = !{!14, !6, i64 96}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = !{!14, !12, i64 116}
!25 = !{!18, !12, i64 4}
!26 = !{!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] }
%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] }>

@.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__._ZN4Node13backPropagateEPS_Piifi = external hidden unnamed_addr constant [57 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_ZN4Node17getLastActivationEi(ptr noundef nonnull align 8 dereferenceable(132), i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4Node14incrementDeltaEif(ptr noundef nonnull align 8 dereferenceable(132), i32 noundef, float noundef) local_unnamed_addr #0 align 2

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4Node13backPropagateEPS_Piifi(ptr nocapture noundef nonnull align 8 dereferenceable(132) %0, ptr noundef %1, ptr nocapture noundef readonly %2, i32 noundef %3, float noundef %4, i32 noundef %5) local_unnamed_addr #0 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 %16

.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 i8, ptr %0, i64 64
  %15 = getelementptr inbounds i8, ptr %0, i64 96
  %wide.trip.count = zext nneg i32 %3 to i64
  br label %26

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

._crit_edge.loopexit:                             ; preds = %26
  %.pre = load ptr, ptr %7, align 8, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %17 = phi ptr [ %.pre, %._crit_edge.loopexit ], [ %8, %.preheader ]
  %18 = getelementptr inbounds %struct.train, ptr %17, i64 %9
  %19 = load float, ptr %18, align 64, !tbaa !16
  %20 = getelementptr inbounds i8, ptr %0, i64 116
  %21 = load float, ptr %20, align 4, !tbaa !17
  %22 = fadd float %19, %21
  store float %22, ptr %20, align 4, !tbaa !17
  %23 = getelementptr inbounds %struct.train, ptr %17, i64 %9, i32 3
  store i32 0, ptr %23, align 4, !tbaa !14
  store <2 x float> zeroinitializer, ptr %18, align 64, !tbaa !18
  %24 = load i32, ptr %0, align 8, !tbaa !19
  %25 = add nsw i32 %24, -1
  store i32 %25, ptr %0, align 8, !tbaa !19
  ret void

26:                                               ; preds = %.lr.ph, %26
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %26 ]
  %27 = getelementptr inbounds i32, ptr %2, i64 %indvars.iv
  %28 = load i32, ptr %27, align 4, !tbaa !20
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds %class.Node, ptr %1, i64 %29
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.train, ptr %31, i64 %9
  %33 = load float, ptr %32, align 64, !tbaa !16
  %34 = load ptr, ptr %14, align 8, !tbaa !21
  %35 = getelementptr inbounds float, ptr %34, i64 %29
  %36 = load float, ptr %35, align 4, !tbaa !18
  %37 = fmul float %33, %36
  tail call void @_ZN4Node14incrementDeltaEif(ptr noundef nonnull align 8 dereferenceable(132) %30, i32 noundef %5, float noundef %37)
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.train, ptr %38, i64 %9
  %40 = load float, ptr %39, align 64, !tbaa !16
  %41 = tail call noundef float @_ZN4Node17getLastActivationEi(ptr noundef nonnull align 8 dereferenceable(132) %30, i32 noundef %5)
  %42 = fmul float %40, %41
  %43 = load ptr, ptr %15, align 8, !tbaa !22
  %44 = load i32, ptr %27, align 4, !tbaa !20
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds float, ptr %43, i64 %45
  %47 = load float, ptr %46, align 4, !tbaa !18
  %48 = fadd float %42, %47
  store float %48, ptr %46, align 4, !tbaa !18
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge.loopexit, label %26, !llvm.loop !23
}

attributes #0 = { 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 #1 = { 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 #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 = !{!15, !13, i64 0}
!17 = !{!6, !13, i64 116}
!18 = !{!13, !13, i64 0}
!19 = !{!6, !7, i64 0}
!20 = !{!7, !7, i64 0}
!21 = !{!6, !11, i64 64}
!22 = !{!6, !11, i64 96}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}


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