; LLVM IR from freakout42/macrocalc :: mc/src (wksfio)

; 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.CELLREC = type { %struct.CELLADR, ptr, i8, i8, i8, ptr, %struct.CELLVALUE, %struct.CELLSTRING }
%struct.CELLADR = type { i32, i32 }
%struct.CELLVALUE = type { double, double, ptr }
%struct.CELLSTRING = type { i16, ptr }
%union.anon = type { double }
%struct.Lotrec = type { i16, i16, %union.anon.0 }
%union.anon.0 = type <{ %struct.anon.5, [2039 x i8] }>
%struct.anon.5 = type { [16 x i8], %struct.CELLADR123, %struct.CELLADR123 }
%struct.CELLADR123 = type { i16, i16 }
%struct.anon = type { i16 }
%struct.anon.3 = type <{ i16, i16, i8, i8, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i8, i16 }>
%struct.anon.4 = type <{ i16, i8 }>
%struct.anon.10 = type { i8 }
%struct.anon.6 = type <{ i8, %struct.CELLADR123, i16 }>
%struct.anon.7 = type <{ i8, %struct.CELLADR123, %struct.mydouble }>
%struct.mydouble = type { [8 x i8] }
%struct.anon.8 = type <{ i8, %struct.CELLADR123, [240 x i8] }>
%struct.anon.9 = type <{ i8, %struct.CELLADR123, %struct.mydouble, i16, [2048 x i8] }>

@.str = external hidden unnamed_addr constant [13 x i8], align 1
@curcol = external global i32, align 4
@currow = external global i32, align 4
@leftcol = external global i32, align 4
@windowrow = external global i32, align 4
@borderline = external global i32, align 4
@windowline = external global i32, align 4
@toprow = external global i32, align 4
@colwidth = external global [702 x i8], align 16
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@omarkrow = external global i32, align 4
@omarkcol = external global i32, align 4
@lastcol = external global i32, align 4
@markcol = external global i32, align 4
@lastrow = external global i32, align 4
@markrow = external global i32, align 4

