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

; 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 [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [90 x i8], align 1
@__PRETTY_FUNCTION__.wchgat = external hidden unnamed_addr constant [55 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @wchgat(ptr noundef %0, i32 noundef %1, i64 noundef %2, i16 noundef signext %3, ptr noundef %4) #2 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %10 = alloca i16, align 2
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !9
  store i64 %2, ptr %9, align 8, !tbaa !11
  store i16 %3, ptr %10, align 2, !tbaa !13
  store ptr %4, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  %18 = load ptr, ptr %11, align 8, !tbaa !5
  %19 = icmp ne ptr %18, null
  br i1 %19, label %20, label %23

20:                                               ; preds = %5
  %21 = load ptr, ptr %11, align 8, !tbaa !5
  %22 = load i32, ptr %21, align 4, !tbaa !9
  br label %26

23:                                               ; preds = %5
  %24 = load i16, ptr %10, align 2, !tbaa !13
  %25 = sext i16 %24 to i32
  br label %26

26:                                               ; preds = %23, %20
  %27 = phi i32 [ %22, %20 ], [ %25, %23 ]
  store i32 %27, ptr %16, align 4, !tbaa !9
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = icmp ne ptr %28, null
  br i1 %29, label %30, label %31

30:                                               ; preds = %26
  br label %32

31:                                               ; preds = %26
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 356, ptr noundef @__PRETTY_FUNCTION__.wchgat) #5
  unreachable

32:                                               ; preds = %30
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = icmp ne ptr %33, null
  br i1 %34, label %36, label %35

35:                                               ; preds = %32
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %17, align 4
  br label %112

36:                                               ; preds = %32
  %37 = load i64, ptr %9, align 8, !tbaa !11
  %38 = and i64 %37, 9007199252643840
  %39 = load i32, ptr %16, align 4, !tbaa !9
  %40 = sext i32 %39 to i64
  %41 = shl i64 %40, 33
  %42 = and i64 %41, 9007190664806400
  %43 = or i64 %38, %42
  store i64 %43, ptr %13, align 8, !tbaa !11
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct._win, ptr %44, i32 0, i32 1
  %46 = load i32, ptr %45, align 4, !tbaa !15
  store i32 %46, ptr %14, align 4, !tbaa !9
  %47 = load i32, ptr %8, align 4, !tbaa !9
  %48 = icmp slt i32 %47, 0
  br i1 %48, label %49, label %53

49:                                               ; preds = %36
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct._win, ptr %50, i32 0, i32 3
  %52 = load i32, ptr %51, align 4, !tbaa !18
  br label %71

53:                                               ; preds = %36
  %54 = load i32, ptr %14, align 4, !tbaa !9
  %55 = load i32, ptr %8, align 4, !tbaa !9
  %56 = add nsw i32 %54, %55
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct._win, ptr %57, i32 0, i32 3
  %59 = load i32, ptr %58, align 4, !tbaa !18
  %60 = icmp slt i32 %56, %59
  br i1 %60, label %61, label %65

61:                                               ; preds = %53
  %62 = load i32, ptr %14, align 4, !tbaa !9
  %63 = load i32, ptr %8, align 4, !tbaa !9
  %64 = add nsw i32 %62, %63
  br label %69

65:                                               ; preds = %53
  %66 = load ptr, ptr %7, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct._win, ptr %66, i32 0, i32 3
  %68 = load i32, ptr %67, align 4, !tbaa !18
  br label %69

69:                                               ; preds = %65, %61
  %70 = phi i32 [ %64, %61 ], [ %68, %65 ]
  br label %71

71:                                               ; preds = %69, %49
  %72 = phi i32 [ %52, %49 ], [ %70, %69 ]
  %73 = sub nsw i32 %72, 1
  store i32 %73, ptr %15, align 4, !tbaa !9
  %74 = load ptr, ptr %7, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct._win, ptr %74, i32 0, i32 16
  %76 = load ptr, ptr %75, align 8, !tbaa !19
  %77 = load ptr, ptr %7, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct._win, ptr %77, i32 0, i32 0
  %79 = load i32, ptr %78, align 8, !tbaa !20
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds ptr, ptr %76, i64 %80
  %82 = load ptr, ptr %81, align 8, !tbaa !5
  store ptr %82, ptr %12, align 8, !tbaa !5
  %83 = load i32, ptr %14, align 4, !tbaa !9
  store i32 %83, ptr %8, align 4, !tbaa !9
  br label %84

84:                                               ; preds = %101, %71
  %85 = load i32, ptr %8, align 4, !tbaa !9
  %86 = load i32, ptr %15, align 4, !tbaa !9
  %87 = icmp sle i32 %85, %86
  br i1 %87, label %88, label %104

88:                                               ; preds = %84
  %89 = load ptr, ptr %12, align 8, !tbaa !5
  %90 = load i32, ptr %8, align 4, !tbaa !9
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds i64, ptr %89, i64 %91
  %93 = load i64, ptr %92, align 8, !tbaa !11
  %94 = and i64 %93, 2097151
  %95 = load i64, ptr %13, align 8, !tbaa !11
  %96 = or i64 %94, %95
  %97 = load ptr, ptr %12, align 8, !tbaa !5
  %98 = load i32, ptr %8, align 4, !tbaa !9
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds i64, ptr %97, i64 %99
  store i64 %96, ptr %100, align 8, !tbaa !11
  br label %101

101:                                              ; preds = %88
  %102 = load i32, ptr %8, align 4, !tbaa !9
  %103 = add nsw i32 %102, 1
  store i32 %103, ptr %8, align 4, !tbaa !9
  br label %84, !llvm.loop !21

104:                                              ; preds = %84
  %105 = load ptr, ptr %7, align 8, !tbaa !5
  %106 = load ptr, ptr %7, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct._win, ptr %106, i32 0, i32 0
  %108 = load i32, ptr %107, align 8, !tbaa !20
  %109 = load i32, ptr %14, align 4, !tbaa !9
  %110 = load i32, ptr %15, align 4, !tbaa !9
  call void @PDC_mark_cells_as_changed(ptr noundef %105, i32 noundef %108, i32 noundef %109, i32 noundef %110)
  %111 = load ptr, ptr %7, align 8, !tbaa !5
  call void @PDC_sync(ptr noundef %111)
  store i32 0, ptr %6, align 4
  store i32 1, ptr %17, align 4
  br label %112

112:                                              ; preds = %104, %35
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  %113 = load i32, ptr %6, align 4
  ret i32 %113
}

declare void @PDC_mark_cells_as_changed(ptr noundef, i32 noundef, i32 noundef, i32 noundef) #3

declare void @PDC_sync(ptr noundef) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = !{!16, !10, i64 4}
!16 = !{!"_win", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !12, i64 32, !12, i64 40, !17, i64 48, !17, i64 49, !17, i64 50, !17, i64 51, !17, i64 52, !17, i64 53, !17, i64 54, !6, i64 56, !6, i64 64, !6, i64 72, !10, i64 80, !10, i64 84, !10, i64 88, !10, i64 92, !10, i64 96, !6, i64 104, !10, i64 112, !10, i64 116, !10, i64 120, !10, i64 124, !10, i64 128, !10, i64 132}
!17 = !{!"_Bool", !7, i64 0}
!18 = !{!16, !10, i64 12}
!19 = !{!16, !6, i64 56}
!20 = !{!16, !10, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


; 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 [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [90 x i8], align 1
@__PRETTY_FUNCTION__.wchgat = external hidden unnamed_addr constant [55 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 noundef i32 @wchgat(ptr noundef %0, i32 noundef %1, i64 noundef %2, i16 noundef signext %3, ptr noundef readonly %4) local_unnamed_addr #1 {
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %8, label %6

6:                                                ; preds = %5
  %7 = load i32, ptr %4, align 4, !tbaa !5
  br label %10

8:                                                ; preds = %5
  %9 = sext i16 %3 to i32
  br label %10

10:                                               ; preds = %8, %6
  %11 = phi i32 [ %7, %6 ], [ %9, %8 ]
  %.not39 = icmp eq ptr %0, null
  br i1 %.not39, label %12, label %13

12:                                               ; preds = %10
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 356, ptr noundef nonnull @__PRETTY_FUNCTION__.wchgat) #4
  unreachable

13:                                               ; preds = %10
  %14 = and i64 %2, 9007199252643840
  %15 = zext i32 %11 to i64
  %16 = shl i64 %15, 33
  %17 = and i64 %16, 9007190664806400
  %18 = or i64 %17, %14
  %19 = getelementptr inbounds i8, ptr %0, i64 4
  %20 = load i32, ptr %19, align 4, !tbaa !9
  %21 = icmp slt i32 %1, 0
  br i1 %21, label %22, label %25

22:                                               ; preds = %13
  %23 = getelementptr inbounds i8, ptr %0, i64 12
  %24 = load i32, ptr %23, align 4, !tbaa !14
  br label %29

25:                                               ; preds = %13
  %26 = add nsw i32 %20, %1
  %27 = getelementptr inbounds i8, ptr %0, i64 12
  %28 = load i32, ptr %27, align 4, !tbaa !14
  %. = tail call i32 @llvm.smin.i32(i32 %26, i32 %28)
  br label %29

29:                                               ; preds = %25, %22
  %30 = phi i32 [ %24, %22 ], [ %., %25 ]
  %31 = getelementptr inbounds i8, ptr %0, i64 56
  %32 = load ptr, ptr %31, align 8, !tbaa !15
  %33 = load i32, ptr %0, align 8, !tbaa !16
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds ptr, ptr %32, i64 %34
  %36 = load ptr, ptr %35, align 8, !tbaa !17
  %.not40.not41 = icmp slt i32 %20, %30
  br i1 %.not40.not41, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %29
  %37 = sext i32 %20 to i64
  %wide.trip.count = sext i32 %30 to i64
  %38 = sub nsw i64 %wide.trip.count, %37
  %min.iters.check = icmp ult i64 %38, 4
  br i1 %min.iters.check, label %.lr.ph.preheader45, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph.preheader
  %n.vec = and i64 %38, -4
  %ind.end = add nsw i64 %n.vec, %37
  %broadcast.splatinsert = insertelement <2 x i64> poison, i64 %18, i64 0
  %broadcast.splat = shufflevector <2 x i64> %broadcast.splatinsert, <2 x i64> poison, <2 x i32> zeroinitializer
  %invariant.gep = getelementptr i64, ptr %36, i64 %37
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %gep = getelementptr i64, ptr %invariant.gep, i64 %index
  %39 = getelementptr inbounds i8, ptr %gep, i64 16
  %wide.load = load <2 x i64>, ptr %gep, align 8, !tbaa !18
  %wide.load44 = load <2 x i64>, ptr %39, align 8, !tbaa !18
  %40 = and <2 x i64> %wide.load, <i64 2097151, i64 2097151>
  %41 = and <2 x i64> %wide.load44, <i64 2097151, i64 2097151>
  %42 = or disjoint <2 x i64> %broadcast.splat, %40
  %43 = or disjoint <2 x i64> %broadcast.splat, %41
  store <2 x i64> %42, ptr %gep, align 8, !tbaa !18
  store <2 x i64> %43, ptr %39, align 8, !tbaa !18
  %index.next = add nuw i64 %index, 4
  %44 = icmp eq i64 %index.next, %n.vec
  br i1 %44, label %middle.block, label %vector.body, !llvm.loop !19

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %38, %n.vec
  br i1 %cmp.n, label %._crit_edge, label %.lr.ph.preheader45

.lr.ph.preheader45:                               ; preds = %middle.block, %.lr.ph.preheader
  %indvars.iv.ph = phi i64 [ %37, %.lr.ph.preheader ], [ %ind.end, %middle.block ]
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader45, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ %indvars.iv.ph, %.lr.ph.preheader45 ]
  %45 = getelementptr inbounds i64, ptr %36, i64 %indvars.iv
  %46 = load i64, ptr %45, align 8, !tbaa !18
  %47 = and i64 %46, 2097151
  %48 = or disjoint i64 %18, %47
  store i64 %48, ptr %45, align 8, !tbaa !18
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !23

._crit_edge:                                      ; preds = %.lr.ph, %middle.block, %29
  %49 = add nsw i32 %30, -1
  tail call void @PDC_mark_cells_as_changed(ptr noundef nonnull %0, i32 noundef %33, i32 noundef %20, i32 noundef %49) #5
  tail call void @PDC_sync(ptr noundef nonnull %0) #5
  ret i32 0
}

declare void @PDC_mark_cells_as_changed(ptr noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

declare void @PDC_sync(ptr noundef) local_unnamed_addr #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #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 = { "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 nosync nounwind speculatable willreturn memory(none) }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 4}
!10 = !{!"_win", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !6, i64 24, !11, i64 32, !11, i64 40, !12, i64 48, !12, i64 49, !12, i64 50, !12, i64 51, !12, i64 52, !12, i64 53, !12, i64 54, !13, i64 56, !13, i64 64, !13, i64 72, !6, i64 80, !6, i64 84, !6, i64 88, !6, i64 92, !6, i64 96, !13, i64 104, !6, i64 112, !6, i64 116, !6, i64 120, !6, i64 124, !6, i64 128, !6, i64 132}
!11 = !{!"long", !7, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!"any pointer", !7, i64 0}
!14 = !{!10, !6, i64 12}
!15 = !{!10, !13, i64 56}
!16 = !{!10, !6, i64 0}
!17 = !{!13, !13, i64 0}
!18 = !{!11, !11, i64 0}
!19 = distinct !{!19, !20, !21, !22}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!"llvm.loop.isvectorized", i32 1}
!22 = !{!"llvm.loop.unroll.runtime.disable"}
!23 = distinct !{!23, !20, !22, !21}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass