; LLVM IR from cornell-zhang/rosetta :: BNN/cpp/minizip (ioapi_buf)

; 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.ourstream_s = type { [65536 x i8], i32, i32, i32, i32, [65536 x i8], i32, i32, i32, i32, i64, ptr }
%struct.ourbuffer_s = type { %struct.zlib_filefunc_def_s, %struct.zlib_filefunc64_def_s }
%struct.zlib_filefunc_def_s = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.zlib_filefunc64_def_s = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

; 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 i64 @fflush_buf(ptr noundef, ptr noundef) #1

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

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

33:                                               ; preds = %4
  %34 = load ptr, ptr %11, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.ourstream_s, ptr %34, i32 0, i32 1
  %36 = load i32, ptr %35, align 8, !tbaa !13
  %37 = zext i32 %36 to i64
  %38 = load ptr, ptr %11, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.ourstream_s, ptr %38, i32 0, i32 10
  %40 = load i64, ptr %39, align 8, !tbaa !16
  %41 = sub i64 %40, %37
  store i64 %41, ptr %39, align 8, !tbaa !16
  %42 = load ptr, ptr %11, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.ourstream_s, ptr %42, i32 0, i32 2
  %44 = load i32, ptr %43, align 4, !tbaa !17
  %45 = zext i32 %44 to i64
  %46 = load ptr, ptr %11, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.ourstream_s, ptr %46, i32 0, i32 10
  %48 = load i64, ptr %47, align 8, !tbaa !16
  %49 = add i64 %48, %45
  store i64 %49, ptr %47, align 8, !tbaa !16
  %50 = load ptr, ptr %11, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.ourstream_s, ptr %50, i32 0, i32 1
  store i32 0, ptr %51, align 8, !tbaa !13
  %52 = load ptr, ptr %11, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.ourstream_s, ptr %52, i32 0, i32 2
  store i32 0, ptr %53, align 4, !tbaa !17
  %54 = load ptr, ptr %10, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.ourbuffer_s, ptr %54, i32 0, i32 1
  %56 = getelementptr inbounds %struct.zlib_filefunc64_def_s, ptr %55, i32 0, i32 5
  %57 = load ptr, ptr %56, align 8, !tbaa !18
  %58 = icmp ne ptr %57, null
  br i1 %58, label %59, label %76

59:                                               ; preds = %33
  %60 = load ptr, ptr %10, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.ourbuffer_s, ptr %60, i32 0, i32 1
  %62 = getelementptr inbounds %struct.zlib_filefunc64_def_s, ptr %61, i32 0, i32 5
  %63 = load ptr, ptr %62, align 8, !tbaa !18
  %64 = load ptr, ptr %10, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.ourbuffer_s, ptr %64, i32 0, i32 1
  %66 = getelementptr inbounds %struct.zlib_filefunc64_def_s, ptr %65, i32 0, i32 8
  %67 = load ptr, ptr %66, align 8, !tbaa !22
  %68 = load ptr, ptr %11, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.ourstream_s, ptr %68, i32 0, i32 11
  %70 = load ptr, ptr %69, align 8, !tbaa !23
  %71 = load ptr, ptr %11, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.ourstream_s, ptr %71, i32 0, i32 10
  %73 = load i64, ptr %72, align 8, !tbaa !16
  %74 = call i64 %63(ptr noundef %67, ptr noundef %70, i64 noundef %73, i32 noundef 0)
  %75 = trunc i64 %74 to i32
  store i32 %75, ptr %15, align 4, !tbaa !11
  br label %93

76:                                               ; preds = %33
  %77 = load ptr, ptr %10, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.ourbuffer_s, ptr %77, i32 0, i32 0
  %79 = getelementptr inbounds %struct.zlib_filefunc_def_s, ptr %78, i32 0, i32 5
  %80 = load ptr, ptr %79, align 8, !tbaa !24
  %81 = load ptr, ptr %10, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.ourbuffer_s, ptr %81, i32 0, i32 0
  %83 = getelementptr inbounds %struct.zlib_filefunc_def_s, ptr %82, i32 0, i32 8
  %84 = load ptr, ptr %83, align 8, !tbaa !25
  %85 = load ptr, ptr %11, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.ourstream_s, ptr %85, i32 0, i32 11
  %87 = load ptr, ptr %86, align 8, !tbaa !23
  %88 = load ptr, ptr %11, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.ourstream_s, ptr %88, i32 0, i32 10
  %90 = load i64, ptr %89, align 8, !tbaa !16
  %91 = call i64 %80(ptr noundef %84, ptr noundef %87, i64 noundef %90, i32 noundef 0)
  %92 = trunc i64 %91 to i32
  store i32 %92, ptr %15, align 4, !tbaa !11
  br label %93

93:                                               ; preds = %76, %59
  %94 = load i32, ptr %15, align 4, !tbaa !11
  %95 = icmp ne i32 %94, 0
  br i1 %95, label %96, label %97

96:                                               ; preds = %93
  store i64 -1, ptr %5, align 8
  store i32 1, ptr %16, align 4
  br label %198

97:                                               ; preds = %93
  br label %98

98:                                               ; preds = %97, %4
  br label %99

99:                                               ; preds = %192, %143, %98
  %100 = load i32, ptr %13, align 4, !tbaa !11
  %101 = icmp ugt i32 %100, 0
  br i1 %101, label %102, label %193

102:                                              ; preds = %99
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  %103 = load i32, ptr %13, align 4, !tbaa !11
  store i32 %103, ptr %17, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  %104 = load ptr, ptr %11, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.ourstream_s, ptr %104, i32 0, i32 6
  %106 = load i32, ptr %105, align 8, !tbaa !26
  store i32 %106, ptr %19, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #3
  %107 = load ptr, ptr %11, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.ourstream_s, ptr %107, i32 0, i32 7
  %109 = load i32, ptr %108, align 4, !tbaa !27
  store i32 %109, ptr %20, align 4, !tbaa !11
  %110 = icmp eq ptr %19, %20
  %111 = zext i1 %110 to i32
  %112 = load i32, ptr %19, align 4, !tbaa !11
  %113 = load i32, ptr %20, align 4, !tbaa !11
  %114 = icmp ult i32 %112, %113
  br i1 %114, label %115, label %117

115:                                              ; preds = %102
  %116 = load i32, ptr %19, align 4, !tbaa !11
  br label %119

117:                                              ; preds = %102
  %118 = load i32, ptr %20, align 4, !tbaa !11
  br label %119

119:                                              ; preds = %117, %115
  %120 = phi i32 [ %116, %115 ], [ %118, %117 ]
  store i32 %120, ptr %21, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  %121 = load i32, ptr %21, align 4, !tbaa !11
  %122 = sub i32 65536, %121
  store i32 %122, ptr %18, align 4, !tbaa !11
  %123 = icmp eq ptr %17, %18
  %124 = zext i1 %123 to i32
  %125 = load i32, ptr %17, align 4, !tbaa !11
  %126 = load i32, ptr %18, align 4, !tbaa !11
  %127 = icmp ult i32 %125, %126
  br i1 %127, label %128, label %130

128:                                              ; preds = %119
  %129 = load i32, ptr %17, align 4, !tbaa !11
  br label %132

130:                                              ; preds = %119
  %131 = load i32, ptr %18, align 4, !tbaa !11
  br label %132

132:                                              ; preds = %130, %128
  %133 = phi i32 [ %129, %128 ], [ %131, %130 ]
  store i32 %133, ptr %22, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  %134 = load i32, ptr %22, align 4, !tbaa !11
  store i32 %134, ptr %14, align 4, !tbaa !11
  %135 = load i32, ptr %14, align 4, !tbaa !11
  %136 = icmp eq i32 %135, 0
  br i1 %136, label %137, label %144

137:                                              ; preds = %132
  %138 = load ptr, ptr %6, align 8, !tbaa !5
  %139 = load ptr, ptr %7, align 8, !tbaa !5
  %140 = call i64 @fflush_buf(ptr noundef %138, ptr noundef %139)
  %141 = icmp sle i64 %140, 0
  br i1 %141, label %142, label %143

142:                                              ; preds = %137
  store i64 0, ptr %5, align 8
  store i32 1, ptr %16, align 4
  br label %198

143:                                              ; preds = %137
  br label %99, !llvm.loop !28

144:                                              ; preds = %132
  %145 = load ptr, ptr %11, align 8, !tbaa !5
  %146 = getelementptr inbounds %struct.ourstream_s, ptr %145, i32 0, i32 5
  %147 = getelementptr inbounds [65536 x i8], ptr %146, i64 0, i64 0
  %148 = load ptr, ptr %11, align 8, !tbaa !5
  %149 = getelementptr inbounds %struct.ourstream_s, ptr %148, i32 0, i32 7
  %150 = load i32, ptr %149, align 4, !tbaa !27
  %151 = zext i32 %150 to i64
  %152 = getelementptr inbounds i8, ptr %147, i64 %151
  %153 = load ptr, ptr %8, align 8, !tbaa !5
  %154 = load i32, ptr %12, align 4, !tbaa !11
  %155 = load i32, ptr %13, align 4, !tbaa !11
  %156 = sub i32 %154, %155
  %157 = zext i32 %156 to i64
  %158 = getelementptr inbounds i8, ptr %153, i64 %157
  %159 = load i32, ptr %14, align 4, !tbaa !11
  %160 = zext i32 %159 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %152, ptr align 1 %158, i64 %160, i1 false)
  %161 = load i32, ptr %14, align 4, !tbaa !11
  %162 = load i32, ptr %13, align 4, !tbaa !11
  %163 = sub i32 %162, %161
  store i32 %163, ptr %13, align 4, !tbaa !11
  %164 = load i32, ptr %14, align 4, !tbaa !11
  %165 = load ptr, ptr %11, align 8, !tbaa !5
  %166 = getelementptr inbounds %struct.ourstream_s, ptr %165, i32 0, i32 7
  %167 = load i32, ptr %166, align 4, !tbaa !27
  %168 = add i32 %167, %164
  store i32 %168, ptr %166, align 4, !tbaa !27
  %169 = load ptr, ptr %11, align 8, !tbaa !5
  %170 = getelementptr inbounds %struct.ourstream_s, ptr %169, i32 0, i32 8
  %171 = load i32, ptr %170, align 8, !tbaa !30
  %172 = add i32 %171, 1
  store i32 %172, ptr %170, align 8, !tbaa !30
  %173 = load ptr, ptr %11, align 8, !tbaa !5
  %174 = getelementptr inbounds %struct.ourstream_s, ptr %173, i32 0, i32 7
  %175 = load i32, ptr %174, align 4, !tbaa !27
  %176 = load ptr, ptr %11, align 8, !tbaa !5
  %177 = getelementptr inbounds %struct.ourstream_s, ptr %176, i32 0, i32 6
  %178 = load i32, ptr %177, align 8, !tbaa !26
  %179 = icmp ugt i32 %175, %178
  br i1 %179, label %180, label %192

180:                                              ; preds = %144
  %181 = load ptr, ptr %11, align 8, !tbaa !5
  %182 = getelementptr inbounds %struct.ourstream_s, ptr %181, i32 0, i32 7
  %183 = load i32, ptr %182, align 4, !tbaa !27
  %184 = load ptr, ptr %11, align 8, !tbaa !5
  %185 = getelementptr inbounds %struct.ourstream_s, ptr %184, i32 0, i32 6
  %186 = load i32, ptr %185, align 8, !tbaa !26
  %187 = sub i32 %183, %186
  %188 = load ptr, ptr %11, align 8, !tbaa !5
  %189 = getelementptr inbounds %struct.ourstream_s, ptr %188, i32 0, i32 6
  %190 = load i32, ptr %189, align 8, !tbaa !26
  %191 = add i32 %190, %187
  store i32 %191, ptr %189, align 8, !tbaa !26
  br label %192

192:                                              ; preds = %180, %144
  br label %99, !llvm.loop !28

193:                                              ; preds = %99
  %194 = load i64, ptr %9, align 8, !tbaa !9
  %195 = load i32, ptr %13, align 4, !tbaa !11
  %196 = zext i32 %195 to i64
  %197 = sub i64 %194, %196
  store i64 %197, ptr %5, align 8
  store i32 1, ptr %16, align 4
  br label %198

198:                                              ; preds = %193, %142, %96
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %199 = load i64, ptr %5, align 8
  ret i64 %199
}

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !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, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 65536}
!14 = !{!"ourstream_s", !7, i64 0, !12, i64 65536, !12, i64 65540, !12, i64 65544, !12, i64 65548, !7, i64 65552, !12, i64 131088, !12, i64 131092, !12, i64 131096, !12, i64 131100, !15, i64 131104, !6, i64 131112}
!15 = !{!"long long", !7, i64 0}
!16 = !{!14, !15, i64 131104}
!17 = !{!14, !12, i64 65540}
!18 = !{!19, !6, i64 112}
!19 = !{!"ourbuffer_s", !20, i64 0, !21, i64 72}
!20 = !{!"zlib_filefunc_def_s", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64}
!21 = !{!"zlib_filefunc64_def_s", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64}
!22 = !{!19, !6, i64 136}
!23 = !{!14, !6, i64 131112}
!24 = !{!19, !6, i64 40}
!25 = !{!19, !6, i64 64}
!26 = !{!14, !12, i64 131088}
!27 = !{!14, !12, i64 131092}
!28 = distinct !{!28, !29}
!29 = !{!"llvm.loop.mustprogress"}
!30 = !{!14, !12, i64 131096}


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

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

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

; Function Attrs: nounwind uwtable
define dso_local noundef i64 @fwrite_buf_func(ptr noundef %0, ptr noundef %1, ptr nocapture noundef readonly %2, i64 noundef %3) local_unnamed_addr #0 {
  %5 = trunc i64 %3 to i32
  %6 = getelementptr inbounds i8, ptr %1, i64 65536
  %7 = load i32, ptr %6, align 8, !tbaa !5
  %.not = icmp eq i32 %7, 0
  br i1 %.not, label %29, label %8

8:                                                ; preds = %4
  %9 = zext i32 %7 to i64
  %10 = getelementptr inbounds i8, ptr %1, i64 131104
  %11 = load i64, ptr %10, align 8, !tbaa !12
  %12 = sub i64 %11, %9
  %13 = getelementptr inbounds i8, ptr %1, i64 65540
  %14 = load i32, ptr %13, align 4, !tbaa !13
  %15 = zext i32 %14 to i64
  %16 = add i64 %12, %15
  store i64 %16, ptr %10, align 8, !tbaa !12
  store i32 0, ptr %6, align 8, !tbaa !5
  store i32 0, ptr %13, align 4, !tbaa !13
  %17 = getelementptr inbounds i8, ptr %0, i64 112
  %18 = load ptr, ptr %17, align 8, !tbaa !14
  %.not55 = icmp eq ptr %18, null
  br i1 %.not55, label %19, label %22

19:                                               ; preds = %8
  %20 = getelementptr inbounds i8, ptr %0, i64 40
  %21 = load ptr, ptr %20, align 8, !tbaa !18
  br label %22

22:                                               ; preds = %8, %19
  %.sink = phi i64 [ 64, %19 ], [ 136, %8 ]
  %.sink70 = phi ptr [ %21, %19 ], [ %18, %8 ]
  %23 = getelementptr inbounds i8, ptr %0, i64 %.sink
  %24 = load ptr, ptr %23, align 8, !tbaa !19
  %25 = getelementptr inbounds i8, ptr %1, i64 131112
  %26 = load ptr, ptr %25, align 8, !tbaa !20
  %27 = tail call i64 %.sink70(ptr noundef %24, ptr noundef %26, i64 noundef %16, i32 noundef 0) #3
  %28 = and i64 %27, 4294967295
  %.not56 = icmp eq i64 %28, 0
  br i1 %.not56, label %29, label %.loopexit.split

29:                                               ; preds = %22, %4
  %30 = getelementptr inbounds i8, ptr %1, i64 131088
  %31 = getelementptr inbounds i8, ptr %1, i64 131092
  %32 = getelementptr inbounds i8, ptr %1, i64 65552
  %33 = getelementptr inbounds i8, ptr %1, i64 131096
  %.not5777 = icmp eq i32 %5, 0
  br i1 %.not5777, label %.loopexit.split, label %.outer.split.preheader

.outer.split.preheader:                           ; preds = %29, %.outer
  %.048.ph78 = phi i32 [ %50, %.outer ], [ %5, %29 ]
  br label %.outer.split

.outer.split:                                     ; preds = %.outer.split.preheader, %38
  %34 = load i32, ptr %30, align 8, !tbaa !21
  %35 = load i32, ptr %31, align 4, !tbaa !22
  %36 = tail call i32 @llvm.umin.i32(i32 %34, i32 %35)
  %37 = icmp eq i32 %36, 65536
  br i1 %37, label %38, label %41

38:                                               ; preds = %.outer.split
  %39 = tail call i64 @fflush_buf(ptr noundef %0, ptr noundef nonnull %1)
  %40 = icmp slt i64 %39, 1
  br i1 %40, label %.loopexit.split, label %.outer.split, !llvm.loop !23

41:                                               ; preds = %.outer.split
  %42 = sub i32 65536, %36
  %43 = tail call i32 @llvm.umin.i32(i32 %.048.ph78, i32 %42)
  %44 = zext i32 %35 to i64
  %45 = getelementptr inbounds i8, ptr %32, i64 %44
  %46 = sub i32 %5, %.048.ph78
  %47 = zext i32 %46 to i64
  %48 = getelementptr inbounds i8, ptr %2, i64 %47
  %49 = zext i32 %43 to i64
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %45, ptr align 1 %48, i64 %49, i1 false)
  %50 = sub i32 %.048.ph78, %43
  %51 = load i32, ptr %31, align 4, !tbaa !22
  %52 = add i32 %51, %43
  store i32 %52, ptr %31, align 4, !tbaa !22
  %53 = load i32, ptr %33, align 8, !tbaa !25
  %54 = add i32 %53, 1
  store i32 %54, ptr %33, align 8, !tbaa !25
  %55 = load i32, ptr %30, align 8, !tbaa !21
  %56 = icmp ugt i32 %52, %55
  br i1 %56, label %57, label %.outer

57:                                               ; preds = %41
  store i32 %52, ptr %30, align 8, !tbaa !21
  br label %.outer

.outer:                                           ; preds = %57, %41
  %.not57 = icmp eq i32 %50, 0
  br i1 %.not57, label %.loopexit.split, label %.outer.split.preheader, !llvm.loop !23

.loopexit.split:                                  ; preds = %.outer, %38, %29, %22
  %.0 = phi i64 [ -1, %22 ], [ %3, %29 ], [ 0, %38 ], [ %3, %.outer ]
  ret i64 %.0
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umin.i32(i32, i32) #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !9, i64 65536}
!6 = !{!"ourstream_s", !7, i64 0, !9, i64 65536, !9, i64 65540, !9, i64 65544, !9, i64 65548, !7, i64 65552, !9, i64 131088, !9, i64 131092, !9, i64 131096, !9, i64 131100, !10, i64 131104, !11, i64 131112}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!6, !10, i64 131104}
!13 = !{!6, !9, i64 65540}
!14 = !{!15, !11, i64 112}
!15 = !{!"ourbuffer_s", !16, i64 0, !17, i64 72}
!16 = !{!"zlib_filefunc_def_s", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64}
!17 = !{!"zlib_filefunc64_def_s", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64}
!18 = !{!15, !11, i64 40}
!19 = !{!11, !11, i64 0}
!20 = !{!6, !11, i64 131112}
!21 = !{!6, !9, i64 131088}
!22 = !{!6, !9, i64 131092}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = !{!6, !9, i64 131096}


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