; LLVM IR from xing1357/SimpleOS :: src (mouse)

; 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.MOUSE_STATUS = type { i8 }

@g_mouse_x_pos = external dso_local global i32, align 4
@g_mouse_y_pos = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [25 x i8], align 1
@g_status = external dso_local global %struct.MOUSE_STATUS, align 1
@.str.1 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [22 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @print_mouse_info() #0 {
  call void @console_gotoxy(i16 noundef zeroext 0, i16 noundef zeroext 0)
  %1 = load i32, ptr @g_mouse_x_pos, align 4, !tbaa !5
  %2 = load i32, ptr @g_mouse_y_pos, align 4, !tbaa !5
  call void (ptr, ...) @printf(ptr noundef @.str, i32 noundef %1, i32 noundef %2)
  %3 = load i8, ptr @g_status, align 1
  %4 = and i8 %3, 1
  %5 = icmp ne i8 %4, 0
  br i1 %5, label %6, label %7

6:                                                ; preds = %0
  call void (ptr, ...) @printf(ptr noundef @.str.1)
  br label %7

7:                                                ; preds = %6, %0
  %8 = load i8, ptr @g_status, align 1
  %9 = lshr i8 %8, 1
  %10 = and i8 %9, 1
  %11 = icmp ne i8 %10, 0
  br i1 %11, label %12, label %13

12:                                               ; preds = %7
  call void (ptr, ...) @printf(ptr noundef @.str.2)
  br label %13

13:                                               ; preds = %12, %7
  %14 = load i8, ptr @g_status, align 1
  %15 = lshr i8 %14, 2
  %16 = and i8 %15, 1
  %17 = icmp ne i8 %16, 0
  br i1 %17, label %18, label %19

18:                                               ; preds = %13
  call void (ptr, ...) @printf(ptr noundef @.str.3)
  br label %19

19:                                               ; preds = %18, %13
  ret void
}

declare void @console_gotoxy(i16 noundef zeroext, i16 noundef zeroext) #1

declare void @printf(ptr noundef, ...) #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 = { "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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; 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.MOUSE_STATUS = type { i8 }

@g_mouse_x_pos = external dso_local local_unnamed_addr global i32, align 4
@g_mouse_y_pos = external dso_local local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [25 x i8], align 1
@g_status = external dso_local local_unnamed_addr global %struct.MOUSE_STATUS, align 1
@.str.1 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [22 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @print_mouse_info() local_unnamed_addr #0 {
  tail call void @console_gotoxy(i16 noundef zeroext 0, i16 noundef zeroext 0) #2
  %1 = load i32, ptr @g_mouse_x_pos, align 4, !tbaa !5
  %2 = load i32, ptr @g_mouse_y_pos, align 4, !tbaa !5
  tail call void (ptr, ...) @printf(ptr noundef nonnull @.str, i32 noundef %1, i32 noundef %2) #2
  %3 = load i8, ptr @g_status, align 1
  %4 = and i8 %3, 1
  %.not = icmp eq i8 %4, 0
  br i1 %.not, label %6, label %5

5:                                                ; preds = %0
  tail call void (ptr, ...) @printf(ptr noundef nonnull @.str.1) #2
  %.pre = load i8, ptr @g_status, align 1
  br label %6

6:                                                ; preds = %5, %0
  %7 = phi i8 [ %.pre, %5 ], [ %3, %0 ]
  %8 = and i8 %7, 2
  %.not1 = icmp eq i8 %8, 0
  br i1 %.not1, label %10, label %9

9:                                                ; preds = %6
  tail call void (ptr, ...) @printf(ptr noundef nonnull @.str.2) #2
  %.pre3 = load i8, ptr @g_status, align 1
  br label %10

10:                                               ; preds = %9, %6
  %11 = phi i8 [ %.pre3, %9 ], [ %7, %6 ]
  %12 = and i8 %11, 4
  %.not2 = icmp eq i8 %12, 0
  br i1 %.not2, label %14, label %13

13:                                               ; preds = %10
  tail call void (ptr, ...) @printf(ptr noundef nonnull @.str.3) #2
  br label %14

14:                                               ; preds = %13, %10
  ret void
}

declare void @console_gotoxy(i16 noundef zeroext, i16 noundef zeroext) local_unnamed_addr #1

declare void @printf(ptr noundef, ...) local_unnamed_addr #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 = { "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 }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: GVNPass,GlobalOptPass,InstCombinePass,TailCallElimPass