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

; 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 [92 x i8], align 1
@__PRETTY_FUNCTION__.whline = external hidden unnamed_addr constant [34 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: nounwind uwtable
declare hidden i64 @_attr_passthru(ptr noundef, i64 noundef) #2

declare void @PDC_sync(ptr noundef) #3

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

14:                                               ; preds = %3
  br label %16

15:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 241, ptr noundef @__PRETTY_FUNCTION__.whline) #5
  unreachable

16:                                               ; preds = %14
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = icmp ne ptr %17, null
  br i1 %18, label %19, label %22

19:                                               ; preds = %16
  %20 = load i32, ptr %7, align 4, !tbaa !11
  %21 = icmp slt i32 %20, 1
  br i1 %21, label %22, label %23

22:                                               ; preds = %19, %16
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %86

23:                                               ; preds = %19
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct._win, ptr %24, i32 0, i32 1
  %26 = load i32, ptr %25, align 4, !tbaa !13
  store i32 %26, ptr %9, align 4, !tbaa !11
  %27 = load i32, ptr %9, align 4, !tbaa !11
  %28 = load i32, ptr %7, align 4, !tbaa !11
  %29 = add nsw i32 %27, %28
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct._win, ptr %30, i32 0, i32 3
  %32 = load i32, ptr %31, align 4, !tbaa !16
  %33 = icmp slt i32 %29, %32
  br i1 %33, label %34, label %38

34:                                               ; preds = %23
  %35 = load i32, ptr %9, align 4, !tbaa !11
  %36 = load i32, ptr %7, align 4, !tbaa !11
  %37 = add nsw i32 %35, %36
  br label %42

38:                                               ; preds = %23
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct._win, ptr %39, i32 0, i32 3
  %41 = load i32, ptr %40, align 4, !tbaa !16
  br label %42

42:                                               ; preds = %38, %34
  %43 = phi i32 [ %37, %34 ], [ %41, %38 ]
  %44 = sub nsw i32 %43, 1
  store i32 %44, ptr %10, align 4, !tbaa !11
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct._win, ptr %45, i32 0, i32 16
  %47 = load ptr, ptr %46, align 8, !tbaa !17
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct._win, ptr %48, i32 0, i32 0
  %50 = load i32, ptr %49, align 8, !tbaa !18
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds ptr, ptr %47, i64 %51
  %53 = load ptr, ptr %52, align 8, !tbaa !5
  store ptr %53, ptr %8, align 8, !tbaa !5
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = load i64, ptr %6, align 8, !tbaa !9
  %56 = icmp ne i64 %55, 0
  br i1 %56, label %57, label %59

57:                                               ; preds = %42
  %58 = load i64, ptr %6, align 8, !tbaa !9
  br label %60

59:                                               ; preds = %42
  br label %60

60:                                               ; preds = %59, %57
  %61 = phi i64 [ %58, %57 ], [ 2097247, %59 ]
  %62 = call i64 @_attr_passthru(ptr noundef %54, i64 noundef %61)
  store i64 %62, ptr %6, align 8, !tbaa !9
  %63 = load i32, ptr %9, align 4, !tbaa !11
  store i32 %63, ptr %7, align 4, !tbaa !11
  br label %64

64:                                               ; preds = %74, %60
  %65 = load i32, ptr %7, align 4, !tbaa !11
  %66 = load i32, ptr %10, align 4, !tbaa !11
  %67 = icmp sle i32 %65, %66
  br i1 %67, label %68, label %77

68:                                               ; preds = %64
  %69 = load i64, ptr %6, align 8, !tbaa !9
  %70 = load ptr, ptr %8, align 8, !tbaa !5
  %71 = load i32, ptr %7, align 4, !tbaa !11
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds i64, ptr %70, i64 %72
  store i64 %69, ptr %73, align 8, !tbaa !9
  br label %74

74:                                               ; preds = %68
  %75 = load i32, ptr %7, align 4, !tbaa !11
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr %7, align 4, !tbaa !11
  br label %64, !llvm.loop !19

77:                                               ; preds = %64
  %78 = load ptr, ptr %5, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct._win, ptr %78, i32 0, i32 0
  %80 = load i32, ptr %79, align 8, !tbaa !18
  store i32 %80, ptr %7, align 4, !tbaa !11
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  %82 = load i32, ptr %7, align 4, !tbaa !11
  %83 = load i32, ptr %9, align 4, !tbaa !11
  %84 = load i32, ptr %10, align 4, !tbaa !11
  call void @PDC_mark_cells_as_changed(ptr noundef %81, i32 noundef %82, i32 noundef %83, i32 noundef %84)
  %85 = load ptr, ptr %5, align 8, !tbaa !5
  call void @PDC_sync(ptr noundef %85)
  store i32 0, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %86

86:                                               ; preds = %77, %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  %87 = load i32, ptr %4, align 4
  ret i32 %87
}

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

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 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 4}
!14 = !{!"_win", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !12, i64 24, !10, i64 32, !10, i64 40, !15, i64 48, !15, i64 49, !15, i64 50, !15, i64 51, !15, i64 52, !15, i64 53, !15, i64 54, !6, i64 56, !6, i64 64, !6, i64 72, !12, i64 80, !12, i64 84, !12, i64 88, !12, i64 92, !12, i64 96, !6, i64 104, !12, i64 112, !12, i64 116, !12, i64 120, !12, i64 124, !12, i64 128, !12, i64 132}
!15 = !{!"_Bool", !7, i64 0}
!16 = !{!14, !12, i64 12}
!17 = !{!14, !6, i64 56}
!18 = !{!14, !12, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"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 [92 x i8], align 1
@__PRETTY_FUNCTION__.whline = external hidden unnamed_addr constant [34 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
declare hidden i64 @_attr_passthru(ptr noundef, i64 noundef) local_unnamed_addr #1

declare void @PDC_sync(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @whline(ptr noundef %0, i64 noundef %1, i32 noundef %2) local_unnamed_addr #1 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %4, label %5

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

5:                                                ; preds = %3
  %6 = icmp slt i32 %2, 1
  br i1 %6, label %30, label %7

7:                                                ; preds = %5
  %8 = getelementptr inbounds i8, ptr %0, i64 4
  %9 = load i32, ptr %8, align 4, !tbaa !5
  %10 = add nsw i32 %9, %2
  %11 = getelementptr inbounds i8, ptr %0, i64 12
  %12 = load i32, ptr %11, align 4, !tbaa !13
  %. = tail call i32 @llvm.smin.i32(i32 %10, i32 %12)
  %13 = add nsw i32 %., -1
  %14 = getelementptr inbounds i8, ptr %0, i64 56
  %15 = load ptr, ptr %14, align 8, !tbaa !14
  %16 = load i32, ptr %0, align 8, !tbaa !15
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds ptr, ptr %15, i64 %17
  %19 = load ptr, ptr %18, align 8, !tbaa !16
  %.not35 = icmp eq i64 %1, 0
  %20 = select i1 %.not35, i64 2097247, i64 %1
  %21 = tail call i64 @_attr_passthru(ptr noundef nonnull %0, i64 noundef %20)
  %.not36.not37 = icmp sgt i32 %12, %9
  br i1 %.not36.not37, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %7
  %22 = sext i32 %9 to i64
  %23 = sext i32 %. to i64
  %24 = add nsw i64 %22, 1
  %smax = tail call i64 @llvm.smax.i64(i64 %23, i64 %24)
  %25 = sub i64 %smax, %22
  %min.iters.check = icmp ult i64 %25, 4
  br i1 %min.iters.check, label %.lr.ph.preheader40, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph.preheader
  %n.vec = and i64 %25, -4
  %ind.end = add i64 %n.vec, %22
  %broadcast.splatinsert = insertelement <2 x i64> poison, i64 %21, i64 0
  %broadcast.splat = shufflevector <2 x i64> %broadcast.splatinsert, <2 x i64> poison, <2 x i32> zeroinitializer
  %invariant.gep = getelementptr i64, ptr %19, i64 %22
  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
  %26 = getelementptr inbounds i8, ptr %gep, i64 16
  store <2 x i64> %broadcast.splat, ptr %gep, align 8, !tbaa !17
  store <2 x i64> %broadcast.splat, ptr %26, align 8, !tbaa !17
  %index.next = add nuw i64 %index, 4
  %27 = icmp eq i64 %index.next, %n.vec
  br i1 %27, label %middle.block, label %vector.body, !llvm.loop !18

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

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

.lr.ph:                                           ; preds = %.lr.ph.preheader40, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ %indvars.iv.ph, %.lr.ph.preheader40 ]
  %28 = getelementptr inbounds i64, ptr %19, i64 %indvars.iv
  store i64 %21, ptr %28, align 8, !tbaa !17
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %.not36.not = icmp slt i64 %indvars.iv.next, %23
  br i1 %.not36.not, label %.lr.ph, label %._crit_edge, !llvm.loop !22

._crit_edge:                                      ; preds = %.lr.ph, %middle.block, %7
  %29 = load i32, ptr %0, align 8, !tbaa !15
  tail call void @PDC_mark_cells_as_changed(ptr noundef nonnull %0, i32 noundef %29, i32 noundef %9, i32 noundef %13) #5
  tail call void @PDC_sync(ptr noundef nonnull %0) #5
  br label %30

30:                                               ; preds = %5, %._crit_edge
  %.0 = phi i32 [ 0, %._crit_edge ], [ -1, %5 ]
  ret i32 %.0
}

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #3

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


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