; LLVM IR from Stephane-D/SGDK :: src (vdp_spr)

; 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.VDPSprite = type { i16, %union.anon, %union.anon.1, i16 }
%union.anon = type { %struct.anon }
%struct.anon = type { i16 }
%union.anon.1 = type { i16 }
%struct.anon.0 = type { i8, i8 }

@vdpSpriteCache = external dso_local global [96 x %struct.VDPSprite], align 16
@.str = external hidden unnamed_addr constant [15 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local void @logVDPSprite(i16 noundef zeroext %0) #1 {
  %2 = alloca i16, align 2
  %3 = alloca [64 x i8], align 16
  %4 = alloca [16 x i8], align 16
  %5 = alloca ptr, align 8
  store i16 %0, ptr %2, align 2, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 64, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %6 = load i16, ptr %2, align 2, !tbaa !5
  %7 = zext i16 %6 to i64
  %8 = getelementptr inbounds [96 x %struct.VDPSprite], ptr @vdpSpriteCache, i64 0, i64 %7
  store ptr %8, ptr %5, align 8, !tbaa !9
  %9 = getelementptr inbounds [64 x i8], ptr %3, i64 0, i64 0
  %10 = call ptr @strcpy(ptr noundef %9, ptr noundef @.str) #4
  %11 = load i16, ptr %2, align 2, !tbaa !5
  %12 = zext i16 %11 to i64
  %13 = getelementptr inbounds [16 x i8], ptr %4, i64 0, i64 0
  %14 = call zeroext i16 @intToStr(i64 noundef %12, ptr noundef %13, i16 noundef zeroext 1)
  %15 = getelementptr inbounds [64 x i8], ptr %3, i64 0, i64 0
  %16 = getelementptr inbounds [16 x i8], ptr %4, i64 0, i64 0
  %17 = call ptr @strcat(ptr noundef %15, ptr noundef %16) #4
  %18 = getelementptr inbounds [64 x i8], ptr %3, i64 0, i64 0
  %19 = call ptr @strcat(ptr noundef %18, ptr noundef @.str.1) #4
  %20 = load ptr, ptr %5, align 8, !tbaa !9
  %21 = getelementptr inbounds %struct.VDPSprite, ptr %20, i32 0, i32 3
  %22 = load i16, ptr %21, align 2, !tbaa !11
  %23 = sext i16 %22 to i64
  %24 = getelementptr inbounds [16 x i8], ptr %4, i64 0, i64 0
  %25 = call zeroext i16 @intToStr(i64 noundef %23, ptr noundef %24, i16 noundef zeroext 1)
  %26 = getelementptr inbounds [64 x i8], ptr %3, i64 0, i64 0
  %27 = getelementptr inbounds [16 x i8], ptr %4, i64 0, i64 0
  %28 = call ptr @strcat(ptr noundef %26, ptr noundef %27) #4
  %29 = getelementptr inbounds [64 x i8], ptr %3, i64 0, i64 0
  %30 = call ptr @strcat(ptr noundef %29, ptr noundef @.str.2) #4
  %31 = load ptr, ptr %5, align 8, !tbaa !9
  %32 = getelementptr inbounds %struct.VDPSprite, ptr %31, i32 0, i32 0
  %33 = load i16, ptr %32, align 2, !tbaa !13
  %34 = sext i16 %33 to i64
  %35 = getelementptr inbounds [16 x i8], ptr %4, i64 0, i64 0
  %36 = call zeroext i16 @intToStr(i64 noundef %34, ptr noundef %35, i16 noundef zeroext 1)
  %37 = getelementptr inbounds [64 x i8], ptr %3, i64 0, i64 0
  %38 = getelementptr inbounds [16 x i8], ptr %4, i64 0, i64 0
  %39 = call ptr @strcat(ptr noundef %37, ptr noundef %38) #4
  %40 = getelementptr inbounds [64 x i8], ptr %3, i64 0, i64 0
  %41 = call ptr @strcat(ptr noundef %40, ptr noundef @.str.3) #4
  %42 = load ptr, ptr %5, align 8, !tbaa !9
  %43 = getelementptr inbounds %struct.VDPSprite, ptr %42, i32 0, i32 1
  %44 = getelementptr inbounds %struct.anon.0, ptr %43, i32 0, i32 0
  %45 = load i8, ptr %44, align 2, !tbaa !14
  %46 = zext i8 %45 to i64
  %47 = getelementptr inbounds [16 x i8], ptr %4, i64 0, i64 0
  %48 = call zeroext i16 @intToHex(i64 noundef %46, ptr noundef %47, i16 noundef zeroext 2)
  %49 = getelementptr inbounds [64 x i8], ptr %3, i64 0, i64 0
  %50 = getelementptr inbounds [16 x i8], ptr %4, i64 0, i64 0
  %51 = call ptr @strcat(ptr noundef %49, ptr noundef %50) #4
  %52 = getelementptr inbounds [64 x i8], ptr %3, i64 0, i64 0
  %53 = call ptr @strcat(ptr noundef %52, ptr noundef @.str.4) #4
  %54 = load ptr, ptr %5, align 8, !tbaa !9
  %55 = getelementptr inbounds %struct.VDPSprite, ptr %54, i32 0, i32 2
  %56 = load i16, ptr %55, align 2, !tbaa !14
  %57 = zext i16 %56 to i64
  %58 = getelementptr inbounds [16 x i8], ptr %4, i64 0, i64 0
  %59 = call zeroext i16 @intToHex(i64 noundef %57, ptr noundef %58, i16 noundef zeroext 4)
  %60 = getelementptr inbounds [64 x i8], ptr %3, i64 0, i64 0
  %61 = getelementptr inbounds [16 x i8], ptr %4, i64 0, i64 0
  %62 = call ptr @strcat(ptr noundef %60, ptr noundef %61) #4
  %63 = getelementptr inbounds [64 x i8], ptr %3, i64 0, i64 0
  %64 = call ptr @strcat(ptr noundef %63, ptr noundef @.str.5) #4
  %65 = load ptr, ptr %5, align 8, !tbaa !9
  %66 = getelementptr inbounds %struct.VDPSprite, ptr %65, i32 0, i32 1
  %67 = getelementptr inbounds %struct.anon.0, ptr %66, i32 0, i32 1
  %68 = load i8, ptr %67, align 1, !tbaa !14
  %69 = zext i8 %68 to i64
  %70 = getelementptr inbounds [16 x i8], ptr %4, i64 0, i64 0
  %71 = call zeroext i16 @intToStr(i64 noundef %69, ptr noundef %70, i16 noundef zeroext 1)
  %72 = getelementptr inbounds [64 x i8], ptr %3, i64 0, i64 0
  %73 = getelementptr inbounds [16 x i8], ptr %4, i64 0, i64 0
  %74 = call ptr @strcat(ptr noundef %72, ptr noundef %73) #4
  %75 = getelementptr inbounds [64 x i8], ptr %3, i64 0, i64 0
  call void @KLog(ptr noundef %75)
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 64, ptr %3) #4
  ret void
}

; Function Attrs: nounwind
declare ptr @strcpy(ptr noundef, ptr noundef) #2

declare zeroext i16 @intToStr(i64 noundef, ptr noundef, i16 noundef zeroext) #3

; Function Attrs: nounwind
declare ptr @strcat(ptr noundef, ptr noundef) #2

declare zeroext i16 @intToHex(i64 noundef, ptr noundef, i16 noundef zeroext) #3

declare void @KLog(ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { "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 }

!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 = !{!"short", !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 = !{!12, !6, i64 6}
!12 = !{!"", !6, i64 0, !7, i64 2, !7, i64 4, !6, i64 6}
!13 = !{!12, !6, i64 0}
!14 = !{!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.VDPSprite = type { i16, %union.anon, %union.anon.1, i16 }
%union.anon = type { %struct.anon }
%struct.anon = type { i16 }
%union.anon.1 = type { i16 }

@vdpSpriteCache = external dso_local local_unnamed_addr global [96 x %struct.VDPSprite], align 16
@.str = external hidden unnamed_addr constant [15 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local void @logVDPSprite(i16 noundef zeroext %0) local_unnamed_addr #1 {
  %2 = alloca [64 x i8], align 16
  %3 = alloca [16 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %2) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #4
  %4 = zext i16 %0 to i64
  %5 = getelementptr inbounds [96 x %struct.VDPSprite], ptr @vdpSpriteCache, i64 0, i64 %4
  %6 = call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %2, ptr noundef nonnull dereferenceable(1) @.str) #4
  %7 = call zeroext i16 @intToStr(i64 noundef %4, ptr noundef nonnull %3, i16 noundef zeroext 1) #4
  %8 = call ptr @strcat(ptr noundef nonnull dereferenceable(1) %2, ptr noundef nonnull dereferenceable(1) %3) #4
  %9 = call ptr @strcat(ptr noundef nonnull dereferenceable(1) %2, ptr noundef nonnull dereferenceable(1) @.str.1) #4
  %10 = getelementptr inbounds i8, ptr %5, i64 6
  %11 = load i16, ptr %10, align 2, !tbaa !5
  %12 = sext i16 %11 to i64
  %13 = call zeroext i16 @intToStr(i64 noundef %12, ptr noundef nonnull %3, i16 noundef zeroext 1) #4
  %14 = call ptr @strcat(ptr noundef nonnull dereferenceable(1) %2, ptr noundef nonnull dereferenceable(1) %3) #4
  %15 = call ptr @strcat(ptr noundef nonnull dereferenceable(1) %2, ptr noundef nonnull dereferenceable(1) @.str.2) #4
  %16 = load i16, ptr %5, align 8, !tbaa !10
  %17 = sext i16 %16 to i64
  %18 = call zeroext i16 @intToStr(i64 noundef %17, ptr noundef nonnull %3, i16 noundef zeroext 1) #4
  %19 = call ptr @strcat(ptr noundef nonnull dereferenceable(1) %2, ptr noundef nonnull dereferenceable(1) %3) #4
  %20 = call ptr @strcat(ptr noundef nonnull dereferenceable(1) %2, ptr noundef nonnull dereferenceable(1) @.str.3) #4
  %21 = getelementptr inbounds i8, ptr %5, i64 2
  %22 = load i8, ptr %21, align 2, !tbaa !11
  %23 = zext i8 %22 to i64
  %24 = call zeroext i16 @intToHex(i64 noundef %23, ptr noundef nonnull %3, i16 noundef zeroext 2) #4
  %25 = call ptr @strcat(ptr noundef nonnull dereferenceable(1) %2, ptr noundef nonnull dereferenceable(1) %3) #4
  %26 = call ptr @strcat(ptr noundef nonnull dereferenceable(1) %2, ptr noundef nonnull dereferenceable(1) @.str.4) #4
  %27 = getelementptr inbounds i8, ptr %5, i64 4
  %28 = load i16, ptr %27, align 4, !tbaa !11
  %29 = zext i16 %28 to i64
  %30 = call zeroext i16 @intToHex(i64 noundef %29, ptr noundef nonnull %3, i16 noundef zeroext 4) #4
  %31 = call ptr @strcat(ptr noundef nonnull dereferenceable(1) %2, ptr noundef nonnull dereferenceable(1) %3) #4
  %32 = call ptr @strcat(ptr noundef nonnull dereferenceable(1) %2, ptr noundef nonnull dereferenceable(1) @.str.5) #4
  %33 = getelementptr inbounds i8, ptr %5, i64 3
  %34 = load i8, ptr %33, align 1, !tbaa !11
  %35 = zext i8 %34 to i64
  %36 = call zeroext i16 @intToStr(i64 noundef %35, ptr noundef nonnull %3, i16 noundef zeroext 1) #4
  %37 = call ptr @strcat(ptr noundef nonnull dereferenceable(1) %2, ptr noundef nonnull dereferenceable(1) %3) #4
  call void @KLog(ptr noundef nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %2) #4
  ret void
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strcpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly) local_unnamed_addr #2

declare zeroext i16 @intToStr(i64 noundef, ptr noundef, i16 noundef zeroext) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strcat(ptr noalias noundef returned, ptr noalias nocapture noundef readonly) local_unnamed_addr #2

declare zeroext i16 @intToHex(i64 noundef, ptr noundef, i16 noundef zeroext) local_unnamed_addr #3

declare void @KLog(ptr noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { mustprogress nofree nounwind willreturn memory(argmem: readwrite) "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 = { "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 }

!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, !7, i64 6}
!6 = !{!"", !7, i64 0, !8, i64 2, !8, i64 4, !7, i64 6}
!7 = !{!"short", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 0}
!11 = !{!8, !8, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,SROAPass