; 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] }

@__const.main.targets = external hidden unnamed_addr constant [4 x [1 x double]], align 16
@.str = external hidden unnamed_addr constant [31 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [31 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @initialize_network(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: nounwind uwtable
declare dso_local void @forward_pass(ptr noundef) #0

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

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca %struct.NeuralNetwork, align 8
  %3 = alloca [4 x [2 x double]], align 16
  %4 = alloca [4 x [1 x double]], align 16
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 112, ptr %2) #5
  call void @initialize_network(ptr noundef %2)
  call void @llvm.lifetime.start.p0(i64 64, ptr %3) #5
  call void @llvm.memset.p0.i64(ptr align 16 %3, i8 0, i64 64, i1 false)
  %11 = getelementptr inbounds [4 x [2 x double]], ptr %3, i32 0, i32 1
  %12 = getelementptr inbounds [2 x double], ptr %11, i32 0, i32 1
  store double 1.000000e+00, ptr %12, align 8
  %13 = getelementptr inbounds [4 x [2 x double]], ptr %3, i32 0, i32 2
  %14 = getelementptr inbounds [2 x double], ptr %13, i32 0, i32 0
  store double 1.000000e+00, ptr %14, align 16
  %15 = getelementptr inbounds [4 x [2 x double]], ptr %3, i32 0, i32 3
  %16 = getelementptr inbounds [2 x double], ptr %15, i32 0, i32 0
  store double 1.000000e+00, ptr %16, align 16
  %17 = getelementptr inbounds [2 x double], ptr %15, i32 0, i32 1
  store double 1.000000e+00, ptr %17, align 8
  call void @llvm.lifetime.start.p0(i64 32, ptr %4) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %4, ptr align 16 @__const.main.targets, i64 32, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %56, %0
  %19 = load i32, ptr %5, align 4, !tbaa !5
  %20 = icmp slt i32 %19, 10000
  br i1 %20, label %22, label %21

21:                                               ; preds = %18
  store i32 2, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %59

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

23:                                               ; preds = %52, %22
  %24 = load i32, ptr %7, align 4, !tbaa !5
  %25 = icmp slt i32 %24, 4
  br i1 %25, label %27, label %26

26:                                               ; preds = %23
  store i32 5, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %55

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

28:                                               ; preds = %44, %27
  %29 = load i32, ptr %8, align 4, !tbaa !5
  %30 = icmp slt i32 %29, 2
  br i1 %30, label %32, label %31

31:                                               ; preds = %28
  store i32 8, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %47

32:                                               ; preds = %28
  %33 = load i32, ptr %7, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [4 x [2 x double]], ptr %3, i64 0, i64 %34
  %36 = load i32, ptr %8, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [2 x double], ptr %35, i64 0, i64 %37
  %39 = load double, ptr %38, align 8, !tbaa !9
  %40 = getelementptr inbounds %struct.NeuralNetwork, ptr %2, i32 0, i32 0
  %41 = load i32, ptr %8, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [2 x double], ptr %40, i64 0, i64 %42
  store double %39, ptr %43, align 8, !tbaa !9
  br label %44

44:                                               ; preds = %32
  %45 = load i32, ptr %8, align 4, !tbaa !5
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr %8, align 4, !tbaa !5
  br label %28, !llvm.loop !11

47:                                               ; preds = %31
  call void @forward_pass(ptr noundef %2)
  %48 = load i32, ptr %7, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [4 x [1 x double]], ptr %4, i64 0, i64 %49
  %51 = getelementptr inbounds [1 x double], ptr %50, i64 0, i64 0
  call void @backpropagation(ptr noundef %2, ptr noundef %51)
  br label %52

52:                                               ; preds = %47
  %53 = load i32, ptr %7, align 4, !tbaa !5
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr %7, align 4, !tbaa !5
  br label %23, !llvm.loop !13

55:                                               ; preds = %26
  br label %56

56:                                               ; preds = %55
  %57 = load i32, ptr %5, align 4, !tbaa !5
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %5, align 4, !tbaa !5
  br label %18, !llvm.loop !14

59:                                               ; preds = %21
  %60 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %61

61:                                               ; preds = %96, %59
  %62 = load i32, ptr %9, align 4, !tbaa !5
  %63 = icmp slt i32 %62, 4
  br i1 %63, label %65, label %64

64:                                               ; preds = %61
  store i32 11, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %99

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

66:                                               ; preds = %82, %65
  %67 = load i32, ptr %10, align 4, !tbaa !5
  %68 = icmp slt i32 %67, 2
  br i1 %68, label %70, label %69

69:                                               ; preds = %66
  store i32 14, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %85

70:                                               ; preds = %66
  %71 = load i32, ptr %9, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [4 x [2 x double]], ptr %3, i64 0, i64 %72
  %74 = load i32, ptr %10, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [2 x double], ptr %73, i64 0, i64 %75
  %77 = load double, ptr %76, align 8, !tbaa !9
  %78 = getelementptr inbounds %struct.NeuralNetwork, ptr %2, i32 0, i32 0
  %79 = load i32, ptr %10, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [2 x double], ptr %78, i64 0, i64 %80
  store double %77, ptr %81, align 8, !tbaa !9
  br label %82

82:                                               ; preds = %70
  %83 = load i32, ptr %10, align 4, !tbaa !5
  %84 = add nsw i32 %83, 1
  store i32 %84, ptr %10, align 4, !tbaa !5
  br label %66, !llvm.loop !15

85:                                               ; preds = %69
  call void @forward_pass(ptr noundef %2)
  %86 = getelementptr inbounds %struct.NeuralNetwork, ptr %2, i32 0, i32 0
  %87 = getelementptr inbounds [2 x double], ptr %86, i64 0, i64 0
  %88 = load double, ptr %87, align 8, !tbaa !9
  %89 = getelementptr inbounds %struct.NeuralNetwork, ptr %2, i32 0, i32 0
  %90 = getelementptr inbounds [2 x double], ptr %89, i64 0, i64 1
  %91 = load double, ptr %90, align 8, !tbaa !9
  %92 = getelementptr inbounds %struct.NeuralNetwork, ptr %2, i32 0, i32 2
  %93 = getelementptr inbounds [1 x double], ptr %92, i64 0, i64 0
  %94 = load double, ptr %93, align 8, !tbaa !9
  %95 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, double noundef %88, double noundef %91, double noundef %94)
  br label %96

96:                                               ; preds = %85
  %97 = load i32, ptr %9, align 4, !tbaa !5
  %98 = add nsw i32 %97, 1
  store i32 %98, ptr %9, align 4, !tbaa !5
  br label %61, !llvm.loop !16

99:                                               ; preds = %64
  store i32 0, ptr %1, align 4
  store i32 1, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 32, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 112, ptr %2) #5
  %100 = load i32, ptr %1, align 4
  ret i32 %100
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

declare i32 @printf(ptr noundef, ...) #4

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { "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 }

!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 = !{!"int", !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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12}


; 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.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] }

@__const.main.targets = external hidden unnamed_addr constant [4 x [1 x double]], align 16
@.str = external hidden unnamed_addr constant [31 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [31 x i8], align 1

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

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca %struct.NeuralNetwork, align 16
  %2 = alloca [4 x [1 x double]], align 16
  call void @llvm.lifetime.start.p0(i64 112, ptr nonnull %1) #5
  call void @initialize_network(ptr noundef nonnull %1)
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %2) #5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(32) %2, ptr noundef nonnull align 16 dereferenceable(32) @__const.main.targets, i64 32, i1 false)
  %.sroa.7.16..sroa_idx = getelementptr inbounds i8, ptr %1, i64 8
  %3 = getelementptr inbounds i8, ptr %2, i64 8
  %4 = getelementptr inbounds i8, ptr %2, i64 16
  %5 = getelementptr inbounds i8, ptr %2, i64 24
  br label %.preheader23

.preheader23:                                     ; preds = %0, %.preheader23
  %.02126 = phi i32 [ 0, %0 ], [ %6, %.preheader23 ]
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %1, i8 0, i64 16, i1 false)
  call void @forward_pass(ptr noundef nonnull %1)
  call void @backpropagation(ptr noundef nonnull %1, ptr noundef nonnull %2)
  store i64 0, ptr %1, align 16, !tbaa !5
  store double 1.000000e+00, ptr %.sroa.7.16..sroa_idx, align 8, !tbaa !5
  call void @forward_pass(ptr noundef nonnull %1)
  call void @backpropagation(ptr noundef nonnull %1, ptr noundef nonnull %3)
  store <2 x double> <double 1.000000e+00, double 0.000000e+00>, ptr %1, align 16, !tbaa !5
  call void @forward_pass(ptr noundef nonnull %1)
  call void @backpropagation(ptr noundef nonnull %1, ptr noundef nonnull %4)
  store <2 x double> <double 1.000000e+00, double 1.000000e+00>, ptr %1, align 16, !tbaa !5
  call void @forward_pass(ptr noundef nonnull %1)
  call void @backpropagation(ptr noundef nonnull %1, ptr noundef nonnull %5)
  %6 = add nuw nsw i32 %.02126, 1
  %exitcond.not = icmp eq i32 %6, 10000
  br i1 %exitcond.not, label %.preheader, label %.preheader23, !llvm.loop !9

.preheader:                                       ; preds = %.preheader23
  %.sroa.7.16..sroa_idx.le = getelementptr inbounds i8, ptr %1, i64 8
  %7 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  %8 = getelementptr inbounds i8, ptr %1, i64 32
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %1, i8 0, i64 16, i1 false)
  call void @forward_pass(ptr noundef nonnull %1)
  %9 = load double, ptr %1, align 16, !tbaa !5
  %10 = load double, ptr %.sroa.7.16..sroa_idx.le, align 8, !tbaa !5
  %11 = load double, ptr %8, align 16, !tbaa !5
  %12 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, double noundef %9, double noundef %10, double noundef %11)
  store i64 0, ptr %1, align 16, !tbaa !5
  store double 1.000000e+00, ptr %.sroa.7.16..sroa_idx.le, align 8, !tbaa !5
  call void @forward_pass(ptr noundef nonnull %1)
  %13 = load double, ptr %1, align 16, !tbaa !5
  %14 = load double, ptr %.sroa.7.16..sroa_idx.le, align 8, !tbaa !5
  %15 = load double, ptr %8, align 16, !tbaa !5
  %16 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, double noundef %13, double noundef %14, double noundef %15)
  store <2 x double> <double 1.000000e+00, double 0.000000e+00>, ptr %1, align 16, !tbaa !5
  call void @forward_pass(ptr noundef nonnull %1)
  %17 = load double, ptr %1, align 16, !tbaa !5
  %18 = load double, ptr %.sroa.7.16..sroa_idx.le, align 8, !tbaa !5
  %19 = load double, ptr %8, align 16, !tbaa !5
  %20 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, double noundef %17, double noundef %18, double noundef %19)
  store <2 x double> <double 1.000000e+00, double 1.000000e+00>, ptr %1, align 16, !tbaa !5
  call void @forward_pass(ptr noundef nonnull %1)
  %21 = load double, ptr %1, align 16, !tbaa !5
  %22 = load double, ptr %.sroa.7.16..sroa_idx.le, align 8, !tbaa !5
  %23 = load double, ptr %8, align 16, !tbaa !5
  %24 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, double noundef %21, double noundef %22, double noundef %23)
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 112, ptr nonnull %1) #5
  ret i32 0
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4

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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { 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"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LICMPass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyPass,MemCpyOptPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass