; LLVM IR from AngelJumbo/lavat :: lavat (tb_present)

; 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.tb_global_t = type { i32, i32, i32, i32, [2 x i32], i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, i64, [36 x ptr], %struct.cap_trie_t, %struct.bytebuf_t, %struct.bytebuf_t, %struct.cellbuf_t, %struct.cellbuf_t, %struct.termios, i32, i32, i32, ptr, ptr, [1024 x i8] }
%struct.cap_trie_t = type { i8, ptr, i64, i32, i16, i8 }
%struct.bytebuf_t = type { ptr, i64, i64 }
%struct.cellbuf_t = type { i32, i32, ptr }
%struct.termios = type { i32, i32, i32, i32, i8, [32 x i8], i32, i32 }
%struct.tb_cell = type { i32, i32, i32, ptr, i64, i64 }

@global = external hidden global %struct.tb_global_t, 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
define dso_local i32 @tb_present() #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = load i32, ptr getelementptr inbounds (%struct.tb_global_t, ptr @global, i32 0, i32 28), align 4, !tbaa !5
  %12 = icmp ne i32 %11, 0
  br i1 %12, label %14, label %13

13:                                               ; preds = %0
  store i32 -8, ptr %1, align 4
  br label %183

14:                                               ; preds = %0
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  store i32 -1, ptr getelementptr inbounds (%struct.tb_global_t, ptr @global, i32 0, i32 9), align 8, !tbaa !17
  store i32 -1, ptr getelementptr inbounds (%struct.tb_global_t, ptr @global, i32 0, i32 10), align 4, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %4, align 4, !tbaa !19
  br label %15

15:                                               ; preds = %165, %14
  %16 = load i32, ptr %4, align 4, !tbaa !19
  %17 = load i32, ptr getelementptr inbounds (%struct.cellbuf_t, ptr getelementptr inbounds (%struct.tb_global_t, ptr @global, i32 0, i32 24), i32 0, i32 1), align 4, !tbaa !20
  %18 = icmp slt i32 %16, %17
  br i1 %18, label %19, label %168

19:                                               ; preds = %15
  store i32 0, ptr %3, align 4, !tbaa !19
  br label %20

20:                                               ; preds = %163, %19
  %21 = load i32, ptr %3, align 4, !tbaa !19
  %22 = load i32, ptr getelementptr inbounds (%struct.tb_global_t, ptr @global, i32 0, i32 24), align 8, !tbaa !21
  %23 = icmp slt i32 %21, %22
  br i1 %23, label %24, label %164

24:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %25 = load i32, ptr %3, align 4, !tbaa !19
  %26 = load i32, ptr %4, align 4, !tbaa !19
  %27 = call i32 @cellbuf_get(ptr noundef getelementptr inbounds (%struct.tb_global_t, ptr @global, i32 0, i32 23), i32 noundef %25, i32 noundef %26, ptr noundef %6)
  store i32 %27, ptr %2, align 4, !tbaa !19
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %29, label %31

29:                                               ; preds = %24
  %30 = load i32, ptr %2, align 4, !tbaa !19
  store i32 %30, ptr %1, align 4
  store i32 1, ptr %8, align 4
  br label %161

31:                                               ; preds = %24
  %32 = load i32, ptr %3, align 4, !tbaa !19
  %33 = load i32, ptr %4, align 4, !tbaa !19
  %34 = call i32 @cellbuf_get(ptr noundef getelementptr inbounds (%struct.tb_global_t, ptr @global, i32 0, i32 24), i32 noundef %32, i32 noundef %33, ptr noundef %7)
  store i32 %34, ptr %2, align 4, !tbaa !19
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %36, label %38

36:                                               ; preds = %31
  %37 = load i32, ptr %2, align 4, !tbaa !19
  store i32 %37, ptr %1, align 4
  store i32 1, ptr %8, align 4
  br label %161

38:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %39 = load ptr, ptr %6, align 8, !tbaa !22
  %40 = getelementptr inbounds %struct.tb_cell, ptr %39, i32 0, i32 4
  %41 = load i64, ptr %40, align 8, !tbaa !23
  %42 = icmp ugt i64 %41, 0
  br i1 %42, label %43, label %51

