; LLVM IR from oservo/aiFi :: mlp (mlpSingletonNew)

; 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.mlpSingleton = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

@mlpSingletonNew.np = external hidden global ptr, align 8
@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [53 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [51 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [17 x i8], align 1
@__PRETTY_FUNCTION__.mlpSingletonNew = external hidden unnamed_addr constant [32 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @mlpSingletonNew() #0 {
  %1 = load ptr, ptr @mlpSingletonNew.np, align 8, !tbaa !5
  %2 = icmp eq ptr %1, null
  br i1 %2, label %3, label %48

3:                                                ; preds = %0
  %4 = call noalias ptr @malloc(i64 noundef 88) #5
  store ptr %4, ptr @mlpSingletonNew.np, align 8, !tbaa !5
  %5 = load ptr, ptr @mlpSingletonNew.np, align 8, !tbaa !5
  %6 = icmp ne ptr %5, null
  br i1 %6, label %25, label %7

7:                                                ; preds = %3
  %8 = load ptr, ptr @stderr, align 8, !tbaa !5
  %9 = call ptr @__errno_location() #6
  %10 = load i32, ptr %9, align 4, !tbaa !9
  %11 = icmp eq i32 %10, 0
  br i1 %11, label %12, label %13

12:                                               ; preds = %7
  br label %17

13:                                               ; preds = %7
  %14 = call ptr @__errno_location() #6
  %15 = load i32, ptr %14, align 4, !tbaa !9
  %16 = call ptr @strerror(i32 noundef %15) #7
  br label %17

17:                                               ; preds = %13, %12
  %18 = phi ptr [ @.str.2, %12 ], [ %16, %13 ]
  %19 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %8, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 20, ptr noundef %18) #7
  %20 = load ptr, ptr @mlpSingletonNew.np, align 8, !tbaa !5
  %21 = icmp ne ptr %20, null
  br i1 %21, label %22, label %23

22:                                               ; preds = %17
  br label %24

23:                                               ; preds = %17
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 20, ptr noundef @__PRETTY_FUNCTION__.mlpSingletonNew) #8
  unreachable

24:                                               ; preds = %22
  br label %25

25:                                               ; preds = %24, %3
  %26 = load ptr, ptr @mlpSingletonNew.np, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.mlpSingleton, ptr %26, i32 0, i32 0
  store ptr @mlpNew, ptr %27, align 8, !tbaa !11
  %28 = load ptr, ptr @mlpSingletonNew.np, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.mlpSingleton, ptr %28, i32 0, i32 1
  store ptr @mlpDel, ptr %29, align 8, !tbaa !13
  %30 = load ptr, ptr @mlpSingletonNew.np, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.mlpSingleton, ptr %30, i32 0, i32 2
  store ptr @mlpAddLayer, ptr %31, align 8, !tbaa !14
  %32 = load ptr, ptr @mlpSingletonNew.np, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.mlpSingleton, ptr %32, i32 0, i32 3
  store ptr @mlpTrain, ptr %33, align 8, !tbaa !15
  %34 = load ptr, ptr @mlpSingletonNew.np, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.mlpSingleton, ptr %34, i32 0, i32 4
  store ptr @mlpTrainTuple, ptr %35, align 8, !tbaa !16
  %36 = load ptr, ptr @mlpSingletonNew.np, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.mlpSingleton, ptr %36, i32 0, i32 5
  store ptr @mlpPredict, ptr %37, align 8, !tbaa !17
  %38 = load ptr, ptr @mlpSingletonNew.np, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.mlpSingleton, ptr %38, i32 0, i32 6
  store ptr @mlpPredictTuple, ptr %39, align 8, !tbaa !18
  %40 = load ptr, ptr @mlpSingletonNew.np, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.mlpSingleton, ptr %40, i32 0, i32 7
  store ptr @mlpSetInput, ptr %41, align 8, !tbaa !19
  %42 = load ptr, ptr @mlpSingletonNew.np, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.mlpSingleton, ptr %42, i32 0, i32 8
  store ptr @mlpSetTarget, ptr %43, align 8, !tbaa !20
  %44 = load ptr, ptr @mlpSingletonNew.np, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.mlpSingleton, ptr %44, i32 0, i32 9
  store ptr @mlpPropagateForward, ptr %45, align 8, !tbaa !21
  %46 = load ptr, ptr @mlpSingletonNew.np, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.mlpSingleton, ptr %46, i32 0, i32 10
  store ptr @mlpPropagateBackward, ptr %47, align 8, !tbaa !22
  br label %48

48:                                               ; preds = %25, %0
  %49 = load ptr, ptr @mlpSingletonNew.np, align 8, !tbaa !5
  ret ptr %49
}

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

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #2

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__errno_location() #3

; Function Attrs: nounwind
declare ptr @strerror(i32 noundef) #2

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

; Function Attrs: nounwind uwtable
declare dso_local void @mlpDel(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @mlpAddLayer(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @mlpTrain(ptr noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, double noundef, double noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @mlpTrainTuple(ptr noundef, i32 noundef, ptr noundef, ptr noundef, double noundef, double noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @mlpPredict(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @mlpPredictTuple(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @mlpSetInput(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @mlpSetTarget(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @mlpPropagateForward(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @mlpPropagateBackward(ptr noundef, double noundef, double noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @mlpNew() #0

attributes #0 = { 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 = { 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 #2 = { 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 #3 = { nounwind willreturn memory(none) "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 = { 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 #5 = { nounwind allocsize(0) }
attributes #6 = { nounwind willreturn memory(none) }
attributes #7 = { nounwind }
attributes #8 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"mlpSingleton", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80}
!13 = !{!12, !6, i64 8}
!14 = !{!12, !6, i64 16}
!15 = !{!12, !6, i64 24}
!16 = !{!12, !6, i64 32}
!17 = !{!12, !6, i64 40}
!18 = !{!12, !6, i64 48}
!19 = !{!12, !6, i64 56}
!20 = !{!12, !6, i64 64}
!21 = !{!12, !6, i64 72}
!22 = !{!12, !6, i64 80}


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

@mlpSingletonNew.np = external hidden local_unnamed_addr global ptr, align 8
@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [53 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [51 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [17 x i8], align 1
@__PRETTY_FUNCTION__.mlpSingletonNew = external hidden unnamed_addr constant [32 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @mlpSingletonNew() local_unnamed_addr #0 {
  %1 = load ptr, ptr @mlpSingletonNew.np, align 8, !tbaa !5
  %2 = icmp eq ptr %1, null
  br i1 %2, label %3, label %30

3:                                                ; preds = %0
  %4 = tail call noalias dereferenceable_or_null(88) ptr @malloc(i64 noundef 88) #6
  store ptr %4, ptr @mlpSingletonNew.np, align 8, !tbaa !5
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %5, label %17

5:                                                ; preds = %3
  %6 = load ptr, ptr @stderr, align 8, !tbaa !5
  %7 = tail call ptr @__errno_location() #7
  %8 = load i32, ptr %7, align 4, !tbaa !9
  %9 = icmp eq i32 %8, 0
  br i1 %9, label %12, label %10

10:                                               ; preds = %5
  %11 = tail call ptr @strerror(i32 noundef %8) #8
  br label %12

12:                                               ; preds = %5, %10
  %13 = phi ptr [ %11, %10 ], [ @.str.2, %5 ]
  %14 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %6, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 20, ptr noundef %13) #9
  %15 = load ptr, ptr @mlpSingletonNew.np, align 8, !tbaa !5
  %.not1 = icmp eq ptr %15, null
  br i1 %.not1, label %16, label %17

16:                                               ; preds = %12
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 20, ptr noundef nonnull @__PRETTY_FUNCTION__.mlpSingletonNew) #10
  unreachable

17:                                               ; preds = %12, %3
  %18 = phi ptr [ %15, %12 ], [ %4, %3 ]
  store ptr @mlpNew, ptr %18, align 8, !tbaa !11
  %19 = load ptr, ptr @mlpSingletonNew.np, align 8, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %19, i64 8
  store ptr @mlpDel, ptr %20, align 8, !tbaa !13
  %21 = getelementptr inbounds i8, ptr %19, i64 16
  store ptr @mlpAddLayer, ptr %21, align 8, !tbaa !14
  %22 = getelementptr inbounds i8, ptr %19, i64 24
  store ptr @mlpTrain, ptr %22, align 8, !tbaa !15
  %23 = getelementptr inbounds i8, ptr %19, i64 32
  store ptr @mlpTrainTuple, ptr %23, align 8, !tbaa !16
  %24 = getelementptr inbounds i8, ptr %19, i64 40
  store ptr @mlpPredict, ptr %24, align 8, !tbaa !17
  %25 = getelementptr inbounds i8, ptr %19, i64 48
  store ptr @mlpPredictTuple, ptr %25, align 8, !tbaa !18
  %26 = getelementptr inbounds i8, ptr %19, i64 56
  store ptr @mlpSetInput, ptr %26, align 8, !tbaa !19
  %27 = getelementptr inbounds i8, ptr %19, i64 64
  store ptr @mlpSetTarget, ptr %27, align 8, !tbaa !20
  %28 = getelementptr inbounds i8, ptr %19, i64 72
  store ptr @mlpPropagateForward, ptr %28, align 8, !tbaa !21
  %29 = getelementptr inbounds i8, ptr %19, i64 80
  store ptr @mlpPropagateBackward, ptr %29, align 8, !tbaa !22
  br label %30

30:                                               ; preds = %17, %0
  %31 = phi ptr [ %19, %17 ], [ %1, %0 ]
  ret ptr %31
}

; 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: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__errno_location() local_unnamed_addr #3

; Function Attrs: nounwind
declare ptr @strerror(i32 noundef) local_unnamed_addr #4

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

; Function Attrs: nounwind uwtable
declare dso_local void @mlpDel(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @mlpAddLayer(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @mlpTrain(ptr noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, double noundef, double noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @mlpTrainTuple(ptr noundef, i32 noundef, ptr noundef, ptr noundef, double noundef, double noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @mlpPredict(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @mlpPredictTuple(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @mlpSetInput(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @mlpSetTarget(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @mlpPropagateForward(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @mlpPropagateBackward(ptr noundef, double noundef, double noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @mlpNew() #0

attributes #0 = { 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 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 = { nofree 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 #3 = { mustprogress nofree nosync nounwind willreturn memory(none) "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 "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 #5 = { 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 #6 = { nounwind allocsize(0) }
attributes #7 = { nounwind willreturn memory(none) }
attributes #8 = { nounwind }
attributes #9 = { cold nounwind }
attributes #10 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"mlpSingleton", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80}
!13 = !{!12, !6, i64 8}
!14 = !{!12, !6, i64 16}
!15 = !{!12, !6, i64 24}
!16 = !{!12, !6, i64 32}
!17 = !{!12, !6, i64 40}
!18 = !{!12, !6, i64 48}
!19 = !{!12, !6, i64 56}
!20 = !{!12, !6, i64 64}
!21 = !{!12, !6, i64 72}
!22 = !{!12, !6, i64 80}


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