; LLVM IR from AlgoGenesis/C :: Machine_Learning_Algorithms/Artificial Neural Network(ANN) (Program)

; 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.NeuralNetwork = type { [2 x double], [2 x double], [1 x double], [2 x [2 x double]], [2 x [1 x double]], [2 x double], [1 x double] }

; Function Attrs: nounwind uwtable
define dso_local void @initialize_network(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %9

9:                                                ; preds = %35, %1
  %10 = load i32, ptr %3, align 4, !tbaa !9
  %11 = icmp slt i32 %10, 2
  br i1 %11, label %13, label %12

12:                                               ; preds = %9
  store i32 2, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  br label %38

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

14:                                               ; preds = %31, %13
  %15 = load i32, ptr %5, align 4, !tbaa !9
  %16 = icmp slt i32 %15, 2
  br i1 %16, label %18, label %17

17:                                               ; preds = %14
  store i32 5, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %34

18:                                               ; preds = %14
  %19 = call i32 @rand() #4
  %20 = sitofp i32 %19 to double
  %21 = fdiv double %20, 0x41DFFFFFFFC00000
  %22 = call double @llvm.fmuladd.f64(double %21, double 2.000000e+00, double -1.000000e+00)
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.NeuralNetwork, ptr %23, i32 0, i32 3
  %25 = load i32, ptr %3, align 4, !tbaa !9
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [2 x [2 x double]], ptr %24, i64 0, i64 %26
  %28 = load i32, ptr %5, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [2 x double], ptr %27, i64 0, i64 %29
  store double %22, ptr %30, align 8, !tbaa !11
  br label %31

31:                                               ; preds = %18
  %32 = load i32, ptr %5, align 4, !tbaa !9
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %5, align 4, !tbaa !9
  br label %14, !llvm.loop !13

34:                                               ; preds = %17
  br label %35

35:                                               ; preds = %34
  %36 = load i32, ptr %3, align 4, !tbaa !9
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %3, align 4, !tbaa !9
  br label %9, !llvm.loop !15

38:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %39

39:                                               ; preds = %74, %38
  %40 = load i32, ptr %6, align 4, !tbaa !9
  %41 = icmp slt i32 %40, 2
  br i1 %41, label %43, label %42

42:                                               ; preds = %39
  store i32 8, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %77

43:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %44

44:                                               ; preds = %61, %43
  %45 = load i32, ptr %7, align 4, !tbaa !9
  %46 = icmp slt i32 %45, 1
  br i1 %46, label %48, label %47

47:                                               ; preds = %44
  store i32 11, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %64

48:                                               ; preds = %44
  %49 = call i32 @rand() #4
  %50 = sitofp i32 %49 to double
  %51 = fdiv double %50, 0x41DFFFFFFFC00000
  %52 = call double @llvm.fmuladd.f64(double %51, double 2.000000e+00, double -1.000000e+00)
  %53 = load ptr, ptr %2, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.NeuralNetwork, ptr %53, i32 0, i32 4
  %55 = load i32, ptr %6, align 4, !tbaa !9
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [2 x [1 x double]], ptr %54, i64 0, i64 %56
  %58 = load i32, ptr %7, align 4, !tbaa !9
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [1 x double], ptr %57, i64 0, i64 %59
  store double %52, ptr %60, align 8, !tbaa !11
  br label %61

61:                                               ; preds = %48
  %62 = load i32, ptr %7, align 4, !tbaa !9
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %7, align 4, !tbaa !9
  br label %44, !llvm.loop !16

64:                                               ; preds = %47
  %65 = call i32 @rand() #4
  %66 = sitofp i32 %65 to double
  %67 = fdiv double %66, 0x41DFFFFFFFC00000
  %68 = call double @llvm.fmuladd.f64(double %67, double 2.000000e+00, double -1.000000e+00)
  %69 = load ptr, ptr %2, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.NeuralNetwork, ptr %69, i32 0, i32 5
  %71 = load i32, ptr %6, align 4, !tbaa !9
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [2 x double], ptr %70, i64 0, i64 %72
  store double %68, ptr %73, align 8, !tbaa !11
  br label %74

74:                                               ; preds = %64
  %75 = load i32, ptr %6, align 4, !tbaa !9
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr %6, align 4, !tbaa !9
  br label %39, !llvm.loop !17

77:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %78

78:                                               ; preds = %92, %77
  %79 = load i32, ptr %8, align 4, !tbaa !9
  %80 = icmp slt i32 %79, 1
  br i1 %80, label %82, label %81

81:                                               ; preds = %78
  store i32 14, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %95

82:                                               ; preds = %78
  %83 = call i32 @rand() #4
  %84 = sitofp i32 %83 to double
  %85 = fdiv double %84, 0x41DFFFFFFFC00000
  %86 = call double @llvm.fmuladd.f64(double %85, double 2.000000e+00, double -1.000000e+00)
  %87 = load ptr, ptr %2, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.NeuralNetwork, ptr %87, i32 0, i32 6
  %89 = load i32, ptr %8, align 4, !tbaa !9
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [1 x double], ptr %88, i64 0, i64 %90
  store double %86, ptr %91, align 8, !tbaa !11
  br label %92

92:                                               ; preds = %82
  %93 = load i32, ptr %8, align 4, !tbaa !9
  %94 = add nsw i32 %93, 1
  store i32 %94, ptr %8, align 4, !tbaa !9
  br label %78, !llvm.loop !18

95:                                               ; preds = %81
  ret void
}

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

; Function Attrs: nounwind
declare i32 @rand() #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !14}
!18 = distinct !{!18, !14}


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

; Function Attrs: nounwind uwtable
define dso_local void @initialize_network(ptr nocapture noundef writeonly %0) local_unnamed_addr #0 {
.preheader25:
  %1 = getelementptr inbounds i8, ptr %0, i64 40
  %2 = tail call i32 @rand() #3
  %3 = sitofp i32 %2 to double
  %4 = fdiv double %3, 0x41DFFFFFFFC00000
  %5 = tail call double @llvm.fmuladd.f64(double %4, double 2.000000e+00, double -1.000000e+00)
  store double %5, ptr %1, align 8, !tbaa !5
  %6 = tail call i32 @rand() #3
  %7 = sitofp i32 %6 to double
  %8 = fdiv double %7, 0x41DFFFFFFFC00000
  %9 = tail call double @llvm.fmuladd.f64(double %8, double 2.000000e+00, double -1.000000e+00)
  %10 = getelementptr inbounds i8, ptr %0, i64 48
  store double %9, ptr %10, align 8, !tbaa !5
  %11 = tail call i32 @rand() #3
  %12 = sitofp i32 %11 to double
  %13 = fdiv double %12, 0x41DFFFFFFFC00000
  %14 = tail call double @llvm.fmuladd.f64(double %13, double 2.000000e+00, double -1.000000e+00)
  %15 = getelementptr inbounds i8, ptr %0, i64 56
  store double %14, ptr %15, align 8, !tbaa !5
  %16 = tail call i32 @rand() #3
  %17 = sitofp i32 %16 to double
  %18 = fdiv double %17, 0x41DFFFFFFFC00000
  %19 = tail call double @llvm.fmuladd.f64(double %18, double 2.000000e+00, double -1.000000e+00)
  %20 = getelementptr inbounds i8, ptr %0, i64 64
  store double %19, ptr %20, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %0, i64 72
  %22 = getelementptr inbounds i8, ptr %0, i64 88
  %23 = tail call i32 @rand() #3
  %24 = sitofp i32 %23 to double
  %25 = fdiv double %24, 0x41DFFFFFFFC00000
  %26 = tail call double @llvm.fmuladd.f64(double %25, double 2.000000e+00, double -1.000000e+00)
  store double %26, ptr %21, align 8, !tbaa !5
  %27 = tail call i32 @rand() #3
  %28 = sitofp i32 %27 to double
  %29 = fdiv double %28, 0x41DFFFFFFFC00000
  %30 = tail call double @llvm.fmuladd.f64(double %29, double 2.000000e+00, double -1.000000e+00)
  store double %30, ptr %22, align 8, !tbaa !5
  %31 = tail call i32 @rand() #3
  %32 = sitofp i32 %31 to double
  %33 = fdiv double %32, 0x41DFFFFFFFC00000
  %34 = tail call double @llvm.fmuladd.f64(double %33, double 2.000000e+00, double -1.000000e+00)
  %35 = getelementptr inbounds i8, ptr %0, i64 80
  store double %34, ptr %35, align 8, !tbaa !5
  %36 = tail call i32 @rand() #3
  %37 = sitofp i32 %36 to double
  %38 = fdiv double %37, 0x41DFFFFFFFC00000
  %39 = tail call double @llvm.fmuladd.f64(double %38, double 2.000000e+00, double -1.000000e+00)
  %40 = getelementptr inbounds i8, ptr %0, i64 96
  store double %39, ptr %40, align 8, !tbaa !5
  %41 = tail call i32 @rand() #3
  %42 = sitofp i32 %41 to double
  %43 = fdiv double %42, 0x41DFFFFFFFC00000
  %44 = tail call double @llvm.fmuladd.f64(double %43, double 2.000000e+00, double -1.000000e+00)
  %45 = getelementptr inbounds i8, ptr %0, i64 104
  store double %44, ptr %45, align 8, !tbaa !5
  ret void
}

; Function Attrs: nounwind
declare i32 @rand() local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

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 "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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


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