; LLVM IR from Farama-Foundation/stable-retro :: cores/32x/cpu/sh2/mame (sh2dasm)

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

; Function Attrs: nounwind uwtable
define dso_local i32 @DasmSH2(ptr noundef %0, i32 noundef %1, i16 noundef zeroext %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i16, align 2
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i16 %2, ptr %6, align 2, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  %8 = load i32, ptr %5, align 4, !tbaa !9
  %9 = add i32 %8, 2
  store i32 %9, ptr %5, align 4, !tbaa !9
  %10 = load i16, ptr %6, align 2, !tbaa !11
  %11 = zext i16 %10 to i32
  %12 = ashr i32 %11, 12
  %13 = and i32 %12, 15
  switch i32 %13, label %89 [
    i32 0, label %14
    i32 1, label %19
    i32 2, label %24
    i32 3, label %29
    i32 4, label %34
    i32 5, label %39
    i32 6, label %44
    i32 7, label %49
    i32 8, label %54
    i32 9, label %59
    i32 10, label %64
    i32 11, label %69
    i32 12, label %74
    i32 13, label %79
    i32 14, label %84
  ]

14:                                               ; preds = %3
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = load i32, ptr %5, align 4, !tbaa !9
  %17 = load i16, ptr %6, align 2, !tbaa !11
  %18 = call i32 @op0000(ptr noundef %15, i32 noundef %16, i16 noundef zeroext %17)
  store i32 %18, ptr %7, align 4, !tbaa !9
  br label %94

19:                                               ; preds = %3
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = load i32, ptr %5, align 4, !tbaa !9
  %22 = load i16, ptr %6, align 2, !tbaa !11
  %23 = call i32 @op0001(ptr noundef %20, i32 noundef %21, i16 noundef zeroext %22)
  store i32 %23, ptr %7, align 4, !tbaa !9
  br label %94

24:                                               ; preds = %3
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = load i32, ptr %5, align 4, !tbaa !9
  %27 = load i16, ptr %6, align 2, !tbaa !11
  %28 = call i32 @op0010(ptr noundef %25, i32 noundef %26, i16 noundef zeroext %27)
  store i32 %28, ptr %7, align 4, !tbaa !9
  br label %94

29:                                               ; preds = %3
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = load i32, ptr %5, align 4, !tbaa !9
  %32 = load i16, ptr %6, align 2, !tbaa !11
  %33 = call i32 @op0011(ptr noundef %30, i32 noundef %31, i16 noundef zeroext %32)
  store i32 %33, ptr %7, align 4, !tbaa !9
  br label %94

34:                                               ; preds = %3
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = load i32, ptr %5, align 4, !tbaa !9
  %37 = load i16, ptr %6, align 2, !tbaa !11
  %38 = call i32 @op0100(ptr noundef %35, i32 noundef %36, i16 noundef zeroext %37)
  store i32 %38, ptr %7, align 4, !tbaa !9
  br label %94

39:                                               ; preds = %3
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = load i32, ptr %5, align 4, !tbaa !9
  %42 = load i16, ptr %6, align 2, !tbaa !11
  %43 = call i32 @op0101(ptr noundef %40, i32 noundef %41, i16 noundef zeroext %42)
  store i32 %43, ptr %7, align 4, !tbaa !9
  br label %94

44:                                               ; preds = %3
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = load i32, ptr %5, align 4, !tbaa !9
  %47 = load i16, ptr %6, align 2, !tbaa !11
  %48 = call i32 @op0110(ptr noundef %45, i32 noundef %46, i16 noundef zeroext %47)
  store i32 %48, ptr %7, align 4, !tbaa !9
  br label %94

49:                                               ; preds = %3
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = load i32, ptr %5, align 4, !tbaa !9
  %52 = load i16, ptr %6, align 2, !tbaa !11
  %53 = call i32 @op0111(ptr noundef %50, i32 noundef %51, i16 noundef zeroext %52)
  store i32 %53, ptr %7, align 4, !tbaa !9
  br label %94

54:                                               ; preds = %3
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = load i32, ptr %5, align 4, !tbaa !9
  %57 = load i16, ptr %6, align 2, !tbaa !11
  %58 = call i32 @op1000(ptr noundef %55, i32 noundef %56, i16 noundef zeroext %57)
  store i32 %58, ptr %7, align 4, !tbaa !9
  br label %94

59:                                               ; preds = %3
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = load i32, ptr %5, align 4, !tbaa !9
  %62 = load i16, ptr %6, align 2, !tbaa !11
  %63 = call i32 @op1001(ptr noundef %60, i32 noundef %61, i16 noundef zeroext %62)
  store i32 %63, ptr %7, align 4, !tbaa !9
  br label %94

64:                                               ; preds = %3
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = load i32, ptr %5, align 4, !tbaa !9
  %67 = load i16, ptr %6, align 2, !tbaa !11
  %68 = call i32 @op1010(ptr noundef %65, i32 noundef %66, i16 noundef zeroext %67)
  store i32 %68, ptr %7, align 4, !tbaa !9
  br label %94

69:                                               ; preds = %3
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = load i32, ptr %5, align 4, !tbaa !9
  %72 = load i16, ptr %6, align 2, !tbaa !11
  %73 = call i32 @op1011(ptr noundef %70, i32 noundef %71, i16 noundef zeroext %72)
  store i32 %73, ptr %7, align 4, !tbaa !9
  br label %94

74:                                               ; preds = %3
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = load i32, ptr %5, align 4, !tbaa !9
  %77 = load i16, ptr %6, align 2, !tbaa !11
  %78 = call i32 @op1100(ptr noundef %75, i32 noundef %76, i16 noundef zeroext %77)
  store i32 %78, ptr %7, align 4, !tbaa !9
  br label %94

79:                                               ; preds = %3
  %80 = load ptr, ptr %4, align 8, !tbaa !5
  %81 = load i32, ptr %5, align 4, !tbaa !9
  %82 = load i16, ptr %6, align 2, !tbaa !11
  %83 = call i32 @op1101(ptr noundef %80, i32 noundef %81, i16 noundef zeroext %82)
  store i32 %83, ptr %7, align 4, !tbaa !9
  br label %94

84:                                               ; preds = %3
  %85 = load ptr, ptr %4, align 8, !tbaa !5
  %86 = load i32, ptr %5, align 4, !tbaa !9
  %87 = load i16, ptr %6, align 2, !tbaa !11
  %88 = call i32 @op1110(ptr noundef %85, i32 noundef %86, i16 noundef zeroext %87)
  store i32 %88, ptr %7, align 4, !tbaa !9
  br label %94

89:                                               ; preds = %3
  %90 = load ptr, ptr %4, align 8, !tbaa !5
  %91 = load i32, ptr %5, align 4, !tbaa !9
  %92 = load i16, ptr %6, align 2, !tbaa !11
  %93 = call i32 @op1111(ptr noundef %90, i32 noundef %91, i16 noundef zeroext %92)
  store i32 %93, ptr %7, align 4, !tbaa !9
  br label %94

94:                                               ; preds = %89, %84, %79, %74, %69, %64, %59, %54, %49, %44, %39, %34, %29, %24, %19, %14
  %95 = load i32, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  ret i32 0
}

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

; Function Attrs: nounwind uwtable
declare hidden i32 @op0000(ptr noundef, i32 noundef, i16 noundef zeroext) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @op0001(ptr noundef, i32 noundef, i16 noundef zeroext) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @op0010(ptr noundef, i32 noundef, i16 noundef zeroext) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @op0011(ptr noundef, i32 noundef, i16 noundef zeroext) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @op0100(ptr noundef, i32 noundef, i16 noundef zeroext) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @op0101(ptr noundef, i32 noundef, i16 noundef zeroext) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @op0110(ptr noundef, i32 noundef, i16 noundef zeroext) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @op0111(ptr noundef, i32 noundef, i16 noundef zeroext) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @op1000(ptr noundef, i32 noundef, i16 noundef zeroext) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @op1001(ptr noundef, i32 noundef, i16 noundef zeroext) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @op1010(ptr noundef, i32 noundef, i16 noundef zeroext) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @op1011(ptr noundef, i32 noundef, i16 noundef zeroext) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @op1100(ptr noundef, i32 noundef, i16 noundef zeroext) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @op1101(ptr noundef, i32 noundef, i16 noundef zeroext) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @op1110(ptr noundef, i32 noundef, i16 noundef zeroext) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @op1111(ptr noundef, i32 noundef, i16 noundef zeroext) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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)"}
!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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"short", !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"

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @DasmSH2(ptr noundef %0, i32 noundef %1, i16 noundef zeroext %2) local_unnamed_addr #0 {
  %4 = add i32 %1, 2
  %5 = lshr i16 %2, 12
  switch i16 %5, label %default.unreachable50 [
    i16 0, label %6
    i16 1, label %8
    i16 2, label %10
    i16 3, label %12
    i16 4, label %14
    i16 5, label %16
    i16 6, label %18
    i16 7, label %20
    i16 8, label %22
    i16 9, label %24
    i16 10, label %26
    i16 11, label %28
    i16 12, label %30
    i16 13, label %32
    i16 14, label %34
    i16 15, label %36
  ]

6:                                                ; preds = %3
  %7 = tail call i32 @op0000(ptr noundef %0, i32 noundef %4, i16 noundef zeroext %2)
  br label %38

8:                                                ; preds = %3
  %9 = tail call i32 @op0001(ptr noundef %0, i32 noundef %4, i16 noundef zeroext %2)
  br label %38

10:                                               ; preds = %3
  %11 = tail call i32 @op0010(ptr noundef %0, i32 noundef %4, i16 noundef zeroext %2)
  br label %38

12:                                               ; preds = %3
  %13 = tail call i32 @op0011(ptr noundef %0, i32 noundef %4, i16 noundef zeroext %2)
  br label %38

14:                                               ; preds = %3
  %15 = tail call i32 @op0100(ptr noundef %0, i32 noundef %4, i16 noundef zeroext %2)
  br label %38

16:                                               ; preds = %3
  %17 = tail call i32 @op0101(ptr noundef %0, i32 noundef %4, i16 noundef zeroext %2)
  br label %38

18:                                               ; preds = %3
  %19 = tail call i32 @op0110(ptr noundef %0, i32 noundef %4, i16 noundef zeroext %2)
  br label %38

20:                                               ; preds = %3
  %21 = tail call i32 @op0111(ptr noundef %0, i32 noundef %4, i16 noundef zeroext %2)
  br label %38

22:                                               ; preds = %3
  %23 = tail call i32 @op1000(ptr noundef %0, i32 noundef %4, i16 noundef zeroext %2)
  br label %38

24:                                               ; preds = %3
  %25 = tail call i32 @op1001(ptr noundef %0, i32 noundef %4, i16 noundef zeroext %2)
  br label %38

26:                                               ; preds = %3
  %27 = tail call i32 @op1010(ptr noundef %0, i32 noundef %4, i16 noundef zeroext %2)
  br label %38

28:                                               ; preds = %3
  %29 = tail call i32 @op1011(ptr noundef %0, i32 noundef %4, i16 noundef zeroext %2)
  br label %38

30:                                               ; preds = %3
  %31 = tail call i32 @op1100(ptr noundef %0, i32 noundef %4, i16 noundef zeroext %2)
  br label %38

32:                                               ; preds = %3
  %33 = tail call i32 @op1101(ptr noundef %0, i32 noundef %4, i16 noundef zeroext %2)
  br label %38

34:                                               ; preds = %3
  %35 = tail call i32 @op1110(ptr noundef %0, i32 noundef %4, i16 noundef zeroext %2)
  br label %38

default.unreachable50:                            ; preds = %3
  unreachable

36:                                               ; preds = %3
  %37 = tail call i32 @op1111(ptr noundef %0, i32 noundef %4, i16 noundef zeroext %2)
  br label %38

38:                                               ; preds = %36, %34, %32, %30, %28, %26, %24, %22, %20, %18, %16, %14, %12, %10, %8, %6
  ret i32 0
}

; Function Attrs: nounwind uwtable
declare hidden i32 @op0000(ptr noundef, i32 noundef, i16 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @op0001(ptr noundef, i32 noundef, i16 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @op0010(ptr noundef, i32 noundef, i16 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @op0011(ptr noundef, i32 noundef, i16 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @op0100(ptr noundef, i32 noundef, i16 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @op0101(ptr noundef, i32 noundef, i16 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @op0110(ptr noundef, i32 noundef, i16 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @op0111(ptr noundef, i32 noundef, i16 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @op1000(ptr noundef, i32 noundef, i16 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @op1001(ptr noundef, i32 noundef, i16 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @op1010(ptr noundef, i32 noundef, i16 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @op1011(ptr noundef, i32 noundef, i16 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @op1100(ptr noundef, i32 noundef, i16 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @op1101(ptr noundef, i32 noundef, i16 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @op1110(ptr noundef, i32 noundef, i16 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @op1111(ptr noundef, i32 noundef, i16 noundef zeroext) local_unnamed_addr #0

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


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass