; 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.1 = external hidden unnamed_addr constant [92 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@__PRETTY_FUNCTION__.mvderwin = external hidden unnamed_addr constant [33 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

; 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 @mvderwin(ptr noundef %0, i32 noundef %1, i32 noundef %2) #2 {
  %4 = alloca i32, align 4
  %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 ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %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.2, ptr noundef @.str.1, i32 noundef 407, ptr noundef @__PRETTY_FUNCTION__.mvderwin) #4
  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 %24

19:                                               ; preds = %16
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct._win, ptr %20, i32 0, i32 24
  %22 = load ptr, ptr %21, align 8, !tbaa !11
  %23 = icmp ne ptr %22, null
  br i1 %23, label %25, label %24

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

25:                                               ; preds = %19
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct._win, ptr %26, i32 0, i32 24
  %28 = load ptr, ptr %27, align 8, !tbaa !11
  store ptr %28, ptr %10, align 8, !tbaa !5
  %29 = load i32, ptr %6, align 4, !tbaa !9
  %30 = icmp slt i32 %29, 0
  br i1 %30, label %54, label %31

31:                                               ; preds = %25
  %32 = load i32, ptr %7, align 4, !tbaa !9
  %33 = icmp slt i32 %32, 0
  br i1 %33, label %54, label %34

34:                                               ; preds = %31
  %35 = load i32, ptr %6, align 4, !tbaa !9
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct._win, ptr %36, i32 0, i32 2
  %38 = load i32, ptr %37, align 8, !tbaa !15
  %39 = add nsw i32 %35, %38
  %40 = load ptr, ptr %10, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct._win, ptr %40, i32 0, i32 2
  %42 = load i32, ptr %41, align 8, !tbaa !15
  %43 = icmp sgt i32 %39, %42
  br i1 %43, label %54, label %44

44:                                               ; preds = %34
  %45 = load i32, ptr %7, align 4, !tbaa !9
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct._win, ptr %46, i32 0, i32 3
  %48 = load i32, ptr %47, align 4, !tbaa !16
  %49 = add nsw i32 %45, %48
  %50 = load ptr, ptr %10, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct._win, ptr %50, i32 0, i32 3
  %52 = load i32, ptr %51, align 4, !tbaa !16
  %53 = icmp sgt i32 %49, %52
  br i1 %53, label %54, label %55

54:                                               ; preds = %44, %34, %31, %25
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %91

55:                                               ; preds = %44
  %56 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %56, ptr %9, align 4, !tbaa !9
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %57

57:                                               ; preds = %81, %55
  %58 = load i32, ptr %8, align 4, !tbaa !9
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct._win, ptr %59, i32 0, i32 2
  %61 = load i32, ptr %60, align 8, !tbaa !15
  %62 = icmp slt i32 %58, %61
  br i1 %62, label %63, label %84

63:                                               ; preds = %57
  %64 = load ptr, ptr %10, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct._win, ptr %64, i32 0, i32 16
  %66 = load ptr, ptr %65, align 8, !tbaa !17
  %67 = load i32, ptr %9, align 4, !tbaa !9
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %9, align 4, !tbaa !9
  %69 = sext i32 %67 to i64
  %70 = getelementptr inbounds ptr, ptr %66, i64 %69
  %71 = load ptr, ptr %70, align 8, !tbaa !5
  %72 = load i32, ptr %7, align 4, !tbaa !9
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds i64, ptr %71, i64 %73
  %75 = load ptr, ptr %5, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct._win, ptr %75, i32 0, i32 16
  %77 = load ptr, ptr %76, align 8, !tbaa !17
  %78 = load i32, ptr %8, align 4, !tbaa !9
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds ptr, ptr %77, i64 %79
  store ptr %74, ptr %80, align 8, !tbaa !5
  br label %81

81:                                               ; preds = %63
  %82 = load i32, ptr %8, align 4, !tbaa !9
  %83 = add nsw i32 %82, 1
  store i32 %83, ptr %8, align 4, !tbaa !9
  br label %57, !llvm.loop !18

84:                                               ; preds = %57
  %85 = load i32, ptr %6, align 4, !tbaa !9
  %86 = load ptr, ptr %5, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct._win, ptr %86, i32 0, i32 23
  store i32 %85, ptr %87, align 8, !tbaa !20
  %88 = load i32, ptr %7, align 4, !tbaa !9
  %89 = load ptr, ptr %5, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct._win, ptr %89, i32 0, i32 22
  store i32 %88, ptr %90, align 4, !tbaa !21
  store i32 0, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %91

91:                                               ; preds = %84, %54, %24
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %92 = load i32, ptr %4, align 4
  ret i32 %92
}

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 = { nounwind }
attributes #4 = { 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, !6, i64 104}
!12 = !{!"_win", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, 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, !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}
!13 = !{!"long", !7, i64 0}
!14 = !{!"_Bool", !7, i64 0}
!15 = !{!12, !10, i64 8}
!16 = !{!12, !10, i64 12}
!17 = !{!12, !6, i64 56}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!12, !10, i64 96}
!21 = !{!12, !10, 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.1 = external hidden unnamed_addr constant [92 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@__PRETTY_FUNCTION__.mvderwin = external hidden unnamed_addr constant [33 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 range(i32 -1, 1) i32 @mvderwin(ptr noundef %0, i32 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.2, ptr noundef nonnull @.str.1, i32 noundef 407, ptr noundef nonnull @__PRETTY_FUNCTION__.mvderwin) #2
  unreachable

5:                                                ; preds = %3
  %6 = getelementptr inbounds i8, ptr %0, i64 104
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %.not32 = icmp ne ptr %7, null
  %8 = or i32 %2, %1
  %or.cond.not = icmp sgt i32 %8, -1
  %or.cond = and i1 %or.cond.not, %.not32
  br i1 %or.cond, label %9, label %51

9:                                                ; preds = %5
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load i32, ptr %10, align 8, !tbaa !13
  %12 = add nsw i32 %11, %1
  %13 = getelementptr inbounds i8, ptr %7, i64 8
  %14 = load i32, ptr %13, align 8, !tbaa !13
  %15 = icmp sgt i32 %12, %14
  br i1 %15, label %51, label %16

16:                                               ; preds = %9
  %17 = getelementptr inbounds i8, ptr %0, i64 12
  %18 = load i32, ptr %17, align 4, !tbaa !14
  %19 = add nsw i32 %18, %2
  %20 = getelementptr inbounds i8, ptr %7, i64 12
  %21 = load i32, ptr %20, align 4, !tbaa !14
  %22 = icmp sgt i32 %19, %21
  br i1 %22, label %51, label %.preheader

.preheader:                                       ; preds = %16
  %23 = icmp sgt i32 %11, 0
  br i1 %23, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader
  %24 = getelementptr inbounds i8, ptr %7, i64 56
  %25 = zext nneg i32 %2 to i64
  %26 = getelementptr inbounds i8, ptr %0, i64 56
  %27 = zext i32 %1 to i64
  %wide.trip.count = zext nneg i32 %11 to i64
  %xtraiter = and i64 %wide.trip.count, 1
  %28 = icmp eq i32 %11, 1
  br i1 %28, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i64 %wide.trip.count, 2147483646
  br label %29

29:                                               ; preds = %29, %.lr.ph.new
  %indvars.iv35 = phi i64 [ 0, %.lr.ph.new ], [ %indvars.iv.next36.1, %29 ]
  %indvars.iv = phi i64 [ %27, %.lr.ph.new ], [ %indvars.iv.next.1, %29 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.1, %29 ]
  %30 = load ptr, ptr %24, align 8, !tbaa !15
  %31 = getelementptr inbounds ptr, ptr %30, i64 %indvars.iv
  %32 = load ptr, ptr %31, align 8, !tbaa !16
  %33 = getelementptr inbounds i64, ptr %32, i64 %25
  %34 = load ptr, ptr %26, align 8, !tbaa !15
  %35 = getelementptr inbounds ptr, ptr %34, i64 %indvars.iv35
  store ptr %33, ptr %35, align 8, !tbaa !16
  %indvars.iv.next36 = or disjoint i64 %indvars.iv35, 1
  %36 = load ptr, ptr %24, align 8, !tbaa !15
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %37 = getelementptr inbounds ptr, ptr %36, i64 %indvars.iv
  %38 = getelementptr inbounds i8, ptr %37, i64 8
  %39 = load ptr, ptr %38, align 8, !tbaa !16
  %40 = getelementptr inbounds i64, ptr %39, i64 %25
  %41 = load ptr, ptr %26, align 8, !tbaa !15
  %42 = getelementptr inbounds ptr, ptr %41, i64 %indvars.iv.next36
  store ptr %40, ptr %42, align 8, !tbaa !16
  %indvars.iv.next36.1 = add nuw nsw i64 %indvars.iv35, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.loopexit.unr-lcssa, label %29, !llvm.loop !17

._crit_edge.loopexit.unr-lcssa:                   ; preds = %29, %.lr.ph
  %indvars.iv35.unr = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next36.1, %29 ]
  %indvars.iv.unr = phi i64 [ %27, %.lr.ph ], [ %indvars.iv.next.1, %29 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %._crit_edge.loopexit.epilog-lcssa

._crit_edge.loopexit.epilog-lcssa:                ; preds = %._crit_edge.loopexit.unr-lcssa
  %43 = load ptr, ptr %24, align 8, !tbaa !15
  %44 = getelementptr inbounds ptr, ptr %43, i64 %indvars.iv.unr
  %45 = load ptr, ptr %44, align 8, !tbaa !16
  %46 = getelementptr inbounds i64, ptr %45, i64 %25
  %47 = load ptr, ptr %26, align 8, !tbaa !15
  %48 = getelementptr inbounds ptr, ptr %47, i64 %indvars.iv35.unr
  store ptr %46, ptr %48, align 8, !tbaa !16
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit.epilog-lcssa, %._crit_edge.loopexit.unr-lcssa, %.preheader
  %49 = getelementptr inbounds i8, ptr %0, i64 96
  store i32 %1, ptr %49, align 8, !tbaa !19
  %50 = getelementptr inbounds i8, ptr %0, i64 92
  store i32 %2, ptr %50, align 4, !tbaa !20
  br label %51

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

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 = { 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, !12, i64 104}
!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 8}
!14 = !{!6, !7, i64 12}
!15 = !{!6, !12, i64 56}
!16 = !{!12, !12, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!6, !7, i64 96}
!20 = !{!6, !7, i64 92}


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