; LLVM IR from alekmaul/pvsneslib :: snes-examples/maps/DynamicMap (map64x64)

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

@.str = external hidden unnamed_addr constant [43 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @drawSpriteRaw64x64(i8 noundef zeroext, i8 noundef zeroext, i16 noundef zeroext) #0

; Function Attrs: nounwind uwtable
define dso_local void @drawSprite64x64(i8 noundef zeroext %0, i8 noundef zeroext %1, i16 noundef zeroext %2) #0 {
  %4 = alloca i8, align 1
  %5 = alloca i8, align 1
  %6 = alloca i16, align 2
  store i8 %0, ptr %4, align 1, !tbaa !5
  store i8 %1, ptr %5, align 1, !tbaa !5
  store i16 %2, ptr %6, align 2, !tbaa !8
  %7 = load i8, ptr %4, align 1, !tbaa !5
  %8 = zext i8 %7 to i32
  %9 = icmp slt i32 %8, 32
  br i1 %9, label %10, label %18

10:                                               ; preds = %3
  %11 = load i8, ptr %5, align 1, !tbaa !5
  %12 = zext i8 %11 to i32
  %13 = icmp slt i32 %12, 32
  br i1 %13, label %14, label %18

14:                                               ; preds = %10
  %15 = load i8, ptr %4, align 1, !tbaa !5
  %16 = load i8, ptr %5, align 1, !tbaa !5
  %17 = load i16, ptr %6, align 2, !tbaa !8
  call void @drawSpriteRaw64x64(i8 noundef zeroext %15, i8 noundef zeroext %16, i16 noundef zeroext %17)
  br label %77

18:                                               ; preds = %10, %3
  %19 = load i8, ptr %4, align 1, !tbaa !5
  %20 = zext i8 %19 to i32
  %21 = icmp slt i32 %20, 64
  br i1 %21, label %22, label %36

22:                                               ; preds = %18
  %23 = load i8, ptr %5, align 1, !tbaa !5
  %24 = zext i8 %23 to i32
  %25 = icmp slt i32 %24, 32
  br i1 %25, label %26, label %36

26:                                               ; preds = %22
  %27 = load i8, ptr %4, align 1, !tbaa !5
  %28 = zext i8 %27 to i32
  %29 = sub nsw i32 %28, 32
  %30 = trunc i32 %29 to i8
  %31 = load i8, ptr %5, align 1, !tbaa !5
  %32 = zext i8 %31 to i32
  %33 = add nsw i32 %32, 32
  %34 = trunc i32 %33 to i8
  %35 = load i16, ptr %6, align 2, !tbaa !8
  call void @drawSpriteRaw64x64(i8 noundef zeroext %30, i8 noundef zeroext %34, i16 noundef zeroext %35)
  br label %76

36:                                               ; preds = %22, %18
  %37 = load i8, ptr %4, align 1, !tbaa !5
  %38 = zext i8 %37 to i32
  %39 = icmp slt i32 %38, 32
  br i1 %39, label %40, label %51

40:                                               ; preds = %36
  %41 = load i8, ptr %5, align 1, !tbaa !5
  %42 = zext i8 %41 to i32
  %43 = icmp slt i32 %42, 64
  br i1 %43, label %44, label %51

44:                                               ; preds = %40
  %45 = load i8, ptr %4, align 1, !tbaa !5
  %46 = load i8, ptr %5, align 1, !tbaa !5
  %47 = zext i8 %46 to i32
  %48 = add nsw i32 %47, 32
  %49 = trunc i32 %48 to i8
  %50 = load i16, ptr %6, align 2, !tbaa !8
  call void @drawSpriteRaw64x64(i8 noundef zeroext %45, i8 noundef zeroext %49, i16 noundef zeroext %50)
  br label %75

51:                                               ; preds = %40, %36
  %52 = load i8, ptr %4, align 1, !tbaa !5
  %53 = zext i8 %52 to i32
  %54 = icmp slt i32 %53, 64
  br i1 %54, label %55, label %69

55:                                               ; preds = %51
  %56 = load i8, ptr %5, align 1, !tbaa !5
  %57 = zext i8 %56 to i32
  %58 = icmp slt i32 %57, 64
  br i1 %58, label %59, label %69

59:                                               ; preds = %55
  %60 = load i8, ptr %4, align 1, !tbaa !5
  %61 = zext i8 %60 to i32
  %62 = sub nsw i32 %61, 32
  %63 = trunc i32 %62 to i8
  %64 = load i8, ptr %5, align 1, !tbaa !5
  %65 = zext i8 %64 to i32
  %66 = add nsw i32 %65, 64
  %67 = trunc i32 %66 to i8
  %68 = load i16, ptr %6, align 2, !tbaa !8
  call void @drawSpriteRaw64x64(i8 noundef zeroext %63, i8 noundef zeroext %67, i16 noundef zeroext %68)
  br label %74

69:                                               ; preds = %55, %51
  %70 = load i8, ptr %4, align 1, !tbaa !5
  %71 = zext i8 %70 to i32
  %72 = load i8, ptr %5, align 1, !tbaa !5
  %73 = zext i8 %72 to i32
  call void (ptr, ...) @consoleNocashMessage(ptr noundef @.str, i32 noundef %71, i32 noundef %73)
  br label %74

74:                                               ; preds = %69, %59
  br label %75

75:                                               ; preds = %74, %44
  br label %76

76:                                               ; preds = %75, %26
  br label %77

77:                                               ; preds = %76, %14
  ret void
}

