; LLVM IR from alekras/ao.rtos.cpp :: Tools/ARM-Raspberry_Pi/Initial_Interactive_Loader (InitialInteractiveLoaderSM)

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

%class.InitialInteractiveLoaderSM = type <{ %class.Efsm, i32, i32, i32, i32, i32, i32, i32, [4 x i8], ptr, i32, i32, i32, [4 x i8] }>
%class.Efsm = type { { i64, i64 } }

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN26InitialInteractiveLoaderSM7initialE5PhasePc(ptr noundef nonnull align 8 dereferenceable(68), i32 noundef, ptr noundef) #0 align 2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN26InitialInteractiveLoaderSM5debugEv(ptr noundef nonnull align 8 dereferenceable(68)) #2 align 2

declare void @sendString(ptr noundef) #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4EfsmIcE4tranEMS0_Fi5PhasePcE(ptr noundef nonnull align 8 dereferenceable(16), i64, i64) #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN26InitialInteractiveLoaderSM2goE5PhasePc(ptr noundef nonnull align 8 dereferenceable(68) %0, i32 noundef %1, ptr noundef %2) #0 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i8, align 1
  %8 = alloca { i64, i64 }, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  %9 = load ptr, ptr %4, align 8
  %10 = load i32, ptr %5, align 4, !tbaa !9
  switch i32 %10, label %76 [
    i32 0, label %11
    i32 1, label %14
    i32 2, label %73
  ]

11:                                               ; preds = %3
  %12 = getelementptr inbounds %class.InitialInteractiveLoaderSM, ptr %9, i32 0, i32 2
  store i32 0, ptr %12, align 4, !tbaa !11
  %13 = getelementptr inbounds %class.InitialInteractiveLoaderSM, ptr %9, i32 0, i32 1
  store i32 0, ptr %13, align 8, !tbaa !15
  br label %76

14:                                               ; preds = %3
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = load i8, ptr %15, align 1, !tbaa !16
  %17 = sext i8 %16 to i32
  switch i32 %17, label %26 [
    i32 10, label %18
    i32 13, label %22
  ]

18:                                               ; preds = %14
  %19 = getelementptr inbounds %class.InitialInteractiveLoaderSM, ptr %9, i32 0, i32 1
  %20 = load i32, ptr %19, align 8, !tbaa !15
  %21 = add nsw i32 %20, 3
  store i32 %21, ptr %19, align 8, !tbaa !15
  br label %60

22:                                               ; preds = %14
  %23 = getelementptr inbounds %class.InitialInteractiveLoaderSM, ptr %9, i32 0, i32 1
  %24 = load i32, ptr %23, align 8, !tbaa !15
  %25 = add nsw i32 %24, 5
  store i32 %25, ptr %23, align 8, !tbaa !15
  br label %60

26:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #4
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = load i8, ptr %27, align 1, !tbaa !16
  store i8 %28, ptr %7, align 1, !tbaa !16
  %29 = load i8, ptr %7, align 1, !tbaa !16
  %30 = sext i8 %29 to i32
  %31 = icmp sge i32 %30, 48
  br i1 %31, label %32, label %36

32:                                               ; preds = %26
  %33 = load i8, ptr %7, align 1, !tbaa !16
  %34 = sext i8 %33 to i32
  %35 = icmp sle i32 %34, 57
  br i1 %35, label %52, label %36

36:                                               ; preds = %32, %26
  %37 = load i8, ptr %7, align 1, !tbaa !16
  %38 = sext i8 %37 to i32
  %39 = icmp sge i32 %38, 65
  br i1 %39, label %40, label %44

40:                                               ; preds = %36
  %41 = load i8, ptr %7, align 1, !tbaa !16
  %42 = sext i8 %41 to i32
  %43 = icmp sle i32 %42, 70
  br i1 %43, label %52, label %44

44:                                               ; preds = %40, %36
  %45 = load i8, ptr %7, align 1, !tbaa !16
  %46 = sext i8 %45 to i32
  %47 = icmp sge i32 %46, 97
  br i1 %47, label %48, label %58

48:                                               ; preds = %44
  %49 = load i8, ptr %7, align 1, !tbaa !16
  %50 = sext i8 %49 to i32
  %51 = icmp sle i32 %50, 102
  br i1 %51, label %52, label %58

52:                                               ; preds = %48, %40, %32
  %53 = getelementptr inbounds %class.InitialInteractiveLoaderSM, ptr %9, i32 0, i32 2
  %54 = load i32, ptr %53, align 4, !tbaa !11
  %55 = load i8, ptr %7, align 1, !tbaa !16
  %56 = call i32 @convert(i32 noundef %54, i8 noundef signext %55)
  %57 = getelementptr inbounds %class.InitialInteractiveLoaderSM, ptr %9, i32 0, i32 2
  store i32 %56, ptr %57, align 4, !tbaa !11
  br label %59

58:                                               ; preds = %48, %44
  call void @_ZN26InitialInteractiveLoaderSM5debugEv(ptr noundef nonnull align 8 dereferenceable(68) %9)
  br label %59

59:                                               ; preds = %58, %52
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #4
  br label %60

60:                                               ; preds = %59, %22, %18
  %61 = getelementptr inbounds %class.InitialInteractiveLoaderSM, ptr %9, i32 0, i32 1
  %62 = load i32, ptr %61, align 8, !tbaa !15
  %63 = icmp sge i32 %62, 3
  br i1 %63, label %64, label %72

64:                                               ; preds = %60
  call void @sendString(ptr noundef @.str.1)
  %65 = getelementptr inbounds %class.InitialInteractiveLoaderSM, ptr %9, i32 0, i32 2
  %66 = load i32, ptr %65, align 4, !tbaa !11
  %67 = getelementptr inbounds %class.InitialInteractiveLoaderSM, ptr %9, i32 0, i32 6
  store i32 %66, ptr %67, align 4, !tbaa !17
  store { i64, i64 } { i64 ptrtoint (ptr @_ZN26InitialInteractiveLoaderSM7initialE5PhasePc to i64), i64 0 }, ptr %8, align 8, !tbaa !16
  %68 = getelementptr inbounds { i64, i64 }, ptr %8, i32 0, i32 0
  %69 = load i64, ptr %68, align 8
  %70 = getelementptr inbounds { i64, i64 }, ptr %8, i32 0, i32 1
  %71 = load i64, ptr %70, align 8
  call void @_ZN4EfsmIcE4tranEMS0_Fi5PhasePcE(ptr noundef nonnull align 8 dereferenceable(16) %9, i64 %69, i64 %71)
  br label %72

72:                                               ; preds = %64, %60
  br label %76

73:                                               ; preds = %3
  call void @disable_irq()
  %74 = getelementptr inbounds %class.InitialInteractiveLoaderSM, ptr %9, i32 0, i32 6
  %75 = load i32, ptr %74, align 4, !tbaa !17
  call void @GOTO(i32 noundef %75)
  br label %76

76:                                               ; preds = %73, %72, %11, %3
  ret i32 0
}

declare i32 @convert(i32 noundef, i8 noundef signext) #3

declare void @disable_irq() #3

declare void @GOTO(i32 noundef) #3

attributes #0 = { mustprogress 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 = { mustprogress 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"_ZTS5Phase", !7, i64 0}
!11 = !{!12, !14, i64 20}
!12 = !{!"_ZTS26InitialInteractiveLoaderSM", !13, i64 0, !14, i64 16, !14, i64 20, !14, i64 24, !14, i64 28, !14, i64 32, !14, i64 36, !14, i64 40, !6, i64 48, !14, i64 56, !14, i64 60, !14, i64 64}
!13 = !{!"_ZTS4EfsmIcE", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!12, !14, i64 16}
!16 = !{!7, !7, i64 0}
!17 = !{!12, !14, i64 36}


; 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.1 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN26InitialInteractiveLoaderSM7initialE5PhasePc(ptr noundef nonnull align 8 dereferenceable(68), i32 noundef, ptr noundef) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN26InitialInteractiveLoaderSM5debugEv(ptr noundef nonnull align 8 dereferenceable(68)) local_unnamed_addr #1 align 2

declare void @sendString(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4EfsmIcE4tranEMS0_Fi5PhasePcE(ptr noundef nonnull align 8 dereferenceable(16), i64, i64) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN26InitialInteractiveLoaderSM2goE5PhasePc(ptr noundef nonnull align 8 dereferenceable(68) %0, i32 noundef %1, ptr nocapture noundef readonly %2) local_unnamed_addr #0 align 2 {
  switch i32 %1, label %35 [
    i32 0, label %4
    i32 1, label %7
    i32 2, label %32
  ]

4:                                                ; preds = %3
  %5 = getelementptr inbounds i8, ptr %0, i64 20
  store i32 0, ptr %5, align 4, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 0, ptr %6, align 8, !tbaa !12
  br label %35

7:                                                ; preds = %3
  %8 = load i8, ptr %2, align 1, !tbaa !13
  switch i8 %8, label %17 [
    i8 10, label %9
    i8 13, label %13
  ]

9:                                                ; preds = %7
  %10 = getelementptr inbounds i8, ptr %0, i64 16
  %11 = load i32, ptr %10, align 8, !tbaa !12
  %12 = add nsw i32 %11, 3
  store i32 %12, ptr %10, align 8, !tbaa !12
  br label %24

13:                                               ; preds = %7
  %14 = getelementptr inbounds i8, ptr %0, i64 16
  %15 = load i32, ptr %14, align 8, !tbaa !12
  %16 = add nsw i32 %15, 5
  store i32 %16, ptr %14, align 8, !tbaa !12
  br label %24

17:                                               ; preds = %7
  %18 = add i8 %8, -48
  %or.cond = icmp ult i8 %18, 10
  br i1 %or.cond, label %19, label %switch.early.test

switch.early.test:                                ; preds = %17
  switch i8 %8, label %23 [
    i8 102, label %19
    i8 101, label %19
    i8 100, label %19
    i8 99, label %19
    i8 98, label %19
    i8 97, label %19
    i8 70, label %19
    i8 69, label %19
    i8 68, label %19
    i8 67, label %19
    i8 66, label %19
    i8 65, label %19
  ]

19:                                               ; preds = %switch.early.test, %switch.early.test, %switch.early.test, %switch.early.test, %switch.early.test, %switch.early.test, %switch.early.test, %switch.early.test, %switch.early.test, %switch.early.test, %switch.early.test, %switch.early.test, %17
  %20 = getelementptr inbounds i8, ptr %0, i64 20
  %21 = load i32, ptr %20, align 4, !tbaa !5
  %22 = tail call i32 @convert(i32 noundef %21, i8 noundef signext %8)
  store i32 %22, ptr %20, align 4, !tbaa !5
  br label %24

23:                                               ; preds = %switch.early.test
  tail call void @_ZN26InitialInteractiveLoaderSM5debugEv(ptr noundef nonnull align 8 dereferenceable(68) %0)
  br label %24

24:                                               ; preds = %19, %23, %13, %9
  %25 = getelementptr inbounds i8, ptr %0, i64 16
  %26 = load i32, ptr %25, align 8, !tbaa !12
  %27 = icmp sgt i32 %26, 2
  br i1 %27, label %28, label %35

28:                                               ; preds = %24
  tail call void @sendString(ptr noundef nonnull @.str.1)
  %29 = getelementptr inbounds i8, ptr %0, i64 20
  %30 = load i32, ptr %29, align 4, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %0, i64 36
  store i32 %30, ptr %31, align 4, !tbaa !14
  tail call void @_ZN4EfsmIcE4tranEMS0_Fi5PhasePcE(ptr noundef nonnull align 8 dereferenceable(16) %0, i64 ptrtoint (ptr @_ZN26InitialInteractiveLoaderSM7initialE5PhasePc to i64), i64 0)
  br label %35

32:                                               ; preds = %3
  tail call void @disable_irq()
  %33 = getelementptr inbounds i8, ptr %0, i64 36
  %34 = load i32, ptr %33, align 4, !tbaa !14
  tail call void @GOTO(i32 noundef %34)
  br label %35

35:                                               ; preds = %24, %28, %32, %4, %3
  ret i32 0
}

declare i32 @convert(i32 noundef, i8 noundef signext) local_unnamed_addr #2

declare void @disable_irq() local_unnamed_addr #2

declare void @GOTO(i32 noundef) local_unnamed_addr #2

attributes #0 = { mustprogress 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 = { mustprogress 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 = { "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, !10, i64 20}
!6 = !{!"_ZTS26InitialInteractiveLoaderSM", !7, i64 0, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !11, i64 48, !10, i64 56, !10, i64 60, !10, i64 64}
!7 = !{!"_ZTS4EfsmIcE", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!6, !10, i64 16}
!13 = !{!8, !8, i64 0}
!14 = !{!6, !10, i64 36}


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