; LLVM IR from seppo0010/rlite :: src (page_list)

; 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.rl_list = type { i64, i64, ptr, i64, i64 }
%struct.rl_list_type = type { ptr, ptr, i32, ptr }
%struct.rl_list_node = type { i64, i64, i64, ptr }

@stderr = external global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [48 x i8], align 1

; 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 allocsize(0)
declare noalias ptr @malloc(i64 noundef) #1

; Function Attrs: nounwind
declare void @free(ptr noundef) #2

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

declare i32 @rl_read(ptr noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef, i32 noundef) #3

; Function Attrs: nounwind uwtable
define dso_local i32 @rl_list_is_balanced(ptr noundef %0, ptr noundef %1) #4 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  store i64 0, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.rl_list, ptr %16, i32 0, i32 3
  %18 = load i64, ptr %17, align 8, !tbaa !11
  store i64 %18, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  store i64 0, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.rl_list, ptr %19, i32 0, i32 1
  %21 = load i64, ptr %20, align 8, !tbaa !13
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.rl_list, ptr %22, i32 0, i32 0
  %24 = load i64, ptr %23, align 8, !tbaa !14
  %25 = sdiv i64 %21, %24
  %26 = add nsw i64 %25, 1
  %27 = mul nsw i64 %26, 2
  store i64 %27, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  store i32 0, ptr %11, align 4, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  store ptr null, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  store ptr null, ptr %13, align 8, !tbaa !5
  %28 = load i64, ptr %10, align 8, !tbaa !9
  %29 = mul i64 8, %28
  %30 = call noalias ptr @malloc(i64 noundef %29) #6
  store ptr %30, ptr %13, align 8, !tbaa !5
  %31 = load ptr, ptr %13, align 8, !tbaa !5
  %32 = icmp ne ptr %31, null
  br i1 %32, label %34, label %33

33:                                               ; preds = %2
  store i32 4, ptr %11, align 4, !tbaa !15
  br label %190

34:                                               ; preds = %2
  %35 = load i64, ptr %10, align 8, !tbaa !9
  %36 = mul i64 8, %35
  %37 = call noalias ptr @malloc(i64 noundef %36) #6
  store ptr %37, ptr %12, align 8, !tbaa !5
  %38 = load ptr, ptr %12, align 8, !tbaa !5
  %39 = icmp ne ptr %38, null
  br i1 %39, label %41, label %40

40:                                               ; preds = %34
  store i32 4, ptr %11, align 4, !tbaa !15
  br label %190

41:                                               ; preds = %34
  br label %42

42:                                               ; preds = %125, %41
  %43 = load i64, ptr %7, align 8, !tbaa !9
  %44 = icmp ne i64 %43, 0
  br i1 %44, label %45, label %128

45:                                               ; preds = %42
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.rl_list, ptr %47, i32 0, i32 2
  %49 = load ptr, ptr %48, align 8, !tbaa !17
  %50 = getelementptr inbounds %struct.rl_list_type, ptr %49, i32 0, i32 1
  %51 = load ptr, ptr %50, align 8, !tbaa !18
  %52 = load i64, ptr %7, align 8, !tbaa !9
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = call i32 @rl_read(ptr noundef %46, ptr noundef %51, i64 noundef %52, ptr noundef %53, ptr noundef %15, i32 noundef 1)
  store i32 %54, ptr %11, align 4, !tbaa !15
  %55 = load i32, ptr %11, align 4, !tbaa !15
  %56 = icmp ne i32 2, %55
  br i1 %56, label %57, label %58

57:                                               ; preds = %45
  br label %190

58:                                               ; preds = %45
  %59 = load ptr, ptr %15, align 8, !tbaa !5
  store ptr %59, ptr %14, align 8, !tbaa !5
  %60 = load ptr, ptr %14, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.rl_list_node, ptr %60, i32 0, i32 0
  %62 = load i64, ptr %61, align 8, !tbaa !20
  %63 = load i64, ptr %8, align 8, !tbaa !9
  %64 = add nsw i64 %63, %62
  store i64 %64, ptr %8, align 8, !tbaa !9
  %65 = load ptr, ptr %14, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.rl_list_node, ptr %65, i32 0, i32 1
  %67 = load i64, ptr %66, align 8, !tbaa !22
  %68 = load ptr, ptr %12, align 8, !tbaa !5
  %69 = load i64, ptr %6, align 8, !tbaa !9
  %70 = getelementptr inbounds i64, ptr %68, i64 %69
  store i64 %67, ptr %70, align 8, !tbaa !9
  %71 = load ptr, ptr %14, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.rl_list_node, ptr %71, i32 0, i32 2
  %73 = load i64, ptr %72, align 8, !tbaa !23
  %74 = load ptr, ptr %13, align 8, !tbaa !5
  %75 = load i64, ptr %6, align 8, !tbaa !9
  %76 = getelementptr inbounds i64, ptr %74, i64 %75
  store i64 %73, ptr %76, align 8, !tbaa !9
  %77 = load i64, ptr %6, align 8, !tbaa !9
  %78 = icmp ne i64 %77, 0
  br i1 %78, label %79, label %93

79:                                               ; preds = %58
  %80 = load ptr, ptr %14, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.rl_list_node, ptr %80, i32 0, i32 0
  %82 = load i64, ptr %81, align 8, !tbaa !20
  %83 = load i64, ptr %9, align 8, !tbaa !9
  %84 = add nsw i64 %82, %83
  %85 = load ptr, ptr %4, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.rl_list, ptr %85, i32 0, i32 0
  %87 = load i64, ptr %86, align 8, !tbaa !14
  %88 = icmp slt i64 %84, %87
  br i1 %88, label %89, label %92

89:                                               ; preds = %79
  %90 = load ptr, ptr @stderr, align 8, !tbaa !5
  %91 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %90, ptr noundef @.str.1) #5
  store i32 1, ptr %11, align 4, !tbaa !15
  br label %190

92:                                               ; preds = %79
  br label %93

93:                                               ; preds = %92, %58
  %94 = load ptr, ptr %14, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.rl_list_node, ptr %94, i32 0, i32 0
  %96 = load i64, ptr %95, align 8, !tbaa !20
  %97 = icmp eq i64 %96, 0
  br i1 %97, label %98, label %101

98:                                               ; preds = %93
  %99 = load ptr, ptr @stderr, align 8, !tbaa !5
  %100 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %99, ptr noundef @.str.2) #5
  store i32 1, ptr %11, align 4, !tbaa !15
  br label %190

101:                                              ; preds = %93
  %102 = load ptr, ptr %14, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.rl_list_node, ptr %102, i32 0, i32 0
  %104 = load i64, ptr %103, align 8, !tbaa !20
  store i64 %104, ptr %9, align 8, !tbaa !9
  %105 = load ptr, ptr %14, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.rl_list_node, ptr %105, i32 0, i32 2
  %107 = load i64, ptr %106, align 8, !tbaa !23
  store i64 %107, ptr %7, align 8, !tbaa !9
  %108 = load i64, ptr %6, align 8, !tbaa !9
  %109 = icmp sge i64 %108, 2
  br i1 %109, label %110, label %125

110:                                              ; preds = %101
  %111 = load ptr, ptr %13, align 8, !tbaa !5
  %112 = load i64, ptr %6, align 8, !tbaa !9
  %113 = sub nsw i64 %112, 2
  %114 = getelementptr inbounds i64, ptr %111, i64 %113
  %115 = load i64, ptr %114, align 8, !tbaa !9
  %116 = load ptr, ptr %12, align 8, !tbaa !5
  %117 = load i64, ptr %6, align 8, !tbaa !9
  %118 = getelementptr inbounds i64, ptr %116, i64 %117
  %119 = load i64, ptr %118, align 8, !tbaa !9
  %120 = icmp ne i64 %115, %119
  br i1 %120, label %121, label %125

121:                                              ; preds = %110
  %122 = load ptr, ptr @stderr, align 8, !tbaa !5
  %123 = load i64, ptr %6, align 8, !tbaa !9
  %124 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %122, ptr noundef @.str.3, i64 noundef %123) #5
  store i32 1, ptr %11, align 4, !tbaa !15
  br label %190

125:                                              ; preds = %110, %101
  %126 = load i64, ptr %6, align 8, !tbaa !9
  %127 = add nsw i64 %126, 1
  store i64 %127, ptr %6, align 8, !tbaa !9
  br label %42, !llvm.loop !24

128:                                              ; preds = %42
  %129 = load i64, ptr %8, align 8, !tbaa !9
  %130 = load ptr, ptr %4, align 8, !tbaa !5
  %131 = getelementptr inbounds %struct.rl_list, ptr %130, i32 0, i32 1
  %132 = load i64, ptr %131, align 8, !tbaa !13
  %133 = icmp ne i64 %129, %132
  br i1 %133, label %134, label %141

134:                                              ; preds = %128
  %135 = load ptr, ptr @stderr, align 8, !tbaa !5
  %136 = load i64, ptr %8, align 8, !tbaa !9
  %137 = load ptr, ptr %4, align 8, !tbaa !5
  %138 = getelementptr inbounds %struct.rl_list, ptr %137, i32 0, i32 1
  %139 = load i64, ptr %138, align 8, !tbaa !13
  %140 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %135, ptr noundef @.str.4, i64 noundef %136, i64 noundef %139) #5
  store i32 6, ptr %11, align 4, !tbaa !15
  br label %190

141:                                              ; preds = %128
  store i64 0, ptr %6, align 8, !tbaa !9
  %142 = load ptr, ptr %3, align 8, !tbaa !5
  %143 = load ptr, ptr %4, align 8, !tbaa !5
  %144 = call i32 @rl_list_iterator_create(ptr noundef %142, ptr noundef %5, ptr noundef %143, i32 noundef 1)
  store i32 %144, ptr %11, align 4, !tbaa !15
  br label %145

145:                                              ; preds = %149, %141
  %146 = load ptr, ptr %5, align 8, !tbaa !5
  %147 = call i32 @rl_list_iterator_next(ptr noundef %146, ptr noundef null)
  store i32 %147, ptr %11, align 4, !tbaa !15
  %148 = icmp eq i32 %147, 0
  br i1 %148, label %149, label %152

149:                                              ; preds = %145
  %150 = load i64, ptr %6, align 8, !tbaa !9
  %151 = add nsw i64 %150, 1
  store i64 %151, ptr %6, align 8, !tbaa !9
  br label %145, !llvm.loop !26

152:                                              ; preds = %145
  %153 = load i32, ptr %11, align 4, !tbaa !15
  %154 = icmp ne i32 %153, 9
  br i1 %154, label %155, label %156

155:                                              ; preds = %152
  br label %190

156:                                              ; preds = %152
  %157 = load i64, ptr %6, align 8, !tbaa !9
  %158 = load i64, ptr %8, align 8, !tbaa !9
  %159 = icmp ne i64 %157, %158
  br i1 %159, label %160, label %165

160:                                              ; preds = %156
  %161 = load ptr, ptr @stderr, align 8, !tbaa !5
  %162 = load i64, ptr %8, align 8, !tbaa !9
  %163 = load i64, ptr %6, align 8, !tbaa !9
  %164 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %161, ptr noundef @.str.5, i64 noundef %162, i64 noundef %163) #5
  store i32 6, ptr %11, align 4, !tbaa !15
  br label %190

165:                                              ; preds = %156
  store i64 0, ptr %6, align 8, !tbaa !9
  %166 = load ptr, ptr %3, align 8, !tbaa !5
  %167 = load ptr, ptr %4, align 8, !tbaa !5
  %168 = call i32 @rl_list_iterator_create(ptr noundef %166, ptr noundef %5, ptr noundef %167, i32 noundef -1)
  store i32 %168, ptr %11, align 4, !tbaa !15
  br label %169

169:                                              ; preds = %173, %165
  %170 = load ptr, ptr %5, align 8, !tbaa !5
  %171 = call i32 @rl_list_iterator_next(ptr noundef %170, ptr noundef null)
  store i32 %171, ptr %11, align 4, !tbaa !15
  %172 = icmp eq i32 %171, 0
  br i1 %172, label %173, label %176

173:                                              ; preds = %169
  %174 = load i64, ptr %6, align 8, !tbaa !9
  %175 = add nsw i64 %174, 1
  store i64 %175, ptr %6, align 8, !tbaa !9
  br label %169, !llvm.loop !27

176:                                              ; preds = %169
  %177 = load i32, ptr %11, align 4, !tbaa !15
  %178 = icmp ne i32 %177, 9
  br i1 %178, label %179, label %180

179:                                              ; preds = %176
  br label %190

180:                                              ; preds = %176
  %181 = load i64, ptr %6, align 8, !tbaa !9
  %182 = load i64, ptr %8, align 8, !tbaa !9
  %183 = icmp ne i64 %181, %182
  br i1 %183, label %184, label %189

184:                                              ; preds = %180
  %185 = load ptr, ptr @stderr, align 8, !tbaa !5
  %186 = load i64, ptr %8, align 8, !tbaa !9
  %187 = load i64, ptr %6, align 8, !tbaa !9
  %188 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %185, ptr noundef @.str.5, i64 noundef %186, i64 noundef %187) #5
  store i32 6, ptr %11, align 4, !tbaa !15
  br label %190

189:                                              ; preds = %180
  store i32 0, ptr %11, align 4, !tbaa !15
  br label %190

190:                                              ; preds = %189, %184, %179, %160, %155, %134, %121, %98, %89, %57, %40, %33
  %191 = load ptr, ptr %13, align 8, !tbaa !5
  call void @free(ptr noundef %191) #5
  %192 = load ptr, ptr %12, align 8, !tbaa !5
  call void @free(ptr noundef %192) #5
  %193 = load i32, ptr %11, align 4, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  ret i32 %193
}

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

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

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 24}
!12 = !{!"rl_list", !10, i64 0, !10, i64 8, !6, i64 16, !10, i64 24, !10, i64 32}
!13 = !{!12, !10, i64 8}
!14 = !{!12, !10, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"int", !7, i64 0}
!17 = !{!12, !6, i64 16}
!18 = !{!19, !6, i64 8}
!19 = !{!"", !6, i64 0, !6, i64 8, !16, i64 16, !6, i64 24}
!20 = !{!21, !10, i64 0}
!21 = !{!"rl_list_node", !10, i64 0, !10, i64 8, !10, i64 16, !6, i64 24}
!22 = !{!21, !10, i64 8}
!23 = !{!21, !10, i64 16}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = distinct !{!26, !25}
!27 = distinct !{!27, !25}


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

@stderr = external local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [48 x i8], align 1

; 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: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #2

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

declare i32 @rl_read(ptr noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
define dso_local i32 @rl_list_is_balanced(ptr noundef %0, ptr noundef %1) local_unnamed_addr #5 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #6
  %5 = getelementptr inbounds i8, ptr %1, i64 24
  %6 = load i64, ptr %5, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %1, i64 8
  %8 = load i64, ptr %7, align 8, !tbaa !11
  %9 = load i64, ptr %1, align 8, !tbaa !12
  %10 = sdiv i64 %8, %9
  %11 = shl i64 %10, 4
  %12 = add i64 %11, 16
  %13 = tail call noalias ptr @malloc(i64 noundef %12) #7
  %.not = icmp eq ptr %13, null
  br i1 %.not, label %.loopexit, label %14

14:                                               ; preds = %2
  %15 = tail call noalias ptr @malloc(i64 noundef %12) #7
  %.not69 = icmp eq ptr %15, null
  br i1 %.not69, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %14
  %.not70100 = icmp eq i64 %6, 0
  br i1 %.not70100, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %16 = getelementptr inbounds i8, ptr %1, i64 16
  %17 = load ptr, ptr %16, align 8, !tbaa !13
  %18 = getelementptr inbounds i8, ptr %17, i64 8
  %19 = load ptr, ptr %18, align 8, !tbaa !14
  %20 = call i32 @rl_read(ptr noundef %0, ptr noundef %19, i64 noundef %6, ptr noundef nonnull %1, ptr noundef nonnull %4, i32 noundef 1) #6
  %.not76.peel = icmp eq i32 %20, 2
  br i1 %.not76.peel, label %.thread.peel, label %.loopexit

.thread.peel:                                     ; preds = %.lr.ph
  %21 = load ptr, ptr %4, align 8, !tbaa !17
  %22 = load i64, ptr %21, align 8, !tbaa !18
  %23 = getelementptr inbounds i8, ptr %21, i64 8
  %24 = load i64, ptr %23, align 8, !tbaa !20
  store i64 %24, ptr %15, align 8, !tbaa !21
  %25 = getelementptr inbounds i8, ptr %21, i64 16
  %26 = load i64, ptr %25, align 8, !tbaa !22
  store i64 %26, ptr %13, align 8, !tbaa !21
  %27 = icmp eq i64 %22, 0
  br i1 %27, label %.loopexit135, label %.thread79.peel

.thread79.peel:                                   ; preds = %.thread.peel
  %.not70.peel = icmp eq i64 %26, 0
  br i1 %.not70.peel, label %._crit_edge.loopexit, label %.peel.next

.peel.next:                                       ; preds = %.thread79.peel
  %28 = load ptr, ptr %16, align 8, !tbaa !13
  %29 = getelementptr inbounds i8, ptr %28, i64 8
  %30 = load ptr, ptr %29, align 8, !tbaa !14
  %31 = call i32 @rl_read(ptr noundef %0, ptr noundef %30, i64 noundef %26, ptr noundef nonnull %1, ptr noundef nonnull %4, i32 noundef 1) #6
  %.not76.peel126 = icmp eq i32 %31, 2
  br i1 %.not76.peel126, label %32, label %.loopexit

32:                                               ; preds = %.peel.next
  %33 = load ptr, ptr %4, align 8, !tbaa !17
  %34 = load i64, ptr %33, align 8, !tbaa !18
  %35 = add nsw i64 %34, %22
  %36 = getelementptr inbounds i8, ptr %33, i64 8
  %37 = load i64, ptr %36, align 8, !tbaa !20
  %38 = getelementptr inbounds i8, ptr %15, i64 8
  store i64 %37, ptr %38, align 8, !tbaa !21
  %39 = getelementptr inbounds i8, ptr %33, i64 16
  %40 = load i64, ptr %39, align 8, !tbaa !22
  %41 = getelementptr inbounds i8, ptr %13, i64 8
  store i64 %40, ptr %41, align 8, !tbaa !21
  %42 = load i64, ptr %1, align 8, !tbaa !12
  %43 = icmp slt i64 %35, %42
  br i1 %43, label %.loopexit134, label %44

44:                                               ; preds = %32
  %45 = icmp eq i64 %34, 0
  br i1 %45, label %.loopexit135, label %.thread79.peel131

.thread79.peel131:                                ; preds = %44
  %.not70.peel132 = icmp eq i64 %40, 0
  br i1 %.not70.peel132, label %._crit_edge.loopexit, label %.peel.next125

.peel.next125:                                    ; preds = %.thread79.peel131, %.thread79
  %.0104 = phi i64 [ %74, %.thread79 ], [ 2, %.thread79.peel131 ]
  %.059103 = phi i64 [ %58, %.thread79 ], [ %40, %.thread79.peel131 ]
  %.060102 = phi i64 [ %52, %.thread79 ], [ %34, %.thread79.peel131 ]
  %.061101 = phi i64 [ %53, %.thread79 ], [ %35, %.thread79.peel131 ]
  %46 = load ptr, ptr %16, align 8, !tbaa !13
  %47 = getelementptr inbounds i8, ptr %46, i64 8
  %48 = load ptr, ptr %47, align 8, !tbaa !14
  %49 = call i32 @rl_read(ptr noundef %0, ptr noundef %48, i64 noundef %.059103, ptr noundef nonnull %1, ptr noundef nonnull %4, i32 noundef 1) #6
  %.not76 = icmp eq i32 %49, 2
  br i1 %.not76, label %50, label %.loopexit

50:                                               ; preds = %.peel.next125
  %51 = load ptr, ptr %4, align 8, !tbaa !17
  %52 = load i64, ptr %51, align 8, !tbaa !18
  %53 = add nsw i64 %52, %.061101
  %54 = getelementptr inbounds i8, ptr %51, i64 8
  %55 = load i64, ptr %54, align 8, !tbaa !20
  %56 = getelementptr inbounds i64, ptr %15, i64 %.0104
  store i64 %55, ptr %56, align 8, !tbaa !21
  %57 = getelementptr inbounds i8, ptr %51, i64 16
  %58 = load i64, ptr %57, align 8, !tbaa !22
  %59 = getelementptr inbounds i64, ptr %13, i64 %.0104
  store i64 %58, ptr %59, align 8, !tbaa !21
  %60 = add nsw i64 %52, %.060102
  %61 = load i64, ptr %1, align 8, !tbaa !12
  %62 = icmp slt i64 %60, %61
  br i1 %62, label %.loopexit134, label %65

.loopexit134:                                     ; preds = %50, %32
  %63 = load ptr, ptr @stderr, align 8, !tbaa !17
  %64 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %63, ptr noundef nonnull @.str.1) #8
  br label %.loopexit

65:                                               ; preds = %50
  %66 = icmp eq i64 %52, 0
  br i1 %66, label %.loopexit135, label %69

.loopexit135:                                     ; preds = %65, %44, %.thread.peel
  %67 = load ptr, ptr @stderr, align 8, !tbaa !17
  %68 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %67, ptr noundef nonnull @.str.2) #8
  br label %.loopexit

69:                                               ; preds = %65
  %70 = getelementptr i8, ptr %59, i64 -16
  %71 = load i64, ptr %70, align 8, !tbaa !21
  %.not78 = icmp eq i64 %71, %55
  br i1 %.not78, label %.thread79, label %.loopexit136

.loopexit136:                                     ; preds = %69
  %72 = load ptr, ptr @stderr, align 8, !tbaa !17
  %73 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %72, ptr noundef nonnull @.str.3, i64 noundef %.0104) #8
  br label %.loopexit

.thread79:                                        ; preds = %69
  %74 = add nuw nsw i64 %.0104, 1
  %.not70 = icmp eq i64 %58, 0
  br i1 %.not70, label %._crit_edge.loopexit, label %.peel.next125, !llvm.loop !23

._crit_edge.loopexit:                             ; preds = %.thread79, %.thread79.peel131, %.thread79.peel
  %.lcssa124 = phi i64 [ %22, %.thread79.peel ], [ %35, %.thread79.peel131 ], [ %53, %.thread79 ]
  %.pre = load i64, ptr %7, align 8, !tbaa !11
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %75 = phi i64 [ %8, %.preheader ], [ %.pre, %._crit_edge.loopexit ]
  %.061.lcssa = phi i64 [ 0, %.preheader ], [ %.lcssa124, %._crit_edge.loopexit ]
  %.not71 = icmp eq i64 %.061.lcssa, %75
  br i1 %.not71, label %79, label %76

76:                                               ; preds = %._crit_edge
  %77 = load ptr, ptr @stderr, align 8, !tbaa !17
  %78 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %77, ptr noundef nonnull @.str.4, i64 noundef %.061.lcssa, i64 noundef %75) #8
  br label %.loopexit

79:                                               ; preds = %._crit_edge
  %80 = call i32 @rl_list_iterator_create(ptr noundef %0, ptr noundef nonnull %3, ptr noundef nonnull %1, i32 noundef 1)
  br label %81

81:                                               ; preds = %84, %79
  %.1 = phi i64 [ 0, %79 ], [ %85, %84 ]
  %82 = load ptr, ptr %3, align 8, !tbaa !17
  %83 = call i32 @rl_list_iterator_next(ptr noundef %82, ptr noundef null)
  switch i32 %83, label %.loopexit [
    i32 0, label %84
    i32 9, label %86
  ]

84:                                               ; preds = %81
  %85 = add nuw nsw i64 %.1, 1
  br label %81, !llvm.loop !26

86:                                               ; preds = %81
  %.not73 = icmp eq i64 %.1, %75
  br i1 %.not73, label %90, label %87

87:                                               ; preds = %86
  %88 = load ptr, ptr @stderr, align 8, !tbaa !17
  %89 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %88, ptr noundef nonnull @.str.5, i64 noundef %75, i64 noundef %.1) #8
  br label %.loopexit

90:                                               ; preds = %86
  %91 = call i32 @rl_list_iterator_create(ptr noundef %0, ptr noundef nonnull %3, ptr noundef nonnull %1, i32 noundef -1)
  br label %92

92:                                               ; preds = %95, %90
  %.2 = phi i64 [ 0, %90 ], [ %96, %95 ]
  %93 = load ptr, ptr %3, align 8, !tbaa !17
  %94 = call i32 @rl_list_iterator_next(ptr noundef %93, ptr noundef null)
  switch i32 %94, label %.loopexit [
    i32 0, label %95
    i32 9, label %97
  ]

95:                                               ; preds = %92
  %96 = add nuw nsw i64 %.2, 1
  br label %92, !llvm.loop !27

97:                                               ; preds = %92
  %.not75 = icmp eq i64 %.2, %75
  br i1 %.not75, label %.loopexit, label %98

98:                                               ; preds = %97
  %99 = load ptr, ptr @stderr, align 8, !tbaa !17
  %100 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %99, ptr noundef nonnull @.str.5, i64 noundef %75, i64 noundef %.2) #8
  br label %.loopexit

.loopexit:                                        ; preds = %.peel.next125, %81, %92, %.lr.ph, %.peel.next, %97, %14, %2, %98, %87, %76, %.loopexit136, %.loopexit135, %.loopexit134
  %.058 = phi i32 [ 1, %.loopexit134 ], [ 1, %.loopexit135 ], [ 1, %.loopexit136 ], [ 6, %76 ], [ 6, %87 ], [ 6, %98 ], [ 4, %2 ], [ 4, %14 ], [ 0, %97 ], [ %20, %.lr.ph ], [ %31, %.peel.next ], [ %94, %92 ], [ %83, %81 ], [ %49, %.peel.next125 ]
  %.057 = phi ptr [ %15, %.loopexit134 ], [ %15, %.loopexit135 ], [ %15, %.loopexit136 ], [ %15, %76 ], [ %15, %87 ], [ %15, %98 ], [ null, %2 ], [ null, %14 ], [ %15, %97 ], [ %15, %.lr.ph ], [ %15, %.peel.next ], [ %15, %92 ], [ %15, %81 ], [ %15, %.peel.next125 ]
  call void @free(ptr noundef %13) #6
  call void @free(ptr noundef %.057) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #6
  ret i32 %.058
}

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #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 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nounwind 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 #6 = { nounwind }
attributes #7 = { nounwind allocsize(0) }
attributes #8 = { cold 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 24}
!6 = !{!"rl_list", !7, i64 0, !7, i64 8, !10, i64 16, !7, i64 24, !7, i64 32}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 8}
!12 = !{!6, !7, i64 0}
!13 = !{!6, !10, i64 16}
!14 = !{!15, !10, i64 8}
!15 = !{!"", !10, i64 0, !10, i64 8, !16, i64 16, !10, i64 24}
!16 = !{!"int", !8, i64 0}
!17 = !{!10, !10, i64 0}
!18 = !{!19, !7, i64 0}
!19 = !{!"rl_list_node", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24}
!20 = !{!19, !7, i64 8}
!21 = !{!7, !7, i64 0}
!22 = !{!19, !7, i64 16}
!23 = distinct !{!23, !24, !25}
!24 = !{!"llvm.loop.mustprogress"}
!25 = !{!"llvm.loop.peeled.count", i32 2}
!26 = distinct !{!26, !24}
!27 = distinct !{!27, !24}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopFullUnrollPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass