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

; 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.Map = type { i16, i16, ptr, ptr, ptr, ptr, i32, i16, i64, i64, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, [240 x i16], [20 x i16], ptr, ptr, ptr, ptr, ptr }

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

11:                                               ; preds = %3
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.Map, ptr %12, i32 0, i32 12
  store i16 128, ptr %13, align 4, !tbaa !11
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.Map, ptr %14, i32 0, i32 14
  store i16 63, ptr %15, align 8, !tbaa !15
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.Map, ptr %16, i32 0, i32 16
  store i16 9, ptr %17, align 4, !tbaa !16
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.Map, ptr %18, i32 0, i32 13
  store i16 32, ptr %19, align 2, !tbaa !17
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.Map, ptr %20, i32 0, i32 15
  store i16 15, ptr %21, align 2, !tbaa !18
  br label %83

22:                                               ; preds = %3
  %23 = load i16, ptr %5, align 2, !tbaa !9
  %24 = zext i16 %23 to i32
  %25 = and i32 %24, 64
  %26 = icmp ne i32 %25, 0
  br i1 %26, label %27, label %49

27:                                               ; preds = %22
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.Map, ptr %28, i32 0, i32 12
  store i16 64, ptr %29, align 4, !tbaa !11
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.Map, ptr %30, i32 0, i32 14
  store i16 31, ptr %31, align 8, !tbaa !15
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.Map, ptr %32, i32 0, i32 16
  store i16 8, ptr %33, align 4, !tbaa !16
  %34 = load i16, ptr %6, align 2, !tbaa !9
  %35 = zext i16 %34 to i32
  %36 = and i32 %35, 64
  %37 = icmp ne i32 %36, 0
  br i1 %37, label %38, label %43

38:                                               ; preds = %27
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.Map, ptr %39, i32 0, i32 13
  store i16 64, ptr %40, align 2, !tbaa !17
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.Map, ptr %41, i32 0, i32 15
  store i16 31, ptr %42, align 2, !tbaa !18
  br label %48

43:                                               ; preds = %27
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.Map, ptr %44, i32 0, i32 13
  store i16 32, ptr %45, align 2, !tbaa !17
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.Map, ptr %46, i32 0, i32 15
  store i16 15, ptr %47, align 2, !tbaa !18
  br label %48

48:                                               ; preds = %43, %38
  br label %82

49:                                               ; preds = %22
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.Map, ptr %50, i32 0, i32 12
  store i16 32, ptr %51, align 4, !tbaa !11
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.Map, ptr %52, i32 0, i32 14
  store i16 15, ptr %53, align 8, !tbaa !15
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.Map, ptr %54, i32 0, i32 16
  store i16 7, ptr %55, align 4, !tbaa !16
  %56 = load i16, ptr %6, align 2, !tbaa !9
  %57 = zext i16 %56 to i32
  %58 = and i32 %57, 128
  %59 = icmp ne i32 %58, 0
  br i1 %59, label %60, label %65

60:                                               ; preds = %49
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.Map, ptr %61, i32 0, i32 13
  store i16 128, ptr %62, align 2, !tbaa !17
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.Map, ptr %63, i32 0, i32 15
  store i16 63, ptr %64, align 2, !tbaa !18
  br label %81

65:                                               ; preds = %49
  %66 = load i16, ptr %6, align 2, !tbaa !9
  %67 = zext i16 %66 to i32
  %68 = and i32 %67, 64
  %69 = icmp ne i32 %68, 0
  br i1 %69, label %70, label %75

70:                                               ; preds = %65
  %71 = load ptr, ptr %4, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.Map, ptr %71, i32 0, i32 13
  store i16 64, ptr %72, align 2, !tbaa !17
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.Map, ptr %73, i32 0, i32 15
  store i16 31, ptr %74, align 2, !tbaa !18
  br label %80

75:                                               ; preds = %65
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.Map, ptr %76, i32 0, i32 13
  store i16 32, ptr %77, align 2, !tbaa !17
  %78 = load ptr, ptr %4, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.Map, ptr %78, i32 0, i32 15
  store i16 15, ptr %79, align 2, !tbaa !18
  br label %80

80:                                               ; preds = %75, %70
  br label %81

81:                                               ; preds = %80, %60
  br label %82

82:                                               ; preds = %81, %48
  br label %83

83:                                               ; preds = %82, %11
  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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"short", !7, i64 0}
!11 = !{!12, !10, i64 68}
!12 = !{!"Map", !10, i64 0, !10, i64 2, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !13, i64 40, !10, i64 44, !14, i64 48, !14, i64 56, !10, i64 64, !10, i64 66, !10, i64 68, !10, i64 70, !10, i64 72, !10, i64 74, !10, i64 76, !10, i64 78, !10, i64 80, !10, i64 82, !7, i64 84, !7, i64 564, !6, i64 608, !6, i64 616, !6, i64 624, !6, i64 632, !6, i64 640}
!13 = !{!"int", !7, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!12, !10, i64 72}
!16 = !{!12, !10, i64 76}
!17 = !{!12, !10, i64 70}
!18 = !{!12, !10, i64 74}


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

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) uwtable
define dso_local void @MAP_overridePlaneSize(ptr nocapture noundef writeonly %0, i16 noundef zeroext %1, i16 noundef zeroext %2) local_unnamed_addr #0 {
  %4 = zext i16 %1 to i32
  %5 = and i32 %4, 128
  %.not = icmp eq i32 %5, 0
  %6 = getelementptr inbounds i8, ptr %0, i64 76
  br i1 %.not, label %9, label %7

7:                                                ; preds = %3
  %8 = getelementptr inbounds i8, ptr %0, i64 68
  store i16 9, ptr %6, align 4, !tbaa !5
  store <4 x i16> <i16 128, i16 32, i16 63, i16 15>, ptr %8, align 4, !tbaa !13
  br label %31

9:                                                ; preds = %3
  %10 = and i32 %4, 64
  %.not25 = icmp eq i32 %10, 0
  %11 = getelementptr inbounds i8, ptr %0, i64 68
  %12 = getelementptr inbounds i8, ptr %0, i64 72
  br i1 %.not25, label %19, label %13

13:                                               ; preds = %9
  store i16 64, ptr %11, align 4, !tbaa !14
  store i16 31, ptr %12, align 8, !tbaa !15
  store i16 8, ptr %6, align 4, !tbaa !5
  %14 = and i16 %2, 64
  %.not28 = icmp eq i16 %14, 0
  %15 = getelementptr inbounds i8, ptr %0, i64 70
  %16 = getelementptr inbounds i8, ptr %0, i64 74
  br i1 %.not28, label %18, label %17

17:                                               ; preds = %13
  store i16 64, ptr %15, align 2, !tbaa !16
  store i16 31, ptr %16, align 2, !tbaa !17
  br label %31

18:                                               ; preds = %13
  store i16 32, ptr %15, align 2, !tbaa !16
  store i16 15, ptr %16, align 2, !tbaa !17
  br label %31

19:                                               ; preds = %9
  store i16 32, ptr %11, align 4, !tbaa !14
  store i16 15, ptr %12, align 8, !tbaa !15
  store i16 7, ptr %6, align 4, !tbaa !5
  %20 = zext i16 %2 to i32
  %21 = and i32 %20, 128
  %.not26 = icmp eq i32 %21, 0
  br i1 %.not26, label %25, label %22

22:                                               ; preds = %19
  %23 = getelementptr inbounds i8, ptr %0, i64 70
  store i16 128, ptr %23, align 2, !tbaa !16
  %24 = getelementptr inbounds i8, ptr %0, i64 74
  store i16 63, ptr %24, align 2, !tbaa !17
  br label %31

25:                                               ; preds = %19
  %26 = and i32 %20, 64
  %.not27 = icmp eq i32 %26, 0
  %27 = getelementptr inbounds i8, ptr %0, i64 70
  %28 = getelementptr inbounds i8, ptr %0, i64 74
  br i1 %.not27, label %30, label %29

29:                                               ; preds = %25
  store i16 64, ptr %27, align 2, !tbaa !16
  store i16 31, ptr %28, align 2, !tbaa !17
  br label %31

30:                                               ; preds = %25
  store i16 32, ptr %27, align 2, !tbaa !16
  store i16 15, ptr %28, align 2, !tbaa !17
  br label %31

31:                                               ; preds = %18, %17, %29, %30, %22, %7
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) 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, !7, i64 76}
!6 = !{!"Map", !7, i64 0, !7, i64 2, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !11, i64 40, !7, i64 44, !12, i64 48, !12, i64 56, !7, i64 64, !7, i64 66, !7, i64 68, !7, i64 70, !7, i64 72, !7, i64 74, !7, i64 76, !7, i64 78, !7, i64 80, !7, i64 82, !8, i64 84, !8, i64 564, !10, i64 608, !10, i64 616, !10, i64 624, !10, i64 632, !10, i64 640}
!7 = !{!"short", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!"long", !8, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{!6, !7, i64 68}
!15 = !{!6, !7, i64 72}
!16 = !{!6, !7, i64 70}
!17 = !{!6, !7, i64 74}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass