; LLVM IR from aferikoglou/GenHLSOptimizer :: dataset/machsuite-backprop (backprop)

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

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

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

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

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

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

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

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

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @backprop(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6, ptr noundef %7) #0 {
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca [64 x double], align 16
  %20 = alloca [64 x double], align 16
  %21 = alloca [3 x double], align 16
  %22 = alloca [64 x double], align 16
  %23 = alloca [64 x double], align 16
  %24 = alloca [3 x double], align 16
  %25 = alloca [3 x double], align 16
  %26 = alloca [3 x double], align 16
  %27 = alloca [832 x double], align 16
  %28 = alloca [4096 x double], align 16
  %29 = alloca [192 x double], align 16
  %30 = alloca [64 x double], align 16
  %31 = alloca [64 x double], align 16
  store ptr %0, ptr %9, align 8, !tbaa !5
  store ptr %1, ptr %10, align 8, !tbaa !5
  store ptr %2, ptr %11, align 8, !tbaa !5
  store ptr %3, ptr %12, align 8, !tbaa !5
  store ptr %4, ptr %13, align 8, !tbaa !5
  store ptr %5, ptr %14, align 8, !tbaa !5
  store ptr %6, ptr %15, align 8, !tbaa !5
  store ptr %7, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #2
  br label %32

32:                                               ; preds = %8
  br label %33

33:                                               ; preds = %32
  br label %34

34:                                               ; preds = %33
  br label %35

35:                                               ; preds = %34
  br label %36

36:                                               ; preds = %35
  br label %37

37:                                               ; preds = %36
  br label %38

38:                                               ; preds = %37
  br label %39

39:                                               ; preds = %38
  br label %40

40:                                               ; preds = %39
  br label %41

41:                                               ; preds = %40
  br label %42

42:                                               ; preds = %41
  br label %43

43:                                               ; preds = %42
  br label %44

44:                                               ; preds = %43
  br label %45

45:                                               ; preds = %44
  store i32 0, ptr %17, align 4, !tbaa !9
  br label %46

46:                                               ; preds = %137, %45
  %47 = load i32, ptr %17, align 4, !tbaa !9
  %48 = icmp slt i32 %47, 163
  br i1 %48, label %49, label %140

49:                                               ; preds = %46
  br label %50

50:                                               ; preds = %49
  store i32 0, ptr %18, align 4, !tbaa !9
  br label %51

51:                                               ; preds = %68, %50
  %52 = load i32, ptr %18, align 4, !tbaa !9
  %53 = icmp slt i32 %52, 64
  br i1 %53, label %54, label %71

54:                                               ; preds = %51
  %55 = load i32, ptr %18, align 4, !tbaa !9
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [64 x double], ptr %19, i64 0, i64 %56
  store double 0.000000e+00, ptr %57, align 8, !tbaa !11
  %58 = load i32, ptr %18, align 4, !tbaa !9
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [64 x double], ptr %20, i64 0, i64 %59
  store double 0.000000e+00, ptr %60, align 8, !tbaa !11
  %61 = load i32, ptr %18, align 4, !tbaa !9
  %62 = icmp slt i32 %61, 3
  br i1 %62, label %63, label %67

63:                                               ; preds = %54
  %64 = load i32, ptr %18, align 4, !tbaa !9
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [3 x double], ptr %21, i64 0, i64 %65
  store double 0.000000e+00, ptr %66, align 8, !tbaa !11
  br label %67

67:                                               ; preds = %63, %54
  br label %68

68:                                               ; preds = %67
  %69 = load i32, ptr %18, align 4, !tbaa !9
  %70 = add nsw i32 %69, 1
  store i32 %70, ptr %18, align 4, !tbaa !9
  br label %51, !llvm.loop !13

71:                                               ; preds = %51
  %72 = load ptr, ptr %12, align 8, !tbaa !5
  %73 = load ptr, ptr %9, align 8, !tbaa !5
  %74 = getelementptr inbounds [64 x double], ptr %19, i64 0, i64 0
  %75 = load ptr, ptr %15, align 8, !tbaa !5
  %76 = load i32, ptr %17, align 4, !tbaa !9
  %77 = mul nsw i32 %76, 13
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds double, ptr %75, i64 %78
  call void @matrix_vector_product_with_bias_input_layer(ptr noundef %72, ptr noundef %73, ptr noundef %74, ptr noundef %79)
  %80 = getelementptr inbounds [64 x double], ptr %19, i64 0, i64 0
  %81 = getelementptr inbounds [64 x double], ptr %22, i64 0, i64 0
  call void @RELU(ptr noundef %80, ptr noundef %81, i32 noundef 64)
  %82 = load ptr, ptr %13, align 8, !tbaa !5
  %83 = load ptr, ptr %10, align 8, !tbaa !5
  %84 = getelementptr inbounds [64 x double], ptr %20, i64 0, i64 0
  %85 = getelementptr inbounds [64 x double], ptr %19, i64 0, i64 0
  call void @matrix_vector_product_with_bias_second_layer(ptr noundef %82, ptr noundef %83, ptr noundef %84, ptr noundef %85)
  %86 = getelementptr inbounds [64 x double], ptr %20, i64 0, i64 0
  %87 = getelementptr inbounds [64 x double], ptr %23, i64 0, i64 0
  call void @RELU(ptr noundef %86, ptr noundef %87, i32 noundef 64)
  %88 = load ptr, ptr %14, align 8, !tbaa !5
  %89 = load ptr, ptr %11, align 8, !tbaa !5
  %90 = getelementptr inbounds [3 x double], ptr %21, i64 0, i64 0
  %91 = getelementptr inbounds [64 x double], ptr %20, i64 0, i64 0
  call void @matrix_vector_product_with_bias_output_layer(ptr noundef %88, ptr noundef %89, ptr noundef %90, ptr noundef %91)
  %92 = getelementptr inbounds [3 x double], ptr %21, i64 0, i64 0
  %93 = getelementptr inbounds [3 x double], ptr %24, i64 0, i64 0
  call void @RELU(ptr noundef %92, ptr noundef %93, i32 noundef 3)
  %94 = getelementptr inbounds [3 x double], ptr %25, i64 0, i64 0
  %95 = getelementptr inbounds [3 x double], ptr %21, i64 0, i64 0
  call void @soft_max(ptr noundef %94, ptr noundef %95)
  %96 = getelementptr inbounds [3 x double], ptr %25, i64 0, i64 0
  %97 = load ptr, ptr %16, align 8, !tbaa !5
  %98 = load i32, ptr %17, align 4, !tbaa !9
  %99 = mul nsw i32 %98, 3
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds double, ptr %97, i64 %100
  %102 = getelementptr inbounds [3 x double], ptr %26, i64 0, i64 0
  %103 = getelementptr inbounds [3 x double], ptr %24, i64 0, i64 0
  call void @take_difference(ptr noundef %96, ptr noundef %101, ptr noundef %102, ptr noundef %103)
  %104 = getelementptr inbounds [192 x double], ptr %29, i64 0, i64 0
  %105 = getelementptr inbounds [3 x double], ptr %26, i64 0, i64 0
  %106 = getelementptr inbounds [64 x double], ptr %20, i64 0, i64 0
  call void @get_delta_matrix_weights3(ptr noundef %104, ptr noundef %105, ptr noundef %106)
  %107 = load ptr, ptr %11, align 8, !tbaa !5
  %108 = getelementptr inbounds [3 x double], ptr %26, i64 0, i64 0
  %109 = getelementptr inbounds [64 x double], ptr %31, i64 0, i64 0
  %110 = getelementptr inbounds [64 x double], ptr %23, i64 0, i64 0
  call void @get_oracle_activations2(ptr noundef %107, ptr noundef %108, ptr noundef %109, ptr noundef %110)
  %111 = getelementptr inbounds [4096 x double], ptr %28, i64 0, i64 0
  %112 = getelementptr inbounds [64 x double], ptr %31, i64 0, i64 0
  %113 = getelementptr inbounds [64 x double], ptr %19, i64 0, i64 0
  call void @get_delta_matrix_weights2(ptr noundef %111, ptr noundef %112, ptr noundef %113)
  %114 = load ptr, ptr %10, align 8, !tbaa !5
  %115 = getelementptr inbounds [64 x double], ptr %31, i64 0, i64 0
  %116 = getelementptr inbounds [64 x double], ptr %30, i64 0, i64 0
  %117 = getelementptr inbounds [64 x double], ptr %22, i64 0, i64 0
  call void @get_oracle_activations1(ptr noundef %114, ptr noundef %115, ptr noundef %116, ptr noundef %117)
  %118 = getelementptr inbounds [832 x double], ptr %27, i64 0, i64 0
  %119 = getelementptr inbounds [64 x double], ptr %30, i64 0, i64 0
  %120 = load ptr, ptr %15, align 8, !tbaa !5
  %121 = load i32, ptr %17, align 4, !tbaa !9
  %122 = mul nsw i32 %121, 13
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds double, ptr %120, i64 %123
  call void @get_delta_matrix_weights1(ptr noundef %118, ptr noundef %119, ptr noundef %124)
  %125 = load ptr, ptr %9, align 8, !tbaa !5
  %126 = load ptr, ptr %10, align 8, !tbaa !5
  %127 = load ptr, ptr %11, align 8, !tbaa !5
  %128 = getelementptr inbounds [832 x double], ptr %27, i64 0, i64 0
  %129 = getelementptr inbounds [4096 x double], ptr %28, i64 0, i64 0
  %130 = getelementptr inbounds [192 x double], ptr %29, i64 0, i64 0
  %131 = load ptr, ptr %12, align 8, !tbaa !5
  %132 = load ptr, ptr %13, align 8, !tbaa !5
  %133 = load ptr, ptr %14, align 8, !tbaa !5
  %134 = getelementptr inbounds [64 x double], ptr %30, i64 0, i64 0
  %135 = getelementptr inbounds [64 x double], ptr %31, i64 0, i64 0
  %136 = getelementptr inbounds [3 x double], ptr %26, i64 0, i64 0
  call void @update_weights(ptr noundef %125, ptr noundef %126, ptr noundef %127, ptr noundef %128, ptr noundef %129, ptr noundef %130, ptr noundef %131, ptr noundef %132, ptr noundef %133, ptr noundef %134, ptr noundef %135, ptr noundef %136)
  br label %137

137:                                              ; preds = %71
  %138 = load i32, ptr %17, align 4, !tbaa !9
  %139 = add nsw i32 %138, 1
  store i32 %139, ptr %17, align 4, !tbaa !9
  br label %46, !llvm.loop !15

140:                                              ; preds = %46
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #2
  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 = { 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}


; 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 void @soft_max(ptr noundef, ptr noundef) local_unnamed_addr #0

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

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

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

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

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

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

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

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @backprop(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6, ptr noundef %7) local_unnamed_addr #0 {
  %9 = alloca [64 x double], align 16
  %10 = alloca [64 x double], align 16
  %11 = alloca [3 x double], align 16
  %12 = alloca [64 x double], align 16
  %13 = alloca [64 x double], align 16
  %14 = alloca [3 x double], align 16
  %15 = alloca [3 x double], align 16
  %16 = alloca [3 x double], align 16
  %17 = alloca [832 x double], align 16
  %18 = alloca [4096 x double], align 16
  %19 = alloca [192 x double], align 16
  %20 = alloca [64 x double], align 16
  %21 = alloca [64 x double], align 16
  br label %.peel.next34

.peel.next34:                                     ; preds = %.peel.next34, %8
  %indvars.iv38 = phi i64 [ 0, %8 ], [ %indvars.iv.next39, %.peel.next34 ]
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(512) %9, i8 0, i64 512, i1 false), !tbaa !5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(512) %10, i8 0, i64 512, i1 false), !tbaa !5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(24) %11, i8 0, i64 24, i1 false)
  %.idx = mul i64 %indvars.iv38, 104
  %22 = getelementptr inbounds i8, ptr %6, i64 %.idx
  call void @matrix_vector_product_with_bias_input_layer(ptr noundef %3, ptr noundef %0, ptr noundef nonnull %9, ptr noundef %22)
  call void @RELU(ptr noundef nonnull %9, ptr noundef nonnull %12, i32 noundef 64)
  call void @matrix_vector_product_with_bias_second_layer(ptr noundef %4, ptr noundef %1, ptr noundef nonnull %10, ptr noundef nonnull %9)
  call void @RELU(ptr noundef nonnull %10, ptr noundef nonnull %13, i32 noundef 64)
  call void @matrix_vector_product_with_bias_output_layer(ptr noundef %5, ptr noundef %2, ptr noundef nonnull %11, ptr noundef nonnull %10)
  call void @RELU(ptr noundef nonnull %11, ptr noundef nonnull %14, i32 noundef 3)
  call void @soft_max(ptr noundef nonnull %15, ptr noundef nonnull %11)
  %.idx44 = mul i64 %indvars.iv38, 24
  %23 = getelementptr inbounds i8, ptr %7, i64 %.idx44
  call void @take_difference(ptr noundef nonnull %15, ptr noundef %23, ptr noundef nonnull %16, ptr noundef nonnull %14)
  call void @get_delta_matrix_weights3(ptr noundef nonnull %19, ptr noundef nonnull %16, ptr noundef nonnull %10)
  call void @get_oracle_activations2(ptr noundef %2, ptr noundef nonnull %16, ptr noundef nonnull %21, ptr noundef nonnull %13)
  call void @get_delta_matrix_weights2(ptr noundef nonnull %18, ptr noundef nonnull %21, ptr noundef nonnull %9)
  call void @get_oracle_activations1(ptr noundef %1, ptr noundef nonnull %21, ptr noundef nonnull %20, ptr noundef nonnull %12)
  call void @get_delta_matrix_weights1(ptr noundef nonnull %17, ptr noundef nonnull %20, ptr noundef %22)
  call void @update_weights(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef nonnull %17, ptr noundef nonnull %18, ptr noundef nonnull %19, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef nonnull %20, ptr noundef nonnull %21, ptr noundef nonnull %16)
  %indvars.iv.next39 = add nuw nsw i64 %indvars.iv38, 1
  %exitcond41.not = icmp eq i64 %indvars.iv.next39, 163
  br i1 %exitcond41.not, label %24, label %.peel.next34, !llvm.loop !9

24:                                               ; preds = %.peel.next34
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 nounwind willreturn memory(argmem: write) }

!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,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopFullUnrollPass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyPass,MemCpyOptPass,SCCPPass,SROAPass,SimplifyCFGPass