; LLVM IR from alekmaul/pvsneslib :: snes-examples/graphics/Backgrounds/Mode7Perspective (Mode7Perspective)

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

@sx = external dso_local global i16, align 2
@sy = external dso_local global i16, align 2
@data_to_transfertMode = external dso_local global %struct.dmaMemory, align 8
@data_to_transfertBG = external dso_local global %struct.dmaMemory, align 8
@data_to_transfertX = external dso_local global %struct.dmaMemory, align 8
@data_to_transfertY = external dso_local global %struct.dmaMemory, align 8

; Function Attrs: nounwind uwtable
define dso_local void @setMode7_HdmaPerspective() #0 {
  %1 = load i16, ptr @sx, align 2, !tbaa !5
  %2 = zext i16 %1 to i32
  %3 = and i32 %2, 255
  %4 = trunc i32 %3 to i8
  store volatile i8 %4, ptr inttoptr (i64 8461 to ptr), align 1, !tbaa !9
  %5 = load i16, ptr @sx, align 2, !tbaa !5
  %6 = zext i16 %5 to i32
  %7 = ashr i32 %6, 8
  %8 = trunc i32 %7 to i8
  store volatile i8 %8, ptr inttoptr (i64 8461 to ptr), align 1, !tbaa !9
  %9 = load i16, ptr @sy, align 2, !tbaa !5
  %10 = zext i16 %9 to i32
  %11 = and i32 %10, 255
  %12 = trunc i32 %11 to i8
  store volatile i8 %12, ptr inttoptr (i64 8462 to ptr), align 1, !tbaa !9
  %13 = load i16, ptr @sy, align 2, !tbaa !5
  %14 = zext i16 %13 to i32
  %15 = ashr i32 %14, 8
  %16 = trunc i32 %15 to i8
  store volatile i8 %16, ptr inttoptr (i64 8462 to ptr), align 1, !tbaa !9
  %17 = load i16, ptr @sx, align 2, !tbaa !5
  %18 = zext i16 %17 to i32
  %19 = and i32 %18, 255
  %20 = trunc i32 %19 to i8
  store volatile i8 %20, ptr inttoptr (i64 8463 to ptr), align 1, !tbaa !9
  %21 = load i16, ptr @sx, align 2, !tbaa !5
  %22 = zext i16 %21 to i32
  %23 = ashr i32 %22, 8
  %24 = trunc i32 %23 to i8
  store volatile i8 %24, ptr inttoptr (i64 8463 to ptr), align 1, !tbaa !9
  %25 = load i16, ptr @sx, align 2, !tbaa !5
  %26 = zext i16 %25 to i32
  %27 = add nsw i32 %26, 128
  %28 = and i32 %27, 255
  %29 = trunc i32 %28 to i8
  store volatile i8 %29, ptr inttoptr (i64 8479 to ptr), align 1, !tbaa !9
  %30 = load i16, ptr @sx, align 2, !tbaa !5
  %31 = zext i16 %30 to i32
  %32 = add nsw i32 %31, 128
  %33 = ashr i32 %32, 8
  %34 = trunc i32 %33 to i8
  store volatile i8 %34, ptr inttoptr (i64 8479 to ptr), align 1, !tbaa !9
  %35 = load i16, ptr @sy, align 2, !tbaa !5
  %36 = zext i16 %35 to i32
  %37 = add nsw i32 %36, 112
  %38 = and i32 %37, 255
  %39 = trunc i32 %38 to i8
  store volatile i8 %39, ptr inttoptr (i64 8480 to ptr), align 1, !tbaa !9
  %40 = load i16, ptr @sy, align 2, !tbaa !5
  %41 = zext i16 %40 to i32
  %42 = add nsw i32 %41, 112
  %43 = ashr i32 %42, 8
  %44 = trunc i32 %43 to i8
  store volatile i8 %44, ptr inttoptr (i64 8480 to ptr), align 1, !tbaa !9
  store volatile i8 0, ptr inttoptr (i64 16908 to ptr), align 1, !tbaa !9
  store volatile i8 0, ptr inttoptr (i64 17168 to ptr), align 1, !tbaa !9
  store volatile i8 5, ptr inttoptr (i64 17169 to ptr), align 1, !tbaa !9
  %45 = load i16, ptr @data_to_transfertMode, align 8, !tbaa !9
  store volatile i16 %45, ptr inttoptr (i64 17170 to ptr), align 2, !tbaa !5
  %46 = load i8, ptr getelementptr inbounds (%struct.anon, ptr @data_to_transfertMode, i32 0, i32 1), align 2, !tbaa !9
  store volatile i8 %46, ptr inttoptr (i64 17172 to ptr), align 1, !tbaa !9
  store volatile i8 0, ptr inttoptr (i64 17184 to ptr), align 1, !tbaa !9
  store volatile i8 44, ptr inttoptr (i64 17185 to ptr), align 1, !tbaa !9
  %47 = load i16, ptr @data_to_transfertBG, align 8, !tbaa !9
  store volatile i16 %47, ptr inttoptr (i64 17186 to ptr), align 2, !tbaa !5
  %48 = load i8, ptr getelementptr inbounds (%struct.anon, ptr @data_to_transfertBG, i32 0, i32 1), align 2, !tbaa !9
  store volatile i8 %48, ptr inttoptr (i64 17188 to ptr), align 1, !tbaa !9
  store volatile i8 2, ptr inttoptr (i64 17200 to ptr), align 1, !tbaa !9
  store volatile i8 27, ptr inttoptr (i64 17201 to ptr), align 1, !tbaa !9
  %49 = load i16, ptr @data_to_transfertX, align 8, !tbaa !9
  store volatile i16 %49, ptr inttoptr (i64 17202 to ptr), align 2, !tbaa !5
  %50 = load i8, ptr getelementptr inbounds (%struct.anon, ptr @data_to_transfertX, i32 0, i32 1), align 2, !tbaa !9
  store volatile i8 %50, ptr inttoptr (i64 17204 to ptr), align 1, !tbaa !9
  store volatile i8 2, ptr inttoptr (i64 17216 to ptr), align 1, !tbaa !9
  store volatile i8 30, ptr inttoptr (i64 17217 to ptr), align 1, !tbaa !9
  %51 = load i16, ptr @data_to_transfertY, align 8, !tbaa !9
  store volatile i16 %51, ptr inttoptr (i64 17218 to ptr), align 2, !tbaa !5
  %52 = load i8, ptr getelementptr inbounds (%struct.anon, ptr @data_to_transfertY, i32 0, i32 1), align 2, !tbaa !9
  store volatile i8 %52, ptr inttoptr (i64 17220 to ptr), align 1, !tbaa !9
  store volatile i8 30, ptr inttoptr (i64 16908 to ptr), align 1, !tbaa !9
  ret void
}

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

!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 = !{!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.dmaMemory = type { %union.anon }
%union.anon = type { ptr }

@sx = external dso_local local_unnamed_addr global i16, align 2
@sy = external dso_local local_unnamed_addr global i16, align 2
@data_to_transfertMode = external dso_local local_unnamed_addr global %struct.dmaMemory, align 8
@data_to_transfertBG = external dso_local local_unnamed_addr global %struct.dmaMemory, align 8
@data_to_transfertX = external dso_local local_unnamed_addr global %struct.dmaMemory, align 8
@data_to_transfertY = external dso_local local_unnamed_addr global %struct.dmaMemory, align 8

; Function Attrs: nofree norecurse nounwind uwtable
define dso_local void @setMode7_HdmaPerspective() local_unnamed_addr #0 {
  %1 = load i16, ptr @sx, align 2, !tbaa !5
  %2 = trunc i16 %1 to i8
  store volatile i8 %2, ptr inttoptr (i64 8461 to ptr), align 1, !tbaa !9
  %3 = load i16, ptr @sx, align 2, !tbaa !5
  %4 = lshr i16 %3, 8
  %5 = trunc nuw i16 %4 to i8
  store volatile i8 %5, ptr inttoptr (i64 8461 to ptr), align 1, !tbaa !9
  %6 = load i16, ptr @sy, align 2, !tbaa !5
  %7 = trunc i16 %6 to i8
  store volatile i8 %7, ptr inttoptr (i64 8462 to ptr), align 2, !tbaa !9
  %8 = load i16, ptr @sy, align 2, !tbaa !5
  %9 = lshr i16 %8, 8
  %10 = trunc nuw i16 %9 to i8
  store volatile i8 %10, ptr inttoptr (i64 8462 to ptr), align 2, !tbaa !9
  %11 = load i16, ptr @sx, align 2, !tbaa !5
  %12 = trunc i16 %11 to i8
  store volatile i8 %12, ptr inttoptr (i64 8463 to ptr), align 1, !tbaa !9
  %13 = load i16, ptr @sx, align 2, !tbaa !5
  %14 = lshr i16 %13, 8
  %15 = trunc nuw i16 %14 to i8
  store volatile i8 %15, ptr inttoptr (i64 8463 to ptr), align 1, !tbaa !9
  %16 = load i16, ptr @sx, align 2, !tbaa !5
  %17 = trunc i16 %16 to i8
  %18 = xor i8 %17, -128
  store volatile i8 %18, ptr inttoptr (i64 8479 to ptr), align 1, !tbaa !9
  %19 = load i16, ptr @sx, align 2, !tbaa !5
  %20 = zext i16 %19 to i32
  %21 = add nuw nsw i32 %20, 128
  %22 = lshr i32 %21, 8
  %23 = trunc i32 %22 to i8
  store volatile i8 %23, ptr inttoptr (i64 8479 to ptr), align 1, !tbaa !9
  %24 = load i16, ptr @sy, align 2, !tbaa !5
  %25 = trunc i16 %24 to i8
  %26 = add i8 %25, 112
  store volatile i8 %26, ptr inttoptr (i64 8480 to ptr), align 32, !tbaa !9
  %27 = load i16, ptr @sy, align 2, !tbaa !5
  %28 = zext i16 %27 to i32
  %29 = add nuw nsw i32 %28, 112
  %30 = lshr i32 %29, 8
  %31 = trunc i32 %30 to i8
  store volatile i8 %31, ptr inttoptr (i64 8480 to ptr), align 32, !tbaa !9
  store volatile i8 0, ptr inttoptr (i64 16908 to ptr), align 4, !tbaa !9
  store volatile i8 0, ptr inttoptr (i64 17168 to ptr), align 16, !tbaa !9
  store volatile i8 5, ptr inttoptr (i64 17169 to ptr), align 1, !tbaa !9
  %32 = load i16, ptr @data_to_transfertMode, align 8, !tbaa !9
  store volatile i16 %32, ptr inttoptr (i64 17170 to ptr), align 2, !tbaa !5
  %33 = load i8, ptr getelementptr inbounds (i8, ptr @data_to_transfertMode, i64 2), align 2, !tbaa !9
  store volatile i8 %33, ptr inttoptr (i64 17172 to ptr), align 4, !tbaa !9
  store volatile i8 0, ptr inttoptr (i64 17184 to ptr), align 32, !tbaa !9
  store volatile i8 44, ptr inttoptr (i64 17185 to ptr), align 1, !tbaa !9
  %34 = load i16, ptr @data_to_transfertBG, align 8, !tbaa !9
  store volatile i16 %34, ptr inttoptr (i64 17186 to ptr), align 2, !tbaa !5
  %35 = load i8, ptr getelementptr inbounds (i8, ptr @data_to_transfertBG, i64 2), align 2, !tbaa !9
  store volatile i8 %35, ptr inttoptr (i64 17188 to ptr), align 4, !tbaa !9
  store volatile i8 2, ptr inttoptr (i64 17200 to ptr), align 16, !tbaa !9
  store volatile i8 27, ptr inttoptr (i64 17201 to ptr), align 1, !tbaa !9
  %36 = load i16, ptr @data_to_transfertX, align 8, !tbaa !9
  store volatile i16 %36, ptr inttoptr (i64 17202 to ptr), align 2, !tbaa !5
  %37 = load i8, ptr getelementptr inbounds (i8, ptr @data_to_transfertX, i64 2), align 2, !tbaa !9
  store volatile i8 %37, ptr inttoptr (i64 17204 to ptr), align 4, !tbaa !9
  store volatile i8 2, ptr inttoptr (i64 17216 to ptr), align 64, !tbaa !9
  store volatile i8 30, ptr inttoptr (i64 17217 to ptr), align 1, !tbaa !9
  %38 = load i16, ptr @data_to_transfertY, align 8, !tbaa !9
  store volatile i16 %38, ptr inttoptr (i64 17218 to ptr), align 2, !tbaa !5
  %39 = load i8, ptr getelementptr inbounds (i8, ptr @data_to_transfertY, i64 2), align 2, !tbaa !9
  store volatile i8 %39, ptr inttoptr (i64 17220 to ptr), align 4, !tbaa !9
  store volatile i8 30, ptr inttoptr (i64 16908 to ptr), align 4, !tbaa !9
  ret void
}

attributes #0 = { nofree norecurse 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" }

!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 = !{!7, !7, i64 0}


; Effective O3 passes: GlobalOptPass,IPSCCPPass,InferAlignmentPass,InstCombinePass,PostOrderFunctionAttrsPass