43:                                               ; preds = %38
  %44 = load ptr, ptr %6, align 8, !tbaa !22
  %45 = getelementptr inbounds %struct.tb_cell, ptr %44, i32 0, i32 3
  %46 = load ptr, ptr %45, align 8, !tbaa !25
  %47 = load ptr, ptr %6, align 8, !tbaa !22
  %48 = getelementptr inbounds %struct.tb_cell, ptr %47, i32 0, i32 4
  %49 = load i64, ptr %48, align 8, !tbaa !23
  %50 = call i32 @wcswidth(ptr noundef %46, i64 noundef %49) #3
  store i32 %50, ptr %9, align 4, !tbaa !19
  br label %56

51:                                               ; preds = %38
  %52 = load ptr, ptr %6, align 8, !tbaa !22
  %53 = getelementptr inbounds %struct.tb_cell, ptr %52, i32 0, i32 0
  %54 = load i32, ptr %53, align 8, !tbaa !26
  %55 = call i32 @wcwidth(i32 noundef %54) #3
  store i32 %55, ptr %9, align 4, !tbaa !19
  br label %56

56:                                               ; preds = %51, %43
  %57 = load i32, ptr %9, align 4, !tbaa !19
  %58 = icmp slt i32 %57, 1
  br i1 %58, label %59, label %60

59:                                               ; preds = %56
  store i32 1, ptr %9, align 4, !tbaa !19
  br label %60

60:                                               ; preds = %59, %56
  %61 = load ptr, ptr %6, align 8, !tbaa !22
  %62 = load ptr, ptr %7, align 8, !tbaa !22
  %63 = call i32 @cell_cmp(ptr noundef %61, ptr noundef %62)
  %64 = icmp ne i32 %63, 0
  br i1 %64, label %65, label %156

65:                                               ; preds = %60
  %66 = load ptr, ptr %7, align 8, !tbaa !22
  %67 = load ptr, ptr %6, align 8, !tbaa !22
  %68 = call i32 @cell_copy(ptr noundef %66, ptr noundef %67)
  %69 = load ptr, ptr %6, align 8, !tbaa !22
  %70 = getelementptr inbounds %struct.tb_cell, ptr %69, i32 0, i32 1
  %71 = load i32, ptr %70, align 4, !tbaa !27
  %72 = load ptr, ptr %6, align 8, !tbaa !22
  %73 = getelementptr inbounds %struct.tb_cell, ptr %72, i32 0, i32 2
  %74 = load i32, ptr %73, align 8, !tbaa !28
  %75 = call i32 @send_attr(i32 noundef %71, i32 noundef %74)
  %76 = load i32, ptr %9, align 4, !tbaa !19
  %77 = icmp sgt i32 %76, 1
  br i1 %77, label %78, label %99

78:                                               ; preds = %65
  %79 = load i32, ptr %3, align 4, !tbaa !19
  %80 = load i32, ptr getelementptr inbounds (%struct.tb_global_t, ptr @global, i32 0, i32 24), align 8, !tbaa !21
  %81 = load i32, ptr %9, align 4, !tbaa !19
  %82 = sub nsw i32 %81, 1
  %83 = sub nsw i32 %80, %82
  %84 = icmp sge i32 %79, %83
  br i1 %84, label %85, label %99

85:                                               ; preds = %78
  %86 = load i32, ptr %3, align 4, !tbaa !19
  store i32 %86, ptr %5, align 4, !tbaa !19
  br label %87

87:                                               ; preds = %95, %85
  %88 = load i32, ptr %5, align 4, !tbaa !19
  %89 = load i32, ptr getelementptr inbounds (%struct.tb_global_t, ptr @global, i32 0, i32 24), align 8, !tbaa !21
  %90 = icmp slt i32 %88, %89
  br i1 %90, label %91, label %98

91:                                               ; preds = %87
  %92 = load i32, ptr %5, align 4, !tbaa !19
  %93 = load i32, ptr %4, align 4, !tbaa !19
  %94 = call i32 @send_char(i32 noundef %92, i32 noundef %93, i32 noundef 32)
  br label %95

95:                                               ; preds = %91
  %96 = load i32, ptr %5, align 4, !tbaa !19
  %97 = add nsw i32 %96, 1
  store i32 %97, ptr %5, align 4, !tbaa !19
  br label %87, !llvm.loop !29

98:                                               ; preds = %87
  br label %155

99:                                               ; preds = %78, %65
  %100 = load ptr, ptr %6, align 8, !tbaa !22
  %101 = getelementptr inbounds %struct.tb_cell, ptr %100, i32 0, i32 4
  %102 = load i64, ptr %101, align 8, !tbaa !23
  %103 = icmp ugt i64 %102, 0
  br i1 %103, label %104, label %114

104:                                              ; preds = %99
  %105 = load i32, ptr %3, align 4, !tbaa !19
  %106 = load i32, ptr %4, align 4, !tbaa !19
  %107 = load ptr, ptr %6, align 8, !tbaa !22
  %108 = getelementptr inbounds %struct.tb_cell, ptr %107, i32 0, i32 3
  %109 = load ptr, ptr %108, align 8, !tbaa !25
  %110 = load ptr, ptr %6, align 8, !tbaa !22
  %111 = getelementptr inbounds %struct.tb_cell, ptr %110, i32 0, i32 4
  %112 = load i64, ptr %111, align 8, !tbaa !23
  %113 = call i32 @send_cluster(i32 noundef %105, i32 noundef %106, ptr noundef %109, i64 noundef %112)
  br label %121

114:                                              ; preds = %99
  %115 = load i32, ptr %3, align 4, !tbaa !19
  %116 = load i32, ptr %4, align 4, !tbaa !19
  %117 = load ptr, ptr %6, align 8, !tbaa !22
  %118 = getelementptr inbounds %struct.tb_cell, ptr %117, i32 0, i32 0
  %119 = load i32, ptr %118, align 8, !tbaa !26
  %120 = call i32 @send_char(i32 noundef %115, i32 noundef %116, i32 noundef %119)
  br label %121

121:                                              ; preds = %114, %104
  store i32 1, ptr %5, align 4, !tbaa !19
  br label %122

122:                                              ; preds = %151, %121
  %123 = load i32, ptr %5, align 4, !tbaa !19
  %124 = load i32, ptr %9, align 4, !tbaa !19
  %125 = icmp slt i32 %123, %124
  br i1 %125, label %126, label %154

126:                                              ; preds = %122
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %127 = load i32, ptr %3, align 4, !tbaa !19
  %128 = load i32, ptr %5, align 4, !tbaa !19
  %129 = add nsw i32 %127, %128
  %130 = load i32, ptr %4, align 4, !tbaa !19
  %131 = call i32 @cellbuf_get(ptr noundef getelementptr inbounds (%struct.tb_global_t, ptr @global, i32 0, i32 24), i32 noundef %129, i32 noundef %130, ptr noundef %10)
  store i32 %131, ptr %2, align 4, !tbaa !19
  %132 = icmp ne i32 %131, 0
  br i1 %132, label %133, label %135

133:                                              ; preds = %126
  %134 = load i32, ptr %2, align 4, !tbaa !19
  store i32 %134, ptr %1, align 4
  store i32 1, ptr %8, align 4
  br label %148

135:                                              ; preds = %126
  %136 = load ptr, ptr %10, align 8, !tbaa !22
  %137 = load ptr, ptr %6, align 8, !tbaa !22
  %138 = getelementptr inbounds %struct.tb_cell, ptr %137, i32 0, i32 1
  %139 = load i32, ptr %138, align 4, !tbaa !27
  %140 = load ptr, ptr %6, align 8, !tbaa !22
  %141 = getelementptr inbounds %struct.tb_cell, ptr %140, i32 0, i32 2
  %142 = load i32, ptr %141, align 8, !tbaa !28
  %143 = call i32 @cell_set(ptr noundef %136, ptr noundef null, i64 noundef 1, i32 noundef %139, i32 noundef %142)
  store i32 %143, ptr %2, align 4, !tbaa !19
  %144 = icmp ne i32 %143, 0
  br i1 %144, label %145, label %147

145:                                              ; preds = %135
  %146 = load i32, ptr %2, align 4, !tbaa !19
  store i32 %146, ptr %1, align 4
  store i32 1, ptr %8, align 4
  br label %148

147:                                              ; preds = %135
  store i32 0, ptr %8, align 4
  br label %148

148:                                              ; preds = %147, %145, %133
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %149 = load i32, ptr %8, align 4
  switch i32 %149, label %160 [
    i32 0, label %150
  ]

150:                                              ; preds = %148
  br label %151

151:                                              ; preds = %150
  %152 = load i32, ptr %5, align 4, !tbaa !19
  %153 = add nsw i32 %152, 1
  store i32 %153, ptr %5, align 4, !tbaa !19
  br label %122, !llvm.loop !31

154:                                              ; preds = %122
  br label %155

155:                                              ; preds = %154, %98
  br label %156

156:                                              ; preds = %155, %60
  %157 = load i32, ptr %9, align 4, !tbaa !19
  %158 = load i32, ptr %3, align 4, !tbaa !19
  %159 = add nsw i32 %158, %157
  store i32 %159, ptr %3, align 4, !tbaa !19
  store i32 0, ptr %8, align 4
  br label %160

160:                                              ; preds = %156, %148
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  br label %161

161:                                              ; preds = %160, %36, %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %162 = load i32, ptr %8, align 4
  switch i32 %162, label %182 [
    i32 0, label %163
  ]

163:                                              ; preds = %161
  br label %20, !llvm.loop !32

164:                                              ; preds = %20
  br label %165

165:                                              ; preds = %164
  %166 = load i32, ptr %4, align 4, !tbaa !19
  %167 = add nsw i32 %166, 1
  store i32 %167, ptr %4, align 4, !tbaa !19
  br label %15, !llvm.loop !33

168:                                              ; preds = %15
  %169 = load i32, ptr getelementptr inbounds (%struct.tb_global_t, ptr @global, i32 0, i32 7), align 8, !tbaa !34
  %170 = load i32, ptr getelementptr inbounds (%struct.tb_global_t, ptr @global, i32 0, i32 8), align 4, !tbaa !35
  %171 = call i32 @send_cursor_if(i32 noundef %169, i32 noundef %170)
  store i32 %171, ptr %2, align 4, !tbaa !19
  %172 = icmp ne i32 %171, 0
  br i1 %172, label %173, label %175

173:                                              ; preds = %168
  %174 = load i32, ptr %2, align 4, !tbaa !19
  store i32 %174, ptr %1, align 4
  store i32 1, ptr %8, align 4
  br label %182

175:                                              ; preds = %168
  %176 = load i32, ptr getelementptr inbounds (%struct.tb_global_t, ptr @global, i32 0, i32 2), align 8, !tbaa !36
  %177 = call i32 @bytebuf_flush(ptr noundef getelementptr inbounds (%struct.tb_global_t, ptr @global, i32 0, i32 22), i32 noundef %176)
  store i32 %177, ptr %2, align 4, !tbaa !19
  %178 = icmp ne i32 %177, 0
  br i1 %178, label %179, label %181

179:                                              ; preds = %175
  %180 = load i32, ptr %2, align 4, !tbaa !19
  store i32 %180, ptr %1, align 4
  store i32 1, ptr %8, align 4
  br label %182

181:                                              ; preds = %175
  store i32 0, ptr %1, align 4
  store i32 1, ptr %8, align 4
  br label %182

182:                                              ; preds = %181, %179, %173, %161
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  br label %183

183:                                              ; preds = %182, %13
  %184 = load i32, ptr %1, align 4
  ret i32 %184
}

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

; Function Attrs: nounwind
declare i32 @wcswidth(ptr noundef, i64 noundef) #2

; Function Attrs: nounwind
declare i32 @wcwidth(i32 noundef) #2

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

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

; Function Attrs: nounwind uwtable
declare hidden i32 @send_attr(i32 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @send_char(i32 noundef, i32 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @send_cluster(i32 noundef, i32 noundef, ptr noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @cell_set(ptr noundef, ptr noundef, i64 noundef, i32 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @send_cursor_if(i32 noundef, i32 noundef) #1

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

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 = { 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 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !7, i64 556}
!6 = !{!"tb_global_t", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !8, i64 16, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !7, i64 40, !7, i64 44, !7, i64 48, !7, i64 52, !7, i64 56, !7, i64 60, !7, i64 64, !7, i64 68, !10, i64 72, !11, i64 80, !8, i64 88, !12, i64 376, !14, i64 408, !14, i64 432, !15, i64 456, !15, i64 472, !16, i64 488, !7, i64 548, !7, i64 552, !7, i64 556, !10, i64 560, !10, i64 568, !8, i64 576}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!"cap_trie_t", !8, i64 0, !10, i64 8, !11, i64 16, !7, i64 24, !13, i64 28, !8, i64 30}
!13 = !{!"short", !8, i64 0}
!14 = !{!"bytebuf_t", !10, i64 0, !11, i64 8, !11, i64 16}
!15 = !{!"cellbuf_t", !7, i64 0, !7, i64 4, !10, i64 8}
!16 = !{!"termios", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !8, i64 16, !8, i64 17, !7, i64 52, !7, i64 56}
!17 = !{!6, !7, i64 40}
!18 = !{!6, !7, i64 44}
!19 = !{!7, !7, i64 0}
!20 = !{!6, !7, i64 476}
!21 = !{!6, !7, i64 472}
!22 = !{!10, !10, i64 0}
!23 = !{!24, !11, i64 24}
!24 = !{!"tb_cell", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 16, !11, i64 24, !11, i64 32}
!25 = !{!24, !10, i64 16}
!26 = !{!24, !7, i64 0}
!27 = !{!24, !7, i64 4}
!28 = !{!24, !7, i64 8}
!29 = distinct !{!29, !30}
!30 = !{!"llvm.loop.mustprogress"}
!31 = distinct !{!31, !30}
!32 = distinct !{!32, !30}
!33 = distinct !{!33, !30}
!34 = !{!6, !7, i64 32}
!35 = !{!6, !7, i64 36}
!36 = !{!6, !7, i64 8}


; 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.tb_global_t = type { i32, i32, i32, i32, [2 x i32], i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, i64, [36 x ptr], %struct.cap_trie_t, %struct.bytebuf_t, %struct.bytebuf_t, %struct.cellbuf_t, %struct.cellbuf_t, %struct.termios, i32, i32, i32, ptr, ptr, [1024 x i8] }
%struct.cap_trie_t = type { i8, ptr, i64, i32, i16, i8 }
%struct.bytebuf_t = type { ptr, i64, i64 }
%struct.cellbuf_t = type { i32, i32, ptr }
%struct.termios = type { i32, i32, i32, i32, i8, [32 x i8], i32, i32 }

@global = external hidden global %struct.tb_global_t, 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
define dso_local i32 @tb_present() local_unnamed_addr #1 {
  %1 = alloca ptr, align 8
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = load i32, ptr getelementptr inbounds (i8, ptr @global, i64 556), align 4, !tbaa !5
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %87, label %5

5:                                                ; preds = %0
  store i32 -1, ptr getelementptr inbounds (i8, ptr @global, i64 40), align 8, !tbaa !17
  store i32 -1, ptr getelementptr inbounds (i8, ptr @global, i64 44), align 4, !tbaa !18
  %6 = load i32, ptr getelementptr inbounds (i8, ptr @global, i64 476), align 4, !tbaa !19
  %7 = icmp sgt i32 %6, 0
  %8 = load i32, ptr getelementptr inbounds (i8, ptr @global, i64 472), align 8
  %9 = icmp sgt i32 %8, 0
  %or.cond = select i1 %7, i1 %9, i1 false
  br i1 %or.cond, label %.preheader75, label %._crit_edge86

.preheader75:                                     ; preds = %5, %._crit_edge
  %10 = phi i32 [ %77, %._crit_edge ], [ %6, %5 ]
  %11 = phi i32 [ %78, %._crit_edge ], [ %8, %5 ]
  %.04185 = phi i32 [ %79, %._crit_edge ], [ 0, %5 ]
  %12 = icmp sgt i32 %11, 0
  br i1 %12, label %.lr.ph84, label %._crit_edge

.lr.ph84:                                         ; preds = %.preheader75, %.loopexit
  %.04282 = phi i32 [ %74, %.loopexit ], [ 0, %.preheader75 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  %13 = call i32 @cellbuf_get(ptr noundef nonnull getelementptr inbounds (i8, ptr @global, i64 456), i32 noundef %.04282, i32 noundef %.04185, ptr noundef nonnull %1)
  %.not58 = icmp eq i32 %13, 0
  br i1 %.not58, label %14, label %.thread69

14:                                               ; preds = %.lr.ph84
  %15 = call i32 @cellbuf_get(ptr noundef nonnull getelementptr inbounds (i8, ptr @global, i64 472), i32 noundef %.04282, i32 noundef %.04185, ptr noundef nonnull %2)
  %.not59 = icmp eq i32 %15, 0
  br i1 %.not59, label %16, label %.thread69

16:                                               ; preds = %14
  %17 = load ptr, ptr %1, align 8, !tbaa !20
  %18 = getelementptr inbounds i8, ptr %17, i64 24
  %19 = load i64, ptr %18, align 8, !tbaa !21
  %.not60 = icmp eq i64 %19, 0
  br i1 %.not60, label %24, label %20

20:                                               ; preds = %16
  %21 = getelementptr inbounds i8, ptr %17, i64 16
  %22 = load ptr, ptr %21, align 8, !tbaa !23
  %23 = call i32 @wcswidth(ptr noundef %22, i64 noundef %19) #4
  br label %27

24:                                               ; preds = %16
  %25 = load i32, ptr %17, align 8, !tbaa !24
  %26 = call i32 @wcwidth(i32 noundef %25) #4
  br label %27

27:                                               ; preds = %24, %20
  %.0 = phi i32 [ %23, %20 ], [ %26, %24 ]
  %spec.store.select = call i32 @llvm.smax.i32(i32 %.0, i32 1)
  %28 = load ptr, ptr %1, align 8, !tbaa !20
  %29 = load ptr, ptr %2, align 8, !tbaa !20
  %30 = call i32 @cell_cmp(ptr noundef %28, ptr noundef %29)
  %.not61 = icmp eq i32 %30, 0
  br i1 %.not61, label %.loopexit, label %31

31:                                               ; preds = %27
  %32 = load ptr, ptr %2, align 8, !tbaa !20
  %33 = load ptr, ptr %1, align 8, !tbaa !20
  %34 = call i32 @cell_copy(ptr noundef %32, ptr noundef %33)
  %35 = load ptr, ptr %1, align 8, !tbaa !20
  %36 = getelementptr inbounds i8, ptr %35, i64 4
  %37 = load i32, ptr %36, align 4, !tbaa !25
  %38 = getelementptr inbounds i8, ptr %35, i64 8
  %39 = load i32, ptr %38, align 8, !tbaa !26
  %40 = call i32 @send_attr(i32 noundef %37, i32 noundef %39)
  %41 = icmp sgt i32 %.0, 1
  br i1 %41, label %42, label %50

42:                                               ; preds = %31
  %43 = load i32, ptr getelementptr inbounds (i8, ptr @global, i64 472), align 8, !tbaa !27
  %reass.sub = sub i32 %43, %spec.store.select
  %44 = add i32 %reass.sub, 1
  %.not62 = icmp slt i32 %.04282, %44
  br i1 %.not62, label %50, label %.preheader

.preheader:                                       ; preds = %42
  %45 = icmp slt i32 %.04282, %43
  br i1 %45, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.03979 = phi i32 [ %47, %.lr.ph ], [ %.04282, %.preheader ]
  %46 = call i32 @send_char(i32 noundef %.03979, i32 noundef %.04185, i32 noundef 32)
  %47 = add nuw nsw i32 %.03979, 1
  %48 = load i32, ptr getelementptr inbounds (i8, ptr @global, i64 472), align 8, !tbaa !27
  %49 = icmp slt i32 %47, %48
  br i1 %49, label %.lr.ph, label %.loopexit, !llvm.loop !28

50:                                               ; preds = %42, %31
  %51 = load ptr, ptr %1, align 8, !tbaa !20
  %52 = getelementptr inbounds i8, ptr %51, i64 24
  %53 = load i64, ptr %52, align 8, !tbaa !21
  %.not63 = icmp eq i64 %53, 0
  br i1 %.not63, label %58, label %54

54:                                               ; preds = %50
  %55 = getelementptr inbounds i8, ptr %51, i64 16
  %56 = load ptr, ptr %55, align 8, !tbaa !23
  %57 = call i32 @send_cluster(i32 noundef %.04282, i32 noundef %.04185, ptr noundef %56, i64 noundef %53)
  br label %61

58:                                               ; preds = %50
  %59 = load i32, ptr %51, align 8, !tbaa !24
  %60 = call i32 @send_char(i32 noundef %.04282, i32 noundef %.04185, i32 noundef %59)
  br label %61

61:                                               ; preds = %58, %54
  br i1 %41, label %.lr.ph81, label %.loopexit

62:                                               ; preds = %66
  %63 = add nuw nsw i32 %.14080, 1
  %exitcond.not = icmp eq i32 %63, %.0
  br i1 %exitcond.not, label %.loopexit, label %.lr.ph81, !llvm.loop !30

.lr.ph81:                                         ; preds = %61, %62
  %.14080 = phi i32 [ %63, %62 ], [ 1, %61 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  %64 = add nuw nsw i32 %.14080, %.04282
  %65 = call i32 @cellbuf_get(ptr noundef nonnull getelementptr inbounds (i8, ptr @global, i64 472), i32 noundef %64, i32 noundef %.04185, ptr noundef nonnull %3)
  %.not64 = icmp eq i32 %65, 0
  br i1 %.not64, label %66, label %.thread

.thread:                                          ; preds = %.lr.ph81
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  br label %.thread69

66:                                               ; preds = %.lr.ph81
  %67 = load ptr, ptr %3, align 8, !tbaa !20
  %68 = load ptr, ptr %1, align 8, !tbaa !20
  %69 = getelementptr inbounds i8, ptr %68, i64 4
  %70 = load i32, ptr %69, align 4, !tbaa !25
  %71 = getelementptr inbounds i8, ptr %68, i64 8
  %72 = load i32, ptr %71, align 8, !tbaa !26
  %73 = call i32 @cell_set(ptr noundef %67, ptr noundef null, i64 noundef 1, i32 noundef %70, i32 noundef %72)
  %.not65 = icmp eq i32 %73, 0
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  br i1 %.not65, label %62, label %.thread69

.thread69:                                        ; preds = %.lr.ph84, %14, %66, %.thread
  %.6.ph = phi i32 [ %65, %.thread ], [ %73, %66 ], [ %13, %.lr.ph84 ], [ %15, %14 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #4
  br label %87

.loopexit:                                        ; preds = %.lr.ph, %62, %.preheader, %61, %27
  %74 = add nuw nsw i32 %spec.store.select, %.04282
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #4
  %75 = load i32, ptr getelementptr inbounds (i8, ptr @global, i64 472), align 8, !tbaa !27
  %76 = icmp slt i32 %74, %75
  br i1 %76, label %.lr.ph84, label %._crit_edge.loopexit, !llvm.loop !31

._crit_edge.loopexit:                             ; preds = %.loopexit
  %.pre = load i32, ptr getelementptr inbounds (i8, ptr @global, i64 476), align 4, !tbaa !19
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader75
  %77 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %10, %.preheader75 ]
  %78 = phi i32 [ %75, %._crit_edge.loopexit ], [ %11, %.preheader75 ]
  %79 = add nuw nsw i32 %.04185, 1
  %80 = icmp slt i32 %79, %77
  br i1 %80, label %.preheader75, label %._crit_edge86, !llvm.loop !32

._crit_edge86:                                    ; preds = %._crit_edge, %5
  %81 = load i32, ptr getelementptr inbounds (i8, ptr @global, i64 32), align 8, !tbaa !34
  %82 = load i32, ptr getelementptr inbounds (i8, ptr @global, i64 36), align 4, !tbaa !35
  %83 = call i32 @send_cursor_if(i32 noundef %81, i32 noundef %82)
  %.not56 = icmp eq i32 %83, 0
  br i1 %.not56, label %84, label %87

84:                                               ; preds = %._crit_edge86
  %85 = load i32, ptr getelementptr inbounds (i8, ptr @global, i64 8), align 8, !tbaa !36
  %86 = call i32 @bytebuf_flush(ptr noundef nonnull getelementptr inbounds (i8, ptr @global, i64 432), i32 noundef %85)
  br label %87

87:                                               ; preds = %.thread69, %._crit_edge86, %84, %0
  %.8 = phi i32 [ -8, %0 ], [ %83, %._crit_edge86 ], [ %86, %84 ], [ %.6.ph, %.thread69 ]
  ret i32 %.8
}

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

; Function Attrs: nounwind
declare i32 @wcswidth(ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: nounwind
declare i32 @wcwidth(i32 noundef) local_unnamed_addr #2

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

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

; Function Attrs: nounwind uwtable
declare hidden i32 @send_attr(i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i32 @send_char(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i32 @send_cluster(i32 noundef, i32 noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i32 @cell_set(ptr noundef, ptr noundef, i64 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i32 @send_cursor_if(i32 noundef, i32 noundef) local_unnamed_addr #1

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #3

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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !7, i64 556}
!6 = !{!"tb_global_t", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !8, i64 16, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !7, i64 40, !7, i64 44, !7, i64 48, !7, i64 52, !7, i64 56, !7, i64 60, !7, i64 64, !7, i64 68, !10, i64 72, !11, i64 80, !8, i64 88, !12, i64 376, !14, i64 408, !14, i64 432, !15, i64 456, !15, i64 472, !16, i64 488, !7, i64 548, !7, i64 552, !7, i64 556, !10, i64 560, !10, i64 568, !8, i64 576}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!"cap_trie_t", !8, i64 0, !10, i64 8, !11, i64 16, !7, i64 24, !13, i64 28, !8, i64 30}
!13 = !{!"short", !8, i64 0}
!14 = !{!"bytebuf_t", !10, i64 0, !11, i64 8, !11, i64 16}
!15 = !{!"cellbuf_t", !7, i64 0, !7, i64 4, !10, i64 8}
!16 = !{!"termios", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !8, i64 16, !8, i64 17, !7, i64 52, !7, i64 56}
!17 = !{!6, !7, i64 40}
!18 = !{!6, !7, i64 44}
!19 = !{!6, !7, i64 476}
!20 = !{!10, !10, i64 0}
!21 = !{!22, !11, i64 24}
!22 = !{!"tb_cell", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 16, !11, i64 24, !11, i64 32}
!23 = !{!22, !10, i64 16}
!24 = !{!22, !7, i64 0}
!25 = !{!22, !7, i64 4}
!26 = !{!22, !7, i64 8}
!27 = !{!6, !7, i64 472}
!28 = distinct !{!28, !29}
!29 = !{!"llvm.loop.mustprogress"}
!30 = distinct !{!30, !29}
!31 = distinct !{!31, !29}
!32 = distinct !{!32, !29, !33}
!33 = !{!"llvm.loop.unswitch.partial.disable"}
!34 = !{!6, !7, i64 32}
!35 = !{!6, !7, i64 36}
!36 = !{!6, !7, i64 8}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimpleLoopUnswitchPass,SimplifyCFGPass