; LLVM IR from aagdev/mlimgsynth :: src/ccommon (stream)

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

@.str.2 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [16 x i8], align 1
@__PRETTY_FUNCTION__.stream_open_argv = external hidden unnamed_addr constant [50 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 uwtable
declare dso_local i32 @stream_close(ptr noundef, i32 noundef) #1

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

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @stream_write_buffer_(ptr noundef, ptr noundef) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @stream_commit(ptr noalias noundef, ptr noalias noundef) #3

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

22:                                               ; preds = %4
  %23 = load i32, ptr %7, align 4, !tbaa !9
  br label %25

24:                                               ; preds = %4
  br label %25

25:                                               ; preds = %24, %22
  %26 = phi i32 [ %23, %22 ], [ 0, %24 ]
  %27 = add nsw i32 1, %26
  store i32 %27, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  store i32 1, ptr %12, align 4, !tbaa !9
  br label %28

28:                                               ; preds = %44, %25
  %29 = load i32, ptr %12, align 4, !tbaa !9
  %30 = load i32, ptr %7, align 4, !tbaa !9
  %31 = icmp slt i32 %29, %30
  br i1 %31, label %33, label %32

32:                                               ; preds = %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  br label %47

33:                                               ; preds = %28
  %34 = load ptr, ptr %8, align 8, !tbaa !5
  %35 = load i32, ptr %12, align 4, !tbaa !9
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds ptr, ptr %34, i64 %36
  %38 = load ptr, ptr %37, align 8, !tbaa !5
  %39 = call i64 @strlen(ptr noundef %38) #6
  %40 = load i32, ptr %11, align 4, !tbaa !9
  %41 = zext i32 %40 to i64
  %42 = add i64 %41, %39
  %43 = trunc i64 %42 to i32
  store i32 %43, ptr %11, align 4, !tbaa !9
  br label %44

44:                                               ; preds = %33
  %45 = load i32, ptr %12, align 4, !tbaa !9
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr %12, align 4, !tbaa !9
  br label %28, !llvm.loop !11

47:                                               ; preds = %32
  %48 = load i32, ptr %11, align 4, !tbaa !9
  %49 = icmp ult i32 %48, 16777215
  br i1 %49, label %50, label %51

50:                                               ; preds = %47
  br label %52

51:                                               ; preds = %47
  call void @__assert_fail(ptr noundef @.str.9, ptr noundef @.str.2, i32 noundef 523, ptr noundef @__PRETTY_FUNCTION__.stream_open_argv) #7
  unreachable

52:                                               ; preds = %50
  br label %53

53:                                               ; preds = %52
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = load i32, ptr %11, align 4, !tbaa !9
  %56 = zext i32 %55 to i64
  %57 = call i32 @stream_open_memory(ptr noundef %54, ptr noundef null, i64 noundef %56, i32 noundef 3)
  store i32 %57, ptr %13, align 4, !tbaa !9
  %58 = load i32, ptr %13, align 4, !tbaa !9
  %59 = icmp slt i32 %58, 0
  br i1 %59, label %60, label %65

60:                                               ; preds = %53
  br label %61

61:                                               ; preds = %60
  %62 = load i32, ptr %13, align 4, !tbaa !9
  store i32 %62, ptr %10, align 4, !tbaa !9
  store i32 9, ptr %14, align 4
  br label %66

63:                                               ; No predecessors!
  br label %64

64:                                               ; preds = %63
  br label %65

65:                                               ; preds = %64, %53
  store i32 0, ptr %14, align 4
  br label %66

66:                                               ; preds = %65, %61
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  %67 = load i32, ptr %14, align 4
  switch i32 %67, label %155 [
    i32 0, label %68
    i32 9, label %147
  ]

68:                                               ; preds = %66
  br label %69

69:                                               ; preds = %68
  br label %70

70:                                               ; preds = %69
  %71 = load ptr, ptr %6, align 8, !tbaa !5
  %72 = call ptr @stream_write_buffer_(ptr noundef %71, ptr noundef null)
  store ptr %72, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  store i32 1, ptr %16, align 4, !tbaa !9
  br label %73

73:                                               ; preds = %109, %70
  %74 = load i32, ptr %16, align 4, !tbaa !9
  %75 = load i32, ptr %7, align 4, !tbaa !9
  %76 = icmp slt i32 %74, %75
  br i1 %76, label %78, label %77

77:                                               ; preds = %73
  store i32 10, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  br label %112

78:                                               ; preds = %73
  %79 = load i32, ptr %16, align 4, !tbaa !9
  %80 = icmp sgt i32 %79, 1
  br i1 %80, label %81, label %89

81:                                               ; preds = %78
  %82 = load i32, ptr %9, align 4, !tbaa !9
  %83 = icmp sge i32 %82, 0
  br i1 %83, label %84, label %89

84:                                               ; preds = %81
  %85 = load i32, ptr %9, align 4, !tbaa !9
  %86 = trunc i32 %85 to i8
  %87 = load ptr, ptr %15, align 8, !tbaa !5
  %88 = getelementptr inbounds i8, ptr %87, i32 1
  store ptr %88, ptr %15, align 8, !tbaa !5
  store i8 %86, ptr %87, align 1, !tbaa !13
  br label %89

89:                                               ; preds = %84, %81, %78
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  %90 = load ptr, ptr %8, align 8, !tbaa !5
  %91 = load i32, ptr %16, align 4, !tbaa !9
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds ptr, ptr %90, i64 %92
  %94 = load ptr, ptr %93, align 8, !tbaa !5
  store ptr %94, ptr %17, align 8, !tbaa !5
  br label %95

95:                                               ; preds = %105, %89
  %96 = load ptr, ptr %17, align 8, !tbaa !5
  %97 = load i8, ptr %96, align 1, !tbaa !13
  %98 = icmp ne i8 %97, 0
  br i1 %98, label %100, label %99

99:                                               ; preds = %95
  store i32 13, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  br label %108

100:                                              ; preds = %95
  %101 = load ptr, ptr %17, align 8, !tbaa !5
  %102 = load i8, ptr %101, align 1, !tbaa !13
  %103 = load ptr, ptr %15, align 8, !tbaa !5
  %104 = getelementptr inbounds i8, ptr %103, i32 1
  store ptr %104, ptr %15, align 8, !tbaa !5
  store i8 %102, ptr %103, align 1, !tbaa !13
  br label %105

105:                                              ; preds = %100
  %106 = load ptr, ptr %17, align 8, !tbaa !5
  %107 = getelementptr inbounds i8, ptr %106, i32 1
  store ptr %107, ptr %17, align 8, !tbaa !5
  br label %95, !llvm.loop !14

108:                                              ; preds = %99
  br label %109

109:                                              ; preds = %108
  %110 = load i32, ptr %16, align 4, !tbaa !9
  %111 = add nsw i32 %110, 1
  store i32 %111, ptr %16, align 4, !tbaa !9
  br label %73, !llvm.loop !15

112:                                              ; preds = %77
  %113 = load ptr, ptr %6, align 8, !tbaa !5
  %114 = load ptr, ptr %15, align 8, !tbaa !5
  call void @stream_commit(ptr noundef %113, ptr noundef %114)
  br label %115

115:                                              ; preds = %112
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #5
  %116 = load ptr, ptr %6, align 8, !tbaa !5
  %117 = call i32 @stream_seek(ptr noundef %116, i64 noundef 0, i32 noundef 0)
  store i32 %117, ptr %18, align 4, !tbaa !9
  %118 = load i32, ptr %18, align 4, !tbaa !9
  %119 = icmp slt i32 %118, 0
  br i1 %119, label %120, label %125

120:                                              ; preds = %115
  br label %121

121:                                              ; preds = %120
  %122 = load i32, ptr %18, align 4, !tbaa !9
  store i32 %122, ptr %10, align 4, !tbaa !9
  store i32 9, ptr %14, align 4
  br label %126

123:                                              ; No predecessors!
  br label %124

124:                                              ; preds = %123
  br label %125

125:                                              ; preds = %124, %115
  store i32 0, ptr %14, align 4
  br label %126

126:                                              ; preds = %125, %121
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  %127 = load i32, ptr %14, align 4
  switch i32 %127, label %155 [
    i32 0, label %128
    i32 9, label %147
  ]

128:                                              ; preds = %126
  br label %129

129:                                              ; preds = %128
  br label %130

130:                                              ; preds = %129
  br label %131

131:                                              ; preds = %130
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #5
  %132 = load ptr, ptr %6, align 8, !tbaa !5
  %133 = call i32 @stream_read_prep(ptr noundef %132, i64 noundef 0)
  store i32 %133, ptr %19, align 4, !tbaa !9
  %134 = load i32, ptr %19, align 4, !tbaa !9
  %135 = icmp slt i32 %134, 0
  br i1 %135, label %136, label %141

136:                                              ; preds = %131
  br label %137

137:                                              ; preds = %136
  %138 = load i32, ptr %19, align 4, !tbaa !9
  store i32 %138, ptr %10, align 4, !tbaa !9
  store i32 9, ptr %14, align 4
  br label %142

139:                                              ; No predecessors!
  br label %140

140:                                              ; preds = %139
  br label %141

141:                                              ; preds = %140, %131
  store i32 0, ptr %14, align 4
  br label %142

142:                                              ; preds = %141, %137
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #5
  %143 = load i32, ptr %14, align 4
  switch i32 %143, label %155 [
    i32 0, label %144
    i32 9, label %147
  ]

144:                                              ; preds = %142
  br label %145

145:                                              ; preds = %144
  br label %146

146:                                              ; preds = %145
  br label %147

147:                                              ; preds = %146, %142, %126, %66
  %148 = load i32, ptr %10, align 4, !tbaa !9
  %149 = icmp slt i32 %148, 0
  br i1 %149, label %150, label %153

150:                                              ; preds = %147
  %151 = load ptr, ptr %6, align 8, !tbaa !5
  %152 = call i32 @stream_close(ptr noundef %151, i32 noundef 0)
  br label %153

153:                                              ; preds = %150, %147
  %154 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %154, ptr %5, align 4
  store i32 1, ptr %14, align 4
  br label %155

155:                                              ; preds = %153, %142, %126, %66
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  %156 = load i32, ptr %5, align 4
  ret i32 %156
}

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @stream_seek(ptr noundef, i64 noundef, i32 noundef) #3

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 = { noreturn nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { inlinehint 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 #4 = { 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 #5 = { nounwind }
attributes #6 = { nounwind willreturn memory(read) }
attributes #7 = { noreturn nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}


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

@.str.2 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [16 x i8], align 1
@__PRETTY_FUNCTION__.stream_open_argv = external hidden unnamed_addr constant [50 x i8], align 1

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @stream_open_memory(ptr noalias noundef, ptr noalias noundef, i64 noundef, i32 noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @stream_read_prep(ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @stream_write_buffer_(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @stream_commit(ptr noalias noundef, ptr noalias noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 16777215) i32 @stream_open_argv(ptr noundef %0, i32 noundef %1, ptr nocapture noundef readonly %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = icmp sgt i32 %3, -1
  %6 = add nsw i32 %1, 1
  %7 = select i1 %5, i32 %6, i32 1
  %8 = icmp sgt i32 %1, 1
  br i1 %8, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %4
  %wide.trip.count = zext nneg i32 %1 to i64
  br label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %4
  %.051.lcssa = phi i32 [ %7, %4 ], [ %14, %.lr.ph ]
  %9 = icmp ult i32 %.051.lcssa, 16777215
  br i1 %9, label %16, label %15

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ 1, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %.05162 = phi i32 [ %7, %.lr.ph.preheader ], [ %14, %.lr.ph ]
  %10 = getelementptr inbounds ptr, ptr %2, i64 %indvars.iv
  %11 = load ptr, ptr %10, align 8, !tbaa !5
  %12 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %11) #4
  %13 = trunc i64 %12 to i32
  %14 = add i32 %.05162, %13
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !9

15:                                               ; preds = %._crit_edge
  tail call void @__assert_fail(ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.2, i32 noundef 523, ptr noundef nonnull @__PRETTY_FUNCTION__.stream_open_argv) #5
  unreachable

16:                                               ; preds = %._crit_edge
  %17 = zext nneg i32 %.051.lcssa to i64
  %18 = tail call i32 @stream_open_memory(ptr noundef %0, ptr noundef null, i64 noundef %17, i32 noundef 3)
  %19 = icmp slt i32 %18, 0
  br i1 %19, label %.critedge, label %20

20:                                               ; preds = %16
  %21 = tail call ptr @stream_write_buffer_(ptr noundef %0, ptr noundef null)
  br i1 %8, label %.lr.ph73, label %._crit_edge74

.lr.ph73:                                         ; preds = %20
  %22 = trunc i32 %3 to i8
  %wide.trip.count88 = zext nneg i32 %1 to i64
  br i1 %5, label %.lr.ph73.split, label %.lr.ph73.split.us.preheader

.lr.ph73.split.us.preheader:                      ; preds = %.lr.ph73
  %23 = add nsw i64 %wide.trip.count88, -1
  %xtraiter = and i64 %23, 1
  %24 = icmp eq i32 %1, 2
  br i1 %24, label %._crit_edge74.loopexit96.unr-lcssa, label %.lr.ph73.split.us.preheader.new

.lr.ph73.split.us.preheader.new:                  ; preds = %.lr.ph73.split.us.preheader
  %unroll_iter = and i64 %23, -2
  %invariant.gep = getelementptr inbounds i8, ptr %2, i64 8
  br label %.lr.ph73.split.us

.lr.ph73.split.us:                                ; preds = %._crit_edge68.us.1, %.lr.ph73.split.us.preheader.new
  %indvars.iv80 = phi i64 [ 1, %.lr.ph73.split.us.preheader.new ], [ %indvars.iv.next81.1, %._crit_edge68.us.1 ]
  %.04570.us = phi ptr [ %21, %.lr.ph73.split.us.preheader.new ], [ %.247.lcssa.us.1, %._crit_edge68.us.1 ]
  %niter = phi i64 [ 0, %.lr.ph73.split.us.preheader.new ], [ %niter.next.1, %._crit_edge68.us.1 ]
  %25 = getelementptr inbounds ptr, ptr %2, i64 %indvars.iv80
  %26 = load ptr, ptr %25, align 8, !tbaa !5
  %27 = load i8, ptr %26, align 1, !tbaa !11
  %.not63.us = icmp eq i8 %27, 0
  br i1 %.not63.us, label %._crit_edge68.us, label %.lr.ph67.us

.lr.ph67.us:                                      ; preds = %.lr.ph73.split.us, %.lr.ph67.us
  %28 = phi i8 [ %31, %.lr.ph67.us ], [ %27, %.lr.ph73.split.us ]
  %.04365.us = phi ptr [ %30, %.lr.ph67.us ], [ %26, %.lr.ph73.split.us ]
  %.24764.us = phi ptr [ %29, %.lr.ph67.us ], [ %.04570.us, %.lr.ph73.split.us ]
  %29 = getelementptr inbounds i8, ptr %.24764.us, i64 1
  store i8 %28, ptr %.24764.us, align 1, !tbaa !11
  %30 = getelementptr inbounds i8, ptr %.04365.us, i64 1
  %31 = load i8, ptr %30, align 1, !tbaa !11
  %.not.us = icmp eq i8 %31, 0
  br i1 %.not.us, label %._crit_edge68.us, label %.lr.ph67.us, !llvm.loop !12

._crit_edge68.us:                                 ; preds = %.lr.ph67.us, %.lr.ph73.split.us
  %.247.lcssa.us = phi ptr [ %.04570.us, %.lr.ph73.split.us ], [ %29, %.lr.ph67.us ]
  %gep = getelementptr inbounds ptr, ptr %invariant.gep, i64 %indvars.iv80
  %32 = load ptr, ptr %gep, align 8, !tbaa !5
  %33 = load i8, ptr %32, align 1, !tbaa !11
  %.not63.us.1 = icmp eq i8 %33, 0
  br i1 %.not63.us.1, label %._crit_edge68.us.1, label %.lr.ph67.us.1

.lr.ph67.us.1:                                    ; preds = %._crit_edge68.us, %.lr.ph67.us.1
  %34 = phi i8 [ %37, %.lr.ph67.us.1 ], [ %33, %._crit_edge68.us ]
  %.04365.us.1 = phi ptr [ %36, %.lr.ph67.us.1 ], [ %32, %._crit_edge68.us ]
  %.24764.us.1 = phi ptr [ %35, %.lr.ph67.us.1 ], [ %.247.lcssa.us, %._crit_edge68.us ]
  %35 = getelementptr inbounds i8, ptr %.24764.us.1, i64 1
  store i8 %34, ptr %.24764.us.1, align 1, !tbaa !11
  %36 = getelementptr inbounds i8, ptr %.04365.us.1, i64 1
  %37 = load i8, ptr %36, align 1, !tbaa !11
  %.not.us.1 = icmp eq i8 %37, 0
  br i1 %.not.us.1, label %._crit_edge68.us.1, label %.lr.ph67.us.1, !llvm.loop !12

._crit_edge68.us.1:                               ; preds = %.lr.ph67.us.1, %._crit_edge68.us
  %.247.lcssa.us.1 = phi ptr [ %.247.lcssa.us, %._crit_edge68.us ], [ %35, %.lr.ph67.us.1 ]
  %indvars.iv.next81.1 = add nuw nsw i64 %indvars.iv80, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge74.loopexit96.unr-lcssa, label %.lr.ph73.split.us, !llvm.loop !13

._crit_edge74.loopexit96.unr-lcssa:               ; preds = %._crit_edge68.us.1, %.lr.ph73.split.us.preheader
  %.247.lcssa.us.lcssa.ph = phi ptr [ poison, %.lr.ph73.split.us.preheader ], [ %.247.lcssa.us.1, %._crit_edge68.us.1 ]
  %indvars.iv80.unr = phi i64 [ 1, %.lr.ph73.split.us.preheader ], [ %indvars.iv.next81.1, %._crit_edge68.us.1 ]
  %.04570.us.unr = phi ptr [ %21, %.lr.ph73.split.us.preheader ], [ %.247.lcssa.us.1, %._crit_edge68.us.1 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge74, label %.lr.ph73.split.us.epil

.lr.ph73.split.us.epil:                           ; preds = %._crit_edge74.loopexit96.unr-lcssa
  %38 = getelementptr inbounds ptr, ptr %2, i64 %indvars.iv80.unr
  %39 = load ptr, ptr %38, align 8, !tbaa !5
  %40 = load i8, ptr %39, align 1, !tbaa !11
  %.not63.us.epil = icmp eq i8 %40, 0
  br i1 %.not63.us.epil, label %._crit_edge74, label %.lr.ph67.us.epil

.lr.ph67.us.epil:                                 ; preds = %.lr.ph73.split.us.epil, %.lr.ph67.us.epil
  %41 = phi i8 [ %44, %.lr.ph67.us.epil ], [ %40, %.lr.ph73.split.us.epil ]
  %.04365.us.epil = phi ptr [ %43, %.lr.ph67.us.epil ], [ %39, %.lr.ph73.split.us.epil ]
  %.24764.us.epil = phi ptr [ %42, %.lr.ph67.us.epil ], [ %.04570.us.unr, %.lr.ph73.split.us.epil ]
  %42 = getelementptr inbounds i8, ptr %.24764.us.epil, i64 1
  store i8 %41, ptr %.24764.us.epil, align 1, !tbaa !11
  %43 = getelementptr inbounds i8, ptr %.04365.us.epil, i64 1
  %44 = load i8, ptr %43, align 1, !tbaa !11
  %.not.us.epil = icmp eq i8 %44, 0
  br i1 %.not.us.epil, label %._crit_edge74, label %.lr.ph67.us.epil, !llvm.loop !12

._crit_edge74:                                    ; preds = %._crit_edge74.loopexit96.unr-lcssa, %.lr.ph67.us.epil, %.lr.ph73.split.us.epil, %._crit_edge68, %20
  %.045.lcssa = phi ptr [ %21, %20 ], [ %.247.lcssa, %._crit_edge68 ], [ %.247.lcssa.us.lcssa.ph, %._crit_edge74.loopexit96.unr-lcssa ], [ %.04570.us.unr, %.lr.ph73.split.us.epil ], [ %42, %.lr.ph67.us.epil ]
  tail call void @stream_commit(ptr noundef %0, ptr noundef %.045.lcssa)
  %45 = tail call i32 @stream_seek(ptr noundef %0, i64 noundef 0, i32 noundef 0)
  %46 = icmp slt i32 %45, 0
  br i1 %46, label %.critedge, label %58

.lr.ph73.split:                                   ; preds = %.lr.ph73, %._crit_edge68
  %indvars.iv85 = phi i64 [ %indvars.iv.next86, %._crit_edge68 ], [ 1, %.lr.ph73 ]
  %.04570 = phi ptr [ %.247.lcssa, %._crit_edge68 ], [ %21, %.lr.ph73 ]
  %47 = icmp ugt i64 %indvars.iv85, 1
  br i1 %47, label %48, label %50

48:                                               ; preds = %.lr.ph73.split
  %49 = getelementptr inbounds i8, ptr %.04570, i64 1
  store i8 %22, ptr %.04570, align 1, !tbaa !11
  br label %50

50:                                               ; preds = %48, %.lr.ph73.split
  %.146 = phi ptr [ %49, %48 ], [ %.04570, %.lr.ph73.split ]
  %51 = getelementptr inbounds ptr, ptr %2, i64 %indvars.iv85
  %52 = load ptr, ptr %51, align 8, !tbaa !5
  %53 = load i8, ptr %52, align 1, !tbaa !11
  %.not63 = icmp eq i8 %53, 0
  br i1 %.not63, label %._crit_edge68, label %.lr.ph67

._crit_edge68:                                    ; preds = %.lr.ph67, %50
  %.247.lcssa = phi ptr [ %.146, %50 ], [ %55, %.lr.ph67 ]
  %indvars.iv.next86 = add nuw nsw i64 %indvars.iv85, 1
  %exitcond89.not = icmp eq i64 %indvars.iv.next86, %wide.trip.count88
  br i1 %exitcond89.not, label %._crit_edge74, label %.lr.ph73.split, !llvm.loop !13

.lr.ph67:                                         ; preds = %50, %.lr.ph67
  %54 = phi i8 [ %57, %.lr.ph67 ], [ %53, %50 ]
  %.04365 = phi ptr [ %56, %.lr.ph67 ], [ %52, %50 ]
  %.24764 = phi ptr [ %55, %.lr.ph67 ], [ %.146, %50 ]
  %55 = getelementptr inbounds i8, ptr %.24764, i64 1
  store i8 %54, ptr %.24764, align 1, !tbaa !11
  %56 = getelementptr inbounds i8, ptr %.04365, i64 1
  %57 = load i8, ptr %56, align 1, !tbaa !11
  %.not = icmp eq i8 %57, 0
  br i1 %.not, label %._crit_edge68, label %.lr.ph67, !llvm.loop !12

58:                                               ; preds = %._crit_edge74
  %59 = tail call i32 @stream_read_prep(ptr noundef %0, i64 noundef 0)
  %60 = icmp slt i32 %59, 0
  br i1 %60, label %.critedge, label %62

.critedge:                                        ; preds = %16, %._crit_edge74, %58
  %61 = tail call i32 @stream_close(ptr noundef %0, i32 noundef 0)
  br label %62

62:                                               ; preds = %58, %.critedge
  ret i32 %.051.lcssa
}

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @stream_seek(ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #2

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}


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