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

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

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

10:                                               ; preds = %2
  %11 = load i32, ptr %5, align 4, !tbaa !5
  %12 = icmp sgt i32 %11, 0
  br i1 %12, label %13, label %14

13:                                               ; preds = %10
  br label %15

14:                                               ; preds = %10, %2
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 89, ptr noundef @__PRETTY_FUNCTION__.newpad) #5
  unreachable

15:                                               ; preds = %13
  %16 = load i32, ptr %4, align 4, !tbaa !5
  %17 = load i32, ptr %5, align 4, !tbaa !5
  %18 = call ptr @PDC_makenew(i32 noundef %16, i32 noundef %17, i32 noundef 0, i32 noundef 0)
  store ptr %18, ptr %6, align 8, !tbaa !9
  %19 = load ptr, ptr %6, align 8, !tbaa !9
  %20 = icmp ne ptr %19, null
  br i1 %20, label %21, label %24

21:                                               ; preds = %15
  %22 = load ptr, ptr %6, align 8, !tbaa !9
  %23 = call ptr @PDC_makelines(ptr noundef %22)
  store ptr %23, ptr %6, align 8, !tbaa !9
  br label %24

24:                                               ; preds = %21, %15
  %25 = load ptr, ptr %6, align 8, !tbaa !9
  %26 = icmp ne ptr %25, null
  br i1 %26, label %28, label %27

27:                                               ; preds = %24
  store ptr null, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %67

28:                                               ; preds = %24
  %29 = load ptr, ptr %6, align 8, !tbaa !9
  %30 = call i32 @werase(ptr noundef %29)
  %31 = load ptr, ptr %6, align 8, !tbaa !9
  %32 = getelementptr inbounds %struct._win, ptr %31, i32 0, i32 6
  store i32 16, ptr %32, align 8, !tbaa !11
  %33 = load ptr, ptr %6, align 8, !tbaa !9
  %34 = getelementptr inbounds %struct._win, ptr %33, i32 0, i32 25
  store i32 0, ptr %34, align 8, !tbaa !15
  %35 = load ptr, ptr %6, align 8, !tbaa !9
  %36 = getelementptr inbounds %struct._win, ptr %35, i32 0, i32 26
  store i32 0, ptr %36, align 4, !tbaa !16
  %37 = load ptr, ptr %6, align 8, !tbaa !9
  %38 = getelementptr inbounds %struct._win, ptr %37, i32 0, i32 27
  store i32 0, ptr %38, align 8, !tbaa !17
  %39 = load ptr, ptr %6, align 8, !tbaa !9
  %40 = getelementptr inbounds %struct._win, ptr %39, i32 0, i32 29
  store i32 0, ptr %40, align 8, !tbaa !18
  %41 = load i32, ptr @LINES, align 4, !tbaa !5
  %42 = load i32, ptr %4, align 4, !tbaa !5
  %43 = icmp slt i32 %41, %42
  br i1 %43, label %44, label %46

44:                                               ; preds = %28
  %45 = load i32, ptr @LINES, align 4, !tbaa !5
  br label %48

46:                                               ; preds = %28
  %47 = load i32, ptr %4, align 4, !tbaa !5
  br label %48

48:                                               ; preds = %46, %44
  %49 = phi i32 [ %45, %44 ], [ %47, %46 ]
  %50 = sub nsw i32 %49, 1
  %51 = load ptr, ptr %6, align 8, !tbaa !9
  %52 = getelementptr inbounds %struct._win, ptr %51, i32 0, i32 28
  store i32 %50, ptr %52, align 4, !tbaa !19
  %53 = load i32, ptr @COLS, align 4, !tbaa !5
  %54 = load i32, ptr %5, align 4, !tbaa !5
  %55 = icmp slt i32 %53, %54
  br i1 %55, label %56, label %58

56:                                               ; preds = %48
  %57 = load i32, ptr @COLS, align 4, !tbaa !5
  br label %60

58:                                               ; preds = %48
  %59 = load i32, ptr %5, align 4, !tbaa !5
  br label %60

60:                                               ; preds = %58, %56
  %61 = phi i32 [ %57, %56 ], [ %59, %58 ]
  %62 = sub nsw i32 %61, 1
  %63 = load ptr, ptr %6, align 8, !tbaa !9
  %64 = getelementptr inbounds %struct._win, ptr %63, i32 0, i32 30
  store i32 %62, ptr %64, align 4, !tbaa !20
  %65 = load ptr, ptr %6, align 8, !tbaa !9
  call void @PDC_add_window_to_list(ptr noundef %65)
  %66 = load ptr, ptr %6, align 8, !tbaa !9
  store ptr %66, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %67

67:                                               ; preds = %60, %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %68 = load ptr, ptr %3, align 8
  ret ptr %68
}

; 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

declare ptr @PDC_makenew(i32 noundef, i32 noundef, i32 noundef, i32 noundef) #3

declare ptr @PDC_makelines(ptr noundef) #3

declare i32 @werase(ptr noundef) #3

declare void @PDC_add_window_to_list(ptr noundef) #3

; 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 = { "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 = !{!"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, !6, i64 24}
!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, !6, i64 112}
!16 = !{!12, !6, i64 116}
!17 = !{!12, !6, i64 120}
!18 = !{!12, !6, i64 128}
!19 = !{!12, !6, i64 124}
!20 = !{!12, !6, i64 132}


; 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 [89 x i8], align 1
@__PRETTY_FUNCTION__.newpad = external hidden unnamed_addr constant [25 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 ptr @newpad(i32 noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = icmp sgt i32 %0, 0
  %4 = icmp sgt i32 %1, 0
  %or.cond = and i1 %3, %4
  br i1 %or.cond, label %6, label %5

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

6:                                                ; preds = %2
  %7 = tail call ptr @PDC_makenew(i32 noundef %0, i32 noundef %1, i32 noundef 0, i32 noundef 0) #5
  %.not = icmp eq ptr %7, null
  br i1 %.not, label %.thread, label %8

8:                                                ; preds = %6
  %9 = tail call ptr @PDC_makelines(ptr noundef nonnull %7) #5
  %.not26 = icmp eq ptr %9, null
  br i1 %.not26, label %.thread, label %10

10:                                               ; preds = %8
  %11 = tail call i32 @werase(ptr noundef nonnull %9) #5
  %12 = getelementptr inbounds i8, ptr %9, i64 24
  store i32 16, ptr %12, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %9, i64 112
  store i32 0, ptr %13, align 8, !tbaa !13
  %14 = getelementptr inbounds i8, ptr %9, i64 116
  store i32 0, ptr %14, align 4, !tbaa !14
  %15 = getelementptr inbounds i8, ptr %9, i64 120
  store i32 0, ptr %15, align 8, !tbaa !15
  %16 = getelementptr inbounds i8, ptr %9, i64 128
  store i32 0, ptr %16, align 8, !tbaa !16
  %17 = load i32, ptr @LINES, align 4
  %18 = tail call i32 @llvm.smin.i32(i32 %17, i32 %0)
  %19 = add nsw i32 %18, -1
  %20 = getelementptr inbounds i8, ptr %9, i64 124
  store i32 %19, ptr %20, align 4, !tbaa !17
  %21 = load i32, ptr @COLS, align 4
  %22 = tail call i32 @llvm.smin.i32(i32 %21, i32 %1)
  %23 = add nsw i32 %22, -1
  %24 = getelementptr inbounds i8, ptr %9, i64 132
  store i32 %23, ptr %24, align 4, !tbaa !18
  tail call void @PDC_add_window_to_list(ptr noundef nonnull %9) #5
  br label %.thread

.thread:                                          ; preds = %6, %8, %10
  %.022 = phi ptr [ %9, %10 ], [ null, %8 ], [ null, %6 ]
  ret ptr %.022
}

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

declare ptr @PDC_makenew(i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

declare ptr @PDC_makelines(ptr noundef) local_unnamed_addr #2

declare i32 @werase(ptr noundef) local_unnamed_addr #2

declare void @PDC_add_window_to_list(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 = { 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 = { "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 24}
!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 112}
!14 = !{!6, !7, i64 116}
!15 = !{!6, !7, i64 120}
!16 = !{!6, !7, i64 128}
!17 = !{!6, !7, i64 124}
!18 = !{!6, !7, i64 132}


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