; 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._win = type { i32, i32, i32, i32, i32, i32, i32, i64, i64, i8, i8, i8, i8, i8, i8, i8, ptr, ptr, ptr, i32, i32, i32, i32, i32, ptr, i32, i32, i32, i32, i32, i32 }

@.str = external hidden unnamed_addr constant [24 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [92 x i8], align 1
@__PRETTY_FUNCTION__.PDC_makenew = external hidden unnamed_addr constant [40 x i8], align 1
@LINES = external global i32, align 4
@COLS = external global i32, align 4

; Function Attrs: nounwind uwtable
define dso_local ptr @PDC_makenew(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) #6
  %12 = load i32, ptr %6, align 4, !tbaa !5
  %13 = icmp sgt i32 %12, 0
  br i1 %13, label %14, label %18

14:                                               ; preds = %4
  %15 = load i32, ptr %7, align 4, !tbaa !5
  %16 = icmp sgt i32 %15, 0
  br i1 %16, label %17, label %18

17:                                               ; preds = %14
  br label %19

18:                                               ; preds = %14, %4
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 154, ptr noundef @__PRETTY_FUNCTION__.PDC_makenew) #7
  unreachable

19:                                               ; preds = %17
  %20 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 136) #8
  store ptr %20, ptr %10, align 8, !tbaa !9
  %21 = load ptr, ptr %10, align 8, !tbaa !9
  %22 = icmp ne ptr %21, null
  br i1 %22, label %25, label %23

23:                                               ; preds = %19
  %24 = load ptr, ptr %10, align 8, !tbaa !9
  store ptr %24, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %97

25:                                               ; preds = %19
  %26 = load i32, ptr %6, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = mul i64 %27, 8
  %29 = call noalias ptr @malloc(i64 noundef %28) #9
  %30 = load ptr, ptr %10, align 8, !tbaa !9
  %31 = getelementptr inbounds %struct._win, ptr %30, i32 0, i32 16
  store ptr %29, ptr %31, align 8, !tbaa !11
  %32 = load i32, ptr %6, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = mul i64 %33, 4
  %35 = mul i64 %34, 2
  %36 = call noalias ptr @malloc(i64 noundef %35) #9
  %37 = load ptr, ptr %10, align 8, !tbaa !9
  %38 = getelementptr inbounds %struct._win, ptr %37, i32 0, i32 17
  store ptr %36, ptr %38, align 8, !tbaa !15
  %39 = load ptr, ptr %10, align 8, !tbaa !9
  %40 = getelementptr inbounds %struct._win, ptr %39, i32 0, i32 17
  %41 = load ptr, ptr %40, align 8, !tbaa !15
  %42 = icmp ne ptr %41, null
  br i1 %42, label %43, label %48

43:                                               ; preds = %25
  %44 = load ptr, ptr %10, align 8, !tbaa !9
  %45 = getelementptr inbounds %struct._win, ptr %44, i32 0, i32 16
  %46 = load ptr, ptr %45, align 8, !tbaa !11
  %47 = icmp ne ptr %46, null
  br i1 %47, label %51, label %48

48:                                               ; preds = %43, %25
  %49 = load ptr, ptr %10, align 8, !tbaa !9
  %50 = call i32 @delwin(ptr noundef %49)
  store ptr null, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %97

51:                                               ; preds = %43
  %52 = load ptr, ptr %10, align 8, !tbaa !9
  %53 = getelementptr inbounds %struct._win, ptr %52, i32 0, i32 17
  %54 = load ptr, ptr %53, align 8, !tbaa !15
  %55 = load i32, ptr %6, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds i32, ptr %54, i64 %56
  %58 = load ptr, ptr %10, align 8, !tbaa !9
  %59 = getelementptr inbounds %struct._win, ptr %58, i32 0, i32 18
  store ptr %57, ptr %59, align 8, !tbaa !16
  %60 = load i32, ptr %6, align 4, !tbaa !5
  %61 = load ptr, ptr %10, align 8, !tbaa !9
  %62 = getelementptr inbounds %struct._win, ptr %61, i32 0, i32 2
  store i32 %60, ptr %62, align 8, !tbaa !17
  %63 = load i32, ptr %7, align 4, !tbaa !5
  %64 = load ptr, ptr %10, align 8, !tbaa !9
  %65 = getelementptr inbounds %struct._win, ptr %64, i32 0, i32 3
  store i32 %63, ptr %65, align 4, !tbaa !18
  %66 = load i32, ptr %8, align 4, !tbaa !5
  %67 = load ptr, ptr %10, align 8, !tbaa !9
  %68 = getelementptr inbounds %struct._win, ptr %67, i32 0, i32 4
  store i32 %66, ptr %68, align 8, !tbaa !19
  %69 = load i32, ptr %9, align 4, !tbaa !5
  %70 = load ptr, ptr %10, align 8, !tbaa !9
  %71 = getelementptr inbounds %struct._win, ptr %70, i32 0, i32 5
  store i32 %69, ptr %71, align 4, !tbaa !20
  %72 = load ptr, ptr %10, align 8, !tbaa !9
  %73 = getelementptr inbounds %struct._win, ptr %72, i32 0, i32 8
  store i64 32, ptr %73, align 8, !tbaa !21
  %74 = load i32, ptr %6, align 4, !tbaa !5
  %75 = load i32, ptr @LINES, align 4, !tbaa !5
  %76 = icmp eq i32 %74, %75
  br i1 %76, label %77, label %81

77:                                               ; preds = %51
  %78 = load i32, ptr %7, align 4, !tbaa !5
  %79 = load i32, ptr @COLS, align 4, !tbaa !5
  %80 = icmp eq i32 %78, %79
  br label %81

81:                                               ; preds = %77, %51
  %82 = phi i1 [ false, %51 ], [ %80, %77 ]
  %83 = load ptr, ptr %10, align 8, !tbaa !9
  %84 = getelementptr inbounds %struct._win, ptr %83, i32 0, i32 9
  %85 = zext i1 %82 to i8
  store i8 %85, ptr %84, align 8, !tbaa !22
  %86 = load i32, ptr %6, align 4, !tbaa !5
  %87 = sub nsw i32 %86, 1
  %88 = load ptr, ptr %10, align 8, !tbaa !9
  %89 = getelementptr inbounds %struct._win, ptr %88, i32 0, i32 20
  store i32 %87, ptr %89, align 4, !tbaa !23
  %90 = load ptr, ptr %10, align 8, !tbaa !9
  %91 = getelementptr inbounds %struct._win, ptr %90, i32 0, i32 23
  store i32 -1, ptr %91, align 8, !tbaa !24
  %92 = load ptr, ptr %10, align 8, !tbaa !9
  %93 = getelementptr inbounds %struct._win, ptr %92, i32 0, i32 22
  store i32 -1, ptr %93, align 4, !tbaa !25
  %94 = load ptr, ptr %10, align 8, !tbaa !9
  %95 = call i32 @touchwin(ptr noundef %94)
  %96 = load ptr, ptr %10, align 8, !tbaa !9
  store ptr %96, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %97

97:                                               ; preds = %81, %48, %23
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  %98 = load ptr, ptr %5, align 8
  ret ptr %98
}

; 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: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #3

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #4

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

declare i32 @touchwin(ptr noundef) #5

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

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 = { nounwind allocsize(0,1) "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 allocsize(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 #5 = { "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 #6 = { nounwind }
attributes #7 = { noreturn nounwind }
attributes #8 = { nounwind allocsize(0,1) }
attributes #9 = { nounwind allocsize(0) }

!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, !10, i64 56}
!12 = !{!"_win", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !6, i64 24, !13, i64 32, !13, i64 40, !14, i64 48, !14, i64 49, !14, i64 50, !14, i64 51, !14, i64 52, !14, i64 53, !14, i64 54, !10, i64 56, !10, i64 64, !10, i64 72, !6, i64 80, !6, i64 84, !6, i64 88, !6, i64 92, !6, i64 96, !10, i64 104, !6, i64 112, !6, i64 116, !6, i64 120, !6, i64 124, !6, i64 128, !6, i64 132}
!13 = !{!"long", !7, i64 0}
!14 = !{!"_Bool", !7, i64 0}
!15 = !{!12, !10, i64 64}
!16 = !{!12, !10, i64 72}
!17 = !{!12, !6, i64 8}
!18 = !{!12, !6, i64 12}
!19 = !{!12, !6, i64 16}
!20 = !{!12, !6, i64 20}
!21 = !{!12, !13, i64 40}
!22 = !{!12, !14, i64 48}
!23 = !{!12, !6, i64 84}
!24 = !{!12, !6, i64 96}
!25 = !{!12, !6, i64 92}


; 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
@__PRETTY_FUNCTION__.PDC_makenew = external hidden unnamed_addr constant [40 x i8], align 1
@LINES = external local_unnamed_addr global i32, align 4
@COLS = external local_unnamed_addr global i32, align 4

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @PDC_makenew(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = icmp sgt i32 %0, 0
  %6 = icmp sgt i32 %1, 0
  %or.cond = and i1 %5, %6
  br i1 %or.cond, label %8, label %7

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

8:                                                ; preds = %4
  %9 = tail call noalias dereferenceable_or_null(136) ptr @calloc(i64 noundef 1, i64 noundef 136) #6
  %.not = icmp eq ptr %9, null
  br i1 %.not, label %39, label %10

10:                                               ; preds = %8
  %11 = zext nneg i32 %0 to i64
  %12 = shl nuw nsw i64 %11, 3
  %13 = tail call noalias ptr @malloc(i64 noundef %12) #7
  %14 = getelementptr inbounds i8, ptr %9, i64 56
  store ptr %13, ptr %14, align 8, !tbaa !5
  %15 = tail call noalias ptr @malloc(i64 noundef %12) #7
  %16 = getelementptr inbounds i8, ptr %9, i64 64
  store ptr %15, ptr %16, align 8, !tbaa !13
  %.not37 = icmp eq ptr %15, null
  %.not38 = icmp eq ptr %13, null
  %or.cond39 = or i1 %.not38, %.not37
  br i1 %or.cond39, label %17, label %19

17:                                               ; preds = %10
  %18 = tail call i32 @delwin(ptr noundef nonnull %9)
  br label %39

19:                                               ; preds = %10
  %20 = getelementptr inbounds i32, ptr %15, i64 %11
  %21 = getelementptr inbounds i8, ptr %9, i64 72
  store ptr %20, ptr %21, align 8, !tbaa !14
  %22 = getelementptr inbounds i8, ptr %9, i64 8
  store i32 %0, ptr %22, align 8, !tbaa !15
  %23 = getelementptr inbounds i8, ptr %9, i64 12
  store i32 %1, ptr %23, align 4, !tbaa !16
  %24 = getelementptr inbounds i8, ptr %9, i64 16
  store i32 %2, ptr %24, align 8, !tbaa !17
  %25 = getelementptr inbounds i8, ptr %9, i64 20
  store i32 %3, ptr %25, align 4, !tbaa !18
  %26 = getelementptr inbounds i8, ptr %9, i64 40
  store i64 32, ptr %26, align 8, !tbaa !19
  %27 = load i32, ptr @LINES, align 4, !tbaa !20
  %28 = icmp eq i32 %27, %0
  %29 = load i32, ptr @COLS, align 4
  %30 = icmp eq i32 %29, %1
  %31 = select i1 %28, i1 %30, i1 false
  %32 = getelementptr inbounds i8, ptr %9, i64 48
  %33 = zext i1 %31 to i8
  store i8 %33, ptr %32, align 8, !tbaa !21
  %34 = add nsw i32 %0, -1
  %35 = getelementptr inbounds i8, ptr %9, i64 84
  store i32 %34, ptr %35, align 4, !tbaa !22
  %36 = getelementptr inbounds i8, ptr %9, i64 96
  store i32 -1, ptr %36, align 8, !tbaa !23
  %37 = getelementptr inbounds i8, ptr %9, i64 92
  store i32 -1, ptr %37, align 4, !tbaa !24
  %38 = tail call i32 @touchwin(ptr noundef nonnull %9) #8
  br label %39

39:                                               ; preds = %8, %19, %17
  %.0 = phi ptr [ %9, %19 ], [ null, %17 ], [ null, %8 ]
  ret ptr %.0
}

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

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #3

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

declare i32 @touchwin(ptr noundef) local_unnamed_addr #4

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 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(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 #4 = { "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 #5 = { noreturn nounwind }
attributes #6 = { nounwind allocsize(0,1) }
attributes #7 = { nounwind allocsize(0) }
attributes #8 = { 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, !12, i64 56}
!6 = !{!"_win", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !10, i64 32, !10, i64 40, !11, i64 48, !11, i64 49, !11, i64 50, !11, i64 51, !11, i64 52, !11, i64 53, !11, i64 54, !12, i64 56, !12, i64 64, !12, i64 72, !7, i64 80, !7, i64 84, !7, i64 88, !7, i64 92, !7, i64 96, !12, i64 104, !7, i64 112, !7, i64 116, !7, i64 120, !7, i64 124, !7, i64 128, !7, i64 132}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"_Bool", !8, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!6, !12, i64 64}
!14 = !{!6, !12, i64 72}
!15 = !{!6, !7, i64 8}
!16 = !{!6, !7, i64 12}
!17 = !{!6, !7, i64 16}
!18 = !{!6, !7, i64 20}
!19 = !{!6, !10, i64 40}
!20 = !{!7, !7, i64 0}
!21 = !{!6, !11, i64 48}
!22 = !{!6, !7, i64 84}
!23 = !{!6, !7, i64 96}
!24 = !{!6, !7, i64 92}


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