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

; 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.BUFFER = type { ptr, ptr, i32, ptr, i32, ptr, i32, i32, [128 x i8], [128 x i8] }
%struct.LINE = type { ptr, ptr, i16, i16, [32768 x i8] }
%struct.WINDOW = type { ptr, ptr, ptr, ptr, i32, ptr, i32, i32, i32, i32, i32, i32 }

@curbp = external global ptr, align 8
@foreignformat = external hidden global i32, align 4
@longline = external hidden global i32, align 4
@.str.9 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [18 x i8], align 1
@curwp = external global ptr, align 8
@.str.12 = external hidden unnamed_addr constant [18 x i8], align 1
@wheadp = external global ptr, align 8

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @ffropen(ptr noundef) #1

declare void @mlwrite(ptr noundef, ...) #2

; Function Attrs: nounwind uwtable
declare dso_local void @frclose() #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @ffgetline(ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @readin(ptr noundef %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca [32768 x i8], align 16
  %15 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 32768, ptr %14) #4
  store i32 0, ptr @longline, align 4, !tbaa !9
  store i32 0, ptr @foreignformat, align 4, !tbaa !9
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = call i32 @ffropen(ptr noundef %16)
  store i32 %17, ptr %9, align 4, !tbaa !9
  %18 = load i32, ptr %9, align 4, !tbaa !9
  %19 = icmp eq i32 %18, 3
  br i1 %19, label %20, label %21

20:                                               ; preds = %1
  call void (ptr, ...) @mlwrite(ptr noundef @.str.9)
  br label %21

21:                                               ; preds = %20, %1
  %22 = load i32, ptr %9, align 4, !tbaa !9
  %23 = icmp eq i32 %22, 1
  br i1 %23, label %24, label %25

24:                                               ; preds = %21
  call void (ptr, ...) @mlwrite(ptr noundef @.str.10)
  br label %25

25:                                               ; preds = %24, %21
  %26 = load i32, ptr %9, align 4, !tbaa !9
  %27 = icmp ne i32 %26, 0
  br i1 %27, label %28, label %30

28:                                               ; preds = %25
  %29 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %29, ptr %2, align 4
  store i32 1, ptr %15, align 4
  br label %192

30:                                               ; preds = %25
  call void (ptr, ...) @mlwrite(ptr noundef @.str.11)
  %31 = load ptr, ptr @curwp, align 8, !tbaa !5
  store ptr %31, ptr %10, align 8, !tbaa !5
  %32 = load ptr, ptr @curbp, align 8, !tbaa !5
  store ptr %32, ptr %11, align 8, !tbaa !5
  %33 = load ptr, ptr %11, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.BUFFER, ptr %33, i32 0, i32 5
  %35 = load ptr, ptr %34, align 8, !tbaa !11
  %36 = getelementptr inbounds %struct.LINE, ptr %35, i32 0, i32 0
  %37 = load ptr, ptr %36, align 8, !tbaa !13
  store ptr %37, ptr %13, align 8, !tbaa !5
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %38

38:                                               ; preds = %120, %30
  %39 = getelementptr inbounds [32768 x i8], ptr %14, i64 0, i64 0
  %40 = call i32 @ffgetline(ptr noundef %39, i32 noundef 32768)
  store i32 %40, ptr %9, align 4, !tbaa !9
  %41 = icmp eq i32 %40, 0
  br i1 %41, label %45, label %42

42:                                               ; preds = %38
  %43 = load i32, ptr %9, align 4, !tbaa !9
  %44 = icmp eq i32 %43, 4
  br label %45

45:                                               ; preds = %42, %38
  %46 = phi i1 [ true, %38 ], [ %44, %42 ]
  br i1 %46, label %47, label %121

47:                                               ; preds = %45
  %48 = getelementptr inbounds [32768 x i8], ptr %14, i64 0, i64 0
  %49 = call i64 @strlen(ptr noundef %48) #5
  %50 = trunc i64 %49 to i32
  store i32 %50, ptr %7, align 4, !tbaa !9
  %51 = load i32, ptr %7, align 4, !tbaa !9
  %52 = icmp eq i32 %51, 0
  br i1 %52, label %53, label %57

53:                                               ; preds = %47
  %54 = load i32, ptr %9, align 4, !tbaa !9
  %55 = icmp eq i32 %54, 4
  br i1 %55, label %56, label %57

56:                                               ; preds = %53
  br label %121

57:                                               ; preds = %53, %47
  %58 = load i32, ptr %7, align 4, !tbaa !9
  %59 = icmp eq i32 %58, 32767
  br i1 %59, label %60, label %61

60:                                               ; preds = %57
  store i32 1, ptr @longline, align 4, !tbaa !9
  br label %61

61:                                               ; preds = %60, %57
  %62 = load i32, ptr %7, align 4, !tbaa !9
  %63 = call ptr (i32, ...) @lalloc(i32 noundef %62)
  store ptr %63, ptr %4, align 8, !tbaa !5
  %64 = icmp eq ptr %63, null
  br i1 %64, label %65, label %70

65:                                               ; preds = %61
  store i32 3, ptr %9, align 4, !tbaa !9
  %66 = load ptr, ptr %11, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.BUFFER, ptr %66, i32 0, i32 7
  %68 = load i32, ptr %67, align 4, !tbaa !16
  %69 = and i32 %68, -5
  store i32 %69, ptr %67, align 4, !tbaa !16
  br label %121

70:                                               ; preds = %61
  %71 = load i32, ptr %8, align 4, !tbaa !9
  %72 = icmp eq i32 %71, 0
  br i1 %72, label %73, label %75

73:                                               ; preds = %70
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %74, ptr %13, align 8, !tbaa !5
  br label %75

75:                                               ; preds = %73, %70
  %76 = load ptr, ptr %10, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.WINDOW, ptr %76, i32 0, i32 3
  %78 = load ptr, ptr %77, align 8, !tbaa !17
  %79 = getelementptr inbounds %struct.LINE, ptr %78, i32 0, i32 1
  %80 = load ptr, ptr %79, align 8, !tbaa !19
  store ptr %80, ptr %12, align 8, !tbaa !5
  %81 = load ptr, ptr %4, align 8, !tbaa !5
  %82 = load ptr, ptr %12, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.LINE, ptr %82, i32 0, i32 0
  store ptr %81, ptr %83, align 8, !tbaa !13
  %84 = load ptr, ptr %10, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.WINDOW, ptr %84, i32 0, i32 3
  %86 = load ptr, ptr %85, align 8, !tbaa !17
  %87 = load ptr, ptr %4, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.LINE, ptr %87, i32 0, i32 0
  store ptr %86, ptr %88, align 8, !tbaa !13
  %89 = load ptr, ptr %12, align 8, !tbaa !5
  %90 = load ptr, ptr %4, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.LINE, ptr %90, i32 0, i32 1
  store ptr %89, ptr %91, align 8, !tbaa !19
  %92 = load ptr, ptr %4, align 8, !tbaa !5
  %93 = load ptr, ptr %10, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.WINDOW, ptr %93, i32 0, i32 3
  %95 = load ptr, ptr %94, align 8, !tbaa !17
  %96 = getelementptr inbounds %struct.LINE, ptr %95, i32 0, i32 1
  store ptr %92, ptr %96, align 8, !tbaa !19
  %97 = getelementptr inbounds [32768 x i8], ptr %14, i64 0, i64 0
  store ptr %97, ptr %5, align 8, !tbaa !5
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %98

98:                                               ; preds = %111, %75
  %99 = load i32, ptr %6, align 4, !tbaa !9
  %100 = load i32, ptr %7, align 4, !tbaa !9
  %101 = icmp slt i32 %99, %100
  br i1 %101, label %102, label %114

102:                                              ; preds = %98
  %103 = load ptr, ptr %5, align 8, !tbaa !5
  %104 = getelementptr inbounds i8, ptr %103, i32 1
  store ptr %104, ptr %5, align 8, !tbaa !5
  %105 = load i8, ptr %103, align 1, !tbaa !20
  %106 = load ptr, ptr %4, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.LINE, ptr %106, i32 0, i32 4
  %108 = load i32, ptr %6, align 4, !tbaa !9
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds [32768 x i8], ptr %107, i64 0, i64 %109
  store i8 %105, ptr %110, align 1, !tbaa !20
  br label %111

111:                                              ; preds = %102
  %112 = load i32, ptr %6, align 4, !tbaa !9
  %113 = add nsw i32 %112, 1
  store i32 %113, ptr %6, align 4, !tbaa !9
  br label %98, !llvm.loop !21

114:                                              ; preds = %98
  %115 = load i32, ptr %8, align 4, !tbaa !9
  %116 = add nsw i32 %115, 1
  store i32 %116, ptr %8, align 4, !tbaa !9
  %117 = load i32, ptr %9, align 4, !tbaa !9
  %118 = icmp eq i32 %117, 4
  br i1 %118, label %119, label %120

119:                                              ; preds = %114
  br label %121

120:                                              ; preds = %114
  br label %38, !llvm.loop !23

121:                                              ; preds = %119, %65, %56, %45
  call void @frclose()
  %122 = load i32, ptr @longline, align 4, !tbaa !9
  %123 = icmp ne i32 %122, 0
  br i1 %123, label %124, label %132

124:                                              ; preds = %121
  %125 = load ptr, ptr %11, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct.BUFFER, ptr %125, i32 0, i32 7
  %127 = load i32, ptr %126, align 4, !tbaa !16
  %128 = and i32 %127, -5
  store i32 %128, ptr %126, align 4, !tbaa !16
  %129 = load ptr, ptr %11, align 8, !tbaa !5
  %130 = getelementptr inbounds %struct.BUFFER, ptr %129, i32 0, i32 8
  %131 = getelementptr inbounds [128 x i8], ptr %130, i64 0, i64 0
  store i8 0, ptr %131, align 8, !tbaa !20
  br label %132

132:                                              ; preds = %124, %121
  %133 = load i32, ptr @foreignformat, align 4, !tbaa !9
  %134 = icmp ne i32 %133, 0
  br i1 %134, label %135, label %140

135:                                              ; preds = %132
  %136 = load ptr, ptr %11, align 8, !tbaa !5
  %137 = getelementptr inbounds %struct.BUFFER, ptr %136, i32 0, i32 7
  %138 = load i32, ptr %137, align 4, !tbaa !16
  %139 = or i32 %138, 8
  store i32 %139, ptr %137, align 4, !tbaa !16
  br label %140

140:                                              ; preds = %135, %132
  %141 = load i32, ptr %9, align 4, !tbaa !9
  %142 = icmp eq i32 %141, 2
  br i1 %142, label %143, label %151

143:                                              ; preds = %140
  %144 = load i32, ptr @longline, align 4, !tbaa !9
  %145 = icmp ne i32 %144, 0
  br i1 %145, label %151, label %146

146:                                              ; preds = %143
  %147 = load i32, ptr @foreignformat, align 4, !tbaa !9
  %148 = icmp ne i32 %147, 0
  br i1 %148, label %151, label %149

149:                                              ; preds = %146
  %150 = load i32, ptr %8, align 4, !tbaa !9
  call void (ptr, ...) @mlwrite(ptr noundef @.str.12, i32 noundef %150)
  br label %151

151:                                              ; preds = %149, %146, %143, %140
  %152 = load i32, ptr %9, align 4, !tbaa !9
  %153 = icmp eq i32 %152, 4
  br i1 %153, label %154, label %155

154:                                              ; preds = %151
  store i32 2, ptr %9, align 4, !tbaa !9
  br label %155

155:                                              ; preds = %154, %151
  %156 = load ptr, ptr @wheadp, align 8, !tbaa !5
  store ptr %156, ptr %10, align 8, !tbaa !5
  br label %157

157:                                              ; preds = %186, %155
  %158 = load ptr, ptr %10, align 8, !tbaa !5
  %159 = icmp ne ptr %158, null
  br i1 %159, label %160, label %190

160:                                              ; preds = %157
  %161 = load ptr, ptr %10, align 8, !tbaa !5
  %162 = getelementptr inbounds %struct.WINDOW, ptr %161, i32 0, i32 1
  %163 = load ptr, ptr %162, align 8, !tbaa !24
  %164 = load ptr, ptr %11, align 8, !tbaa !5
  %165 = icmp eq ptr %163, %164
  br i1 %165, label %166, label %185

166:                                              ; preds = %160
  %167 = load ptr, ptr %13, align 8, !tbaa !5
  %168 = load ptr, ptr %10, align 8, !tbaa !5
  %169 = getelementptr inbounds %struct.WINDOW, ptr %168, i32 0, i32 2
  store ptr %167, ptr %169, align 8, !tbaa !25
  %170 = load ptr, ptr %13, align 8, !tbaa !5
  %171 = load ptr, ptr %10, align 8, !tbaa !5
  %172 = getelementptr inbounds %struct.WINDOW, ptr %171, i32 0, i32 3
  store ptr %170, ptr %172, align 8, !tbaa !17
  %173 = load ptr, ptr %10, align 8, !tbaa !5
  %174 = getelementptr inbounds %struct.WINDOW, ptr %173, i32 0, i32 4
  store i32 0, ptr %174, align 8, !tbaa !26
  %175 = load ptr, ptr %10, align 8, !tbaa !5
  %176 = getelementptr inbounds %struct.WINDOW, ptr %175, i32 0, i32 10
  store i32 0, ptr %176, align 8, !tbaa !27
  %177 = load ptr, ptr %10, align 8, !tbaa !5
  %178 = getelementptr inbounds %struct.WINDOW, ptr %177, i32 0, i32 11
  %179 = load i32, ptr %178, align 4, !tbaa !28
  %180 = or i32 %179, 25
  store i32 %180, ptr %178, align 4, !tbaa !28
  %181 = load ptr, ptr %10, align 8, !tbaa !5
  %182 = getelementptr inbounds %struct.WINDOW, ptr %181, i32 0, i32 5
  store ptr null, ptr %182, align 8, !tbaa !29
  %183 = load ptr, ptr %10, align 8, !tbaa !5
  %184 = getelementptr inbounds %struct.WINDOW, ptr %183, i32 0, i32 6
  store i32 0, ptr %184, align 8, !tbaa !30
  br label %185

185:                                              ; preds = %166, %160
  br label %186

186:                                              ; preds = %185
  %187 = load ptr, ptr %10, align 8, !tbaa !5
  %188 = getelementptr inbounds %struct.WINDOW, ptr %187, i32 0, i32 0
  %189 = load ptr, ptr %188, align 8, !tbaa !31
  store ptr %189, ptr %10, align 8, !tbaa !5
  br label %157, !llvm.loop !32

190:                                              ; preds = %157
  %191 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %191, ptr %2, align 4
  store i32 1, ptr %15, align 4
  br label %192

192:                                              ; preds = %190, %28
  call void @llvm.lifetime.end.p0(i64 32768, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  %193 = load i32, ptr %2, align 4
  ret i32 %193
}

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #3

declare ptr @lalloc(...) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { "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 willreturn memory(read) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }
attributes #5 = { nounwind willreturn memory(read) }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 40}
!12 = !{!"BUFFER", !6, i64 0, !6, i64 8, !10, i64 16, !6, i64 24, !10, i64 32, !6, i64 40, !10, i64 48, !10, i64 52, !7, i64 56, !7, i64 184}
!13 = !{!14, !6, i64 0}
!14 = !{!"LINE", !6, i64 0, !6, i64 8, !15, i64 16, !15, i64 18, !7, i64 20}
!15 = !{!"short", !7, i64 0}
!16 = !{!12, !10, i64 52}
!17 = !{!18, !6, i64 24}
!18 = !{!"WINDOW", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !10, i64 32, !6, i64 40, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68}
!19 = !{!14, !6, i64 8}
!20 = !{!7, !7, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = distinct !{!23, !22}
!24 = !{!18, !6, i64 8}
!25 = !{!18, !6, i64 16}
!26 = !{!18, !10, i64 32}
!27 = !{!18, !10, i64 64}
!28 = !{!18, !10, i64 68}
!29 = !{!18, !6, i64 40}
!30 = !{!18, !10, i64 48}
!31 = !{!18, !6, i64 0}
!32 = distinct !{!32, !22}


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

@curbp = external local_unnamed_addr global ptr, align 8
@foreignformat = external hidden local_unnamed_addr global i32, align 4
@longline = external hidden local_unnamed_addr global i32, align 4
@.str.9 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [18 x i8], align 1
@curwp = external local_unnamed_addr global ptr, align 8
@.str.12 = external hidden unnamed_addr constant [18 x i8], align 1
@wheadp = external local_unnamed_addr global ptr, align 8

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @ffropen(ptr noundef) local_unnamed_addr #1

declare void @mlwrite(ptr noundef, ...) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local void @frclose() local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @ffgetline(ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @readin(ptr noundef %0) local_unnamed_addr #1 {
  %2 = alloca [32768 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 32768, ptr nonnull %2) #4
  store i32 0, ptr @longline, align 4, !tbaa !5
  store i32 0, ptr @foreignformat, align 4, !tbaa !5
  %3 = tail call i32 @ffropen(ptr noundef %0)
  switch i32 %3, label %.loopexit [
    i32 3, label %.loopexit.sink.split
    i32 1, label %4
    i32 0, label %5
  ]

4:                                                ; preds = %1
  br label %.loopexit.sink.split

5:                                                ; preds = %1
  %6 = ptrtoint ptr %2 to i64
  tail call void (ptr, ...) @mlwrite(ptr noundef nonnull @.str.11) #4
  %7 = load ptr, ptr @curwp, align 8, !tbaa !9
  %8 = load ptr, ptr @curbp, align 8, !tbaa !9
  %9 = getelementptr inbounds i8, ptr %8, i64 40
  %10 = load ptr, ptr %9, align 8, !tbaa !11
  %11 = load ptr, ptr %10, align 8, !tbaa !13
  %12 = getelementptr inbounds i8, ptr %7, i64 24
  br label %13

13:                                               ; preds = %._crit_edge, %5
  %.060 = phi i32 [ 0, %5 ], [ %64, %._crit_edge ]
  %.0 = phi ptr [ %11, %5 ], [ %spec.select, %._crit_edge ]
  %14 = call i32 @ffgetline(ptr noundef nonnull %2, i32 noundef 32768)
  %15 = icmp eq i32 %14, 4
  switch i32 %14, label %.loopexit73 [
    i32 4, label %16
    i32 0, label %16
  ]

16:                                               ; preds = %13, %13
  %17 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %2) #5
  %18 = trunc i64 %17 to i32
  %19 = icmp eq i32 %18, 0
  %or.cond = and i1 %15, %19
  br i1 %or.cond, label %.loopexit73, label %20

20:                                               ; preds = %16
  %21 = icmp eq i32 %18, 32767
  br i1 %21, label %22, label %23

22:                                               ; preds = %20
  store i32 1, ptr @longline, align 4, !tbaa !5
  br label %23

23:                                               ; preds = %22, %20
  %24 = call ptr (i32, ...) @lalloc(i32 noundef %18) #4
  %25 = ptrtoint ptr %24 to i64
  %26 = icmp eq ptr %24, null
  br i1 %26, label %27, label %31

27:                                               ; preds = %23
  %28 = getelementptr inbounds i8, ptr %8, i64 52
  %29 = load i32, ptr %28, align 4, !tbaa !16
  %30 = and i32 %29, -5
  store i32 %30, ptr %28, align 4, !tbaa !16
  br label %.loopexit73

31:                                               ; preds = %23
  %32 = icmp eq i32 %.060, 0
  %spec.select = select i1 %32, ptr %24, ptr %.0
  %33 = load ptr, ptr %12, align 8, !tbaa !17
  %34 = getelementptr inbounds i8, ptr %33, i64 8
  %35 = load ptr, ptr %34, align 8, !tbaa !19
  store ptr %24, ptr %35, align 8, !tbaa !13
  store ptr %33, ptr %24, align 8, !tbaa !13
  %36 = getelementptr inbounds i8, ptr %24, i64 8
  store ptr %35, ptr %36, align 8, !tbaa !19
  store ptr %24, ptr %34, align 8, !tbaa !19
  %37 = icmp sgt i32 %18, 0
  br i1 %37, label %iter.check, label %._crit_edge

iter.check:                                       ; preds = %31
  %38 = getelementptr inbounds i8, ptr %24, i64 20
  %wide.trip.count = and i64 %17, 2147483647
  %min.iters.check = icmp ult i64 %wide.trip.count, 8
  br i1 %min.iters.check, label %vec.epilog.scalar.ph.preheader, label %vector.memcheck

vector.memcheck:                                  ; preds = %iter.check
  %reass.sub = sub i64 %25, %6
  %39 = add i64 %reass.sub, 20
  %diff.check = icmp ult i64 %39, 32
  br i1 %diff.check, label %vec.epilog.scalar.ph.preheader, label %vector.main.loop.iter.check

vector.main.loop.iter.check:                      ; preds = %vector.memcheck
  %min.iters.check90 = icmp ult i64 %wide.trip.count, 32
  br i1 %min.iters.check90, label %vec.epilog.ph, label %vector.ph

vector.ph:                                        ; preds = %vector.main.loop.iter.check
  %n.mod.vf = and i64 %17, 31
  %n.vec = sub nsw i64 %wide.trip.count, %n.mod.vf
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %next.gep = getelementptr i8, ptr %2, i64 %index
  %40 = getelementptr i8, ptr %next.gep, i64 16
  %wide.load = load <16 x i8>, ptr %next.gep, align 16, !tbaa !20
  %wide.load92 = load <16 x i8>, ptr %40, align 16, !tbaa !20
  %41 = getelementptr inbounds [32768 x i8], ptr %38, i64 0, i64 %index
  %42 = getelementptr inbounds i8, ptr %41, i64 16
  store <16 x i8> %wide.load, ptr %41, align 1, !tbaa !20
  store <16 x i8> %wide.load92, ptr %42, align 1, !tbaa !20
  %index.next = add nuw i64 %index, 32
  %43 = icmp eq i64 %index.next, %n.vec
  br i1 %43, label %middle.block, label %vector.body, !llvm.loop !21

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.mod.vf, 0
  br i1 %cmp.n, label %._crit_edge, label %vec.epilog.iter.check

vec.epilog.iter.check:                            ; preds = %middle.block
  %ind.end95 = getelementptr i8, ptr %2, i64 %n.vec
  %min.epilog.iters.check = icmp ult i64 %n.mod.vf, 8
  br i1 %min.epilog.iters.check, label %vec.epilog.scalar.ph.preheader, label %vec.epilog.ph

vec.epilog.ph:                                    ; preds = %vector.main.loop.iter.check, %vec.epilog.iter.check
  %vec.epilog.resume.val = phi i64 [ %n.vec, %vec.epilog.iter.check ], [ 0, %vector.main.loop.iter.check ]
  %n.mod.vf93 = and i64 %17, 7
  %n.vec94 = sub nsw i64 %wide.trip.count, %n.mod.vf93
  %ind.end = getelementptr i8, ptr %2, i64 %n.vec94
  br label %vec.epilog.vector.body

vec.epilog.vector.body:                           ; preds = %vec.epilog.vector.body, %vec.epilog.ph
  %index97 = phi i64 [ %vec.epilog.resume.val, %vec.epilog.ph ], [ %index.next100, %vec.epilog.vector.body ]
  %next.gep98 = getelementptr i8, ptr %2, i64 %index97
  %wide.load99 = load <8 x i8>, ptr %next.gep98, align 1, !tbaa !20
  %44 = getelementptr inbounds [32768 x i8], ptr %38, i64 0, i64 %index97
  store <8 x i8> %wide.load99, ptr %44, align 1, !tbaa !20
  %index.next100 = add nuw i64 %index97, 8
  %45 = icmp eq i64 %index.next100, %n.vec94
  br i1 %45, label %vec.epilog.middle.block, label %vec.epilog.vector.body, !llvm.loop !25

vec.epilog.middle.block:                          ; preds = %vec.epilog.vector.body
  %cmp.n101 = icmp eq i64 %n.mod.vf93, 0
  br i1 %cmp.n101, label %._crit_edge, label %vec.epilog.scalar.ph.preheader

vec.epilog.scalar.ph.preheader:                   ; preds = %vec.epilog.middle.block, %vector.memcheck, %iter.check, %vec.epilog.iter.check
  %indvars.iv.ph = phi i64 [ 0, %iter.check ], [ 0, %vector.memcheck ], [ %n.vec, %vec.epilog.iter.check ], [ %n.vec94, %vec.epilog.middle.block ]
  %.05777.ph = phi ptr [ %2, %iter.check ], [ %2, %vector.memcheck ], [ %ind.end95, %vec.epilog.iter.check ], [ %ind.end, %vec.epilog.middle.block ]
  %46 = sub i64 %17, %indvars.iv.ph
  %xtraiter = and i64 %46, 3
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %vec.epilog.scalar.ph.prol.loopexit, label %vec.epilog.scalar.ph.prol

vec.epilog.scalar.ph.prol:                        ; preds = %vec.epilog.scalar.ph.preheader, %vec.epilog.scalar.ph.prol
  %indvars.iv.prol = phi i64 [ %indvars.iv.next.prol, %vec.epilog.scalar.ph.prol ], [ %indvars.iv.ph, %vec.epilog.scalar.ph.preheader ]
  %.05777.prol = phi ptr [ %47, %vec.epilog.scalar.ph.prol ], [ %.05777.ph, %vec.epilog.scalar.ph.preheader ]
  %prol.iter = phi i64 [ %prol.iter.next, %vec.epilog.scalar.ph.prol ], [ 0, %vec.epilog.scalar.ph.preheader ]
  %47 = getelementptr inbounds i8, ptr %.05777.prol, i64 1
  %48 = load i8, ptr %.05777.prol, align 1, !tbaa !20
  %49 = getelementptr inbounds [32768 x i8], ptr %38, i64 0, i64 %indvars.iv.prol
  store i8 %48, ptr %49, align 1, !tbaa !20
  %indvars.iv.next.prol = add nuw nsw i64 %indvars.iv.prol, 1
  %prol.iter.next = add i64 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i64 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %vec.epilog.scalar.ph.prol.loopexit, label %vec.epilog.scalar.ph.prol, !llvm.loop !26

vec.epilog.scalar.ph.prol.loopexit:               ; preds = %vec.epilog.scalar.ph.prol, %vec.epilog.scalar.ph.preheader
  %indvars.iv.unr = phi i64 [ %indvars.iv.ph, %vec.epilog.scalar.ph.preheader ], [ %indvars.iv.next.prol, %vec.epilog.scalar.ph.prol ]
  %.05777.unr = phi ptr [ %.05777.ph, %vec.epilog.scalar.ph.preheader ], [ %47, %vec.epilog.scalar.ph.prol ]
  %50 = sub nsw i64 %indvars.iv.ph, %wide.trip.count
  %51 = icmp ugt i64 %50, -4
  br i1 %51, label %._crit_edge, label %vec.epilog.scalar.ph

vec.epilog.scalar.ph:                             ; preds = %vec.epilog.scalar.ph.prol.loopexit, %vec.epilog.scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next.3, %vec.epilog.scalar.ph ], [ %indvars.iv.unr, %vec.epilog.scalar.ph.prol.loopexit ]
  %.05777 = phi ptr [ %61, %vec.epilog.scalar.ph ], [ %.05777.unr, %vec.epilog.scalar.ph.prol.loopexit ]
  %52 = getelementptr inbounds i8, ptr %.05777, i64 1
  %53 = load i8, ptr %.05777, align 1, !tbaa !20
  %54 = getelementptr inbounds [32768 x i8], ptr %38, i64 0, i64 %indvars.iv
  store i8 %53, ptr %54, align 1, !tbaa !20
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %55 = getelementptr inbounds i8, ptr %.05777, i64 2
  %56 = load i8, ptr %52, align 1, !tbaa !20
  %57 = getelementptr inbounds [32768 x i8], ptr %38, i64 0, i64 %indvars.iv.next
  store i8 %56, ptr %57, align 1, !tbaa !20
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %58 = getelementptr inbounds i8, ptr %.05777, i64 3
  %59 = load i8, ptr %55, align 1, !tbaa !20
  %60 = getelementptr inbounds [32768 x i8], ptr %38, i64 0, i64 %indvars.iv.next.1
  store i8 %59, ptr %60, align 1, !tbaa !20
  %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv, 3
  %61 = getelementptr inbounds i8, ptr %.05777, i64 4
  %62 = load i8, ptr %58, align 1, !tbaa !20
  %63 = getelementptr inbounds [32768 x i8], ptr %38, i64 0, i64 %indvars.iv.next.2
  store i8 %62, ptr %63, align 1, !tbaa !20
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %exitcond.not.3 = icmp eq i64 %indvars.iv.next.3, %wide.trip.count
  br i1 %exitcond.not.3, label %._crit_edge, label %vec.epilog.scalar.ph, !llvm.loop !28

._crit_edge:                                      ; preds = %vec.epilog.scalar.ph.prol.loopexit, %vec.epilog.scalar.ph, %middle.block, %vec.epilog.middle.block, %31
  %64 = add nuw nsw i32 %.060, 1
  br i1 %15, label %.loopexit73, label %13, !llvm.loop !29

.loopexit73:                                      ; preds = %13, %._crit_edge, %16, %27
  %.161 = phi i32 [ %.060, %27 ], [ %.060, %13 ], [ %64, %._crit_edge ], [ %.060, %16 ]
  %.059 = phi i32 [ 3, %27 ], [ %14, %13 ], [ 4, %._crit_edge ], [ 4, %16 ]
  %.2 = phi ptr [ %.0, %27 ], [ %.0, %13 ], [ %spec.select, %._crit_edge ], [ %.0, %16 ]
  call void @frclose()
  %65 = load i32, ptr @longline, align 4
  %.not68 = icmp eq i32 %65, 0
  br i1 %.not68, label %71, label %66

66:                                               ; preds = %.loopexit73
  %67 = getelementptr inbounds i8, ptr %8, i64 52
  %68 = load i32, ptr %67, align 4, !tbaa !16
  %69 = and i32 %68, -5
  store i32 %69, ptr %67, align 4, !tbaa !16
  %70 = getelementptr inbounds i8, ptr %8, i64 56
  store i8 0, ptr %70, align 8, !tbaa !20
  br label %71

71:                                               ; preds = %66, %.loopexit73
  %72 = load i32, ptr @foreignformat, align 4
  %.not69 = icmp eq i32 %72, 0
  br i1 %.not69, label %76, label %.thread

.thread:                                          ; preds = %71
  %73 = getelementptr inbounds i8, ptr %8, i64 52
  %74 = load i32, ptr %73, align 4, !tbaa !16
  %75 = or i32 %74, 8
  store i32 %75, ptr %73, align 4, !tbaa !16
  br label %80

76:                                               ; preds = %71
  %77 = icmp ne i32 %.059, 2
  %78 = icmp ne i32 %65, 0
  %or.cond3 = or i1 %77, %78
  br i1 %or.cond3, label %80, label %79

79:                                               ; preds = %76
  call void (ptr, ...) @mlwrite(ptr noundef nonnull @.str.12, i32 noundef %.161) #4
  br label %80

80:                                               ; preds = %.thread, %79, %76
  %81 = icmp eq i32 %.059, 4
  %spec.store.select = select i1 %81, i32 2, i32 %.059
  %.05878 = load ptr, ptr @wheadp, align 8, !tbaa !9
  %.not7079 = icmp eq ptr %.05878, null
  br i1 %.not7079, label %.loopexit, label %.lr.ph82

.lr.ph82:                                         ; preds = %80, %95
  %.05880 = phi ptr [ %.058, %95 ], [ %.05878, %80 ]
  %82 = getelementptr inbounds i8, ptr %.05880, i64 8
  %83 = load ptr, ptr %82, align 8, !tbaa !30
  %84 = icmp eq ptr %83, %8
  br i1 %84, label %85, label %95

85:                                               ; preds = %.lr.ph82
  %86 = getelementptr inbounds i8, ptr %.05880, i64 16
  store ptr %.2, ptr %86, align 8, !tbaa !31
  %87 = getelementptr inbounds i8, ptr %.05880, i64 24
  store ptr %.2, ptr %87, align 8, !tbaa !17
  %88 = getelementptr inbounds i8, ptr %.05880, i64 32
  store i32 0, ptr %88, align 8, !tbaa !32
  %89 = getelementptr inbounds i8, ptr %.05880, i64 64
  store i32 0, ptr %89, align 8, !tbaa !33
  %90 = getelementptr inbounds i8, ptr %.05880, i64 68
  %91 = load i32, ptr %90, align 4, !tbaa !34
  %92 = or i32 %91, 25
  store i32 %92, ptr %90, align 4, !tbaa !34
  %93 = getelementptr inbounds i8, ptr %.05880, i64 40
  store ptr null, ptr %93, align 8, !tbaa !35
  %94 = getelementptr inbounds i8, ptr %.05880, i64 48
  store i32 0, ptr %94, align 8, !tbaa !36
  br label %95

95:                                               ; preds = %.lr.ph82, %85
  %.058 = load ptr, ptr %.05880, align 8, !tbaa !9
  %.not70 = icmp eq ptr %.058, null
  br i1 %.not70, label %.loopexit, label %.lr.ph82, !llvm.loop !37

.loopexit.sink.split:                             ; preds = %1, %4
  %.str.10.sink = phi ptr [ @.str.10, %4 ], [ @.str.9, %1 ]
  tail call void (ptr, ...) @mlwrite(ptr noundef nonnull %.str.10.sink) #4
  br label %.loopexit

.loopexit:                                        ; preds = %95, %.loopexit.sink.split, %80, %1
  %.056 = phi i32 [ %3, %1 ], [ %spec.store.select, %80 ], [ %3, %.loopexit.sink.split ], [ %spec.store.select, %95 ]
  call void @llvm.lifetime.end.p0(i64 32768, ptr nonnull %2) #4
  ret i32 %.056
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #3

declare ptr @lalloc(...) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { "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 = { mustprogress nofree nounwind willreturn memory(argmem: read) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }
attributes #5 = { nounwind willreturn memory(read) }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !10, i64 40}
!12 = !{!"BUFFER", !10, i64 0, !10, i64 8, !6, i64 16, !10, i64 24, !6, i64 32, !10, i64 40, !6, i64 48, !6, i64 52, !7, i64 56, !7, i64 184}
!13 = !{!14, !10, i64 0}
!14 = !{!"LINE", !10, i64 0, !10, i64 8, !15, i64 16, !15, i64 18, !7, i64 20}
!15 = !{!"short", !7, i64 0}
!16 = !{!12, !6, i64 52}
!17 = !{!18, !10, i64 24}
!18 = !{!"WINDOW", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !6, i64 32, !10, i64 40, !6, i64 48, !6, i64 52, !6, i64 56, !6, i64 60, !6, i64 64, !6, i64 68}
!19 = !{!14, !10, i64 8}
!20 = !{!7, !7, i64 0}
!21 = distinct !{!21, !22, !23, !24}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!"llvm.loop.isvectorized", i32 1}
!24 = !{!"llvm.loop.unroll.runtime.disable"}
!25 = distinct !{!25, !22, !23, !24}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.unroll.disable"}
!28 = distinct !{!28, !22, !23}
!29 = distinct !{!29, !22}
!30 = !{!18, !10, i64 8}
!31 = !{!18, !10, i64 16}
!32 = !{!18, !6, i64 32}
!33 = !{!18, !6, i64 64}
!34 = !{!18, !6, i64 68}
!35 = !{!18, !10, i64 40}
!36 = !{!18, !6, i64 48}
!37 = distinct !{!37, !22}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass