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

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

@.str.12 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [20 x i8], align 1

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

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

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

declare i32 @__isoc99_scanf(ptr noundef, ...) #2

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

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca %struct.NeuralNetwork, align 4
  %8 = alloca i8, align 1
  %9 = alloca i32, align 4
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 150000, ptr %6, align 4, !tbaa !5
  %10 = load i32, ptr %4, align 4, !tbaa !5
  %11 = icmp sgt i32 %10, 1
  br i1 %11, label %12, label %17

12:                                               ; preds = %2
  %13 = load ptr, ptr %5, align 8, !tbaa !9
  %14 = getelementptr inbounds ptr, ptr %13, i64 1
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  %16 = call i32 @atoi(ptr noundef %15) #6
  store i32 %16, ptr %6, align 4, !tbaa !5
  br label %17

17:                                               ; preds = %12, %2
  %18 = call i64 @time(ptr noundef null) #5
  %19 = trunc i64 %18 to i32
  call void @srand(i32 noundef %19) #5
  call void @llvm.lifetime.start.p0(i64 11780, ptr %7) #5
  call void @init_neural_network(ptr noundef %7)
  %20 = load i32, ptr %6, align 4, !tbaa !5
  %21 = icmp sgt i32 %20, 0
  br i1 %21, label %22, label %24

22:                                               ; preds = %17
  %23 = load i32, ptr %6, align 4, !tbaa !5
  call void @train_against_random(ptr noundef %7, i32 noundef %23)
  br label %24

24:                                               ; preds = %22, %17
  br label %25

25:                                               ; preds = %40, %24
  br label %26

26:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #5
  call void @play_game(ptr noundef %7)
  %27 = call i32 (ptr, ...) @printf(ptr noundef @.str.22)
  %28 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.12, ptr noundef %8)
  %29 = load i8, ptr %8, align 1, !tbaa !11
  %30 = sext i8 %29 to i32
  %31 = icmp ne i32 %30, 121
  br i1 %31, label %32, label %37

32:                                               ; preds = %26
  %33 = load i8, ptr %8, align 1, !tbaa !11
  %34 = sext i8 %33 to i32
  %35 = icmp ne i32 %34, 89
  br i1 %35, label %36, label %37

36:                                               ; preds = %32
  store i32 3, ptr %9, align 4
  br label %38

37:                                               ; preds = %32, %26
  store i32 0, ptr %9, align 4
  br label %38

38:                                               ; preds = %37, %36
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #5
  %39 = load i32, ptr %9, align 4
  switch i32 %39, label %43 [
    i32 0, label %40
    i32 3, label %41
  ]

40:                                               ; preds = %38
  br label %25

41:                                               ; preds = %38
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 11780, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  %42 = load i32, ptr %3, align 4
  ret i32 %42

43:                                               ; preds = %38
  unreachable
}

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare i32 @atoi(ptr noundef nonnull) #3

; Function Attrs: nounwind
declare void @srand(i32 noundef) #4

; Function Attrs: nounwind
declare i64 @time(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 = { "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 = { inlinehint nounwind willreturn memory(read) 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 #4 = { 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 }
attributes #6 = { nounwind willreturn memory(read) }

!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 = !{!"any pointer", !7, i64 0}
!11 = !{!7, !7, i64 0}


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

@.str.12 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [20 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @init_neural_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: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

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

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

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = alloca %struct.NeuralNetwork, align 4
  %4 = alloca i8, align 1
  %5 = icmp sgt i32 %0, 1
  br i1 %5, label %6, label %10

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %1, i64 8
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %9 = tail call i32 @atoi(ptr nocapture noundef %8) #5
  br label %10

10:                                               ; preds = %6, %2
  %.07 = phi i32 [ %9, %6 ], [ 150000, %2 ]
  %11 = tail call i64 @time(ptr noundef null) #6
  %12 = trunc i64 %11 to i32
  tail call void @srand(i32 noundef %12) #6
  call void @llvm.lifetime.start.p0(i64 11780, ptr nonnull %3) #6
  call void @init_neural_network(ptr noundef nonnull %3)
  %13 = icmp sgt i32 %.07, 0
  br i1 %13, label %14, label %.preheader

14:                                               ; preds = %10
  call void @train_against_random(ptr noundef nonnull %3, i32 noundef %.07)
  br label %.preheader

.preheader:                                       ; preds = %14, %10
  br label %15

15:                                               ; preds = %.preheader, %15
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %4) #6
  call void @play_game(ptr noundef nonnull %3)
  %16 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.22)
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.12, ptr noundef nonnull %4)
  %18 = load i8, ptr %4, align 1
  %19 = and i8 %18, -33
  %or.cond.not = icmp eq i8 %19, 89
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %4) #6
  br i1 %or.cond.not, label %15, label %20

20:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 11780, ptr nonnull %3) #6
  ret i32 0
}

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare i32 @atoi(ptr nocapture noundef nonnull) local_unnamed_addr #3

; Function Attrs: nounwind
declare void @srand(i32 noundef) local_unnamed_addr #4

; Function Attrs: nounwind
declare i64 @time(ptr noundef) 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 = { 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 #3 = { inlinehint mustprogress nofree nounwind willreturn memory(read) 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 #4 = { 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 willreturn memory(read) }
attributes #6 = { 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"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass