; LLVM IR from skywind3000/ml :: NeuralNetwork (ineuron)

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

@.str.1 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [25 x i8], align 1
@__PRETTY_FUNCTION__.intrain_bp_epoch = external hidden unnamed_addr constant [97 x i8], align 1

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

; 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.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @intrain_bp_create(ptr noundef, double noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @intrain_bp_destroy(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local double @intrain_bp_run(ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @intrain_bp_epoch(ptr noundef %0, ptr noundef %1, ptr noundef %2, double noundef %3, i32 noundef %4, double noundef %5) #2 {
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca double, align 8
  %11 = alloca i32, align 4
  %12 = alloca double, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca double, align 8
  %17 = alloca i32, 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 double %3, ptr %10, align 8, !tbaa !9
  store i32 %4, ptr %11, align 4, !tbaa !11
  store double %5, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = icmp ne ptr %18, null
  br i1 %19, label %20, label %27

20:                                               ; preds = %6
  %21 = load ptr, ptr %8, align 8, !tbaa !5
  %22 = icmp ne ptr %21, null
  br i1 %22, label %23, label %27

23:                                               ; preds = %20
  %24 = load ptr, ptr %9, align 8, !tbaa !5
  %25 = icmp ne ptr %24, null
  br i1 %25, label %26, label %27

26:                                               ; preds = %23
  br label %28

27:                                               ; preds = %23, %20, %6
  call void @__assert_fail(ptr noundef @.str.19, ptr noundef @.str.1, i32 noundef 711, ptr noundef @__PRETTY_FUNCTION__.intrain_bp_epoch) #4
  unreachable

28:                                               ; preds = %26
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = load double, ptr %10, align 8, !tbaa !9
  %31 = call ptr @intrain_bp_create(ptr noundef %29, double noundef %30)
  store ptr %31, ptr %13, align 8, !tbaa !5
  %32 = load ptr, ptr %13, align 8, !tbaa !5
  %33 = icmp ne ptr %32, null
  br i1 %33, label %34, label %35

34:                                               ; preds = %28
  br label %36

35:                                               ; preds = %28
  call void @__assert_fail(ptr noundef @.str.18, ptr noundef @.str.1, i32 noundef 714, ptr noundef @__PRETTY_FUNCTION__.intrain_bp_epoch) #4
  unreachable

36:                                               ; preds = %34
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = getelementptr inbounds ptr, ptr %37, i64 0
  %39 = load ptr, ptr %38, align 8, !tbaa !5
  store ptr %39, ptr %14, align 8, !tbaa !5
  %40 = load ptr, ptr %9, align 8, !tbaa !5
  %41 = getelementptr inbounds ptr, ptr %40, i64 0
  %42 = load ptr, ptr %41, align 8, !tbaa !5
  store ptr %42, ptr %15, align 8, !tbaa !5
  store i32 0, ptr %17, align 4, !tbaa !11
  br label %43

43:                                               ; preds = %65, %36
  %44 = load i32, ptr %17, align 4, !tbaa !11
  %45 = load i32, ptr %11, align 4, !tbaa !11
  %46 = icmp slt i32 %44, %45
  br i1 %46, label %47, label %53

47:                                               ; preds = %43
  %48 = load ptr, ptr %14, align 8, !tbaa !5
  %49 = icmp ne ptr %48, null
  br i1 %49, label %50, label %53

50:                                               ; preds = %47
  %51 = load ptr, ptr %15, align 8, !tbaa !5
  %52 = icmp ne ptr %51, null
  br label %53

53:                                               ; preds = %50, %47, %43
  %54 = phi i1 [ false, %47 ], [ false, %43 ], [ %52, %50 ]
  br i1 %54, label %55, label %72

55:                                               ; preds = %53
  %56 = load ptr, ptr %13, align 8, !tbaa !5
  %57 = load ptr, ptr %14, align 8, !tbaa !5
  %58 = load ptr, ptr %15, align 8, !tbaa !5
  %59 = call double @intrain_bp_run(ptr noundef %56, ptr noundef %57, ptr noundef %58)
  store double %59, ptr %16, align 8, !tbaa !9
  %60 = load double, ptr %16, align 8, !tbaa !9
  %61 = load double, ptr %12, align 8, !tbaa !9
  %62 = fcmp olt double %60, %61
  br i1 %62, label %63, label %64

63:                                               ; preds = %55
  br label %72

64:                                               ; preds = %55
  br label %65

65:                                               ; preds = %64
  %66 = load i32, ptr %17, align 4, !tbaa !11
  %67 = add nsw i32 %66, 1
  store i32 %67, ptr %17, align 4, !tbaa !11
  %68 = load ptr, ptr %14, align 8, !tbaa !5
  %69 = getelementptr inbounds double, ptr %68, i32 1
  store ptr %69, ptr %14, align 8, !tbaa !5
  %70 = load ptr, ptr %15, align 8, !tbaa !5
  %71 = getelementptr inbounds double, ptr %70, i32 1
  store ptr %71, ptr %15, align 8, !tbaa !5
  br label %43, !llvm.loop !13

72:                                               ; preds = %63, %53
  %73 = load ptr, ptr %13, align 8, !tbaa !5
  call void @intrain_bp_destroy(ptr noundef %73)
  %74 = load i32, ptr %17, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  ret i32 %74
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 }
attributes #4 = { 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, !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 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

@.str.1 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [25 x i8], align 1
@__PRETTY_FUNCTION__.intrain_bp_epoch = external hidden unnamed_addr constant [97 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: nounwind uwtable
declare dso_local ptr @intrain_bp_create(ptr noundef, double noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @intrain_bp_destroy(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local double @intrain_bp_run(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @intrain_bp_epoch(ptr noundef %0, ptr noundef readonly %1, ptr noundef readonly %2, double noundef %3, i32 noundef %4, double noundef %5) local_unnamed_addr #1 {
  %7 = icmp ne ptr %0, null
  %8 = icmp ne ptr %1, null
  %or.cond = and i1 %7, %8
  %9 = icmp ne ptr %2, null
  %or.cond3 = and i1 %or.cond, %9
  br i1 %or.cond3, label %11, label %10

10:                                               ; preds = %6
  tail call void @__assert_fail(ptr noundef nonnull @.str.19, ptr noundef nonnull @.str.1, i32 noundef 711, ptr noundef nonnull @__PRETTY_FUNCTION__.intrain_bp_epoch) #2
  unreachable

11:                                               ; preds = %6
  %12 = tail call ptr @intrain_bp_create(ptr noundef nonnull %0, double noundef %3)
  %.not = icmp eq ptr %12, null
  br i1 %.not, label %13, label %14

13:                                               ; preds = %11
  tail call void @__assert_fail(ptr noundef nonnull @.str.18, ptr noundef nonnull @.str.1, i32 noundef 714, ptr noundef nonnull @__PRETTY_FUNCTION__.intrain_bp_epoch) #2
  unreachable

14:                                               ; preds = %11
  %15 = load ptr, ptr %1, align 8, !tbaa !5
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = icmp sgt i32 %4, 0
  %18 = icmp ne ptr %15, null
  %or.cond534 = select i1 %17, i1 %18, i1 false
  %19 = icmp ne ptr %16, null
  %or.cond735 = select i1 %or.cond534, i1 %19, i1 false
  br i1 %or.cond735, label %.lr.ph, label %.critedge

.lr.ph:                                           ; preds = %14, %22
  %.038 = phi i32 [ %23, %22 ], [ 0, %14 ]
  %.02837 = phi ptr [ %24, %22 ], [ %15, %14 ]
  %.02936 = phi ptr [ %25, %22 ], [ %16, %14 ]
  %20 = tail call double @intrain_bp_run(ptr noundef nonnull %12, ptr noundef nonnull %.02837, ptr noundef nonnull %.02936)
  %21 = fcmp olt double %20, %5
  br i1 %21, label %.critedge, label %22

22:                                               ; preds = %.lr.ph
  %23 = add nuw nsw i32 %.038, 1
  %24 = getelementptr inbounds i8, ptr %.02837, i64 8
  %25 = getelementptr inbounds i8, ptr %.02936, i64 8
  %exitcond.not = icmp eq i32 %23, %4
  br i1 %exitcond.not, label %.critedge, label %.lr.ph, !llvm.loop !9

.critedge:                                        ; preds = %.lr.ph, %22, %14
  %.0.lcssa = phi i32 [ 0, %14 ], [ %4, %22 ], [ %.038, %.lr.ph ]
  tail call void @intrain_bp_destroy(ptr noundef nonnull %12)
  ret i32 %.0.lcssa
}

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 = { 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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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