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

@label_fmt = external hidden global i32, align 4
@labels = external hidden global i32, align 4
@slk = external hidden global ptr, align 8
@SP = external global ptr, align 8
@hidden = external hidden global i8, align 1
@label_line = external hidden global i32, align 4
@label_length = external hidden global i32, align 4

; Function Attrs: nounwind
declare void @free(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local void @PDC_slk_free() #1 {
  %1 = load ptr, ptr @slk, align 8, !tbaa !5
  %2 = icmp ne ptr %1, null
  br i1 %2, label %3, label %17

3:                                                ; preds = %0
  %4 = load ptr, ptr @SP, align 8, !tbaa !5
  %5 = getelementptr inbounds %struct.SCREEN, ptr %4, i32 0, i32 21
  %6 = load ptr, ptr %5, align 8, !tbaa !9
  %7 = icmp ne ptr %6, null
  br i1 %7, label %8, label %15

8:                                                ; preds = %3
  %9 = load ptr, ptr @SP, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.SCREEN, ptr %9, i32 0, i32 21
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  %12 = call i32 @delwin(ptr noundef %11)
  %13 = load ptr, ptr @SP, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.SCREEN, ptr %13, i32 0, i32 21
  store ptr null, ptr %14, align 8, !tbaa !9
  br label %15

15:                                               ; preds = %8, %3
  %16 = load ptr, ptr @slk, align 8, !tbaa !5
  call void @free(ptr noundef %16) #3
  store ptr null, ptr @slk, align 8, !tbaa !5
  store i32 0, ptr @label_length, align 4, !tbaa !16
  store i32 0, ptr @labels, align 4, !tbaa !16
  store i32 0, ptr @label_fmt, align 4, !tbaa !16
  store i32 0, ptr @label_line, align 4, !tbaa !16
  store i8 0, ptr @hidden, align 1, !tbaa !17
  br label %17

17:                                               ; preds = %15, %0
  ret void
}

declare i32 @delwin(ptr noundef) #2

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

@label_fmt = external hidden local_unnamed_addr global i32, align 4
@labels = external hidden local_unnamed_addr global i32, align 4
@slk = external hidden local_unnamed_addr global ptr, align 8
@SP = external local_unnamed_addr global ptr, align 8
@hidden = external hidden local_unnamed_addr global i8, align 1
@label_line = external hidden local_unnamed_addr global i32, align 4
@label_length = external hidden local_unnamed_addr global i32, align 4

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @PDC_slk_free() local_unnamed_addr #1 {
  %1 = load ptr, ptr @slk, align 8, !tbaa !5
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %12, label %2

2:                                                ; preds = %0
  %3 = load ptr, ptr @SP, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %3, i64 56
  %5 = load ptr, ptr %4, align 8, !tbaa !9
  %.not1 = icmp eq ptr %5, null
  br i1 %.not1, label %10, label %6

6:                                                ; preds = %2
  %7 = tail call i32 @delwin(ptr noundef nonnull %5) #3
  %8 = load ptr, ptr @SP, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %8, i64 56
  store ptr null, ptr %9, align 8, !tbaa !9
  %.pre = load ptr, ptr @slk, align 8, !tbaa !5
  br label %10

10:                                               ; preds = %6, %2
  %11 = phi ptr [ %.pre, %6 ], [ %1, %2 ]
  tail call void @free(ptr noundef %11) #3
  store ptr null, ptr @slk, align 8, !tbaa !5
  store i32 0, ptr @label_length, align 4, !tbaa !16
  store i32 0, ptr @labels, align 4, !tbaa !16
  store i32 0, ptr @label_fmt, align 4, !tbaa !16
  store i32 0, ptr @label_line, align 4, !tbaa !16
  store i8 0, ptr @hidden, align 1, !tbaa !17
  br label %12

12:                                               ; preds = %10, %0
  ret void
}

declare i32 @delwin(ptr noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { 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, !6, i64 56}
!10 = !{!"", !11, i64 0, !11, i64 1, !11, i64 2, !11, i64 3, !11, i64 4, !11, i64 5, !11, i64 6, !11, i64 7, !11, i64 8, !11, i64 9, !12, i64 10, !12, i64 12, !13, i64 16, !13, i64 20, !13, i64 24, !13, i64 28, !13, i64 32, !13, i64 36, !14, i64 40, !13, i64 48, !13, i64 52, !6, i64 56, !13, i64 64, !13, i64 68, !13, i64 72, !11, i64 76, !13, i64 80, !14, i64 88, !11, i64 96, !11, i64 97, !15, i64 100, !12, i64 132, !14, i64 136, !6, i64 144, !6, i64 152, !11, i64 160, !11, i64 161, !13, i64 164, !13, i64 168, !6, i64 176, !13, i64 184, !13, i64 188, !6, i64 192, !13, i64 200, !13, i64 204, !6, i64 208}
!11 = !{!"_Bool", !7, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!"", !13, i64 0, !13, i64 4, !7, i64 8, !13, i64 28}
!16 = !{!13, !13, i64 0}
!17 = !{!11, !11, i64 0}


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