; LLVM IR from clangen/musikcube :: src/3rdparty/win32_src/pdcurses (move)

; 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.SCREEN = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i16, i16, i32, i32, i32, i32, i32, i32, i64, i32, i32, ptr, i32, i32, i32, i8, i32, i64, i8, i8, %struct.MOUSE_STATUS, i16, i64, ptr, ptr, i8, i8, i32, i32, ptr, i32, i32, ptr, i32, i32, ptr }
%struct.MOUSE_STATUS = type { i32, i32, [9 x i16], i32 }

@.str.1 = external hidden unnamed_addr constant [90 x i8], align 1
@SP = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@__PRETTY_FUNCTION__.mvcur = external hidden unnamed_addr constant [30 x i8], align 1
@LINES = external global i32, align 4
@COLS = external global i32, align 4

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @mvcur(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) #1 {
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store i32 %0, ptr %6, align 4, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !5
  %10 = load ptr, ptr @SP, align 8, !tbaa !9
  %11 = icmp ne ptr %10, null
  br i1 %11, label %12, label %13

12:                                               ; preds = %4
  br label %14

13:                                               ; preds = %4
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 58, ptr noundef @__PRETTY_FUNCTION__.mvcur) #3
  unreachable

14:                                               ; preds = %12
  %15 = load i32, ptr %6, align 4, !tbaa !5
  %16 = load i32, ptr %7, align 4, !tbaa !5
  %17 = load ptr, ptr @SP, align 8, !tbaa !9
  %18 = icmp ne ptr %17, null
  br i1 %18, label %19, label %33

19:                                               ; preds = %14
  %20 = load i32, ptr %8, align 4, !tbaa !5
  %21 = icmp slt i32 %20, 0
  br i1 %21, label %33, label %22

22:                                               ; preds = %19
  %23 = load i32, ptr %8, align 4, !tbaa !5
  %24 = load i32, ptr @LINES, align 4, !tbaa !5
  %25 = icmp sge i32 %23, %24
  br i1 %25, label %33, label %26

26:                                               ; preds = %22
  %27 = load i32, ptr %9, align 4, !tbaa !5
  %28 = icmp slt i32 %27, 0
  br i1 %28, label %33, label %29

29:                                               ; preds = %26
  %30 = load i32, ptr %9, align 4, !tbaa !5
  %31 = load i32, ptr @COLS, align 4, !tbaa !5
  %32 = icmp sge i32 %30, %31
  br i1 %32, label %33, label %34

33:                                               ; preds = %29, %26, %22, %19, %14
  store i32 -1, ptr %5, align 4
  br label %43

34:                                               ; preds = %29
  %35 = load i32, ptr %8, align 4, !tbaa !5
  %36 = load i32, ptr %9, align 4, !tbaa !5
  call void @PDC_gotoyx(i32 noundef %35, i32 noundef %36)
  %37 = load i32, ptr %8, align 4, !tbaa !5
  %38 = load ptr, ptr @SP, align 8, !tbaa !9
  %39 = getelementptr inbounds %struct.SCREEN, ptr %38, i32 0, i32 12
  store i32 %37, ptr %39, align 8, !tbaa !11
  %40 = load i32, ptr %9, align 4, !tbaa !5
  %41 = load ptr, ptr @SP, align 8, !tbaa !9
  %42 = getelementptr inbounds %struct.SCREEN, ptr %41, i32 0, i32 13
  store i32 %40, ptr %42, align 4, !tbaa !17
  store i32 0, ptr %5, align 4
  br label %43

43:                                               ; preds = %34, %33
  %44 = load i32, ptr %5, align 4
  ret i32 %44
}

declare void @PDC_gotoyx(i32 noundef, i32 noundef) #2

attributes #0 = { noreturn nounwind "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 = { 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" }
attributes #3 = { noreturn 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"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 16}
!12 = !{!"", !13, i64 0, !13, i64 1, !13, i64 2, !13, i64 3, !13, i64 4, !13, i64 5, !13, i64 6, !13, i64 7, !13, i64 8, !13, i64 9, !14, i64 10, !14, i64 12, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36, !15, i64 40, !6, i64 48, !6, i64 52, !10, i64 56, !6, i64 64, !6, i64 68, !6, i64 72, !13, i64 76, !6, i64 80, !15, i64 88, !13, i64 96, !13, i64 97, !16, i64 100, !14, i64 132, !15, i64 136, !10, i64 144, !10, i64 152, !13, i64 160, !13, i64 161, !6, i64 164, !6, i64 168, !10, i64 176, !6, i64 184, !6, i64 188, !10, i64 192, !6, i64 200, !6, i64 204, !10, i64 208}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{!"", !6, i64 0, !6, i64 4, !7, i64 8, !6, i64 28}
!17 = !{!12, !6, i64 20}


; 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 [90 x i8], align 1
@SP = external local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@__PRETTY_FUNCTION__.mvcur = external hidden unnamed_addr constant [30 x i8], align 1
@LINES = external local_unnamed_addr global i32, align 4
@COLS = external local_unnamed_addr global i32, align 4

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @mvcur(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #1 {
  %5 = load ptr, ptr @SP, align 8, !tbaa !5
  %.not = icmp eq ptr %5, null
  br i1 %.not, label %6, label %7

6:                                                ; preds = %4
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 58, ptr noundef nonnull @__PRETTY_FUNCTION__.mvcur) #3
  unreachable

7:                                                ; preds = %4
  %8 = icmp slt i32 %2, 0
  br i1 %8, label %18, label %9

9:                                                ; preds = %7
  %10 = load i32, ptr @LINES, align 4, !tbaa !9
  %11 = icmp sgt i32 %10, %2
  %12 = icmp sgt i32 %3, -1
  %or.cond3.not19 = and i1 %12, %11
  %13 = load i32, ptr @COLS, align 4
  %.not16 = icmp sgt i32 %13, %3
  %or.cond = select i1 %or.cond3.not19, i1 %.not16, i1 false
  br i1 %or.cond, label %14, label %18

14:                                               ; preds = %9
  tail call void @PDC_gotoyx(i32 noundef %2, i32 noundef %3) #4
  %15 = load ptr, ptr @SP, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %15, i64 16
  store i32 %2, ptr %16, align 8, !tbaa !11
  %17 = getelementptr inbounds i8, ptr %15, i64 20
  store i32 %3, ptr %17, align 4, !tbaa !17
  br label %18

18:                                               ; preds = %7, %9, %14
  %.0 = phi i32 [ 0, %14 ], [ -1, %9 ], [ -1, %7 ]
  ret i32 %.0
}

declare void @PDC_gotoyx(i32 noundef, i32 noundef) local_unnamed_addr #2

attributes #0 = { noreturn nounwind "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 = { 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" }
attributes #3 = { noreturn nounwind }
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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 16}
!12 = !{!"", !13, i64 0, !13, i64 1, !13, i64 2, !13, i64 3, !13, i64 4, !13, i64 5, !13, i64 6, !13, i64 7, !13, i64 8, !13, i64 9, !14, i64 10, !14, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !15, i64 40, !10, i64 48, !10, i64 52, !6, i64 56, !10, i64 64, !10, i64 68, !10, i64 72, !13, i64 76, !10, i64 80, !15, i64 88, !13, i64 96, !13, i64 97, !16, i64 100, !14, i64 132, !15, i64 136, !6, i64 144, !6, i64 152, !13, i64 160, !13, i64 161, !10, i64 164, !10, i64 168, !6, i64 176, !10, i64 184, !10, i64 188, !6, i64 192, !10, i64 200, !10, i64 204, !6, i64 208}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{!"", !10, i64 0, !10, i64 4, !7, i64 8, !10, i64 28}
!17 = !{!12, !10, i64 20}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass