; LLVM IR from freakout42/macrocalc :: mc/mex (term)

; 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.TERM = type { i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.termios = type { i32, i32, i32, i32, i8, [32 x i8], i32, i32 }
%struct.termtype = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, i16, i16, i16, i16, i16, i16 }
%struct._win_st = type { i16, i16, i16, i16, i16, i16, i16, i32, i32, i8, i8, i8, i8, i8, i8, i8, i8, i8, i32, ptr, i16, i16, i32, i32, ptr, %struct.pdat, i16 }
%struct.pdat = type { i16, i16, i16, i16, i16, i16 }

@windw1 = external dso_local global ptr, align 8
@cur_term = external global ptr, align 8
@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [23 x i8], align 1
@term = external dso_local global %struct.TERM, align 8
@stdin = external global ptr, align 8
@stdscr = external global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local i32 @ttopen() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca %struct.termios, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 60, ptr %5) #5
  %6 = load ptr, ptr @windw1, align 8, !tbaa !5
  %7 = icmp eq ptr %6, null
  br i1 %7, label %8, label %50

8:                                                ; preds = %0
  %9 = call ptr @initscr()
  store ptr %9, ptr @windw1, align 8, !tbaa !5
  %10 = load ptr, ptr @cur_term, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.termtype, ptr %10, i32 0, i32 3
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  %13 = getelementptr inbounds i16, ptr %12, i64 1
  store i16 0, ptr %13, align 2, !tbaa !12
  %14 = load ptr, ptr @windw1, align 8, !tbaa !5
  %15 = icmp eq ptr %14, null
  br i1 %15, label %16, label %19

16:                                               ; preds = %8
  %17 = load ptr, ptr @stderr, align 8, !tbaa !5
  %18 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %17, ptr noundef @.str) #5
  call void @exit(i32 noundef 1) #6
  unreachable

19:                                               ; preds = %8
  %20 = load ptr, ptr @cur_term, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.termtype, ptr %20, i32 0, i32 3
  %22 = load ptr, ptr %21, align 8, !tbaa !9
  %23 = getelementptr inbounds i16, ptr %22, i64 0
  %24 = load i16, ptr %23, align 2, !tbaa !12
  %25 = sext i16 %24 to i32
  store i32 %25, ptr getelementptr inbounds (%struct.TERM, ptr @term, i32 0, i32 1), align 4, !tbaa !13
  %26 = load ptr, ptr @cur_term, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.termtype, ptr %26, i32 0, i32 3
  %28 = load ptr, ptr %27, align 8, !tbaa !9
  %29 = getelementptr inbounds i16, ptr %28, i64 2
  %30 = load i16, ptr %29, align 2, !tbaa !12
  %31 = sext i16 %30 to i32
  %32 = sub nsw i32 %31, 1
  store i32 %32, ptr @term, align 8, !tbaa !16
  %33 = call ptr @signal(i32 noundef 20, ptr noundef inttoptr (i64 1 to ptr)) #5
  %34 = load ptr, ptr @stdin, align 8, !tbaa !5
  %35 = call i32 @fileno(ptr noundef %34) #5
  %36 = call i32 @tcgetattr(i32 noundef %35, ptr noundef %5) #5
  %37 = getelementptr inbounds %struct.termios, ptr %5, i32 0, i32 5
  %38 = getelementptr inbounds [32 x i8], ptr %37, i64 0, i64 0
  store i8 0, ptr %38, align 1, !tbaa !17
  %39 = getelementptr inbounds %struct.termios, ptr %5, i32 0, i32 5
  %40 = getelementptr inbounds [32 x i8], ptr %39, i64 0, i64 10
  store i8 0, ptr %40, align 1, !tbaa !17
  %41 = getelementptr inbounds %struct.termios, ptr %5, i32 0, i32 5
  %42 = getelementptr inbounds [32 x i8], ptr %41, i64 0, i64 15
  store i8 0, ptr %42, align 1, !tbaa !17
  %43 = load ptr, ptr @stdin, align 8, !tbaa !5
  %44 = call i32 @fileno(ptr noundef %43) #5
  %45 = call i32 @tcsetattr(i32 noundef %44, i32 noundef 0, ptr noundef %5) #5
  %46 = call i32 @nonl()
  %47 = call i32 @noecho()
  %48 = load ptr, ptr @stdscr, align 8, !tbaa !5
  %49 = call i32 @keypad(ptr noundef %48, i1 noundef zeroext true)
  br label %142

50:                                               ; preds = %0
  %51 = load ptr, ptr @windw1, align 8, !tbaa !5
  %52 = load ptr, ptr @stdscr, align 8, !tbaa !5
  %53 = icmp eq ptr %51, %52
  br i1 %53, label %54, label %62

54:                                               ; preds = %50
  %55 = load ptr, ptr @stdscr, align 8, !tbaa !5
  %56 = call i32 @wrefresh(ptr noundef %55)
  %57 = call ptr @newwin(i32 noundef 21, i32 noundef 62, i32 noundef 2, i32 noundef 18)
  store ptr %57, ptr @windw1, align 8, !tbaa !5
  %58 = load ptr, ptr @windw1, align 8, !tbaa !5
  %59 = call i32 @wborder(ptr noundef %58, i32 noundef 0, i32 noundef 0, i32 noundef 0, i32 noundef 0, i32 noundef 0, i32 noundef 0, i32 noundef 0, i32 noundef 0)
  %60 = load ptr, ptr @windw1, align 8, !tbaa !5
  %61 = call i32 @wrefresh(ptr noundef %60)
  br label %62

62:                                               ; preds = %54, %50
  %63 = load ptr, ptr @windw1, align 8, !tbaa !5
  %64 = icmp ne ptr null, %63
  br i1 %64, label %65, label %71

65:                                               ; preds = %62
  %66 = load ptr, ptr @windw1, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct._win_st, ptr %66, i32 0, i32 2
  %68 = load i16, ptr %67, align 4, !tbaa !18
  %69 = sext i16 %68 to i32
  %70 = add nsw i32 %69, 1
  br label %72

71:                                               ; preds = %62
  br label %72

72:                                               ; preds = %71, %65
  %73 = phi i32 [ %70, %65 ], [ -1, %71 ]
  store i32 %73, ptr %1, align 4, !tbaa !22
  %74 = load ptr, ptr @windw1, align 8, !tbaa !5
  %75 = icmp ne ptr null, %74
  br i1 %75, label %76, label %82

76:                                               ; preds = %72
  %77 = load ptr, ptr @windw1, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct._win_st, ptr %77, i32 0, i32 3
  %79 = load i16, ptr %78, align 2, !tbaa !23
  %80 = sext i16 %79 to i32
  %81 = add nsw i32 %80, 1
  br label %83

82:                                               ; preds = %72
  br label %83

83:                                               ; preds = %82, %76
  %84 = phi i32 [ %81, %76 ], [ -1, %82 ]
  store i32 %84, ptr %2, align 4, !tbaa !22
  %85 = load ptr, ptr @windw1, align 8, !tbaa !5
  %86 = icmp ne ptr null, %85
  br i1 %86, label %87, label %92

87:                                               ; preds = %83
  %88 = load ptr, ptr @windw1, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct._win_st, ptr %88, i32 0, i32 4
  %90 = load i16, ptr %89, align 8, !tbaa !24
  %91 = sext i16 %90 to i32
  br label %93

92:                                               ; preds = %83
  br label %93

93:                                               ; preds = %92, %87
  %94 = phi i32 [ %91, %87 ], [ -1, %92 ]
  store i32 %94, ptr %3, align 4, !tbaa !22
  %95 = load ptr, ptr @windw1, align 8, !tbaa !5
  %96 = icmp ne ptr null, %95
  br i1 %96, label %97, label %102

97:                                               ; preds = %93
  %98 = load ptr, ptr @windw1, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct._win_st, ptr %98, i32 0, i32 5
  %100 = load i16, ptr %99, align 2, !tbaa !25
  %101 = sext i16 %100 to i32
  br label %103

102:                                              ; preds = %93
  br label %103

103:                                              ; preds = %102, %97
  %104 = phi i32 [ %101, %97 ], [ -1, %102 ]
  store i32 %104, ptr %4, align 4, !tbaa !22
  %105 = load i32, ptr %1, align 4, !tbaa !22
  %106 = sub nsw i32 %105, 2
  %107 = load i32, ptr %2, align 4, !tbaa !22
  %108 = sub nsw i32 %107, 2
  %109 = load i32, ptr %3, align 4, !tbaa !22
  %110 = add nsw i32 %109, 1
  %111 = load i32, ptr %4, align 4, !tbaa !22
  %112 = add nsw i32 %111, 1
  %113 = call ptr @newwin(i32 noundef %106, i32 noundef %108, i32 noundef %110, i32 noundef %112)
  store ptr %113, ptr @windw1, align 8, !tbaa !5
  %114 = load ptr, ptr @windw1, align 8, !tbaa !5
  %115 = icmp ne ptr null, %114
  br i1 %115, label %116, label %122

116:                                              ; preds = %103
  %117 = load ptr, ptr @windw1, align 8, !tbaa !5
  %118 = getelementptr inbounds %struct._win_st, ptr %117, i32 0, i32 2
  %119 = load i16, ptr %118, align 4, !tbaa !18
  %120 = sext i16 %119 to i32
  %121 = add nsw i32 %120, 1
  br label %123

122:                                              ; preds = %103
  br label %123

123:                                              ; preds = %122, %116
  %124 = phi i32 [ %121, %116 ], [ -1, %122 ]
  store i32 %124, ptr @term, align 8, !tbaa !16
  %125 = load ptr, ptr @windw1, align 8, !tbaa !5
  %126 = icmp ne ptr null, %125
  br i1 %126, label %127, label %133

127:                                              ; preds = %123
  %128 = load ptr, ptr @windw1, align 8, !tbaa !5
  %129 = getelementptr inbounds %struct._win_st, ptr %128, i32 0, i32 3
  %130 = load i16, ptr %129, align 2, !tbaa !23
  %131 = sext i16 %130 to i32
  %132 = add nsw i32 %131, 1
  br label %134

133:                                              ; preds = %123
  br label %134

134:                                              ; preds = %133, %127
  %135 = phi i32 [ %132, %127 ], [ -1, %133 ]
  store i32 %135, ptr getelementptr inbounds (%struct.TERM, ptr @term, i32 0, i32 1), align 4, !tbaa !13
  %136 = load i32, ptr @term, align 8, !tbaa !16
  %137 = add nsw i32 %136, -1
  store i32 %137, ptr @term, align 8, !tbaa !16
  %138 = load i32, ptr getelementptr inbounds (%struct.TERM, ptr @term, i32 0, i32 1), align 4, !tbaa !13
  %139 = add nsw i32 %138, 0
  store i32 %139, ptr getelementptr inbounds (%struct.TERM, ptr @term, i32 0, i32 1), align 4, !tbaa !13
  %140 = load ptr, ptr @windw1, align 8, !tbaa !5
  %141 = call i32 @wrefresh(ptr noundef %140)
  br label %142

142:                                              ; preds = %134, %19
  call void @llvm.lifetime.end.p0(i64 60, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #5
  ret i32 0
}

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

declare ptr @initscr() #2

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #3

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #4

; Function Attrs: nounwind
declare ptr @signal(i32 noundef, ptr noundef) #3

; Function Attrs: nounwind
declare i32 @tcgetattr(i32 noundef, ptr noundef) #3

; Function Attrs: nounwind
declare i32 @fileno(ptr noundef) #3

; Function Attrs: nounwind
declare i32 @tcsetattr(i32 noundef, i32 noundef, ptr noundef) #3

declare i32 @nonl() #2

declare i32 @noecho() #2

declare i32 @keypad(ptr noundef, i1 noundef zeroext) #2

declare i32 @wrefresh(ptr noundef) #2

declare ptr @newwin(i32 noundef, i32 noundef, i32 noundef, i32 noundef) #2

declare i32 @wborder(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #2

; 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 = { "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 "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 = { 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 #5 = { nounwind }
attributes #6 = { 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, !6, i64 24}
!10 = !{!"termtype", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !11, i64 56, !11, i64 58, !11, i64 60, !11, i64 62, !11, i64 64, !11, i64 66}
!11 = !{!"short", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!14, !15, i64 4}
!14 = !{!"", !15, i64 0, !15, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96}
!15 = !{!"int", !7, i64 0}
!16 = !{!14, !15, i64 0}
!17 = !{!7, !7, i64 0}
!18 = !{!19, !11, i64 4}
!19 = !{!"_win_st", !11, i64 0, !11, i64 2, !11, i64 4, !11, i64 6, !11, i64 8, !11, i64 10, !11, i64 12, !15, i64 16, !15, i64 20, !20, i64 24, !20, i64 25, !20, i64 26, !20, i64 27, !20, i64 28, !20, i64 29, !20, i64 30, !20, i64 31, !20, i64 32, !15, i64 36, !6, i64 40, !11, i64 48, !11, i64 50, !15, i64 52, !15, i64 56, !6, i64 64, !21, i64 72, !11, i64 84}
!20 = !{!"_Bool", !7, i64 0}
!21 = !{!"pdat", !11, i64 0, !11, i64 2, !11, i64 4, !11, i64 6, !11, i64 8, !11, i64 10}
!22 = !{!15, !15, i64 0}
!23 = !{!19, !11, i64 6}
!24 = !{!19, !11, i64 8}
!25 = !{!19, !11, i64 10}


; 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"

%struct.TERM = type { i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.termios = type { i32, i32, i32, i32, i8, [32 x i8], i32, i32 }

@windw1 = external dso_local local_unnamed_addr global ptr, align 8
@cur_term = external local_unnamed_addr global ptr, align 8
@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [23 x i8], align 1
@term = external dso_local local_unnamed_addr global %struct.TERM, align 8
@stdin = external local_unnamed_addr global ptr, align 8
@stdscr = external local_unnamed_addr global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @ttopen() local_unnamed_addr #0 {
  %1 = alloca %struct.termios, align 4
  call void @llvm.lifetime.start.p0(i64 60, ptr nonnull %1) #6
  %2 = load ptr, ptr @windw1, align 8, !tbaa !5
  %3 = icmp eq ptr %2, null
  br i1 %3, label %4, label %35

4:                                                ; preds = %0
  %5 = tail call ptr @initscr() #6
  store ptr %5, ptr @windw1, align 8, !tbaa !5
  %6 = load ptr, ptr @cur_term, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %6, i64 24
  %8 = load ptr, ptr %7, align 8, !tbaa !9
  %9 = getelementptr inbounds i8, ptr %8, i64 2
  store i16 0, ptr %9, align 2, !tbaa !12
  %10 = icmp eq ptr %5, null
  br i1 %10, label %11, label %14

11:                                               ; preds = %4
  %12 = load ptr, ptr @stderr, align 8, !tbaa !5
  %13 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str) #7
  tail call void @exit(i32 noundef 1) #8
  unreachable

14:                                               ; preds = %4
  %15 = load i16, ptr %8, align 2, !tbaa !12
  %16 = sext i16 %15 to i32
  store i32 %16, ptr getelementptr inbounds (i8, ptr @term, i64 4), align 4, !tbaa !13
  %17 = getelementptr inbounds i8, ptr %8, i64 4
  %18 = load i16, ptr %17, align 2, !tbaa !12
  %19 = sext i16 %18 to i32
  %20 = add nsw i32 %19, -1
  store i32 %20, ptr @term, align 8, !tbaa !16
  %21 = tail call ptr @signal(i32 noundef 20, ptr noundef nonnull inttoptr (i64 1 to ptr)) #6
  %22 = load ptr, ptr @stdin, align 8, !tbaa !5
  %23 = tail call i32 @fileno(ptr noundef %22) #6
  %24 = call i32 @tcgetattr(i32 noundef %23, ptr noundef nonnull %1) #6
  %25 = getelementptr inbounds i8, ptr %1, i64 17
  store i8 0, ptr %25, align 1, !tbaa !17
  %26 = getelementptr inbounds i8, ptr %1, i64 27
  store i8 0, ptr %26, align 1, !tbaa !17
  %27 = getelementptr inbounds i8, ptr %1, i64 32
  store i8 0, ptr %27, align 4, !tbaa !17
  %28 = load ptr, ptr @stdin, align 8, !tbaa !5
  %29 = call i32 @fileno(ptr noundef %28) #6
  %30 = call i32 @tcsetattr(i32 noundef %29, i32 noundef 0, ptr noundef nonnull %1) #6
  %31 = call i32 @nonl() #6
  %32 = call i32 @noecho() #6
  %33 = load ptr, ptr @stdscr, align 8, !tbaa !5
  %34 = call i32 @keypad(ptr noundef %33, i1 noundef zeroext true) #6
  br label %74

35:                                               ; preds = %0
  %36 = load ptr, ptr @stdscr, align 8, !tbaa !5
  %37 = icmp eq ptr %2, %36
  br i1 %37, label %38, label %.thread22

38:                                               ; preds = %35
  %39 = tail call i32 @wrefresh(ptr noundef %36) #6
  %40 = tail call ptr @newwin(i32 noundef 21, i32 noundef 62, i32 noundef 2, i32 noundef 18) #6
  store ptr %40, ptr @windw1, align 8, !tbaa !5
  %41 = tail call i32 @wborder(ptr noundef %40, i32 noundef 0, i32 noundef 0, i32 noundef 0, i32 noundef 0, i32 noundef 0, i32 noundef 0, i32 noundef 0, i32 noundef 0) #6
  %42 = load ptr, ptr @windw1, align 8, !tbaa !5
  %43 = tail call i32 @wrefresh(ptr noundef %42) #6
  %.pr = load ptr, ptr @windw1, align 8, !tbaa !5
  %.not = icmp eq ptr %.pr, null
  br i1 %.not, label %.thread28, label %.thread22

.thread22:                                        ; preds = %35, %38
  %44 = phi ptr [ %.pr, %38 ], [ %2, %35 ]
  %.in.in.in = getelementptr inbounds i8, ptr %44, i64 4
  %.in.in = load i16, ptr %.in.in.in, align 4, !tbaa !18
  %.in = sext i16 %.in.in to i32
  %45 = add nsw i32 %.in, -1
  %46 = getelementptr inbounds i8, ptr %44, i64 6
  %47 = load i16, ptr %46, align 2, !tbaa !22
  %48 = sext i16 %47 to i32
  %49 = add nsw i32 %48, -1
  %50 = getelementptr inbounds i8, ptr %44, i64 8
  %51 = load i16, ptr %50, align 8, !tbaa !23
  %52 = sext i16 %51 to i32
  %53 = add nsw i32 %52, 1
  %54 = getelementptr inbounds i8, ptr %44, i64 10
  %55 = load i16, ptr %54, align 2, !tbaa !24
  %56 = sext i16 %55 to i32
  %57 = add nsw i32 %56, 1
  br label %.thread28

.thread28:                                        ; preds = %38, %.thread22
  %58 = phi i32 [ %53, %.thread22 ], [ 0, %38 ]
  %59 = phi i32 [ %45, %.thread22 ], [ -3, %38 ]
  %60 = phi i32 [ %49, %.thread22 ], [ -3, %38 ]
  %61 = phi i32 [ %57, %.thread22 ], [ 0, %38 ]
  %62 = tail call ptr @newwin(i32 noundef %59, i32 noundef %60, i32 noundef %58, i32 noundef %61) #6
  store ptr %62, ptr @windw1, align 8, !tbaa !5
  %.not14 = icmp eq ptr %62, null
  br i1 %.not14, label %.thread30, label %63

63:                                               ; preds = %.thread28
  %64 = getelementptr inbounds i8, ptr %62, i64 4
  %65 = load i16, ptr %64, align 4, !tbaa !18
  %66 = sext i16 %65 to i32
  %67 = getelementptr inbounds i8, ptr %62, i64 6
  %68 = load i16, ptr %67, align 2, !tbaa !22
  %69 = sext i16 %68 to i32
  %70 = add nsw i32 %69, 1
  br label %.thread30

.thread30:                                        ; preds = %.thread28, %63
  %71 = phi i32 [ %66, %63 ], [ -2, %.thread28 ]
  %72 = phi i32 [ %70, %63 ], [ -1, %.thread28 ]
  store i32 %72, ptr getelementptr inbounds (i8, ptr @term, i64 4), align 4, !tbaa !13
  store i32 %71, ptr @term, align 8, !tbaa !16
  %73 = tail call i32 @wrefresh(ptr noundef %62) #6
  br label %74

74:                                               ; preds = %.thread30, %14
  call void @llvm.lifetime.end.p0(i64 60, ptr nonnull %1) #6
  ret i32 0
}

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

declare ptr @initscr() local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #3

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #4

; Function Attrs: nounwind
declare ptr @signal(i32 noundef, ptr noundef) local_unnamed_addr #5

; Function Attrs: nounwind
declare i32 @tcgetattr(i32 noundef, ptr noundef) local_unnamed_addr #5

; Function Attrs: nofree nounwind
declare noundef i32 @fileno(ptr nocapture noundef) local_unnamed_addr #3

; Function Attrs: nounwind
declare i32 @tcsetattr(i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #5

declare i32 @nonl() local_unnamed_addr #2

declare i32 @noecho() local_unnamed_addr #2

declare i32 @keypad(ptr noundef, i1 noundef zeroext) local_unnamed_addr #2

declare i32 @wrefresh(ptr noundef) local_unnamed_addr #2

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

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

; Function Attrs: mustprogress 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nofree 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 #4 = { 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 #5 = { 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 #6 = { nounwind }
attributes #7 = { cold nounwind }
attributes #8 = { 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, !6, i64 24}
!10 = !{!"termtype", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !11, i64 56, !11, i64 58, !11, i64 60, !11, i64 62, !11, i64 64, !11, i64 66}
!11 = !{!"short", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!14, !15, i64 4}
!14 = !{!"", !15, i64 0, !15, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96}
!15 = !{!"int", !7, i64 0}
!16 = !{!14, !15, i64 0}
!17 = !{!7, !7, i64 0}
!18 = !{!19, !11, i64 4}
!19 = !{!"_win_st", !11, i64 0, !11, i64 2, !11, i64 4, !11, i64 6, !11, i64 8, !11, i64 10, !11, i64 12, !15, i64 16, !15, i64 20, !20, i64 24, !20, i64 25, !20, i64 26, !20, i64 27, !20, i64 28, !20, i64 29, !20, i64 30, !20, i64 31, !20, i64 32, !15, i64 36, !6, i64 40, !11, i64 48, !11, i64 50, !15, i64 52, !15, i64 56, !6, i64 64, !21, i64 72, !11, i64 84}
!20 = !{!"_Bool", !7, i64 0}
!21 = !{!"pdat", !11, i64 0, !11, i64 2, !11, i64 4, !11, i64 6, !11, i64 8, !11, i64 10}
!22 = !{!19, !11, i64 6}
!23 = !{!19, !11, i64 8}
!24 = !{!19, !11, i64 10}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass