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

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

@SP = external global ptr, align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [89 x i8], align 1
@__PRETTY_FUNCTION__.slk_clear = external hidden unnamed_addr constant [20 x i8], align 1
@hidden = external hidden global i8, align 1

; 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 @slk_clear() #1 {
  %1 = alloca i32, align 4
  %2 = load ptr, ptr @SP, align 8, !tbaa !5
  %3 = icmp ne ptr %2, null
  br i1 %3, label %4, label %5

4:                                                ; preds = %0
  br label %6

5:                                                ; preds = %0
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 344, ptr noundef @__PRETTY_FUNCTION__.slk_clear) #3
  unreachable

6:                                                ; preds = %4
  %7 = load ptr, ptr @SP, align 8, !tbaa !5
  %8 = icmp ne ptr %7, null
  br i1 %8, label %10, label %9

9:                                                ; preds = %6
  store i32 -1, ptr %1, align 4
  br label %19

10:                                               ; preds = %6
  store i8 1, ptr @hidden, align 1, !tbaa !9
  %11 = load ptr, ptr @SP, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.SCREEN, ptr %11, i32 0, i32 21
  %13 = load ptr, ptr %12, align 8, !tbaa !11
  %14 = call i32 @werase(ptr noundef %13)
  %15 = load ptr, ptr @SP, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.SCREEN, ptr %15, i32 0, i32 21
  %17 = load ptr, ptr %16, align 8, !tbaa !11
  %18 = call i32 @wrefresh(ptr noundef %17)
  store i32 %18, ptr %1, align 4
  br label %19

19:                                               ; preds = %10, %9
  %20 = load i32, ptr %1, align 4
  ret i32 %20
}

declare i32 @werase(ptr noundef) #2

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


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

@SP = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [89 x i8], align 1
@__PRETTY_FUNCTION__.slk_clear = external hidden unnamed_addr constant [20 x i8], align 1
@hidden = external hidden local_unnamed_addr global i8, align 1

; 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 i32 @slk_clear() local_unnamed_addr #1 {
  %1 = load ptr, ptr @SP, align 8, !tbaa !5
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %2, label %3

2:                                                ; preds = %0
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 344, ptr noundef nonnull @__PRETTY_FUNCTION__.slk_clear) #3
  unreachable

3:                                                ; preds = %0
  store i8 1, ptr @hidden, align 1, !tbaa !9
  %4 = getelementptr inbounds i8, ptr %1, i64 56
  %5 = load ptr, ptr %4, align 8, !tbaa !11
  %6 = tail call i32 @werase(ptr noundef %5) #4
  %7 = load ptr, ptr @SP, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %7, i64 56
  %9 = load ptr, ptr %8, align 8, !tbaa !11
  %10 = tail call i32 @wrefresh(ptr noundef %9) #4
  ret i32 %10
}

declare i32 @werase(ptr noundef) local_unnamed_addr #2

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


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