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

; 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 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [92 x i8], align 1
@LINES = external global i32, align 4
@COLS = external global i32, align 4
@SP = external global ptr, align 8
@__PRETTY_FUNCTION__.newwin = external hidden unnamed_addr constant [35 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local ptr @PDC_makenew(i32 noundef, i32 noundef, i32 noundef, i32 noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @PDC_makelines(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @PDC_add_window_to_list(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local ptr @newwin(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = 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
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %12 = load i32, ptr %6, align 4, !tbaa !5
  %13 = icmp ne i32 %12, 0
  br i1 %13, label %18, label %14

14:                                               ; preds = %4
  %15 = load i32, ptr @LINES, align 4, !tbaa !5
  %16 = load i32, ptr %8, align 4, !tbaa !5
  %17 = sub nsw i32 %15, %16
  store i32 %17, ptr %6, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %14, %4
  %19 = load i32, ptr %7, align 4, !tbaa !5
  %20 = icmp ne i32 %19, 0
  br i1 %20, label %25, label %21

21:                                               ; preds = %18
  %22 = load i32, ptr @COLS, align 4, !tbaa !5
  %23 = load i32, ptr %9, align 4, !tbaa !5
  %24 = sub nsw i32 %22, %23
  store i32 %24, ptr %7, align 4, !tbaa !5
  br label %25

25:                                               ; preds = %21, %18
  %26 = load i32, ptr %6, align 4, !tbaa !5
  %27 = icmp sgt i32 %26, 0
  br i1 %27, label %28, label %32

28:                                               ; preds = %25
  %29 = load i32, ptr %7, align 4, !tbaa !5
  %30 = icmp sgt i32 %29, 0
  br i1 %30, label %31, label %32

31:                                               ; preds = %28
  br label %33

32:                                               ; preds = %28, %25
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 261, ptr noundef @__PRETTY_FUNCTION__.newwin) #5
  unreachable

33:                                               ; preds = %31
  %34 = load i32, ptr %6, align 4, !tbaa !5
  %35 = icmp sle i32 %34, 0
  br i1 %35, label %39, label %36

36:                                               ; preds = %33
  %37 = load i32, ptr %7, align 4, !tbaa !5
  %38 = icmp sle i32 %37, 0
  br i1 %38, label %39, label %40

39:                                               ; preds = %36, %33
  store ptr null, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %85

40:                                               ; preds = %36
  %41 = load ptr, ptr @SP, align 8, !tbaa !9
  %42 = icmp ne ptr %41, null
  br i1 %42, label %43, label %44

43:                                               ; preds = %40
  br label %45

44:                                               ; preds = %40
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 265, ptr noundef @__PRETTY_FUNCTION__.newwin) #5
  unreachable

45:                                               ; preds = %43
  %46 = load ptr, ptr @SP, align 8, !tbaa !9
  %47 = icmp ne ptr %46, null
  br i1 %47, label %48, label %64

48:                                               ; preds = %45
  %49 = load i32, ptr %8, align 4, !tbaa !5
  %50 = load i32, ptr %6, align 4, !tbaa !5
  %51 = add nsw i32 %49, %50
  %52 = load ptr, ptr @SP, align 8, !tbaa !9
  %53 = getelementptr inbounds %struct.SCREEN, ptr %52, i32 0, i32 16
  %54 = load i32, ptr %53, align 8, !tbaa !11
  %55 = icmp sgt i32 %51, %54
  br i1 %55, label %64, label %56

56:                                               ; preds = %48
  %57 = load i32, ptr %9, align 4, !tbaa !5
  %58 = load i32, ptr %7, align 4, !tbaa !5
  %59 = add nsw i32 %57, %58
  %60 = load ptr, ptr @SP, align 8, !tbaa !9
  %61 = getelementptr inbounds %struct.SCREEN, ptr %60, i32 0, i32 17
  %62 = load i32, ptr %61, align 4, !tbaa !17
  %63 = icmp sgt i32 %59, %62
  br i1 %63, label %64, label %65

64:                                               ; preds = %56, %48, %45
  store ptr null, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %85

65:                                               ; preds = %56
  %66 = load i32, ptr %6, align 4, !tbaa !5
  %67 = load i32, ptr %7, align 4, !tbaa !5
  %68 = load i32, ptr %8, align 4, !tbaa !5
  %69 = load i32, ptr %9, align 4, !tbaa !5
  %70 = call ptr @PDC_makenew(i32 noundef %66, i32 noundef %67, i32 noundef %68, i32 noundef %69)
  store ptr %70, ptr %10, align 8, !tbaa !9
  %71 = load ptr, ptr %10, align 8, !tbaa !9
  %72 = icmp ne ptr %71, null
  br i1 %72, label %73, label %76

73:                                               ; preds = %65
  %74 = load ptr, ptr %10, align 8, !tbaa !9
  %75 = call ptr @PDC_makelines(ptr noundef %74)
  store ptr %75, ptr %10, align 8, !tbaa !9
  br label %76

76:                                               ; preds = %73, %65
  %77 = load ptr, ptr %10, align 8, !tbaa !9
  %78 = icmp ne ptr %77, null
  br i1 %78, label %79, label %83

79:                                               ; preds = %76
  %80 = load ptr, ptr %10, align 8, !tbaa !9
  %81 = call i32 @werase(ptr noundef %80)
  %82 = load ptr, ptr %10, align 8, !tbaa !9
  call void @PDC_add_window_to_list(ptr noundef %82)
  br label %83

83:                                               ; preds = %79, %76
  %84 = load ptr, ptr %10, align 8, !tbaa !9
  store ptr %84, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %85

85:                                               ; preds = %83, %64, %39
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  %86 = load ptr, ptr %5, align 8
  ret ptr %86
}

declare i32 @werase(ptr noundef) #3

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { "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 #4 = { nounwind }
attributes #5 = { 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 32}
!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 36}


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

; Function Attrs: nounwind uwtable
declare dso_local ptr @PDC_makenew(i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @PDC_makelines(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @PDC_add_window_to_list(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local ptr @newwin(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %.not = icmp eq i32 %0, 0
  %5 = load i32, ptr @LINES, align 4
  %6 = sub nsw i32 %5, %2
  %.026 = select i1 %.not, i32 %6, i32 %0
  %.not32 = icmp eq i32 %1, 0
  %7 = load i32, ptr @COLS, align 4
  %8 = sub nsw i32 %7, %3
  %.027 = select i1 %.not32, i32 %8, i32 %1
  %9 = icmp sgt i32 %.026, 0
  %10 = icmp sgt i32 %.027, 0
  %or.cond = select i1 %9, i1 %10, i1 false
  br i1 %or.cond, label %12, label %11

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

12:                                               ; preds = %4
  %13 = load ptr, ptr @SP, align 8, !tbaa !5
  %.not33 = icmp eq ptr %13, null
  br i1 %.not33, label %14, label %15

14:                                               ; preds = %12
  tail call void @__assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 265, ptr noundef nonnull @__PRETTY_FUNCTION__.newwin) #3
  unreachable

15:                                               ; preds = %12
  %16 = add nsw i32 %.026, %2
  %17 = getelementptr inbounds i8, ptr %13, i64 32
  %18 = load i32, ptr %17, align 8, !tbaa !9
  %19 = icmp sgt i32 %16, %18
  br i1 %19, label %.thread, label %20

20:                                               ; preds = %15
  %21 = add nsw i32 %.027, %3
  %22 = getelementptr inbounds i8, ptr %13, i64 36
  %23 = load i32, ptr %22, align 4, !tbaa !16
  %24 = icmp sgt i32 %21, %23
  br i1 %24, label %.thread, label %25

25:                                               ; preds = %20
  %26 = tail call ptr @PDC_makenew(i32 noundef %.026, i32 noundef %.027, i32 noundef %2, i32 noundef %3)
  %.not34 = icmp eq ptr %26, null
  br i1 %.not34, label %.thread, label %27

27:                                               ; preds = %25
  %28 = tail call ptr @PDC_makelines(ptr noundef nonnull %26)
  %.not35 = icmp eq ptr %28, null
  br i1 %.not35, label %.thread, label %29

29:                                               ; preds = %27
  %30 = tail call i32 @werase(ptr noundef nonnull %28) #4
  tail call void @PDC_add_window_to_list(ptr noundef nonnull %28)
  br label %.thread

.thread:                                          ; preds = %25, %27, %29, %15, %20
  %.025 = phi ptr [ null, %20 ], [ null, %15 ], [ %28, %29 ], [ null, %27 ], [ null, %25 ]
  ret ptr %.025
}

declare i32 @werase(ptr noundef) local_unnamed_addr #2

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 = { 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 #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, !13, i64 32}
!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 = !{!10, !13, i64 36}


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