declare void @consoleNocashMessage(ptr noundef, ...) #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 = { "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" }

!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}


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

@.str = external hidden unnamed_addr constant [43 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @drawSpriteRaw64x64(i8 noundef zeroext, i8 noundef zeroext, i16 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @drawSprite64x64(i8 noundef zeroext %0, i8 noundef zeroext %1, i16 noundef zeroext %2) local_unnamed_addr #0 {
  %4 = zext i8 %0 to i32
  %5 = icmp ult i8 %0, 32
  %6 = zext i8 %1 to i32
  %7 = or i8 %1, %0
  %or.cond = icmp ult i8 %7, 32
  br i1 %or.cond, label %8, label %9

8:                                                ; preds = %3
  tail call void @drawSpriteRaw64x64(i8 noundef zeroext %0, i8 noundef zeroext %1, i16 noundef zeroext %2)
  br label %24

9:                                                ; preds = %3
  %10 = icmp ult i8 %1, 32
  %11 = icmp ult i8 %0, 64
  %or.cond5 = and i1 %11, %10
  br i1 %or.cond5, label %12, label %15

12:                                               ; preds = %9
  %13 = add nsw i8 %0, -32
  %14 = or disjoint i8 %1, 32
  tail call void @drawSpriteRaw64x64(i8 noundef zeroext %13, i8 noundef zeroext %14, i16 noundef zeroext %2)
  br label %24

15:                                               ; preds = %9
  %16 = icmp ult i8 %1, 64
  %or.cond8 = and i1 %5, %16
  br i1 %or.cond8, label %17, label %19

17:                                               ; preds = %15
  %18 = add nuw nsw i8 %1, 32
  tail call void @drawSpriteRaw64x64(i8 noundef zeroext %0, i8 noundef zeroext %18, i16 noundef zeroext %2)
  br label %24

19:                                               ; preds = %15
  %or.cond11 = icmp ult i8 %7, 64
  br i1 %or.cond11, label %20, label %23

20:                                               ; preds = %19
  %21 = add nsw i8 %0, -32
  %22 = or disjoint i8 %1, 64
  tail call void @drawSpriteRaw64x64(i8 noundef zeroext %21, i8 noundef zeroext %22, i16 noundef zeroext %2)
  br label %24

23:                                               ; preds = %19
  tail call void (ptr, ...) @consoleNocashMessage(ptr noundef nonnull @.str, i32 noundef %4, i32 noundef %6) #2
  br label %24

24:                                               ; preds = %12, %20, %23, %17, %8
  ret void
}

declare void @consoleNocashMessage(ptr noundef, ...) 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 = { "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)"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass