; 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
declare dso_local double @sigmoid(double 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 speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

; 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
define dso_local void @forward_pass(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
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %8

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

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

12:                                               ; preds = %8
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.NeuralNetwork, ptr %13, i32 0, i32 1
  %15 = load i32, ptr %3, align 4, !tbaa !9
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [2 x double], ptr %14, i64 0, i64 %16
  store double 0.000000e+00, ptr %17, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %18

18:                                               ; preds = %45, %12
  %19 = load i32, ptr %5, align 4, !tbaa !9
  %20 = icmp slt i32 %19, 2
  br i1 %20, label %22, label %21

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

22:                                               ; preds = %18
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.NeuralNetwork, ptr %23, i32 0, i32 0
  %25 = load i32, ptr %5, align 4, !tbaa !9
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [2 x double], ptr %24, i64 0, i64 %26
  %28 = load double, ptr %27, align 8, !tbaa !11
  %29 = load ptr, ptr %2, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.NeuralNetwork, ptr %29, i32 0, i32 3
  %31 = load i32, ptr %5, align 4, !tbaa !9
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [2 x [2 x double]], ptr %30, i64 0, i64 %32
  %34 = load i32, ptr %3, align 4, !tbaa !9
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [2 x double], ptr %33, i64 0, i64 %35
  %37 = load double, ptr %36, align 8, !tbaa !11
  %38 = load ptr, ptr %2, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.NeuralNetwork, ptr %38, i32 0, i32 1
  %40 = load i32, ptr %3, align 4, !tbaa !9
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [2 x double], ptr %39, i64 0, i64 %41
  %43 = load double, ptr %42, align 8, !tbaa !11
  %44 = call double @llvm.fmuladd.f64(double %28, double %37, double %43)
  store double %44, ptr %42, align 8, !tbaa !11
  br label %45

45:                                               ; preds = %22
  %46 = load i32, ptr %5, align 4, !tbaa !9
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %5, align 4, !tbaa !9
  br label %18, !llvm.loop !13

48:                                               ; preds = %21
  %49 = load ptr, ptr %2, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.NeuralNetwork, ptr %49, i32 0, i32 5
  %51 = load i32, ptr %3, align 4, !tbaa !9
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [2 x double], ptr %50, i64 0, i64 %52
  %54 = load double, ptr %53, align 8, !tbaa !11
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.NeuralNetwork, ptr %55, i32 0, i32 1
  %57 = load i32, ptr %3, align 4, !tbaa !9
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [2 x double], ptr %56, i64 0, i64 %58
  %60 = load double, ptr %59, align 8, !tbaa !11
  %61 = fadd double %60, %54
  store double %61, ptr %59, align 8, !tbaa !11
  %62 = load ptr, ptr %2, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.NeuralNetwork, ptr %62, i32 0, i32 1
  %64 = load i32, ptr %3, align 4, !tbaa !9
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [2 x double], ptr %63, i64 0, i64 %65
  %67 = load double, ptr %66, align 8, !tbaa !11
  %68 = call double @sigmoid(double noundef %67)
  %69 = load ptr, ptr %2, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.NeuralNetwork, ptr %69, i32 0, i32 1
  %71 = load i32, ptr %3, 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 = %48
  %75 = load i32, ptr %3, align 4, !tbaa !9
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr %3, align 4, !tbaa !9
  br label %8, !llvm.loop !15

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

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

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

82:                                               ; preds = %78
  %83 = load ptr, ptr %2, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.NeuralNetwork, ptr %83, i32 0, i32 2
  %85 = load i32, ptr %6, align 4, !tbaa !9
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [1 x double], ptr %84, i64 0, i64 %86
  store double 0.000000e+00, ptr %87, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %88

88:                                               ; preds = %115, %82
  %89 = load i32, ptr %7, align 4, !tbaa !9
  %90 = icmp slt i32 %89, 2
  br i1 %90, label %92, label %91

91:                                               ; preds = %88
  store i32 11, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %118

92:                                               ; preds = %88
  %93 = load ptr, ptr %2, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.NeuralNetwork, ptr %93, i32 0, i32 1
  %95 = load i32, ptr %7, align 4, !tbaa !9
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [2 x double], ptr %94, i64 0, i64 %96
  %98 = load double, ptr %97, align 8, !tbaa !11
  %99 = load ptr, ptr %2, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.NeuralNetwork, ptr %99, i32 0, i32 4
  %101 = load i32, ptr %7, align 4, !tbaa !9
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [2 x [1 x double]], ptr %100, i64 0, i64 %102
  %104 = load i32, ptr %6, align 4, !tbaa !9
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [1 x double], ptr %103, i64 0, i64 %105
  %107 = load double, ptr %106, align 8, !tbaa !11
  %108 = load ptr, ptr %2, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.NeuralNetwork, ptr %108, i32 0, i32 2
  %110 = load i32, ptr %6, align 4, !tbaa !9
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [1 x double], ptr %109, i64 0, i64 %111
  %113 = load double, ptr %112, align 8, !tbaa !11
  %114 = call double @llvm.fmuladd.f64(double %98, double %107, double %113)
  store double %114, ptr %112, align 8, !tbaa !11
  br label %115

115:                                              ; preds = %92
  %116 = load i32, ptr %7, align 4, !tbaa !9
  %117 = add nsw i32 %116, 1
  store i32 %117, ptr %7, align 4, !tbaa !9
  br label %88, !llvm.loop !16

118:                                              ; preds = %91
  %119 = load ptr, ptr %2, align 8, !tbaa !5
  %120 = getelementptr inbounds %struct.NeuralNetwork, ptr %119, i32 0, i32 6
  %121 = load i32, ptr %6, align 4, !tbaa !9
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds [1 x double], ptr %120, i64 0, i64 %122
  %124 = load double, ptr %123, align 8, !tbaa !11
  %125 = load ptr, ptr %2, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct.NeuralNetwork, ptr %125, i32 0, i32 2
  %127 = load i32, ptr %6, align 4, !tbaa !9
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds [1 x double], ptr %126, i64 0, i64 %128
  %130 = load double, ptr %129, align 8, !tbaa !11
  %131 = fadd double %130, %124
  store double %131, ptr %129, align 8, !tbaa !11
  %132 = load ptr, ptr %2, align 8, !tbaa !5
  %133 = getelementptr inbounds %struct.NeuralNetwork, ptr %132, i32 0, i32 2
  %134 = load i32, ptr %6, align 4, !tbaa !9
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds [1 x double], ptr %133, i64 0, i64 %135
  %137 = load double, ptr %136, align 8, !tbaa !11
  %138 = call double @sigmoid(double noundef %137)
  %139 = load ptr, ptr %2, align 8, !tbaa !5
  %140 = getelementptr inbounds %struct.NeuralNetwork, ptr %139, i32 0, i32 2
  %141 = load i32, ptr %6, align 4, !tbaa !9
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [1 x double], ptr %140, i64 0, i64 %142
  store double %138, ptr %143, align 8, !tbaa !11
  br label %144

144:                                              ; preds = %118
  %145 = load i32, ptr %6, align 4, !tbaa !9
  %146 = add nsw i32 %145, 1
  store i32 %146, ptr %6, align 4, !tbaa !9
  br label %78, !llvm.loop !17

147:                                              ; preds = %81
  ret void
}

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 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 = !{!"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}


; 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
declare dso_local double @sigmoid(double noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local void @forward_pass(ptr nocapture noundef %0) local_unnamed_addr #0 {
.critedge:
  %1 = getelementptr inbounds i8, ptr %0, i64 16
  %2 = getelementptr inbounds i8, ptr %0, i64 40
  %3 = getelementptr inbounds i8, ptr %0, i64 88
  %4 = load double, ptr %0, align 8, !tbaa !5
  %5 = load double, ptr %2, align 8, !tbaa !5
  %6 = tail call double @llvm.fmuladd.f64(double %4, double %5, double 0.000000e+00)
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %8 = load double, ptr %7, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 56
  %10 = load double, ptr %9, align 8, !tbaa !5
  %11 = tail call double @llvm.fmuladd.f64(double %8, double %10, double %6)
  %12 = load double, ptr %3, align 8, !tbaa !5
  %13 = fadd double %12, %11
  store double %13, ptr %1, align 8, !tbaa !5
  %14 = tail call double @sigmoid(double noundef %13)
  store double %14, ptr %1, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %0, i64 24
  %16 = load double, ptr %0, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %0, i64 48
  %18 = load double, ptr %17, align 8, !tbaa !5
  %19 = tail call double @llvm.fmuladd.f64(double %16, double %18, double 0.000000e+00)
  %20 = load double, ptr %7, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %0, i64 64
  %22 = load double, ptr %21, align 8, !tbaa !5
  %23 = tail call double @llvm.fmuladd.f64(double %20, double %22, double %19)
  %24 = getelementptr inbounds i8, ptr %0, i64 96
  %25 = load double, ptr %24, align 8, !tbaa !5
  %26 = fadd double %25, %23
  store double %26, ptr %15, align 8, !tbaa !5
  %27 = tail call double @sigmoid(double noundef %26)
  store double %27, ptr %15, align 8, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %0, i64 32
  %29 = getelementptr inbounds i8, ptr %0, i64 72
  %30 = load double, ptr %1, align 8, !tbaa !5
  %31 = load double, ptr %29, align 8, !tbaa !5
  %32 = tail call double @llvm.fmuladd.f64(double %30, double %31, double 0.000000e+00)
  %33 = getelementptr inbounds i8, ptr %0, i64 80
  %34 = load double, ptr %33, align 8, !tbaa !5
  %35 = tail call double @llvm.fmuladd.f64(double %27, double %34, double %32)
  %36 = getelementptr inbounds i8, ptr %0, i64 104
  %37 = load double, ptr %36, align 8, !tbaa !5
  %38 = fadd double %37, %35
  store double %38, ptr %28, align 8, !tbaa !5
  %39 = tail call double @sigmoid(double noundef %38)
  store double %39, ptr %28, align 8, !tbaa !5
  ret void
}

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 speculatable willreturn memory(none) }

!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: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass