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

; 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.RIPPEDOFFLINE = type { i32, ptr }
%struct.MOUSE_STATUS = type { i32, i32, [9 x i16], i32 }
%struct.SCREEN = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i16, i16, i32, i32, i32, i32, i32, i32, i64, i32, i32, ptr, i32, i32, i32, i8, i32, i64, i8, i8, %struct.MOUSE_STATUS, i16, i64, ptr, ptr, i8, i8, i32, i32, ptr, i32, i32, ptr, i32, i32, ptr }
%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 }
%struct._opaque_screen_t = type { ptr, i32, i32, i8, ptr, i32, i32, i32, ptr, i32, i8, ptr, ptr }

@SP = external dso_local global ptr, align 8
@curscr = external dso_local global ptr, align 8
@stdscr = external dso_local global ptr, align 8
@LINES = external dso_local global i32, align 4
@COLS = external dso_local global i32, align 4
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [93 x i8], align 1
@__PRETTY_FUNCTION__.newterm = external hidden unnamed_addr constant [46 x i8], align 1
@stderr = external global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [42 x i8], align 1
@linesrippedoff = external global i8, align 1
@linesripped = external global [5 x %struct.RIPPEDOFFLINE], align 16
@.str.7 = external hidden unnamed_addr constant [37 x i8], align 1
@Mouse_status = external dso_local global %struct.MOUSE_STATUS, align 4

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

13:                                               ; preds = %3
  %14 = load ptr, ptr @SP, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.SCREEN, ptr %14, i32 0, i32 0
  %16 = load i8, ptr %15, align 8, !tbaa !9, !range !16, !noundef !17
  %17 = trunc i8 %16 to i1
  br i1 %17, label %18, label %19

18:                                               ; preds = %13
  store ptr null, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %256

19:                                               ; preds = %13, %3
  %20 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 216) #8
  store ptr %20, ptr @SP, align 8, !tbaa !5
  %21 = load ptr, ptr @SP, align 8, !tbaa !5
  %22 = icmp ne ptr %21, null
  br i1 %22, label %23, label %24

23:                                               ; preds = %19
  br label %25

24:                                               ; preds = %19
  call void @__assert_fail(ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 161, ptr noundef @__PRETTY_FUNCTION__.newterm) #9
  unreachable

25:                                               ; preds = %23
  %26 = load ptr, ptr @SP, align 8, !tbaa !5
  %27 = icmp ne ptr %26, null
  br i1 %27, label %29, label %28

28:                                               ; preds = %25
  store ptr null, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %256

29:                                               ; preds = %25
  %30 = call i32 @PDC_scr_open()
  %31 = icmp eq i32 %30, -1
  br i1 %31, label %32, label %35

32:                                               ; preds = %29
  %33 = load ptr, ptr @stderr, align 8, !tbaa !5
  %34 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %33, ptr noundef @.str.3) #7
  call void @exit(i32 noundef 8) #9
  unreachable

35:                                               ; preds = %29
  %36 = load ptr, ptr @SP, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.SCREEN, ptr %36, i32 0, i32 1
  store i8 1, ptr %37, align 1, !tbaa !18
  %38 = load ptr, ptr @SP, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.SCREEN, ptr %38, i32 0, i32 5
  store i8 0, ptr %39, align 1, !tbaa !19
  %40 = load ptr, ptr @SP, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.SCREEN, ptr %40, i32 0, i32 4
  store i8 0, ptr %41, align 4, !tbaa !20
  %42 = load ptr, ptr @SP, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.SCREEN, ptr %42, i32 0, i32 2
  store i8 1, ptr %43, align 2, !tbaa !21
  %44 = load ptr, ptr @SP, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.SCREEN, ptr %44, i32 0, i32 27
  store i64 0, ptr %45, align 8, !tbaa !22
  %46 = load ptr, ptr @SP, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.SCREEN, ptr %46, i32 0, i32 28
  store i8 0, ptr %47, align 8, !tbaa !23
  %48 = load ptr, ptr @SP, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.SCREEN, ptr %48, i32 0, i32 3
  store i8 1, ptr %49, align 1, !tbaa !24
  %50 = load ptr, ptr @SP, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.SCREEN, ptr %50, i32 0, i32 14
  store i32 1, ptr %51, align 8, !tbaa !25
  %52 = load ptr, ptr @SP, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.SCREEN, ptr %52, i32 0, i32 8
  store i8 0, ptr %53, align 8, !tbaa !26
  %54 = load ptr, ptr @SP, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.SCREEN, ptr %54, i32 0, i32 18
  store i64 0, ptr %55, align 8, !tbaa !27
  %56 = load ptr, ptr @SP, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.SCREEN, ptr %56, i32 0, i32 22
  store i32 0, ptr %57, align 8, !tbaa !28
  %58 = load ptr, ptr @SP, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.SCREEN, ptr %58, i32 0, i32 23
  store i32 0, ptr %59, align 4, !tbaa !29
  %60 = load ptr, ptr @SP, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.SCREEN, ptr %60, i32 0, i32 24
  store i32 0, ptr %61, align 8, !tbaa !30
  %62 = load ptr, ptr @SP, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.SCREEN, ptr %62, i32 0, i32 31
  store i16 -1, ptr %63, align 4, !tbaa !31
  %64 = load ptr, ptr @SP, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.SCREEN, ptr %64, i32 0, i32 33
  store ptr null, ptr %65, align 8, !tbaa !32
  %66 = load ptr, ptr @SP, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.SCREEN, ptr %66, i32 0, i32 34
  store ptr null, ptr %67, align 8, !tbaa !33
  %68 = load ptr, ptr @SP, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.SCREEN, ptr %68, i32 0, i32 35
  store i8 0, ptr %69, align 8, !tbaa !34
  %70 = load ptr, ptr @SP, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.SCREEN, ptr %70, i32 0, i32 36
  store i8 0, ptr %71, align 1, !tbaa !35
  %72 = load ptr, ptr @SP, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.SCREEN, ptr %72, i32 0, i32 37
  store i32 -1, ptr %73, align 4, !tbaa !36
  %74 = load ptr, ptr @SP, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.SCREEN, ptr %74, i32 0, i32 38
  store i32 -1, ptr %75, align 8, !tbaa !37
  %76 = call i32 @PDC_get_cursor_mode()
  %77 = load ptr, ptr @SP, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.SCREEN, ptr %77, i32 0, i32 15
  store i32 %76, ptr %78, align 4, !tbaa !38
  %79 = call i32 @PDC_get_rows()
  %80 = load ptr, ptr @SP, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.SCREEN, ptr %80, i32 0, i32 16
  store i32 %79, ptr %81, align 8, !tbaa !39
  store i32 %79, ptr @LINES, align 4, !tbaa !40
  %82 = call i32 @PDC_get_columns()
  %83 = load ptr, ptr @SP, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.SCREEN, ptr %83, i32 0, i32 17
  store i32 %82, ptr %84, align 4, !tbaa !41
  store i32 %82, ptr @COLS, align 4, !tbaa !40
  %85 = call i32 @PDC_init_atrtab()
  %86 = icmp ne i32 %85, 0
  br i1 %86, label %87, label %88

87:                                               ; preds = %35
  store ptr null, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %256

88:                                               ; preds = %35
  %89 = load i32, ptr @LINES, align 4, !tbaa !40
  %90 = icmp slt i32 %89, 2
  br i1 %90, label %94, label %91

91:                                               ; preds = %88
  %92 = load i32, ptr @COLS, align 4, !tbaa !40
  %93 = icmp slt i32 %92, 2
  br i1 %93, label %94, label %99

94:                                               ; preds = %91, %88
  %95 = load ptr, ptr @stderr, align 8, !tbaa !5
  %96 = load i32, ptr @LINES, align 4, !tbaa !40
  %97 = load i32, ptr @COLS, align 4, !tbaa !40
  %98 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %95, ptr noundef @.str.4, i32 noundef %96, i32 noundef %97) #7
  call void @exit(i32 noundef 4) #9
  unreachable

99:                                               ; preds = %91
  %100 = load i32, ptr @LINES, align 4, !tbaa !40
  %101 = load i32, ptr @COLS, align 4, !tbaa !40
  %102 = call ptr @newwin(i32 noundef %100, i32 noundef %101, i32 noundef 0, i32 noundef 0)
  store ptr %102, ptr @curscr, align 8, !tbaa !5
  %103 = load ptr, ptr @curscr, align 8, !tbaa !5
  %104 = icmp ne ptr %103, null
  br i1 %104, label %108, label %105

105:                                              ; preds = %99
  %106 = load ptr, ptr @stderr, align 8, !tbaa !5
  %107 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %106, ptr noundef @.str.5) #7
  call void @exit(i32 noundef 2) #9
  unreachable

108:                                              ; preds = %99
  %109 = load i32, ptr @LINES, align 4, !tbaa !40
  %110 = load i32, ptr @COLS, align 4, !tbaa !40
  %111 = call ptr @newwin(i32 noundef %109, i32 noundef %110, i32 noundef 0, i32 noundef 0)
  %112 = load ptr, ptr @SP, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct.SCREEN, ptr %112, i32 0, i32 33
  store ptr %111, ptr %113, align 8, !tbaa !32
  %114 = load ptr, ptr @SP, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.SCREEN, ptr %114, i32 0, i32 33
  %116 = load ptr, ptr %115, align 8, !tbaa !32
  %117 = icmp ne ptr %116, null
  br i1 %117, label %121, label %118

118:                                              ; preds = %108
  %119 = load ptr, ptr @stderr, align 8, !tbaa !5
  %120 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %119, ptr noundef @.str.6) #7
  call void @exit(i32 noundef 2) #9
  unreachable

121:                                              ; preds = %108
  %122 = load ptr, ptr @SP, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct.SCREEN, ptr %122, i32 0, i32 33
  %124 = load ptr, ptr %123, align 8, !tbaa !32
  %125 = call i32 @wattrset(ptr noundef %124, i64 noundef -1)
  %126 = load ptr, ptr @SP, align 8, !tbaa !5
  %127 = getelementptr inbounds %struct.SCREEN, ptr %126, i32 0, i32 33
  %128 = load ptr, ptr %127, align 8, !tbaa !32
  %129 = call i32 @werase(ptr noundef %128)
  call void @PDC_slk_initialize()
  %130 = load ptr, ptr @SP, align 8, !tbaa !5
  %131 = getelementptr inbounds %struct.SCREEN, ptr %130, i32 0, i32 20
  %132 = load i32, ptr %131, align 4, !tbaa !42
  %133 = load i32, ptr @LINES, align 4, !tbaa !40
  %134 = sub nsw i32 %133, %132
  store i32 %134, ptr @LINES, align 4, !tbaa !40
  store i32 0, ptr %8, align 4, !tbaa !40
  br label %135

135:                                              ; preds = %180, %121
  %136 = load i32, ptr %8, align 4, !tbaa !40
  %137 = load i8, ptr @linesrippedoff, align 1, !tbaa !43
  %138 = sext i8 %137 to i32
  %139 = icmp slt i32 %136, %138
  br i1 %139, label %140, label %183

140:                                              ; preds = %135
  %141 = load i32, ptr %8, align 4, !tbaa !40
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [5 x %struct.RIPPEDOFFLINE], ptr @linesripped, i64 0, i64 %142
  %144 = getelementptr inbounds %struct.RIPPEDOFFLINE, ptr %143, i32 0, i32 0
  %145 = load i32, ptr %144, align 16, !tbaa !44
  %146 = icmp slt i32 %145, 0
  br i1 %146, label %147, label %159

147:                                              ; preds = %140
  %148 = load i32, ptr %8, align 4, !tbaa !40
  %149 = sext i32 %148 to i64
  %150 = getelementptr inbounds [5 x %struct.RIPPEDOFFLINE], ptr @linesripped, i64 0, i64 %149
  %151 = getelementptr inbounds %struct.RIPPEDOFFLINE, ptr %150, i32 0, i32 1
  %152 = load ptr, ptr %151, align 8, !tbaa !46
  %153 = load i32, ptr @COLS, align 4, !tbaa !40
  %154 = load i32, ptr @LINES, align 4, !tbaa !40
  %155 = sub nsw i32 %154, 1
  %156 = call ptr @newwin(i32 noundef 1, i32 noundef %153, i32 noundef %155, i32 noundef 0)
  %157 = load i32, ptr @COLS, align 4, !tbaa !40
  %158 = call i32 %152(ptr noundef %156, i32 noundef %157)
  br label %173

159:                                              ; preds = %140
  %160 = load i32, ptr %8, align 4, !tbaa !40
  %161 = sext i32 %160 to i64
  %162 = getelementptr inbounds [5 x %struct.RIPPEDOFFLINE], ptr @linesripped, i64 0, i64 %161
  %163 = getelementptr inbounds %struct.RIPPEDOFFLINE, ptr %162, i32 0, i32 1
  %164 = load ptr, ptr %163, align 8, !tbaa !46
  %165 = load i32, ptr @COLS, align 4, !tbaa !40
  %166 = load ptr, ptr @SP, align 8, !tbaa !5
  %167 = getelementptr inbounds %struct.SCREEN, ptr %166, i32 0, i32 23
  %168 = load i32, ptr %167, align 4, !tbaa !29
  %169 = add nsw i32 %168, 1
  store i32 %169, ptr %167, align 4, !tbaa !29
  %170 = call ptr @newwin(i32 noundef 1, i32 noundef %165, i32 noundef %168, i32 noundef 0)
  %171 = load i32, ptr @COLS, align 4, !tbaa !40
  %172 = call i32 %164(ptr noundef %170, i32 noundef %171)
  br label %173

173:                                              ; preds = %159, %147
  %174 = load ptr, ptr @SP, align 8, !tbaa !5
  %175 = getelementptr inbounds %struct.SCREEN, ptr %174, i32 0, i32 22
  %176 = load i32, ptr %175, align 8, !tbaa !28
  %177 = add nsw i32 %176, 1
  store i32 %177, ptr %175, align 8, !tbaa !28
  %178 = load i32, ptr @LINES, align 4, !tbaa !40
  %179 = add nsw i32 %178, -1
  store i32 %179, ptr @LINES, align 4, !tbaa !40
  br label %180

180:                                              ; preds = %173
  %181 = load i32, ptr %8, align 4, !tbaa !40
  %182 = add nsw i32 %181, 1
  store i32 %182, ptr %8, align 4, !tbaa !40
  br label %135, !llvm.loop !47

183:                                              ; preds = %135
  store i8 0, ptr @linesrippedoff, align 1, !tbaa !43
  %184 = load i32, ptr @LINES, align 4, !tbaa !40
  %185 = load i32, ptr @COLS, align 4, !tbaa !40
  %186 = load ptr, ptr @SP, align 8, !tbaa !5
  %187 = getelementptr inbounds %struct.SCREEN, ptr %186, i32 0, i32 23
  %188 = load i32, ptr %187, align 4, !tbaa !29
  %189 = call ptr @newwin(i32 noundef %184, i32 noundef %185, i32 noundef %188, i32 noundef 0)
  store ptr %189, ptr @stdscr, align 8, !tbaa !5
  %190 = load ptr, ptr @stdscr, align 8, !tbaa !5
  %191 = icmp ne ptr %190, null
  br i1 %191, label %195, label %192

192:                                              ; preds = %183
  %193 = load ptr, ptr @stderr, align 8, !tbaa !5
  %194 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %193, ptr noundef @.str.7) #7
  call void @exit(i32 noundef 1) #9
  unreachable

195:                                              ; preds = %183
  %196 = load ptr, ptr @stdscr, align 8, !tbaa !5
  %197 = call i32 @wclrtobot(ptr noundef %196)
  %198 = load ptr, ptr @SP, align 8, !tbaa !5
  %199 = getelementptr inbounds %struct.SCREEN, ptr %198, i32 0, i32 25
  %200 = load i8, ptr %199, align 4, !tbaa !49, !range !16, !noundef !17
  %201 = trunc i8 %200 to i1
  br i1 %201, label %202, label %211

202:                                              ; preds = %195
  %203 = load ptr, ptr @curscr, align 8, !tbaa !5
  %204 = call i32 @untouchwin(ptr noundef %203)
  %205 = load ptr, ptr @stdscr, align 8, !tbaa !5
  %206 = call i32 @untouchwin(ptr noundef %205)
  %207 = load ptr, ptr @stdscr, align 8, !tbaa !5
  %208 = getelementptr inbounds %struct._win, ptr %207, i32 0, i32 9
  store i8 0, ptr %208, align 8, !tbaa !50
  %209 = load ptr, ptr @curscr, align 8, !tbaa !5
  %210 = getelementptr inbounds %struct._win, ptr %209, i32 0, i32 9
  store i8 0, ptr %210, align 8, !tbaa !50
  br label %214

211:                                              ; preds = %195
  %212 = load ptr, ptr @curscr, align 8, !tbaa !5
  %213 = getelementptr inbounds %struct._win, ptr %212, i32 0, i32 9
  store i8 1, ptr %213, align 8, !tbaa !50
  br label %214

214:                                              ; preds = %211, %202
  store i32 -1, ptr getelementptr inbounds (%struct.MOUSE_STATUS, ptr @Mouse_status, i32 0, i32 1), align 4, !tbaa !52
  store i32 -1, ptr @Mouse_status, align 4, !tbaa !53
  store i16 0, ptr getelementptr inbounds (%struct.MOUSE_STATUS, ptr @Mouse_status, i32 0, i32 2), align 4, !tbaa !54
  store i16 0, ptr getelementptr inbounds ([9 x i16], ptr getelementptr inbounds (%struct.MOUSE_STATUS, ptr @Mouse_status, i32 0, i32 2), i64 0, i64 1), align 2, !tbaa !54
  store i16 0, ptr getelementptr inbounds ([9 x i16], ptr getelementptr inbounds (%struct.MOUSE_STATUS, ptr @Mouse_status, i32 0, i32 2), i64 0, i64 2), align 4, !tbaa !54
  store i32 0, ptr getelementptr inbounds (%struct.MOUSE_STATUS, ptr @Mouse_status, i32 0, i32 3), align 4, !tbaa !55
  %215 = load ptr, ptr @SP, align 8, !tbaa !5
  %216 = getelementptr inbounds %struct.SCREEN, ptr %215, i32 0, i32 0
  store i8 1, ptr %216, align 8, !tbaa !9
  %217 = call i32 @def_shell_mode()
  %218 = call ptr @longname()
  %219 = call noalias ptr @malloc(i64 noundef 2048) #10
  %220 = load ptr, ptr @SP, align 8, !tbaa !5
  %221 = getelementptr inbounds %struct.SCREEN, ptr %220, i32 0, i32 39
  store ptr %219, ptr %221, align 8, !tbaa !56
  %222 = load ptr, ptr @SP, align 8, !tbaa !5
  %223 = getelementptr inbounds %struct.SCREEN, ptr %222, i32 0, i32 39
  %224 = load ptr, ptr %223, align 8, !tbaa !56
  %225 = icmp ne ptr %224, null
  br i1 %225, label %227, label %226

226:                                              ; preds = %214
  store ptr null, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %256

227:                                              ; preds = %214
  %228 = load ptr, ptr @SP, align 8, !tbaa !5
  %229 = getelementptr inbounds %struct.SCREEN, ptr %228, i32 0, i32 40
  store i32 0, ptr %229, align 8, !tbaa !57
  %230 = load ptr, ptr @SP, align 8, !tbaa !5
  %231 = getelementptr inbounds %struct.SCREEN, ptr %230, i32 0, i32 41
  store i32 1, ptr %231, align 4, !tbaa !58
  %232 = call noalias ptr @malloc(i64 noundef 1024) #10
  %233 = load ptr, ptr @SP, align 8, !tbaa !5
  %234 = getelementptr inbounds %struct.SCREEN, ptr %233, i32 0, i32 42
  store ptr %232, ptr %234, align 8, !tbaa !59
  %235 = load ptr, ptr @SP, align 8, !tbaa !5
  %236 = getelementptr inbounds %struct.SCREEN, ptr %235, i32 0, i32 42
  %237 = load ptr, ptr %236, align 8, !tbaa !59
  %238 = icmp ne ptr %237, null
  br i1 %238, label %240, label %239

239:                                              ; preds = %227
  store ptr null, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %256

240:                                              ; preds = %227
  %241 = load ptr, ptr @SP, align 8, !tbaa !5
  %242 = getelementptr inbounds %struct.SCREEN, ptr %241, i32 0, i32 43
  store i32 0, ptr %242, align 8, !tbaa !60
  %243 = load ptr, ptr @SP, align 8, !tbaa !5
  %244 = getelementptr inbounds %struct.SCREEN, ptr %243, i32 0, i32 44
  store i32 256, ptr %244, align 4, !tbaa !61
  %245 = load ptr, ptr %6, align 8, !tbaa !5
  %246 = load ptr, ptr @SP, align 8, !tbaa !5
  %247 = getelementptr inbounds %struct.SCREEN, ptr %246, i32 0, i32 45
  %248 = load ptr, ptr %247, align 8, !tbaa !62
  %249 = getelementptr inbounds %struct._opaque_screen_t, ptr %248, i32 0, i32 11
  store ptr %245, ptr %249, align 8, !tbaa !63
  %250 = load ptr, ptr %7, align 8, !tbaa !5
  %251 = load ptr, ptr @SP, align 8, !tbaa !5
  %252 = getelementptr inbounds %struct.SCREEN, ptr %251, i32 0, i32 45
  %253 = load ptr, ptr %252, align 8, !tbaa !62
  %254 = getelementptr inbounds %struct._opaque_screen_t, ptr %253, i32 0, i32 12
  store ptr %250, ptr %254, align 8, !tbaa !65
  %255 = load ptr, ptr @SP, align 8, !tbaa !5
  store ptr %255, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %256

256:                                              ; preds = %240, %239, %226, %87, %28, %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  %257 = load ptr, ptr %4, align 8
  ret ptr %257
}

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

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #2

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

declare i32 @PDC_scr_open() #4

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

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

declare i32 @PDC_get_cursor_mode() #4

declare i32 @PDC_get_rows() #4

declare i32 @PDC_get_columns() #4

declare i32 @PDC_init_atrtab() #4

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

declare i32 @wattrset(ptr noundef, i64 noundef) #4

declare i32 @werase(ptr noundef) #4

declare void @PDC_slk_initialize() #4

declare i32 @wclrtobot(ptr noundef) #4

declare i32 @untouchwin(ptr noundef) #4

declare i32 @def_shell_mode() #4

declare ptr @longname() #4

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #6

; 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 = { nounwind allocsize(0,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 #3 = { 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 #4 = { "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 allocsize(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 #7 = { nounwind }
attributes #8 = { nounwind allocsize(0,1) }
attributes #9 = { noreturn nounwind }
attributes #10 = { nounwind allocsize(0) }

!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, !11, i64 0}
!10 = !{!"", !11, i64 0, !11, i64 1, !11, i64 2, !11, i64 3, !11, i64 4, !11, i64 5, !11, i64 6, !11, i64 7, !11, i64 8, !11, i64 9, !12, i64 10, !12, i64 12, !13, i64 16, !13, i64 20, !13, i64 24, !13, i64 28, !13, i64 32, !13, i64 36, !14, i64 40, !13, i64 48, !13, i64 52, !6, i64 56, !13, i64 64, !13, i64 68, !13, i64 72, !11, i64 76, !13, i64 80, !14, i64 88, !11, i64 96, !11, i64 97, !15, i64 100, !12, i64 132, !14, i64 136, !6, i64 144, !6, i64 152, !11, i64 160, !11, i64 161, !13, i64 164, !13, i64 168, !6, i64 176, !13, i64 184, !13, i64 188, !6, i64 192, !13, i64 200, !13, i64 204, !6, i64 208}
!11 = !{!"_Bool", !7, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!"", !13, i64 0, !13, i64 4, !7, i64 8, !13, i64 28}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = !{!10, !11, i64 1}
!19 = !{!10, !11, i64 5}
!20 = !{!10, !11, i64 4}
!21 = !{!10, !11, i64 2}
!22 = !{!10, !14, i64 88}
!23 = !{!10, !11, i64 96}
!24 = !{!10, !11, i64 3}
!25 = !{!10, !13, i64 24}
!26 = !{!10, !11, i64 8}
!27 = !{!10, !14, i64 40}
!28 = !{!10, !13, i64 64}
!29 = !{!10, !13, i64 68}
!30 = !{!10, !13, i64 72}
!31 = !{!10, !12, i64 132}
!32 = !{!10, !6, i64 144}
!33 = !{!10, !6, i64 152}
!34 = !{!10, !11, i64 160}
!35 = !{!10, !11, i64 161}
!36 = !{!10, !13, i64 164}
!37 = !{!10, !13, i64 168}
!38 = !{!10, !13, i64 28}
!39 = !{!10, !13, i64 32}
!40 = !{!13, !13, i64 0}
!41 = !{!10, !13, i64 36}
!42 = !{!10, !13, i64 52}
!43 = !{!7, !7, i64 0}
!44 = !{!45, !13, i64 0}
!45 = !{!"", !13, i64 0, !6, i64 8}
!46 = !{!45, !6, i64 8}
!47 = distinct !{!47, !48}
!48 = !{!"llvm.loop.mustprogress"}
!49 = !{!10, !11, i64 76}
!50 = !{!51, !11, i64 48}
!51 = !{!"_win", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20, !13, i64 24, !14, i64 32, !14, i64 40, !11, i64 48, !11, i64 49, !11, i64 50, !11, i64 51, !11, i64 52, !11, i64 53, !11, i64 54, !6, i64 56, !6, i64 64, !6, i64 72, !13, i64 80, !13, i64 84, !13, i64 88, !13, i64 92, !13, i64 96, !6, i64 104, !13, i64 112, !13, i64 116, !13, i64 120, !13, i64 124, !13, i64 128, !13, i64 132}
!52 = !{!15, !13, i64 4}
!53 = !{!15, !13, i64 0}
!54 = !{!12, !12, i64 0}
!55 = !{!15, !13, i64 28}
!56 = !{!10, !6, i64 176}
!57 = !{!10, !13, i64 184}
!58 = !{!10, !13, i64 188}
!59 = !{!10, !6, i64 192}
!60 = !{!10, !13, i64 200}
!61 = !{!10, !13, i64 204}
!62 = !{!10, !6, i64 208}
!63 = !{!64, !6, i64 64}
!64 = !{!"_opaque_screen_t", !6, i64 0, !13, i64 8, !13, i64 12, !11, i64 16, !6, i64 24, !13, i64 32, !13, i64 36, !13, i64 40, !6, i64 48, !13, i64 56, !11, i64 60, !6, i64 64, !6, i64 72}
!65 = !{!64, !6, i64 72}


; 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.RIPPEDOFFLINE = type { i32, ptr }
%struct.MOUSE_STATUS = type { i32, i32, [9 x i16], i32 }

@SP = external dso_local local_unnamed_addr global ptr, align 8
@curscr = external dso_local local_unnamed_addr global ptr, align 8
@stdscr = external dso_local local_unnamed_addr global ptr, align 8
@LINES = external dso_local local_unnamed_addr global i32, align 4
@COLS = external dso_local local_unnamed_addr global i32, align 4
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [93 x i8], align 1
@__PRETTY_FUNCTION__.newterm = external hidden unnamed_addr constant [46 x i8], align 1
@stderr = external local_unnamed_addr global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [42 x i8], align 1
@linesrippedoff = external local_unnamed_addr global i8, align 1
@linesripped = external local_unnamed_addr global [5 x %struct.RIPPEDOFFLINE], align 16
@.str.7 = external hidden unnamed_addr constant [37 x i8], align 1
@Mouse_status = external dso_local local_unnamed_addr global %struct.MOUSE_STATUS, align 4

; Function Attrs: nounwind uwtable
define dso_local ptr @newterm(ptr nocapture noundef readnone %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = load ptr, ptr @SP, align 8, !tbaa !5
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %8, label %5

5:                                                ; preds = %3
  %6 = load i8, ptr %4, align 8, !tbaa !9, !range !16, !noundef !17
  %7 = trunc nuw i8 %6 to i1
  br i1 %7, label %153, label %8

8:                                                ; preds = %5, %3
  %9 = tail call noalias dereferenceable_or_null(216) ptr @calloc(i64 noundef 1, i64 noundef 216) #7
  store ptr %9, ptr @SP, align 8, !tbaa !5
  %.not15 = icmp eq ptr %9, null
  br i1 %.not15, label %10, label %11

10:                                               ; preds = %8
  tail call void @__assert_fail(ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 161, ptr noundef nonnull @__PRETTY_FUNCTION__.newterm) #8
  unreachable

11:                                               ; preds = %8
  %12 = tail call i32 @PDC_scr_open() #9
  %13 = icmp eq i32 %12, -1
  br i1 %13, label %14, label %17

14:                                               ; preds = %11
  %15 = load ptr, ptr @stderr, align 8, !tbaa !5
  %16 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %15, ptr noundef nonnull @.str.3) #10
  tail call void @exit(i32 noundef 8) #8
  unreachable

17:                                               ; preds = %11
  %18 = load ptr, ptr @SP, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %18, i64 1
  store i8 1, ptr %19, align 1, !tbaa !18
  %20 = getelementptr inbounds i8, ptr %18, i64 5
  store i8 0, ptr %20, align 1, !tbaa !19
  %21 = getelementptr inbounds i8, ptr %18, i64 4
  store i8 0, ptr %21, align 4, !tbaa !20
  %22 = getelementptr inbounds i8, ptr %18, i64 2
  store i8 1, ptr %22, align 2, !tbaa !21
  %23 = getelementptr inbounds i8, ptr %18, i64 88
  store i64 0, ptr %23, align 8, !tbaa !22
  %24 = getelementptr inbounds i8, ptr %18, i64 96
  store i8 0, ptr %24, align 8, !tbaa !23
  %25 = getelementptr inbounds i8, ptr %18, i64 3
  store i8 1, ptr %25, align 1, !tbaa !24
  %26 = getelementptr inbounds i8, ptr %18, i64 24
  store i32 1, ptr %26, align 8, !tbaa !25
  %27 = getelementptr inbounds i8, ptr %18, i64 8
  store i8 0, ptr %27, align 8, !tbaa !26
  %28 = getelementptr inbounds i8, ptr %18, i64 40
  store i64 0, ptr %28, align 8, !tbaa !27
  %29 = getelementptr inbounds i8, ptr %18, i64 64
  store i32 0, ptr %29, align 8, !tbaa !28
  %30 = getelementptr inbounds i8, ptr %18, i64 68
  store i32 0, ptr %30, align 4, !tbaa !29
  %31 = getelementptr inbounds i8, ptr %18, i64 72
  store i32 0, ptr %31, align 8, !tbaa !30
  %32 = getelementptr inbounds i8, ptr %18, i64 132
  store i16 -1, ptr %32, align 4, !tbaa !31
  %33 = getelementptr inbounds i8, ptr %18, i64 144
  %34 = getelementptr inbounds i8, ptr %18, i64 164
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(18) %33, i8 0, i64 18, i1 false)
  store i32 -1, ptr %34, align 4, !tbaa !32
  %35 = getelementptr inbounds i8, ptr %18, i64 168
  store i32 -1, ptr %35, align 8, !tbaa !33
  %36 = tail call i32 @PDC_get_cursor_mode() #9
  %37 = load ptr, ptr @SP, align 8, !tbaa !5
  %38 = getelementptr inbounds i8, ptr %37, i64 28
  store i32 %36, ptr %38, align 4, !tbaa !34
  %39 = tail call i32 @PDC_get_rows() #9
  %40 = load ptr, ptr @SP, align 8, !tbaa !5
  %41 = getelementptr inbounds i8, ptr %40, i64 32
  store i32 %39, ptr %41, align 8, !tbaa !35
  store i32 %39, ptr @LINES, align 4, !tbaa !36
  %42 = tail call i32 @PDC_get_columns() #9
  %43 = load ptr, ptr @SP, align 8, !tbaa !5
  %44 = getelementptr inbounds i8, ptr %43, i64 36
  store i32 %42, ptr %44, align 4, !tbaa !37
  store i32 %42, ptr @COLS, align 4, !tbaa !36
  %45 = tail call i32 @PDC_init_atrtab() #9
  %.not16 = icmp eq i32 %45, 0
  br i1 %.not16, label %46, label %153

46:                                               ; preds = %17
  %47 = load i32, ptr @LINES, align 4, !tbaa !36
  %48 = icmp slt i32 %47, 2
  %49 = load i32, ptr @COLS, align 4
  %50 = icmp slt i32 %49, 2
  %or.cond = select i1 %48, i1 true, i1 %50
  br i1 %or.cond, label %51, label %54

51:                                               ; preds = %46
  %52 = load ptr, ptr @stderr, align 8, !tbaa !5
  %53 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %52, ptr noundef nonnull @.str.4, i32 noundef %47, i32 noundef %49) #10
  tail call void @exit(i32 noundef 4) #8
  unreachable

54:                                               ; preds = %46
  %55 = tail call ptr @newwin(i32 noundef %47, i32 noundef %49, i32 noundef 0, i32 noundef 0) #9
  store ptr %55, ptr @curscr, align 8, !tbaa !5
  %.not17 = icmp eq ptr %55, null
  br i1 %.not17, label %56, label %59

56:                                               ; preds = %54
  %57 = load ptr, ptr @stderr, align 8, !tbaa !5
  %58 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %57, ptr noundef nonnull @.str.5) #10
  tail call void @exit(i32 noundef 2) #8
  unreachable

59:                                               ; preds = %54
  %60 = load i32, ptr @LINES, align 4, !tbaa !36
  %61 = load i32, ptr @COLS, align 4, !tbaa !36
  %62 = tail call ptr @newwin(i32 noundef %60, i32 noundef %61, i32 noundef 0, i32 noundef 0) #9
  %63 = load ptr, ptr @SP, align 8, !tbaa !5
  %64 = getelementptr inbounds i8, ptr %63, i64 144
  store ptr %62, ptr %64, align 8, !tbaa !38
  %.not18 = icmp eq ptr %62, null
  br i1 %.not18, label %65, label %68

65:                                               ; preds = %59
  %66 = load ptr, ptr @stderr, align 8, !tbaa !5
  %67 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %66, ptr noundef nonnull @.str.6) #10
  tail call void @exit(i32 noundef 2) #8
  unreachable

68:                                               ; preds = %59
  %69 = tail call i32 @wattrset(ptr noundef nonnull %62, i64 noundef -1) #9
  %70 = load ptr, ptr @SP, align 8, !tbaa !5
  %71 = getelementptr inbounds i8, ptr %70, i64 144
  %72 = load ptr, ptr %71, align 8, !tbaa !38
  %73 = tail call i32 @werase(ptr noundef %72) #9
  tail call void @PDC_slk_initialize() #9
  %74 = load ptr, ptr @SP, align 8, !tbaa !5
  %75 = getelementptr inbounds i8, ptr %74, i64 52
  %76 = load i32, ptr %75, align 4, !tbaa !39
  %77 = load i32, ptr @LINES, align 4, !tbaa !36
  %78 = sub nsw i32 %77, %76
  store i32 %78, ptr @LINES, align 4, !tbaa !36
  %79 = load i8, ptr @linesrippedoff, align 1, !tbaa !40
  %80 = icmp sgt i8 %79, 0
  br i1 %80, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %68, %95
  %81 = phi i32 [ %104, %95 ], [ %78, %68 ]
  %82 = phi ptr [ %99, %95 ], [ %74, %68 ]
  %indvars.iv = phi i64 [ %indvars.iv.next, %95 ], [ 0, %68 ]
  %83 = getelementptr inbounds [5 x %struct.RIPPEDOFFLINE], ptr @linesripped, i64 0, i64 %indvars.iv
  %84 = load i32, ptr %83, align 16, !tbaa !41
  %85 = icmp slt i32 %84, 0
  %86 = getelementptr inbounds i8, ptr %83, i64 8
  %87 = load ptr, ptr %86, align 8, !tbaa !43
  %88 = load i32, ptr @COLS, align 4, !tbaa !36
  br i1 %85, label %89, label %91

89:                                               ; preds = %.lr.ph
  %90 = add nsw i32 %81, -1
  br label %95

91:                                               ; preds = %.lr.ph
  %92 = getelementptr inbounds i8, ptr %82, i64 68
  %93 = load i32, ptr %92, align 4, !tbaa !29
  %94 = add nsw i32 %93, 1
  store i32 %94, ptr %92, align 4, !tbaa !29
  br label %95

95:                                               ; preds = %91, %89
  %.sink26 = phi i32 [ %93, %91 ], [ %90, %89 ]
  %96 = tail call ptr @newwin(i32 noundef 1, i32 noundef %88, i32 noundef %.sink26, i32 noundef 0) #9
  %97 = load i32, ptr @COLS, align 4, !tbaa !36
  %98 = tail call i32 %87(ptr noundef %96, i32 noundef %97) #9
  %99 = load ptr, ptr @SP, align 8, !tbaa !5
  %100 = getelementptr inbounds i8, ptr %99, i64 64
  %101 = load i32, ptr %100, align 8, !tbaa !28
  %102 = add nsw i32 %101, 1
  store i32 %102, ptr %100, align 8, !tbaa !28
  %103 = load i32, ptr @LINES, align 4, !tbaa !36
  %104 = add nsw i32 %103, -1
  store i32 %104, ptr @LINES, align 4, !tbaa !36
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %105 = load i8, ptr @linesrippedoff, align 1, !tbaa !40
  %106 = sext i8 %105 to i64
  %107 = icmp slt i64 %indvars.iv.next, %106
  br i1 %107, label %.lr.ph, label %._crit_edge, !llvm.loop !44

._crit_edge:                                      ; preds = %95, %68
  %108 = phi ptr [ %74, %68 ], [ %99, %95 ]
  %109 = phi i32 [ %78, %68 ], [ %104, %95 ]
  store i8 0, ptr @linesrippedoff, align 1, !tbaa !40
  %110 = load i32, ptr @COLS, align 4, !tbaa !36
  %111 = getelementptr inbounds i8, ptr %108, i64 68
  %112 = load i32, ptr %111, align 4, !tbaa !29
  %113 = tail call ptr @newwin(i32 noundef %109, i32 noundef %110, i32 noundef %112, i32 noundef 0) #9
  store ptr %113, ptr @stdscr, align 8, !tbaa !5
  %.not19 = icmp eq ptr %113, null
  br i1 %.not19, label %114, label %117

114:                                              ; preds = %._crit_edge
  %115 = load ptr, ptr @stderr, align 8, !tbaa !5
  %116 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %115, ptr noundef nonnull @.str.7) #10
  tail call void @exit(i32 noundef 1) #8
  unreachable

117:                                              ; preds = %._crit_edge
  %118 = tail call i32 @wclrtobot(ptr noundef nonnull %113) #9
  %119 = load ptr, ptr @SP, align 8, !tbaa !5
  %120 = getelementptr inbounds i8, ptr %119, i64 76
  %121 = load i8, ptr %120, align 4, !tbaa !46, !range !16, !noundef !17
  %122 = trunc nuw i8 %121 to i1
  %123 = load ptr, ptr @curscr, align 8, !tbaa !5
  br i1 %122, label %124, label %132

124:                                              ; preds = %117
  %125 = tail call i32 @untouchwin(ptr noundef %123) #9
  %126 = load ptr, ptr @stdscr, align 8, !tbaa !5
  %127 = tail call i32 @untouchwin(ptr noundef %126) #9
  %128 = load ptr, ptr @stdscr, align 8, !tbaa !5
  %129 = getelementptr inbounds i8, ptr %128, i64 48
  store i8 0, ptr %129, align 8, !tbaa !47
  %130 = load ptr, ptr @curscr, align 8, !tbaa !5
  %131 = getelementptr inbounds i8, ptr %130, i64 48
  store i8 0, ptr %131, align 8, !tbaa !47
  %.pre = load ptr, ptr @SP, align 8, !tbaa !5
  br label %134

132:                                              ; preds = %117
  %133 = getelementptr inbounds i8, ptr %123, i64 48
  store i8 1, ptr %133, align 8, !tbaa !47
  br label %134

134:                                              ; preds = %132, %124
  %135 = phi ptr [ %119, %132 ], [ %.pre, %124 ]
  store i32 -1, ptr getelementptr inbounds (i8, ptr @Mouse_status, i64 4), align 4, !tbaa !49
  store i32 -1, ptr @Mouse_status, align 4, !tbaa !50
  store i16 0, ptr getelementptr inbounds (i8, ptr @Mouse_status, i64 8), align 4, !tbaa !51
  store i16 0, ptr getelementptr inbounds (i8, ptr @Mouse_status, i64 10), align 2, !tbaa !51
  store i16 0, ptr getelementptr inbounds (i8, ptr @Mouse_status, i64 12), align 4, !tbaa !51
  store i32 0, ptr getelementptr inbounds (i8, ptr @Mouse_status, i64 28), align 4, !tbaa !52
  store i8 1, ptr %135, align 8, !tbaa !9
  %136 = tail call i32 @def_shell_mode() #9
  %137 = tail call ptr @longname() #9
  %138 = tail call noalias dereferenceable_or_null(2048) ptr @malloc(i64 noundef 2048) #11
  %139 = load ptr, ptr @SP, align 8, !tbaa !5
  %140 = getelementptr inbounds i8, ptr %139, i64 176
  store ptr %138, ptr %140, align 8, !tbaa !53
  %.not20 = icmp eq ptr %138, null
  br i1 %.not20, label %153, label %141

141:                                              ; preds = %134
  %142 = getelementptr inbounds i8, ptr %139, i64 184
  store i32 0, ptr %142, align 8, !tbaa !54
  %143 = getelementptr inbounds i8, ptr %139, i64 188
  store i32 1, ptr %143, align 4, !tbaa !55
  %144 = tail call noalias dereferenceable_or_null(1024) ptr @malloc(i64 noundef 1024) #11
  %145 = getelementptr inbounds i8, ptr %139, i64 192
  store ptr %144, ptr %145, align 8, !tbaa !56
  %.not21 = icmp eq ptr %144, null
  br i1 %.not21, label %153, label %146

146:                                              ; preds = %141
  %147 = getelementptr inbounds i8, ptr %139, i64 200
  store i32 0, ptr %147, align 8, !tbaa !57
  %148 = getelementptr inbounds i8, ptr %139, i64 204
  store i32 256, ptr %148, align 4, !tbaa !58
  %149 = getelementptr inbounds i8, ptr %139, i64 208
  %150 = load ptr, ptr %149, align 8, !tbaa !59
  %151 = getelementptr inbounds i8, ptr %150, i64 64
  store ptr %1, ptr %151, align 8, !tbaa !60
  %152 = getelementptr inbounds i8, ptr %150, i64 72
  store ptr %2, ptr %152, align 8, !tbaa !62
  br label %153

153:                                              ; preds = %141, %134, %17, %5, %146
  %.09 = phi ptr [ %139, %146 ], [ null, %5 ], [ null, %17 ], [ null, %134 ], [ null, %141 ]
  ret ptr %.09
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #1

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

declare i32 @PDC_scr_open() local_unnamed_addr #3

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

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

declare i32 @PDC_get_cursor_mode() local_unnamed_addr #3

declare i32 @PDC_get_rows() local_unnamed_addr #3

declare i32 @PDC_get_columns() local_unnamed_addr #3

declare i32 @PDC_init_atrtab() local_unnamed_addr #3

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

declare i32 @wattrset(ptr noundef, i64 noundef) local_unnamed_addr #3

declare i32 @werase(ptr noundef) local_unnamed_addr #3

declare void @PDC_slk_initialize() local_unnamed_addr #3

declare i32 @wclrtobot(ptr noundef) local_unnamed_addr #3

declare i32 @untouchwin(ptr noundef) local_unnamed_addr #3

declare i32 @def_shell_mode() local_unnamed_addr #3

declare ptr @longname() local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #5

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #6

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 nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 "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 = { 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 #5 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #7 = { nounwind allocsize(0,1) }
attributes #8 = { noreturn nounwind }
attributes #9 = { nounwind }
attributes #10 = { cold nounwind }
attributes #11 = { nounwind allocsize(0) }

!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, !11, i64 0}
!10 = !{!"", !11, i64 0, !11, i64 1, !11, i64 2, !11, i64 3, !11, i64 4, !11, i64 5, !11, i64 6, !11, i64 7, !11, i64 8, !11, i64 9, !12, i64 10, !12, i64 12, !13, i64 16, !13, i64 20, !13, i64 24, !13, i64 28, !13, i64 32, !13, i64 36, !14, i64 40, !13, i64 48, !13, i64 52, !6, i64 56, !13, i64 64, !13, i64 68, !13, i64 72, !11, i64 76, !13, i64 80, !14, i64 88, !11, i64 96, !11, i64 97, !15, i64 100, !12, i64 132, !14, i64 136, !6, i64 144, !6, i64 152, !11, i64 160, !11, i64 161, !13, i64 164, !13, i64 168, !6, i64 176, !13, i64 184, !13, i64 188, !6, i64 192, !13, i64 200, !13, i64 204, !6, i64 208}
!11 = !{!"_Bool", !7, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!"", !13, i64 0, !13, i64 4, !7, i64 8, !13, i64 28}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = !{!10, !11, i64 1}
!19 = !{!10, !11, i64 5}
!20 = !{!10, !11, i64 4}
!21 = !{!10, !11, i64 2}
!22 = !{!10, !14, i64 88}
!23 = !{!10, !11, i64 96}
!24 = !{!10, !11, i64 3}
!25 = !{!10, !13, i64 24}
!26 = !{!10, !11, i64 8}
!27 = !{!10, !14, i64 40}
!28 = !{!10, !13, i64 64}
!29 = !{!10, !13, i64 68}
!30 = !{!10, !13, i64 72}
!31 = !{!10, !12, i64 132}
!32 = !{!10, !13, i64 164}
!33 = !{!10, !13, i64 168}
!34 = !{!10, !13, i64 28}
!35 = !{!10, !13, i64 32}
!36 = !{!13, !13, i64 0}
!37 = !{!10, !13, i64 36}
!38 = !{!10, !6, i64 144}
!39 = !{!10, !13, i64 52}
!40 = !{!7, !7, i64 0}
!41 = !{!42, !13, i64 0}
!42 = !{!"", !13, i64 0, !6, i64 8}
!43 = !{!42, !6, i64 8}
!44 = distinct !{!44, !45}
!45 = !{!"llvm.loop.mustprogress"}
!46 = !{!10, !11, i64 76}
!47 = !{!48, !11, i64 48}
!48 = !{!"_win", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20, !13, i64 24, !14, i64 32, !14, i64 40, !11, i64 48, !11, i64 49, !11, i64 50, !11, i64 51, !11, i64 52, !11, i64 53, !11, i64 54, !6, i64 56, !6, i64 64, !6, i64 72, !13, i64 80, !13, i64 84, !13, i64 88, !13, i64 92, !13, i64 96, !6, i64 104, !13, i64 112, !13, i64 116, !13, i64 120, !13, i64 124, !13, i64 128, !13, i64 132}
!49 = !{!15, !13, i64 4}
!50 = !{!15, !13, i64 0}
!51 = !{!12, !12, i64 0}
!52 = !{!15, !13, i64 28}
!53 = !{!10, !6, i64 176}
!54 = !{!10, !13, i64 184}
!55 = !{!10, !13, i64 188}
!56 = !{!10, !6, i64 192}
!57 = !{!10, !13, i64 200}
!58 = !{!10, !13, i64 204}
!59 = !{!10, !6, i64 208}
!60 = !{!61, !6, i64 64}
!61 = !{!"_opaque_screen_t", !6, i64 0, !13, i64 8, !13, i64 12, !11, i64 16, !6, i64 24, !13, i64 32, !13, i64 36, !13, i64 40, !6, i64 48, !13, i64 56, !11, i64 60, !6, i64 64, !6, i64 72}
!62 = !{!61, !6, i64 72}


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