; LLVM IR from alekmaul/pvsneslib :: snes-examples/input/superscope (superscope)

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

@bullet_id = external dso_local global i8, align 1
@shot_bullets = external dso_local global i8, align 1
@difuse_xn = external dso_local global [32 x i16], align 16
@difuse_yn = external dso_local global [32 x i16], align 16
@difuse_x = external dso_local global [32 x i8], align 16
@difuse_y = external dso_local global [32 x i8], align 16
@bullet_frame = external dso_local global [32 x i8], align 16
@bullet_draw = external dso_local global [32 x i8], align 16
@bullet_frame_n = external dso_local global [32 x i8], align 16
@bullet_gravity = external dso_local global [32 x i8], align 16
@bullet_diff = external dso_local global <{ i8, [31 x i8] }>, align 16
@enable_fire = external dso_local global i8, align 1
@target_id = external dso_local global i8, align 1
@target_kill = external dso_local global [64 x i8], align 16
@target_kill_count = external dso_local global [64 x i8], align 16
@target_gravity = external dso_local global [64 x i8], align 16
@targets_shot = external dso_local global i8, align 1
@.str = external hidden unnamed_addr constant [9 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [26 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @hideSprites() #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
define dso_local void @resetGame() #0 {
  %1 = alloca i8, align 1
  call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 12, i16 noundef zeroext 8, ptr noundef @.str)
  call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 11, i16 noundef zeroext 10, ptr noundef @.str.1)
  call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 3, i16 noundef zeroext 14, ptr noundef @.str.2)
  call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 3, i16 noundef zeroext 15, ptr noundef @.str.3)
  call void @hideSprites()
  store i8 0, ptr @targets_shot, align 1, !tbaa !5
  store i8 0, ptr @enable_fire, align 1, !tbaa !5
  store i8 0, ptr @bullet_id, align 1, !tbaa !5
  store i8 0, ptr @shot_bullets, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %1) #3
  store i8 0, ptr %1, align 1, !tbaa !5
  br label %2

2:                                                ; preds = %34, %0
  %3 = load i8, ptr %1, align 1, !tbaa !5
  %4 = zext i8 %3 to i32
  %5 = icmp slt i32 %4, 32
  br i1 %5, label %6, label %37

6:                                                ; preds = %2
  %7 = load i8, ptr %1, align 1, !tbaa !5
  %8 = zext i8 %7 to i64
  %9 = getelementptr inbounds [32 x i16], ptr @difuse_xn, i64 0, i64 %8
  store i16 0, ptr %9, align 2, !tbaa !8
  %10 = load i8, ptr %1, align 1, !tbaa !5
  %11 = zext i8 %10 to i64
  %12 = getelementptr inbounds [32 x i16], ptr @difuse_yn, i64 0, i64 %11
  store i16 0, ptr %12, align 2, !tbaa !8
  %13 = load i8, ptr %1, align 1, !tbaa !5
  %14 = zext i8 %13 to i64
  %15 = getelementptr inbounds [32 x i8], ptr @difuse_x, i64 0, i64 %14
  store i8 0, ptr %15, align 1, !tbaa !5
  %16 = load i8, ptr %1, align 1, !tbaa !5
  %17 = zext i8 %16 to i64
  %18 = getelementptr inbounds [32 x i8], ptr @difuse_y, i64 0, i64 %17
  store i8 0, ptr %18, align 1, !tbaa !5
  %19 = load i8, ptr %1, align 1, !tbaa !5
  %20 = zext i8 %19 to i64
  %21 = getelementptr inbounds [32 x i8], ptr @bullet_frame, i64 0, i64 %20
  store i8 0, ptr %21, align 1, !tbaa !5
  %22 = load i8, ptr %1, align 1, !tbaa !5
  %23 = zext i8 %22 to i64
  %24 = getelementptr inbounds [32 x i8], ptr @bullet_draw, i64 0, i64 %23
  store i8 0, ptr %24, align 1, !tbaa !5
  %25 = load i8, ptr %1, align 1, !tbaa !5
  %26 = zext i8 %25 to i64
  %27 = getelementptr inbounds [32 x i8], ptr @bullet_frame_n, i64 0, i64 %26
  store i8 0, ptr %27, align 1, !tbaa !5
  %28 = load i8, ptr %1, align 1, !tbaa !5
  %29 = zext i8 %28 to i64
  %30 = getelementptr inbounds [32 x i8], ptr @bullet_gravity, i64 0, i64 %29
  store i8 0, ptr %30, align 1, !tbaa !5
  %31 = load i8, ptr %1, align 1, !tbaa !5
  %32 = zext i8 %31 to i64
  %33 = getelementptr inbounds [32 x i8], ptr @bullet_diff, i64 0, i64 %32
  store i8 0, ptr %33, align 1, !tbaa !5
  br label %34

34:                                               ; preds = %6
  %35 = load i8, ptr %1, align 1, !tbaa !5
  %36 = add i8 %35, 1
  store i8 %36, ptr %1, align 1, !tbaa !5
  br label %2, !llvm.loop !10

37:                                               ; preds = %2
  store i8 0, ptr @target_id, align 1, !tbaa !5
  br label %38

38:                                               ; preds = %52, %37
  %39 = load i8, ptr @target_id, align 1, !tbaa !5
  %40 = zext i8 %39 to i32
  %41 = icmp slt i32 %40, 8
  br i1 %41, label %42, label %55

42:                                               ; preds = %38
  %43 = load i8, ptr @target_id, align 1, !tbaa !5
  %44 = zext i8 %43 to i64
  %45 = getelementptr inbounds [64 x i8], ptr @target_kill, i64 0, i64 %44
  store i8 0, ptr %45, align 1, !tbaa !5
  %46 = load i8, ptr @target_id, align 1, !tbaa !5
  %47 = zext i8 %46 to i64
  %48 = getelementptr inbounds [64 x i8], ptr @target_kill_count, i64 0, i64 %47
  store i8 0, ptr %48, align 1, !tbaa !5
  %49 = load i8, ptr @target_id, align 1, !tbaa !5
  %50 = zext i8 %49 to i64
  %51 = getelementptr inbounds [64 x i8], ptr @target_gravity, i64 0, i64 %50
  store i8 0, ptr %51, align 1, !tbaa !5
  br label %52

52:                                               ; preds = %42
  %53 = load i8, ptr @target_id, align 1, !tbaa !5
  %54 = add i8 %53, 1
  store i8 %54, ptr @target_id, align 1, !tbaa !5
  br label %38, !llvm.loop !12

55:                                               ; preds = %38
  call void @llvm.lifetime.end.p0(i64 1, ptr %1) #3
  ret void
}

declare void @consoleDrawText(i16 noundef zeroext, i16 noundef zeroext, ptr noundef, ...) #2

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 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"short", !6, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}


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

@bullet_id = external dso_local local_unnamed_addr global i8, align 1
@shot_bullets = external dso_local local_unnamed_addr global i8, align 1
@difuse_xn = external dso_local local_unnamed_addr global [32 x i16], align 16
@difuse_yn = external dso_local local_unnamed_addr global [32 x i16], align 16
@difuse_x = external dso_local local_unnamed_addr global [32 x i8], align 16
@difuse_y = external dso_local local_unnamed_addr global [32 x i8], align 16
@bullet_frame = external dso_local local_unnamed_addr global [32 x i8], align 16
@bullet_draw = external dso_local local_unnamed_addr global [32 x i8], align 16
@bullet_frame_n = external dso_local local_unnamed_addr global [32 x i8], align 16
@bullet_gravity = external dso_local local_unnamed_addr global [32 x i8], align 16
@bullet_diff = external dso_local local_unnamed_addr global <{ i8, [31 x i8] }>, align 16
@enable_fire = external dso_local local_unnamed_addr global i8, align 1
@target_id = external dso_local local_unnamed_addr global i8, align 1
@target_kill = external dso_local local_unnamed_addr global [64 x i8], align 16
@target_kill_count = external dso_local local_unnamed_addr global [64 x i8], align 16
@target_gravity = external dso_local local_unnamed_addr global [64 x i8], align 16
@targets_shot = external dso_local local_unnamed_addr global i8, align 1
@.str = external hidden unnamed_addr constant [9 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [26 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @hideSprites() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @resetGame() local_unnamed_addr #0 {
.preheader.preheader:
  tail call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 12, i16 noundef zeroext 8, ptr noundef nonnull @.str) #3
  tail call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 11, i16 noundef zeroext 10, ptr noundef nonnull @.str.1) #3
  tail call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 3, i16 noundef zeroext 14, ptr noundef nonnull @.str.2) #3
  tail call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 3, i16 noundef zeroext 15, ptr noundef nonnull @.str.3) #3
  tail call void @hideSprites()
  store i8 0, ptr @targets_shot, align 1, !tbaa !5
  store i8 0, ptr @enable_fire, align 1, !tbaa !5
  store i8 0, ptr @bullet_id, align 1, !tbaa !5
  store i8 0, ptr @shot_bullets, align 1, !tbaa !5
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(64) @difuse_xn, i8 0, i64 64, i1 false), !tbaa !8
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(64) @difuse_yn, i8 0, i64 64, i1 false), !tbaa !8
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(32) @difuse_x, i8 0, i64 32, i1 false), !tbaa !5
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(32) @difuse_y, i8 0, i64 32, i1 false), !tbaa !5
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(32) @bullet_frame, i8 0, i64 32, i1 false), !tbaa !5
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(32) @bullet_draw, i8 0, i64 32, i1 false), !tbaa !5
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(32) @bullet_frame_n, i8 0, i64 32, i1 false), !tbaa !5
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(32) @bullet_gravity, i8 0, i64 32, i1 false), !tbaa !5
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(32) @bullet_diff, i8 0, i64 32, i1 false), !tbaa !5
  store i64 0, ptr @target_kill, align 16
  store i64 0, ptr @target_kill_count, align 16
  store i64 0, ptr @target_gravity, align 16
  store i8 8, ptr @target_id, align 1, !tbaa !5
  ret void
}

declare void @consoleDrawText(i16 noundef zeroext, i16 noundef zeroext, ptr noundef, ...) local_unnamed_addr #1

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

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 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"short", !6, i64 0}


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