; Function Attrs: nounwind uwtable
define dso_local i32 @fromwks(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca %struct.CELLREC, align 8
  %8 = alloca i8, align 1
  %9 = alloca i8, align 1
  %10 = alloca [32768 x i8], align 16
  %11 = alloca double, align 8
  %12 = alloca %union.anon, align 8
  %13 = alloca i32, align 4
  %14 = alloca %struct.Lotrec, align 2
  %15 = alloca i8, align 1
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 0, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 0, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 72, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #6
  call void @llvm.lifetime.start.p0(i64 32768, ptr %10) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  call void @llvm.lifetime.start.p0(i64 2068, ptr %14) #6
  call void @llvm.lifetime.start.p0(i64 1, ptr %15) #6
  store i8 127, ptr %15, align 1, !tbaa !11
  %16 = call i32 @getwksrecord(ptr noundef %14)
  %17 = icmp ne i32 %16, 0
  br i1 %17, label %23, label %18

18:                                               ; preds = %1
  %19 = getelementptr inbounds %struct.Lotrec, ptr %14, i32 0, i32 1
  %20 = load i16, ptr %19, align 2, !tbaa !12
  %21 = sext i16 %20 to i32
  %22 = icmp ne i32 %21, 2
  br i1 %22, label %23, label %24

23:                                               ; preds = %18, %1
  call void @fatal(i32 noundef 10, ptr noundef @.str)
  br label %24

24:                                               ; preds = %23, %18
  %25 = getelementptr inbounds %struct.Lotrec, ptr %14, i32 0, i32 2
  %26 = getelementptr inbounds %struct.anon, ptr %25, i32 0, i32 0
  %27 = load i16, ptr %26, align 2, !tbaa !11
  %28 = sext i16 %27 to i32
  store i32 %28, ptr %13, align 4, !tbaa !9
  %29 = icmp ne i32 %28, 1028
  br i1 %29, label %30, label %37

30:                                               ; preds = %24
  %31 = load i32, ptr %13, align 4, !tbaa !9
  %32 = icmp ne i32 %31, 1029
  br i1 %32, label %33, label %37

33:                                               ; preds = %30
  %34 = load i32, ptr %13, align 4, !tbaa !9
  %35 = icmp ne i32 %34, 1030
  br i1 %35, label %36, label %37

36:                                               ; preds = %33
  call void @fatal(i32 noundef 10, ptr noundef @.str)
  br label %37

37:                                               ; preds = %36, %33, %30, %24
  br label %38

38:                                               ; preds = %221, %37
  %39 = call i32 @getwksrecord(ptr noundef %14)
  %40 = icmp ne i32 %39, 1
  br i1 %40, label %41, label %222

41:                                               ; preds = %38
  %42 = getelementptr inbounds %struct.Lotrec, ptr %14, i32 0, i32 0
  %43 = load i16, ptr %42, align 2, !tbaa !15
  %44 = sext i16 %43 to i32
  switch i32 %44, label %220 [
    i32 7, label %45
    i32 8, label %73
    i32 11, label %84
    i32 36, label %109
    i32 13, label %119
    i32 14, label %130
    i32 15, label %137
    i32 16, label %143
  ]

45:                                               ; preds = %41
  %46 = getelementptr inbounds %struct.Lotrec, ptr %14, i32 0, i32 2
  %47 = getelementptr inbounds %struct.anon.3, ptr %46, i32 0, i32 0
  %48 = load i16, ptr %47, align 2, !tbaa !11
  %49 = sext i16 %48 to i32
  store i32 %49, ptr @curcol, align 4, !tbaa !9
  %50 = getelementptr inbounds %struct.Lotrec, ptr %14, i32 0, i32 2
  %51 = getelementptr inbounds %struct.anon.3, ptr %50, i32 0, i32 1
  %52 = load i16, ptr %51, align 2, !tbaa !11
  %53 = sext i16 %52 to i32
  store i32 %53, ptr @currow, align 4, !tbaa !9
  %54 = getelementptr inbounds %struct.Lotrec, ptr %14, i32 0, i32 2
  %55 = getelementptr inbounds %struct.anon.3, ptr %54, i32 0, i32 7
  %56 = load i16, ptr %55, align 2, !tbaa !11
  %57 = sext i16 %56 to i32
  store i32 %57, ptr @leftcol, align 4, !tbaa !9
  %58 = getelementptr inbounds %struct.Lotrec, ptr %14, i32 0, i32 2
  %59 = getelementptr inbounds %struct.anon.3, ptr %58, i32 0, i32 8
  %60 = load i16, ptr %59, align 2, !tbaa !11
  %61 = sext i16 %60 to i32
  store i32 %61, ptr @windowrow, align 4, !tbaa !9
  %62 = load i32, ptr @borderline, align 4, !tbaa !9
  %63 = add nsw i32 %62, 1
  %64 = getelementptr inbounds %struct.Lotrec, ptr %14, i32 0, i32 2
  %65 = getelementptr inbounds %struct.anon.3, ptr %64, i32 0, i32 10
  %66 = load i16, ptr %65, align 2, !tbaa !11
  %67 = sext i16 %66 to i32
  %68 = add nsw i32 %63, %67
  store i32 %68, ptr @windowline, align 4, !tbaa !9
  %69 = getelementptr inbounds %struct.Lotrec, ptr %14, i32 0, i32 2
  %70 = getelementptr inbounds %struct.anon.3, ptr %69, i32 0, i32 12
  %71 = load i16, ptr %70, align 2, !tbaa !11
  %72 = sext i16 %71 to i32
  store i32 %72, ptr @toprow, align 4, !tbaa !9
  br label %221

73:                                               ; preds = %41
  %74 = getelementptr inbounds %struct.Lotrec, ptr %14, i32 0, i32 2
  %75 = getelementptr inbounds %struct.anon.4, ptr %74, i32 0, i32 0
  %76 = load i16, ptr %75, align 2, !tbaa !11
  %77 = sext i16 %76 to i32
  store i32 %77, ptr %5, align 4, !tbaa !9
  %78 = getelementptr inbounds %struct.Lotrec, ptr %14, i32 0, i32 2
  %79 = getelementptr inbounds %struct.anon.4, ptr %78, i32 0, i32 1
  %80 = load i8, ptr %79, align 2, !tbaa !11
  %81 = load i32, ptr %5, align 4, !tbaa !9
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [702 x i8], ptr @colwidth, i64 0, i64 %82
  store i8 %80, ptr %83, align 1, !tbaa !11
  br label %221

84:                                               ; preds = %41
  %85 = getelementptr inbounds %struct.Lotrec, ptr %14, i32 0, i32 2
  %86 = getelementptr inbounds %struct.anon.5, ptr %85, i32 0, i32 0
  %87 = getelementptr inbounds [16 x i8], ptr %86, i64 0, i64 0
  %88 = getelementptr inbounds %struct.Lotrec, ptr %14, i32 0, i32 2
  %89 = getelementptr inbounds %struct.anon.5, ptr %88, i32 0, i32 1
  %90 = getelementptr inbounds %struct.CELLADR123, ptr %89, i32 0, i32 0
  %91 = load i16, ptr %90, align 2, !tbaa !11
  %92 = sext i16 %91 to i32
  %93 = getelementptr inbounds %struct.Lotrec, ptr %14, i32 0, i32 2
  %94 = getelementptr inbounds %struct.anon.5, ptr %93, i32 0, i32 1
  %95 = getelementptr inbounds %struct.CELLADR123, ptr %94, i32 0, i32 1
  %96 = load i16, ptr %95, align 2, !tbaa !11
  %97 = sext i16 %96 to i32
  %98 = getelementptr inbounds %struct.Lotrec, ptr %14, i32 0, i32 2
  %99 = getelementptr inbounds %struct.anon.5, ptr %98, i32 0, i32 2
  %100 = getelementptr inbounds %struct.CELLADR123, ptr %99, i32 0, i32 0
  %101 = load i16, ptr %100, align 2, !tbaa !11
  %102 = sext i16 %101 to i32
  %103 = getelementptr inbounds %struct.Lotrec, ptr %14, i32 0, i32 2
  %104 = getelementptr inbounds %struct.anon.5, ptr %103, i32 0, i32 2
  %105 = getelementptr inbounds %struct.CELLADR123, ptr %104, i32 0, i32 1
  %106 = load i16, ptr %105, align 2, !tbaa !11
  %107 = sext i16 %106 to i32
  %108 = call i32 @updaterange(ptr noundef %87, i32 noundef %92, i32 noundef %97, i32 noundef %102, i32 noundef %107)
  br label %221

109:                                              ; preds = %41
  %110 = getelementptr inbounds %struct.Lotrec, ptr %14, i32 0, i32 2
  %111 = getelementptr inbounds %struct.anon.10, ptr %110, i32 0, i32 0
  %112 = load i8, ptr %111, align 2, !tbaa !11
  %113 = zext i8 %112 to i32
  %114 = icmp ne i32 %113, 0
  %115 = zext i1 %114 to i64
  %116 = select i1 %114, i32 128, i32 0
  %117 = or i32 -129, %116
  %118 = trunc i32 %117 to i8
  store i8 %118, ptr %15, align 1, !tbaa !11
  br label %221

119:                                              ; preds = %41
  store i8 2, ptr %8, align 1, !tbaa !11
  %120 = getelementptr inbounds %struct.Lotrec, ptr %14, i32 0, i32 2
  %121 = getelementptr inbounds %struct.anon.6, ptr %120, i32 0, i32 2
  %122 = load i16, ptr %121, align 1, !tbaa !11
  %123 = sitofp i16 %122 to double
  store double %123, ptr %11, align 8, !tbaa !16
  %124 = getelementptr inbounds [32768 x i8], ptr %10, i64 0, i64 0
  %125 = getelementptr inbounds %struct.Lotrec, ptr %14, i32 0, i32 2
  %126 = getelementptr inbounds %struct.anon.6, ptr %125, i32 0, i32 2
  %127 = load i16, ptr %126, align 1, !tbaa !11
  %128 = sext i16 %127 to i32
  %129 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %124, ptr noundef @.str.1, i32 noundef %128) #6
  br label %155

130:                                              ; preds = %41
  store i8 2, ptr %8, align 1, !tbaa !11
  %131 = getelementptr inbounds %struct.Lotrec, ptr %14, i32 0, i32 2
  %132 = getelementptr inbounds %struct.anon.7, ptr %131, i32 0, i32 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %12, ptr align 1 %132, i64 8, i1 false), !tbaa.struct !18
  %133 = load double, ptr %12, align 8, !tbaa !11
  store double %133, ptr %11, align 8, !tbaa !16
  %134 = getelementptr inbounds [32768 x i8], ptr %10, i64 0, i64 0
  %135 = load double, ptr %11, align 8, !tbaa !16
  %136 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %134, ptr noundef @.str.2, double noundef %135) #6
  br label %155

137:                                              ; preds = %41
  call void @convertlabel(ptr noundef %14)
  store i8 1, ptr %8, align 1, !tbaa !11
  store double 0.000000e+00, ptr %11, align 8, !tbaa !16
  %138 = getelementptr inbounds [32768 x i8], ptr %10, i64 0, i64 0
  %139 = getelementptr inbounds %struct.Lotrec, ptr %14, i32 0, i32 2
  %140 = getelementptr inbounds %struct.anon.8, ptr %139, i32 0, i32 2
  %141 = getelementptr inbounds [240 x i8], ptr %140, i64 0, i64 0
  %142 = call ptr @strcpy(ptr noundef %138, ptr noundef %141) #6
  br label %155

143:                                              ; preds = %41
  store i8 3, ptr %8, align 1, !tbaa !11
  %144 = getelementptr inbounds %struct.Lotrec, ptr %14, i32 0, i32 2
  %145 = getelementptr inbounds %struct.anon.9, ptr %144, i32 0, i32 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %12, ptr align 1 %145, i64 8, i1 false), !tbaa.struct !18
  %146 = load double, ptr %12, align 8, !tbaa !11
  store double %146, ptr %11, align 8, !tbaa !16
  %147 = getelementptr inbounds [32768 x i8], ptr %10, i64 0, i64 0
  %148 = getelementptr inbounds %struct.Lotrec, ptr %14, i32 0, i32 2
  %149 = getelementptr inbounds %struct.anon.9, ptr %148, i32 0, i32 4
  %150 = getelementptr inbounds [2048 x i8], ptr %149, i64 0, i64 0
  %151 = call i32 @pol2tex(ptr noundef %147, ptr noundef %150)
  %152 = icmp ne i32 %151, 0
  br i1 %152, label %153, label %154

153:                                              ; preds = %143
  br label %221

154:                                              ; preds = %143
  br label %155

155:                                              ; preds = %154, %137, %130, %119
  %156 = getelementptr inbounds %struct.Lotrec, ptr %14, i32 0, i32 2
  %157 = getelementptr inbounds %struct.anon.8, ptr %156, i32 0, i32 1
  %158 = getelementptr inbounds %struct.CELLADR123, ptr %157, i32 0, i32 0
  %159 = load i16, ptr %158, align 1, !tbaa !11
  %160 = sext i16 %159 to i32
  store i32 %160, ptr %5, align 4, !tbaa !9
  %161 = getelementptr inbounds %struct.Lotrec, ptr %14, i32 0, i32 2
  %162 = getelementptr inbounds %struct.anon.8, ptr %161, i32 0, i32 1
  %163 = getelementptr inbounds %struct.CELLADR123, ptr %162, i32 0, i32 1
  %164 = load i16, ptr %163, align 1, !tbaa !11
  %165 = sext i16 %164 to i32
  store i32 %165, ptr %6, align 4, !tbaa !9
  %166 = getelementptr inbounds %struct.Lotrec, ptr %14, i32 0, i32 2
  %167 = getelementptr inbounds %struct.anon.8, ptr %166, i32 0, i32 0
  %168 = load i8, ptr %167, align 2, !tbaa !11
  %169 = call zeroext i8 @convertformat(i8 noundef zeroext %168)
  %170 = zext i8 %169 to i32
  %171 = load i8, ptr %15, align 1, !tbaa !11
  %172 = zext i8 %171 to i32
  %173 = and i32 %170, %172
  %174 = trunc i32 %173 to i8
  store i8 %174, ptr %9, align 1, !tbaa !11
  call void @llvm.memset.p0.i64(ptr align 8 %7, i8 0, i64 72, i1 false)
  %175 = load i32, ptr %5, align 4, !tbaa !9
  %176 = getelementptr inbounds %struct.CELLREC, ptr %7, i32 0, i32 0
  %177 = getelementptr inbounds %struct.CELLADR, ptr %176, i32 0, i32 0
  store i32 %175, ptr %177, align 8, !tbaa !19
  %178 = load i32, ptr %6, align 4, !tbaa !9
  %179 = getelementptr inbounds %struct.CELLREC, ptr %7, i32 0, i32 0
  %180 = getelementptr inbounds %struct.CELLADR, ptr %179, i32 0, i32 1
  store i32 %178, ptr %180, align 4, !tbaa !24
  %181 = load i8, ptr %8, align 1, !tbaa !11
  %182 = zext i8 %181 to i32
  %183 = and i32 %182, 240
  %184 = trunc i32 %183 to i8
  %185 = getelementptr inbounds %struct.CELLREC, ptr %7, i32 0, i32 3
  store i8 %184, ptr %185, align 1, !tbaa !25
  %186 = load i8, ptr %9, align 1, !tbaa !11
  %187 = zext i8 %186 to i32
  %188 = icmp eq i32 %187, 0
  br i1 %188, label %189, label %190

189:                                              ; preds = %155
  br label %193

190:                                              ; preds = %155
  %191 = load i8, ptr %9, align 1, !tbaa !11
  %192 = zext i8 %191 to i32
  br label %193

193:                                              ; preds = %190, %189
  %194 = phi i32 [ 15, %189 ], [ %192, %190 ]
  %195 = trunc i32 %194 to i8
  %196 = getelementptr inbounds %struct.CELLREC, ptr %7, i32 0, i32 4
  store i8 %195, ptr %196, align 2, !tbaa !26
  %197 = load i8, ptr %8, align 1, !tbaa !11
  %198 = zext i8 %197 to i32
  %199 = and i32 %198, 31
  %200 = trunc i32 %199 to i8
  %201 = getelementptr inbounds %struct.CELLREC, ptr %7, i32 0, i32 2
  store i8 %200, ptr %201, align 8, !tbaa !27
  %202 = getelementptr inbounds [32768 x i8], ptr %10, i64 0, i64 0
  %203 = getelementptr inbounds %struct.CELLREC, ptr %7, i32 0, i32 5
  store ptr %202, ptr %203, align 8, !tbaa !28
  %204 = load double, ptr %11, align 8, !tbaa !16
  %205 = getelementptr inbounds %struct.CELLREC, ptr %7, i32 0, i32 6
  %206 = getelementptr inbounds %struct.CELLVALUE, ptr %205, i32 0, i32 0
  store double %204, ptr %206, align 8, !tbaa !29
  %207 = call ptr @migratecell(ptr noundef %7)
  %208 = load i32, ptr %5, align 4, !tbaa !9
  %209 = load i32, ptr %3, align 4, !tbaa !9
  %210 = icmp sgt i32 %208, %209
  br i1 %210, label %211, label %213

211:                                              ; preds = %193
  %212 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %212, ptr %3, align 4, !tbaa !9
  br label %213

213:                                              ; preds = %211, %193
  %214 = load i32, ptr %6, align 4, !tbaa !9
  %215 = load i32, ptr %4, align 4, !tbaa !9
  %216 = icmp sgt i32 %214, %215
  br i1 %216, label %217, label %219

217:                                              ; preds = %213
  %218 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %218, ptr %4, align 4, !tbaa !9
  br label %219

219:                                              ; preds = %217, %213
  br label %221

220:                                              ; preds = %41
  br label %221

221:                                              ; preds = %220, %219, %153, %109, %84, %73, %45
  br label %38, !llvm.loop !30

222:                                              ; preds = %38
  store i32 0, ptr @omarkrow, align 4, !tbaa !9
  store i32 0, ptr @omarkcol, align 4, !tbaa !9
  %223 = load i32, ptr %3, align 4, !tbaa !9
  store i32 %223, ptr @lastcol, align 4, !tbaa !9
  store i32 %223, ptr @markcol, align 4, !tbaa !9
  %224 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %224, ptr @lastrow, align 4, !tbaa !9
  store i32 %224, ptr @markrow, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 1, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 2068, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 32768, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 72, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  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 i32 @getwksrecord(ptr noundef) #2

declare void @fatal(i32 noundef, ptr noundef) #2

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

declare void @convertlabel(ptr noundef) #2

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

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

declare zeroext i8 @convertformat(i8 noundef zeroext) #2

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

declare ptr @migratecell(ptr 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { 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 = !{!7, !7, i64 0}
!12 = !{!13, !14, i64 2}
!13 = !{!"", !14, i64 0, !14, i64 2, !7, i64 4}
!14 = !{!"short", !7, i64 0}
!15 = !{!13, !14, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"double", !7, i64 0}
!18 = !{i64 0, i64 8, !11}
!19 = !{!20, !10, i64 0}
!20 = !{!"CELLREC", !21, i64 0, !6, i64 8, !7, i64 16, !7, i64 17, !7, i64 18, !6, i64 24, !22, i64 32, !23, i64 56}
!21 = !{!"CELLADR", !10, i64 0, !10, i64 4}
!22 = !{!"CELLVALUE", !17, i64 0, !17, i64 8, !6, i64 16}
!23 = !{!"CELLSTRING", !14, i64 0, !6, i64 8}
!24 = !{!20, !10, i64 4}
!25 = !{!20, !7, i64 17}
!26 = !{!20, !7, i64 18}
!27 = !{!20, !7, i64 16}
!28 = !{!20, !6, i64 24}
!29 = !{!20, !17, i64 32}
!30 = distinct !{!30, !31}
!31 = !{!"llvm.loop.mustprogress"}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.CELLREC = type { %struct.CELLADR, ptr, i8, i8, i8, ptr, %struct.CELLVALUE, %struct.CELLSTRING }
%struct.CELLADR = type { i32, i32 }
%struct.CELLVALUE = type { double, double, ptr }
%struct.CELLSTRING = type { i16, ptr }
%struct.Lotrec = type { i16, i16, %union.anon.0 }
%union.anon.0 = type <{ %struct.anon.5, [2039 x i8] }>
%struct.anon.5 = type { [16 x i8], %struct.CELLADR123, %struct.CELLADR123 }
%struct.CELLADR123 = type { i16, i16 }

@.str = external hidden unnamed_addr constant [13 x i8], align 1
@curcol = external local_unnamed_addr global i32, align 4
@currow = external local_unnamed_addr global i32, align 4
@leftcol = external local_unnamed_addr global i32, align 4
@windowrow = external local_unnamed_addr global i32, align 4
@borderline = external local_unnamed_addr global i32, align 4
@windowline = external local_unnamed_addr global i32, align 4
@toprow = external local_unnamed_addr global i32, align 4
@colwidth = external local_unnamed_addr global [702 x i8], align 16
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@omarkrow = external local_unnamed_addr global i32, align 4
@omarkcol = external local_unnamed_addr global i32, align 4
@lastcol = external local_unnamed_addr global i32, align 4
@markcol = external local_unnamed_addr global i32, align 4
@lastrow = external local_unnamed_addr global i32, align 4
@markrow = external local_unnamed_addr global i32, align 4

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @fromwks(ptr nocapture noundef readnone %0) local_unnamed_addr #0 {
  %2 = alloca %struct.CELLREC, align 8
  %3 = alloca [32768 x i8], align 16
  %4 = alloca %struct.Lotrec, align 2
  call void @llvm.lifetime.start.p0(i64 72, ptr nonnull %2) #7
  call void @llvm.lifetime.start.p0(i64 32768, ptr nonnull %3) #7
  call void @llvm.lifetime.start.p0(i64 2068, ptr nonnull %4) #7
  %5 = call i32 @getwksrecord(ptr noundef nonnull %4) #7
  %6 = icmp ne i32 %5, 0
  %7 = getelementptr inbounds i8, ptr %4, i64 2
  %8 = load i16, ptr %7, align 2
  %9 = icmp ne i16 %8, 2
  %or.cond = select i1 %6, i1 true, i1 %9
  br i1 %or.cond, label %10, label %11

10:                                               ; preds = %1
  call void @fatal(i32 noundef 10, ptr noundef nonnull @.str) #7
  br label %11

11:                                               ; preds = %1, %10
  %12 = getelementptr inbounds i8, ptr %4, i64 4
  %13 = load i16, ptr %12, align 2, !tbaa !5
  %14 = add i16 %13, -1031
  %or.cond7 = icmp ult i16 %14, -3
  br i1 %or.cond7, label %15, label %16

15:                                               ; preds = %11
  call void @fatal(i32 noundef 10, ptr noundef nonnull @.str) #7
  br label %16

16:                                               ; preds = %15, %11
  %17 = call i32 @getwksrecord(ptr noundef nonnull %4) #7
  %.not39 = icmp eq i32 %17, 1
  br i1 %.not39, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %16
  %18 = getelementptr inbounds i8, ptr %4, i64 9
  %19 = getelementptr inbounds i8, ptr %4, i64 19
  %20 = getelementptr inbounds i8, ptr %4, i64 5
  %21 = getelementptr inbounds i8, ptr %4, i64 7
  %22 = getelementptr inbounds i8, ptr %2, i64 4
  %23 = getelementptr inbounds i8, ptr %2, i64 18
  %24 = getelementptr inbounds i8, ptr %2, i64 16
  %25 = getelementptr inbounds i8, ptr %2, i64 24
  %26 = getelementptr inbounds i8, ptr %2, i64 32
  %27 = getelementptr inbounds i8, ptr %4, i64 20
  %28 = getelementptr inbounds i8, ptr %4, i64 22
  %29 = getelementptr inbounds i8, ptr %4, i64 24
  %30 = getelementptr inbounds i8, ptr %4, i64 26
  %31 = getelementptr inbounds i8, ptr %4, i64 6
  %32 = getelementptr inbounds i8, ptr %4, i64 16
  %33 = getelementptr inbounds i8, ptr %4, i64 18
  %34 = getelementptr inbounds i8, ptr %2, i64 8
  br label %35

35:                                               ; preds = %.lr.ph, %92
  %.042 = phi i8 [ 127, %.lr.ph ], [ %.1, %92 ]
  %.02841 = phi i32 [ 0, %.lr.ph ], [ %.2, %92 ]
  %.03140 = phi i32 [ 0, %.lr.ph ], [ %.132, %92 ]
  %36 = load i16, ptr %4, align 2, !tbaa !8
  switch i16 %36, label %92 [
    i16 7, label %37
    i16 8, label %53
    i16 11, label %58
    i16 36, label %68
    i16 13, label %71
    i16 14, label %76
    i16 15, label %78
    i16 16, label %80
  ]

37:                                               ; preds = %35
  %38 = load i16, ptr %12, align 2, !tbaa !5
  %39 = sext i16 %38 to i32
  store i32 %39, ptr @curcol, align 4, !tbaa !11
  %40 = load i16, ptr %31, align 2, !tbaa !5
  %41 = sext i16 %40 to i32
  store i32 %41, ptr @currow, align 4, !tbaa !11
  %42 = load i16, ptr %32, align 2, !tbaa !5
  %43 = sext i16 %42 to i32
  store i32 %43, ptr @leftcol, align 4, !tbaa !11
  %44 = load i16, ptr %33, align 2, !tbaa !5
  %45 = sext i16 %44 to i32
  store i32 %45, ptr @windowrow, align 4, !tbaa !11
  %46 = load i32, ptr @borderline, align 4, !tbaa !11
  %47 = add nsw i32 %46, 1
  %48 = load i16, ptr %28, align 2, !tbaa !5
  %49 = sext i16 %48 to i32
  %50 = add nsw i32 %47, %49
  store i32 %50, ptr @windowline, align 4, !tbaa !11
  %51 = load i16, ptr %30, align 2, !tbaa !5
  %52 = sext i16 %51 to i32
  store i32 %52, ptr @toprow, align 4, !tbaa !11
  br label %92

53:                                               ; preds = %35
  %54 = load i16, ptr %12, align 2, !tbaa !5
  %55 = load i8, ptr %31, align 2, !tbaa !5
  %56 = sext i16 %54 to i64
  %57 = getelementptr inbounds [702 x i8], ptr @colwidth, i64 0, i64 %56
  store i8 %55, ptr %57, align 1, !tbaa !5
  br label %92

58:                                               ; preds = %35
  %59 = load i16, ptr %27, align 2, !tbaa !5
  %60 = sext i16 %59 to i32
  %61 = load i16, ptr %28, align 2, !tbaa !5
  %62 = sext i16 %61 to i32
  %63 = load i16, ptr %29, align 2, !tbaa !5
  %64 = sext i16 %63 to i32
  %65 = load i16, ptr %30, align 2, !tbaa !5
  %66 = sext i16 %65 to i32
  %67 = call i32 @updaterange(ptr noundef nonnull %12, i32 noundef %60, i32 noundef %62, i32 noundef %64, i32 noundef %66) #7
  br label %92

68:                                               ; preds = %35
  %69 = load i8, ptr %12, align 2, !tbaa !5
  %.not37 = icmp eq i8 %69, 0
  %70 = select i1 %.not37, i8 127, i8 -1
  br label %92

71:                                               ; preds = %35
  %72 = load i16, ptr %18, align 1, !tbaa !5
  %73 = sitofp i16 %72 to double
  %74 = sext i16 %72 to i32
  %75 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %3, ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %74) #7
  br label %82

76:                                               ; preds = %35
  %.sroa.0.0.copyload = load double, ptr %18, align 1, !tbaa !5
  %77 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %3, ptr noundef nonnull dereferenceable(1) @.str.2, double noundef %.sroa.0.0.copyload) #7
  br label %82

78:                                               ; preds = %35
  call void @convertlabel(ptr noundef nonnull %4) #7
  %79 = call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %3, ptr noundef nonnull dereferenceable(1) %18) #7
  br label %82

80:                                               ; preds = %35
  %.sroa.0.0.copyload11 = load double, ptr %18, align 1, !tbaa !5
  %81 = call i32 @pol2tex(ptr noundef nonnull %3, ptr noundef nonnull %19) #7
  %.not36 = icmp eq i32 %81, 0
  br i1 %.not36, label %82, label %92

82:                                               ; preds = %80, %78, %76, %71
  %.033 = phi i8 [ 3, %80 ], [ 1, %78 ], [ 2, %76 ], [ 2, %71 ]
  %.030 = phi double [ %.sroa.0.0.copyload11, %80 ], [ 0.000000e+00, %78 ], [ %.sroa.0.0.copyload, %76 ], [ %73, %71 ]
  %83 = load i16, ptr %20, align 1, !tbaa !5
  %84 = sext i16 %83 to i32
  %85 = load i16, ptr %21, align 1, !tbaa !5
  %86 = sext i16 %85 to i32
  %87 = load i8, ptr %12, align 2, !tbaa !5
  %88 = call zeroext i8 @convertformat(i8 noundef zeroext %87) #7
  %89 = and i8 %88, %.042
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(72) %34, i8 0, i64 64, i1 false)
  store i32 %84, ptr %2, align 8, !tbaa !13
  store i32 %86, ptr %22, align 4, !tbaa !20
  %90 = icmp eq i8 %89, 0
  %narrow = select i1 %90, i8 15, i8 %89
  store i8 %narrow, ptr %23, align 2, !tbaa !21
  store i8 %.033, ptr %24, align 8, !tbaa !22
  store ptr %3, ptr %25, align 8, !tbaa !23
  store double %.030, ptr %26, align 8, !tbaa !24
  %91 = call ptr @migratecell(ptr noundef nonnull %2) #7
  %spec.select = call i32 @llvm.smax.i32(i32 %.02841, i32 %84)
  %spec.select38 = call i32 @llvm.smax.i32(i32 %.03140, i32 %86)
  br label %92

92:                                               ; preds = %82, %35, %80, %68, %58, %53, %37
  %.132 = phi i32 [ %.03140, %35 ], [ %.03140, %80 ], [ %.03140, %68 ], [ %.03140, %58 ], [ %.03140, %53 ], [ %.03140, %37 ], [ %spec.select38, %82 ]
  %.2 = phi i32 [ %.02841, %35 ], [ %.02841, %80 ], [ %.02841, %68 ], [ %.02841, %58 ], [ %.02841, %53 ], [ %.02841, %37 ], [ %spec.select, %82 ]
  %.1 = phi i8 [ %.042, %35 ], [ %.042, %80 ], [ %70, %68 ], [ %.042, %58 ], [ %.042, %53 ], [ %.042, %37 ], [ %.042, %82 ]
  %93 = call i32 @getwksrecord(ptr noundef nonnull %4) #7
  %.not = icmp eq i32 %93, 1
  br i1 %.not, label %._crit_edge, label %35, !llvm.loop !25

._crit_edge:                                      ; preds = %92, %16
  %.031.lcssa = phi i32 [ 0, %16 ], [ %.132, %92 ]
  %.028.lcssa = phi i32 [ 0, %16 ], [ %.2, %92 ]
  store i32 0, ptr @omarkrow, align 4, !tbaa !11
  store i32 0, ptr @omarkcol, align 4, !tbaa !11
  store i32 %.028.lcssa, ptr @lastcol, align 4, !tbaa !11
  store i32 %.028.lcssa, ptr @markcol, align 4, !tbaa !11
  store i32 %.031.lcssa, ptr @lastrow, align 4, !tbaa !11
  store i32 %.031.lcssa, ptr @markrow, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 2068, ptr nonnull %4) #7
  call void @llvm.lifetime.end.p0(i64 32768, ptr nonnull %3) #7
  call void @llvm.lifetime.end.p0(i64 72, ptr nonnull %2) #7
  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 i32 @getwksrecord(ptr noundef) local_unnamed_addr #2

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

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

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

declare void @convertlabel(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strcpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly) local_unnamed_addr #4

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

declare zeroext i8 @convertformat(i8 noundef zeroext) local_unnamed_addr #2

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

declare ptr @migratecell(ptr 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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #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 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 = { mustprogress nofree nounwind willreturn memory(argmem: readwrite) "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 nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #7 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !10, i64 0}
!9 = !{!"", !10, i64 0, !10, i64 2, !6, i64 4}
!10 = !{!"short", !6, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !6, i64 0}
!13 = !{!14, !12, i64 0}
!14 = !{!"CELLREC", !15, i64 0, !16, i64 8, !6, i64 16, !6, i64 17, !6, i64 18, !16, i64 24, !17, i64 32, !19, i64 56}
!15 = !{!"CELLADR", !12, i64 0, !12, i64 4}
!16 = !{!"any pointer", !6, i64 0}
!17 = !{!"CELLVALUE", !18, i64 0, !18, i64 8, !16, i64 16}
!18 = !{!"double", !6, i64 0}
!19 = !{!"CELLSTRING", !10, i64 0, !16, i64 8}
!20 = !{!14, !12, i64 4}
!21 = !{!14, !6, i64 18}
!22 = !{!14, !6, i64 16}
!23 = !{!14, !16, i64 24}
!24 = !{!14, !18, i64 32}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}


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