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

; 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 [94 x i8], align 1
@__PRETTY_FUNCTION__.winsertln = external hidden unnamed_addr constant [24 x i8], align 1

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

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

declare void @PDC_mark_line_as_changed(ptr noundef, i32 noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local i32 @winsertln(ptr noundef %0) #3 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = icmp ne ptr %9, null
  br i1 %10, label %11, label %12

11:                                               ; preds = %1
  br label %13

12:                                               ; preds = %1
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 160, ptr noundef @__PRETTY_FUNCTION__.winsertln) #5
  unreachable

13:                                               ; preds = %11
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = icmp ne ptr %14, null
  br i1 %15, label %17, label %16

16:                                               ; preds = %13
  store i32 -1, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %93

17:                                               ; preds = %13
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct._win, ptr %18, i32 0, i32 8
  %20 = load i64, ptr %19, align 8, !tbaa !9
  store i64 %20, ptr %4, align 8, !tbaa !14
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct._win, ptr %21, i32 0, i32 16
  %23 = load ptr, ptr %22, align 8, !tbaa !15
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct._win, ptr %24, i32 0, i32 2
  %26 = load i32, ptr %25, align 8, !tbaa !16
  %27 = sub nsw i32 %26, 1
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds ptr, ptr %23, i64 %28
  %30 = load ptr, ptr %29, align 8, !tbaa !5
  store ptr %30, ptr %5, align 8, !tbaa !5
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct._win, ptr %31, i32 0, i32 2
  %33 = load i32, ptr %32, align 8, !tbaa !16
  %34 = sub nsw i32 %33, 1
  store i32 %34, ptr %7, align 4, !tbaa !17
  br label %35

35:                                               ; preds = %58, %17
  %36 = load i32, ptr %7, align 4, !tbaa !17
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct._win, ptr %37, i32 0, i32 0
  %39 = load i32, ptr %38, align 8, !tbaa !18
  %40 = icmp sgt i32 %36, %39
  br i1 %40, label %41, label %61

41:                                               ; preds = %35
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct._win, ptr %42, i32 0, i32 16
  %44 = load ptr, ptr %43, align 8, !tbaa !15
  %45 = load i32, ptr %7, align 4, !tbaa !17
  %46 = sub nsw i32 %45, 1
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds ptr, ptr %44, i64 %47
  %49 = load ptr, ptr %48, align 8, !tbaa !5
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct._win, ptr %50, i32 0, i32 16
  %52 = load ptr, ptr %51, align 8, !tbaa !15
  %53 = load i32, ptr %7, align 4, !tbaa !17
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds ptr, ptr %52, i64 %54
  store ptr %49, ptr %55, align 8, !tbaa !5
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = load i32, ptr %7, align 4, !tbaa !17
  call void @PDC_mark_line_as_changed(ptr noundef %56, i32 noundef %57)
  br label %58

58:                                               ; preds = %41
  %59 = load i32, ptr %7, align 4, !tbaa !17
  %60 = add nsw i32 %59, -1
  store i32 %60, ptr %7, align 4, !tbaa !17
  br label %35, !llvm.loop !19

61:                                               ; preds = %35
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = load ptr, ptr %3, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct._win, ptr %63, i32 0, i32 16
  %65 = load ptr, ptr %64, align 8, !tbaa !15
  %66 = load ptr, ptr %3, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct._win, ptr %66, i32 0, i32 0
  %68 = load i32, ptr %67, align 8, !tbaa !18
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds ptr, ptr %65, i64 %69
  store ptr %62, ptr %70, align 8, !tbaa !5
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = load ptr, ptr %3, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct._win, ptr %72, i32 0, i32 3
  %74 = load i32, ptr %73, align 4, !tbaa !21
  %75 = sub nsw i32 %74, 1
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds i64, ptr %71, i64 %76
  store ptr %77, ptr %6, align 8, !tbaa !5
  br label %78

78:                                               ; preds = %85, %61
  %79 = load ptr, ptr %5, align 8, !tbaa !5
  %80 = load ptr, ptr %6, align 8, !tbaa !5
  %81 = icmp ule ptr %79, %80
  br i1 %81, label %82, label %88

82:                                               ; preds = %78
  %83 = load i64, ptr %4, align 8, !tbaa !14
  %84 = load ptr, ptr %5, align 8, !tbaa !5
  store i64 %83, ptr %84, align 8, !tbaa !14
  br label %85

85:                                               ; preds = %82
  %86 = load ptr, ptr %5, align 8, !tbaa !5
  %87 = getelementptr inbounds i64, ptr %86, i32 1
  store ptr %87, ptr %5, align 8, !tbaa !5
  br label %78, !llvm.loop !22

88:                                               ; preds = %78
  %89 = load ptr, ptr %3, align 8, !tbaa !5
  %90 = load ptr, ptr %3, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct._win, ptr %90, i32 0, i32 0
  %92 = load i32, ptr %91, align 8, !tbaa !18
  call void @PDC_mark_line_as_changed(ptr noundef %89, i32 noundef %92)
  store i32 0, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %93

93:                                               ; preds = %88, %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  %94 = load i32, ptr %2, align 4
  ret i32 %94
}

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


; 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 [94 x i8], align 1
@__PRETTY_FUNCTION__.winsertln = external hidden unnamed_addr constant [24 x i8], align 1

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

declare void @PDC_mark_line_as_changed(ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @winsertln(ptr noundef %0) local_unnamed_addr #2 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %2, label %3

2:                                                ; preds = %1
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 160, ptr noundef nonnull @__PRETTY_FUNCTION__.winsertln) #4
  unreachable

3:                                                ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 40
  %5 = load i64, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 56
  %7 = load ptr, ptr %6, align 8, !tbaa !13
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  %9 = load i32, ptr %8, align 8, !tbaa !14
  %10 = add nsw i32 %9, -1
  %11 = sext i32 %10 to i64
  %12 = getelementptr inbounds ptr, ptr %7, i64 %11
  %13 = load ptr, ptr %12, align 8, !tbaa !15
  %14 = ptrtoint ptr %13 to i64
  %15 = load i32, ptr %0, align 8, !tbaa !16
  %16 = icmp sgt i32 %10, %15
  br i1 %16, label %.lr.ph.preheader, label %.._crit_edge_crit_edge

.._crit_edge_crit_edge:                           ; preds = %3
  %.pre40 = sext i32 %15 to i64
  br label %._crit_edge

.lr.ph.preheader:                                 ; preds = %3
  %17 = sext i32 %9 to i64
  %18 = add nsw i64 %17, -1
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %18, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %19 = load ptr, ptr %6, align 8, !tbaa !13
  %20 = getelementptr ptr, ptr %19, i64 %indvars.iv
  %21 = getelementptr i8, ptr %20, i64 -8
  %22 = load ptr, ptr %21, align 8, !tbaa !15
  store ptr %22, ptr %20, align 8, !tbaa !15
  %23 = trunc nsw i64 %indvars.iv to i32
  tail call void @PDC_mark_line_as_changed(ptr noundef nonnull %0, i32 noundef %23) #5
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %24 = load i32, ptr %0, align 8, !tbaa !16
  %25 = sext i32 %24 to i64
  %26 = icmp sgt i64 %indvars.iv.next, %25
  br i1 %26, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !17

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %.pre = load ptr, ptr %6, align 8, !tbaa !13
  br label %._crit_edge

._crit_edge:                                      ; preds = %.._crit_edge_crit_edge, %._crit_edge.loopexit
  %.pre-phi = phi i64 [ %.pre40, %.._crit_edge_crit_edge ], [ %25, %._crit_edge.loopexit ]
  %27 = phi ptr [ %7, %.._crit_edge_crit_edge ], [ %.pre, %._crit_edge.loopexit ]
  %.lcssa = phi i32 [ %15, %.._crit_edge_crit_edge ], [ %24, %._crit_edge.loopexit ]
  %28 = getelementptr inbounds ptr, ptr %27, i64 %.pre-phi
  store ptr %13, ptr %28, align 8, !tbaa !15
  %29 = getelementptr inbounds i8, ptr %0, i64 12
  %30 = load i32, ptr %29, align 4, !tbaa !19
  %31 = sext i32 %30 to i64
  %32 = getelementptr i64, ptr %13, i64 %31
  %33 = getelementptr i8, ptr %32, i64 -8
  %.not3133 = icmp ugt ptr %13, %33
  br i1 %.not3133, label %._crit_edge37, label %.lr.ph36.preheader

.lr.ph36.preheader:                               ; preds = %._crit_edge
  %34 = shl nsw i64 %31, 3
  %35 = add i64 %34, %14
  %36 = add i64 %35, -7
  %37 = add i64 %14, 8
  %umax = tail call i64 @llvm.umax.i64(i64 %36, i64 %37)
  %38 = xor i64 %14, -1
  %39 = add i64 %umax, %38
  %40 = lshr i64 %39, 3
  %41 = add nuw nsw i64 %40, 1
  %min.iters.check = icmp ult i64 %39, 24
  br i1 %min.iters.check, label %.lr.ph36.preheader46, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph36.preheader
  %n.vec = and i64 %41, 4611686018427387900
  %42 = shl i64 %n.vec, 3
  %ind.end = getelementptr i8, ptr %13, i64 %42
  %broadcast.splatinsert = insertelement <2 x i64> poison, i64 %5, i64 0
  %broadcast.splat = shufflevector <2 x i64> %broadcast.splatinsert, <2 x i64> poison, <2 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %offset.idx = shl i64 %index, 3
  %next.gep = getelementptr i8, ptr %13, i64 %offset.idx
  %43 = getelementptr i8, ptr %next.gep, i64 16
  store <2 x i64> %broadcast.splat, ptr %next.gep, align 8, !tbaa !20
  store <2 x i64> %broadcast.splat, ptr %43, align 8, !tbaa !20
  %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 !21

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %41, %n.vec
  br i1 %cmp.n, label %._crit_edge37, label %.lr.ph36.preheader46

.lr.ph36.preheader46:                             ; preds = %middle.block, %.lr.ph36.preheader
  %.02834.ph = phi ptr [ %13, %.lr.ph36.preheader ], [ %ind.end, %middle.block ]
  br label %.lr.ph36

.lr.ph36:                                         ; preds = %.lr.ph36.preheader46, %.lr.ph36
  %.02834 = phi ptr [ %45, %.lr.ph36 ], [ %.02834.ph, %.lr.ph36.preheader46 ]
  store i64 %5, ptr %.02834, align 8, !tbaa !20
  %45 = getelementptr inbounds i8, ptr %.02834, i64 8
  %.not31 = icmp ugt ptr %45, %33
  br i1 %.not31, label %._crit_edge37, label %.lr.ph36, !llvm.loop !24

._crit_edge37:                                    ; preds = %.lr.ph36, %middle.block, %._crit_edge
  tail call void @PDC_mark_line_as_changed(ptr noundef nonnull %0, i32 noundef %.lcssa) #5
  ret i32 0
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umax.i64(i64, i64) #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 = { "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 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 = { 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, !10, i64 40}
!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 56}
!14 = !{!6, !7, i64 8}
!15 = !{!12, !12, i64 0}
!16 = !{!6, !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!6, !7, i64 12}
!20 = !{!10, !10, i64 0}
!21 = distinct !{!21, !18, !22, !23}
!22 = !{!"llvm.loop.isvectorized", i32 1}
!23 = !{!"llvm.loop.unroll.runtime.disable"}
!24 = distinct !{!24, !18, !23, !22}


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