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

; 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 }
%struct._opaque_screen_t = type { ptr, i32, i32, i8, ptr, i32, i32, i32, ptr, i32, i8, ptr, ptr }

@SP = external global ptr, align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [91 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [18 x i8], align 1
@__PRETTY_FUNCTION__.PDC_free_atrtab = external hidden unnamed_addr constant [27 x 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 void @PDC_free_atrtab() #1 {
  %1 = load ptr, ptr @SP, align 8, !tbaa !5
  %2 = icmp ne ptr %1, null
  br i1 %2, label %3, label %4

3:                                                ; preds = %0
  br label %5

4:                                                ; preds = %0
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 574, ptr noundef @__PRETTY_FUNCTION__.PDC_free_atrtab) #3
  unreachable

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

10:                                               ; preds = %5
  br label %12

11:                                               ; preds = %5
  call void @__assert_fail(ptr noundef @.str.6, ptr noundef @.str.1, i32 noundef 575, ptr noundef @__PRETTY_FUNCTION__.PDC_free_atrtab) #3
  unreachable

12:                                               ; preds = %10
  %13 = load ptr, ptr @SP, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.SCREEN, ptr %13, i32 0, i32 45
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  %16 = getelementptr inbounds %struct._opaque_screen_t, ptr %15, i32 0, i32 0
  %17 = load ptr, ptr %16, align 8, !tbaa !16
  %18 = icmp ne ptr %17, null
  br i1 %18, label %19, label %20

19:                                               ; preds = %12
  br label %21

20:                                               ; preds = %12
  call void @__assert_fail(ptr noundef @.str.7, ptr noundef @.str.1, i32 noundef 576, ptr noundef @__PRETTY_FUNCTION__.PDC_free_atrtab) #3
  unreachable

21:                                               ; preds = %19
  %22 = load ptr, ptr @SP, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.SCREEN, ptr %22, i32 0, i32 45
  %24 = load ptr, ptr %23, align 8, !tbaa !9
  %25 = getelementptr inbounds %struct._opaque_screen_t, ptr %24, i32 0, i32 4
  %26 = load ptr, ptr %25, align 8, !tbaa !18
  %27 = icmp ne ptr %26, null
  br i1 %27, label %28, label %34

28:                                               ; preds = %21
  %29 = load ptr, ptr @SP, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.SCREEN, ptr %29, i32 0, i32 45
  %31 = load ptr, ptr %30, align 8, !tbaa !9
  %32 = getelementptr inbounds %struct._opaque_screen_t, ptr %31, i32 0, i32 4
  %33 = load ptr, ptr %32, align 8, !tbaa !18
  call void @free(ptr noundef %33) #4
  br label %34

34:                                               ; preds = %28, %21
  %35 = load ptr, ptr @SP, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.SCREEN, ptr %35, i32 0, i32 45
  %37 = load ptr, ptr %36, align 8, !tbaa !9
  %38 = getelementptr inbounds %struct._opaque_screen_t, ptr %37, i32 0, i32 4
  store ptr null, ptr %38, align 8, !tbaa !18
  %39 = load ptr, ptr @SP, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.SCREEN, ptr %39, i32 0, i32 45
  %41 = load ptr, ptr %40, align 8, !tbaa !9
  %42 = getelementptr inbounds %struct._opaque_screen_t, ptr %41, i32 0, i32 6
  store i32 0, ptr %42, align 4, !tbaa !19
  %43 = load ptr, ptr @SP, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.SCREEN, ptr %43, i32 0, i32 45
  %45 = load ptr, ptr %44, align 8, !tbaa !9
  %46 = getelementptr inbounds %struct._opaque_screen_t, ptr %45, i32 0, i32 5
  store i32 0, ptr %46, align 8, !tbaa !20
  %47 = load ptr, ptr @SP, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.SCREEN, ptr %47, i32 0, i32 45
  %49 = load ptr, ptr %48, align 8, !tbaa !9
  %50 = getelementptr inbounds %struct._opaque_screen_t, ptr %49, i32 0, i32 0
  %51 = load ptr, ptr %50, align 8, !tbaa !16
  %52 = icmp ne ptr %51, null
  br i1 %52, label %53, label %59

53:                                               ; preds = %34
  %54 = load ptr, ptr @SP, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.SCREEN, ptr %54, i32 0, i32 45
  %56 = load ptr, ptr %55, align 8, !tbaa !9
  %57 = getelementptr inbounds %struct._opaque_screen_t, ptr %56, i32 0, i32 0
  %58 = load ptr, ptr %57, align 8, !tbaa !16
  call void @free(ptr noundef %58) #4
  br label %59

59:                                               ; preds = %53, %34
  %60 = load ptr, ptr @SP, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.SCREEN, ptr %60, i32 0, i32 45
  %62 = load ptr, ptr %61, align 8, !tbaa !9
  call void @free(ptr noundef %62) #4
  %63 = load ptr, ptr @SP, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.SCREEN, ptr %63, i32 0, i32 45
  store ptr null, ptr %64, align 8, !tbaa !9
  ret void
}

; Function Attrs: nounwind
declare void @free(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 = { 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 #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, !6, i64 208}
!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 = !{!17, !6, i64 0}
!17 = !{!"_opaque_screen_t", !6, i64 0, !13, i64 8, !13, i64 12, !11, i64 16, !6, i64 24, !13, i64 32, !13, i64 36, !13, i64 40, !6, i64 48, !13, i64 56, !11, i64 60, !6, i64 64, !6, i64 72}
!18 = !{!17, !6, i64 24}
!19 = !{!17, !13, i64 36}
!20 = !{!17, !13, i64 32}


; 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 [91 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [18 x i8], align 1
@__PRETTY_FUNCTION__.PDC_free_atrtab = external hidden unnamed_addr constant [27 x 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 void @PDC_free_atrtab() 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 574, ptr noundef nonnull @__PRETTY_FUNCTION__.PDC_free_atrtab) #4
  unreachable

3:                                                ; preds = %0
  %4 = getelementptr inbounds i8, ptr %1, i64 208
  %5 = load ptr, ptr %4, align 8, !tbaa !9
  %.not4 = icmp eq ptr %5, null
  br i1 %.not4, label %6, label %7

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

7:                                                ; preds = %3
  %8 = load ptr, ptr %5, align 8, !tbaa !16
  %.not5 = icmp eq ptr %8, null
  br i1 %.not5, label %9, label %10

9:                                                ; preds = %7
  tail call void @__assert_fail(ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.1, i32 noundef 576, ptr noundef nonnull @__PRETTY_FUNCTION__.PDC_free_atrtab) #4
  unreachable

10:                                               ; preds = %7
  %11 = getelementptr inbounds i8, ptr %5, i64 24
  %12 = load ptr, ptr %11, align 8, !tbaa !18
  %.not6 = icmp eq ptr %12, null
  br i1 %.not6, label %.thread, label %14

.thread:                                          ; preds = %10
  %13 = getelementptr inbounds i8, ptr %5, i64 24
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %13, i8 0, i64 16, i1 false)
  br label %16

14:                                               ; preds = %10
  tail call void @free(ptr noundef nonnull %12) #5
  %.pre = load ptr, ptr @SP, align 8, !tbaa !5
  %.phi.trans.insert = getelementptr inbounds i8, ptr %.pre, i64 208
  %.pre8 = load ptr, ptr %.phi.trans.insert, align 8, !tbaa !9
  %.pre9 = load ptr, ptr %.pre8, align 8, !tbaa !16
  %15 = getelementptr inbounds i8, ptr %.pre8, i64 24
  %.not7 = icmp eq ptr %.pre9, null
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %15, i8 0, i64 16, i1 false)
  br i1 %.not7, label %18, label %16

16:                                               ; preds = %.thread, %14
  %17 = phi ptr [ %8, %.thread ], [ %.pre9, %14 ]
  tail call void @free(ptr noundef nonnull %17) #5
  %.pre10 = load ptr, ptr @SP, align 8, !tbaa !5
  %.phi.trans.insert11 = getelementptr inbounds i8, ptr %.pre10, i64 208
  %.pre12 = load ptr, ptr %.phi.trans.insert11, align 8, !tbaa !9
  br label %18

18:                                               ; preds = %16, %14
  %19 = phi ptr [ %.pre12, %16 ], [ %.pre8, %14 ]
  tail call void @free(ptr noundef %19) #5
  %20 = load ptr, ptr @SP, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %20, i64 208
  store ptr null, ptr %21, align 8, !tbaa !9
  ret void
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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 = { 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { noreturn nounwind }
attributes #5 = { 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 208}
!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 = !{!17, !6, i64 0}
!17 = !{!"_opaque_screen_t", !6, i64 0, !13, i64 8, !13, i64 12, !11, i64 16, !6, i64 24, !13, i64 32, !13, i64 36, !13, i64 40, !6, i64 48, !13, i64 56, !11, i64 60, !6, i64 64, !6, i64 72}
!18 = !{!17, !6, i64 24}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,MemCpyOptPass,SimplifyCFGPass,TailCallElimPass