; LLVM IR from antirez/ttt-rl :: ttt (init_neural_network)

; 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 { [1800 x float], [900 x float], [100 x float], [9 x float], [18 x float], [100 x float], [9 x float], [9 x float] }

; Function Attrs: nounwind uwtable
define dso_local void @init_neural_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
  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 %7

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

10:                                               ; preds = %7
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  br label %24

11:                                               ; preds = %7
  %12 = call i32 @rand() #3
  %13 = sitofp i32 %12 to float
  %14 = fdiv float %13, 0x41E0000000000000
  %15 = fsub float %14, 5.000000e-01
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.NeuralNetwork, ptr %16, i32 0, i32 0
  %18 = load i32, ptr %3, align 4, !tbaa !9
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [1800 x float], ptr %17, i64 0, i64 %19
  store float %15, ptr %20, align 4, !tbaa !11
  br label %21

21:                                               ; preds = %11
  %22 = load i32, ptr %3, align 4, !tbaa !9
  %23 = add nsw i32 %22, 1
  store i32 %23, ptr %3, align 4, !tbaa !9
  br label %7, !llvm.loop !13

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

25:                                               ; preds = %39, %24
  %26 = load i32, ptr %4, align 4, !tbaa !9
  %27 = icmp slt i32 %26, 900
  br i1 %27, label %29, label %28

28:                                               ; preds = %25
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %42

29:                                               ; preds = %25
  %30 = call i32 @rand() #3
  %31 = sitofp i32 %30 to float
  %32 = fdiv float %31, 0x41E0000000000000
  %33 = fsub float %32, 5.000000e-01
  %34 = load ptr, ptr %2, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.NeuralNetwork, ptr %34, i32 0, i32 1
  %36 = load i32, ptr %4, align 4, !tbaa !9
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [900 x float], ptr %35, i64 0, i64 %37
  store float %33, ptr %38, align 4, !tbaa !11
  br label %39

39:                                               ; preds = %29
  %40 = load i32, ptr %4, align 4, !tbaa !9
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %4, align 4, !tbaa !9
  br label %25, !llvm.loop !15

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

43:                                               ; preds = %57, %42
  %44 = load i32, ptr %5, align 4, !tbaa !9
  %45 = icmp slt i32 %44, 100
  br i1 %45, label %47, label %46

46:                                               ; preds = %43
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %60

47:                                               ; preds = %43
  %48 = call i32 @rand() #3
  %49 = sitofp i32 %48 to float
  %50 = fdiv float %49, 0x41E0000000000000
  %51 = fsub float %50, 5.000000e-01
  %52 = load ptr, ptr %2, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.NeuralNetwork, ptr %52, i32 0, i32 2
  %54 = load i32, ptr %5, align 4, !tbaa !9
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [100 x float], ptr %53, i64 0, i64 %55
  store float %51, ptr %56, align 4, !tbaa !11
  br label %57

57:                                               ; preds = %47
  %58 = load i32, ptr %5, align 4, !tbaa !9
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %5, align 4, !tbaa !9
  br label %43, !llvm.loop !16

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

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

64:                                               ; preds = %61
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %78

65:                                               ; preds = %61
  %66 = call i32 @rand() #3
  %67 = sitofp i32 %66 to float
  %68 = fdiv float %67, 0x41E0000000000000
  %69 = fsub float %68, 5.000000e-01
  %70 = load ptr, ptr %2, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.NeuralNetwork, ptr %70, i32 0, i32 3
  %72 = load i32, ptr %6, align 4, !tbaa !9
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [9 x float], ptr %71, i64 0, i64 %73
  store float %69, ptr %74, align 4, !tbaa !11
  br label %75

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

78:                                               ; preds = %64
  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 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 = { 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 = !{!"float", !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
define dso_local void @init_neural_network(ptr nocapture noundef writeonly %0) local_unnamed_addr #0 {
  br label %3

.preheader19:                                     ; preds = %3
  %2 = getelementptr inbounds i8, ptr %0, i64 7200
  br label %10

3:                                                ; preds = %1, %3
  %indvars.iv = phi i64 [ 0, %1 ], [ %indvars.iv.next, %3 ]
  %4 = tail call i32 @rand() #2
  %5 = sitofp i32 %4 to float
  %6 = fmul float %5, 0x3E00000000000000
  %7 = fadd float %6, -5.000000e-01
  %8 = getelementptr inbounds [1800 x float], ptr %0, i64 0, i64 %indvars.iv
  store float %7, ptr %8, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 1800
  br i1 %exitcond.not, label %.preheader19, label %3, !llvm.loop !9

.preheader18:                                     ; preds = %10
  %9 = getelementptr inbounds i8, ptr %0, i64 10800
  br label %61

10:                                               ; preds = %.preheader19, %10
  %indvars.iv25 = phi i64 [ 0, %.preheader19 ], [ %indvars.iv.next26, %10 ]
  %11 = tail call i32 @rand() #2
  %12 = sitofp i32 %11 to float
  %13 = fmul float %12, 0x3E00000000000000
  %14 = fadd float %13, -5.000000e-01
  %15 = getelementptr inbounds [900 x float], ptr %2, i64 0, i64 %indvars.iv25
  store float %14, ptr %15, align 4, !tbaa !5
  %indvars.iv.next26 = add nuw nsw i64 %indvars.iv25, 1
  %exitcond28.not = icmp eq i64 %indvars.iv.next26, 900
  br i1 %exitcond28.not, label %.preheader18, label %10, !llvm.loop !11

.preheader:                                       ; preds = %61
  %16 = getelementptr inbounds i8, ptr %0, i64 11200
  %17 = tail call i32 @rand() #2
  %18 = sitofp i32 %17 to float
  %19 = fmul float %18, 0x3E00000000000000
  %20 = fadd float %19, -5.000000e-01
  store float %20, ptr %16, align 4, !tbaa !5
  %21 = tail call i32 @rand() #2
  %22 = sitofp i32 %21 to float
  %23 = fmul float %22, 0x3E00000000000000
  %24 = fadd float %23, -5.000000e-01
  %25 = getelementptr inbounds i8, ptr %0, i64 11204
  store float %24, ptr %25, align 4, !tbaa !5
  %26 = tail call i32 @rand() #2
  %27 = sitofp i32 %26 to float
  %28 = fmul float %27, 0x3E00000000000000
  %29 = fadd float %28, -5.000000e-01
  %30 = getelementptr inbounds i8, ptr %0, i64 11208
  store float %29, ptr %30, align 4, !tbaa !5
  %31 = tail call i32 @rand() #2
  %32 = sitofp i32 %31 to float
  %33 = fmul float %32, 0x3E00000000000000
  %34 = fadd float %33, -5.000000e-01
  %35 = getelementptr inbounds i8, ptr %0, i64 11212
  store float %34, ptr %35, align 4, !tbaa !5
  %36 = tail call i32 @rand() #2
  %37 = sitofp i32 %36 to float
  %38 = fmul float %37, 0x3E00000000000000
  %39 = fadd float %38, -5.000000e-01
  %40 = getelementptr inbounds i8, ptr %0, i64 11216
  store float %39, ptr %40, align 4, !tbaa !5
  %41 = tail call i32 @rand() #2
  %42 = sitofp i32 %41 to float
  %43 = fmul float %42, 0x3E00000000000000
  %44 = fadd float %43, -5.000000e-01
  %45 = getelementptr inbounds i8, ptr %0, i64 11220
  store float %44, ptr %45, align 4, !tbaa !5
  %46 = tail call i32 @rand() #2
  %47 = sitofp i32 %46 to float
  %48 = fmul float %47, 0x3E00000000000000
  %49 = fadd float %48, -5.000000e-01
  %50 = getelementptr inbounds i8, ptr %0, i64 11224
  store float %49, ptr %50, align 4, !tbaa !5
  %51 = tail call i32 @rand() #2
  %52 = sitofp i32 %51 to float
  %53 = fmul float %52, 0x3E00000000000000
  %54 = fadd float %53, -5.000000e-01
  %55 = getelementptr inbounds i8, ptr %0, i64 11228
  store float %54, ptr %55, align 4, !tbaa !5
  %56 = tail call i32 @rand() #2
  %57 = sitofp i32 %56 to float
  %58 = fmul float %57, 0x3E00000000000000
  %59 = fadd float %58, -5.000000e-01
  %60 = getelementptr inbounds i8, ptr %0, i64 11232
  store float %59, ptr %60, align 4, !tbaa !5
  ret void

61:                                               ; preds = %.preheader18, %61
  %indvars.iv29 = phi i64 [ 0, %.preheader18 ], [ %indvars.iv.next30, %61 ]
  %62 = tail call i32 @rand() #2
  %63 = sitofp i32 %62 to float
  %64 = fmul float %63, 0x3E00000000000000
  %65 = fadd float %64, -5.000000e-01
  %66 = getelementptr inbounds [100 x float], ptr %9, i64 0, i64 %indvars.iv29
  store float %65, ptr %66, align 4, !tbaa !5
  %indvars.iv.next30 = add nuw nsw i64 %indvars.iv29, 1
  %exitcond32.not = icmp eq i64 %indvars.iv.next30, 100
  br i1 %exitcond32.not, label %.preheader, label %61, !llvm.loop !12
}

; Function Attrs: nounwind
declare i32 @rand() local_unnamed_addr #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 = { 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 = { 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}


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