; LLVM IR from attractivechaos/klib :: knetfile (khttp_connect_file)

; 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.knetFile_s = type { i32, i32, i64, ptr, ptr, i32, [4 x i32], i32, i32, i32, i32, ptr, ptr, ptr, i64, i64, ptr, ptr }

@stderr = external global ptr, align 8
@.str.14 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [57 x i8], align 1

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

declare i32 @close(i32 noundef) #1

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

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #3

; Function Attrs: nounwind
declare i32 @sprintf(ptr noundef, ptr noundef, ...) #4

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @khttp_connect_file(ptr noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %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 i64, align 8
  %10 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store i32 0, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.knetFile_s, ptr %11, i32 0, i32 1
  %13 = load i32, ptr %12, align 4, !tbaa !11
  %14 = icmp ne i32 %13, -1
  br i1 %14, label %15, label %20

15:                                               ; preds = %1
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.knetFile_s, ptr %16, i32 0, i32 1
  %18 = load i32, ptr %17, align 4, !tbaa !11
  %19 = call i32 @close(i32 noundef %18)
  br label %20

20:                                               ; preds = %15, %1
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.knetFile_s, ptr %21, i32 0, i32 3
  %23 = load ptr, ptr %22, align 8, !tbaa !14
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.knetFile_s, ptr %24, i32 0, i32 4
  %26 = load ptr, ptr %25, align 8, !tbaa !15
  %27 = call i32 @socket_connect(ptr noundef %23, ptr noundef %26)
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.knetFile_s, ptr %28, i32 0, i32 1
  store i32 %27, ptr %29, align 4, !tbaa !11
  %30 = call noalias ptr @calloc(i64 noundef 65536, i64 noundef 1) #7
  store ptr %30, ptr %6, align 8, !tbaa !5
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = load i32, ptr %5, align 4, !tbaa !9
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds i8, ptr %31, i64 %33
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.knetFile_s, ptr %35, i32 0, i32 16
  %37 = load ptr, ptr %36, align 8, !tbaa !16
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.knetFile_s, ptr %38, i32 0, i32 17
  %40 = load ptr, ptr %39, align 8, !tbaa !17
  %41 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %34, ptr noundef @.str.14, ptr noundef %37, ptr noundef %40) #6
  %42 = load i32, ptr %5, align 4, !tbaa !9
  %43 = add nsw i32 %42, %41
  store i32 %43, ptr %5, align 4, !tbaa !9
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = load i32, ptr %5, align 4, !tbaa !9
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds i8, ptr %44, i64 %46
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.knetFile_s, ptr %48, i32 0, i32 2
  %50 = load i64, ptr %49, align 8, !tbaa !18
  %51 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %47, ptr noundef @.str.15, i64 noundef %50) #6
  %52 = load i32, ptr %5, align 4, !tbaa !9
  %53 = add nsw i32 %52, %51
  store i32 %53, ptr %5, align 4, !tbaa !9
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = load i32, ptr %5, align 4, !tbaa !9
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds i8, ptr %54, i64 %56
  %58 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %57, ptr noundef @.str.16) #6
  %59 = load i32, ptr %5, align 4, !tbaa !9
  %60 = add nsw i32 %59, %58
  store i32 %60, ptr %5, align 4, !tbaa !9
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.knetFile_s, ptr %61, i32 0, i32 1
  %63 = load i32, ptr %62, align 4, !tbaa !11
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  %65 = load i32, ptr %5, align 4, !tbaa !9
  %66 = sext i32 %65 to i64
  %67 = call i64 @write(i32 noundef %63, ptr noundef %64, i64 noundef %66)
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %68

68:                                               ; preds = %99, %20
  %69 = load ptr, ptr %3, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.knetFile_s, ptr %69, i32 0, i32 1
  %71 = load i32, ptr %70, align 4, !tbaa !11
  %72 = load ptr, ptr %6, align 8, !tbaa !5
  %73 = load i32, ptr %5, align 4, !tbaa !9
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds i8, ptr %72, i64 %74
  %76 = call i64 @read(i32 noundef %71, ptr noundef %75, i64 noundef 1)
  %77 = icmp ne i64 %76, 0
  br i1 %77, label %78, label %102

78:                                               ; preds = %68
  %79 = load ptr, ptr %6, align 8, !tbaa !5
  %80 = load i32, ptr %5, align 4, !tbaa !9
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds i8, ptr %79, i64 %81
  %83 = load i8, ptr %82, align 1, !tbaa !19
  %84 = sext i8 %83 to i32
  %85 = icmp eq i32 %84, 10
  br i1 %85, label %86, label %99

86:                                               ; preds = %78
  %87 = load i32, ptr %5, align 4, !tbaa !9
  %88 = icmp sge i32 %87, 3
  br i1 %88, label %89, label %99

89:                                               ; preds = %86
  %90 = load ptr, ptr %6, align 8, !tbaa !5
  %91 = load i32, ptr %5, align 4, !tbaa !9
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds i8, ptr %90, i64 %92
  %94 = getelementptr inbounds i8, ptr %93, i64 -3
  %95 = call i32 @strncmp(ptr noundef %94, ptr noundef @.str.17, i64 noundef 4) #8
  %96 = icmp eq i32 %95, 0
  br i1 %96, label %97, label %98

97:                                               ; preds = %89
  br label %102

98:                                               ; preds = %89
  br label %99

99:                                               ; preds = %98, %86, %78
  %100 = load i32, ptr %5, align 4, !tbaa !9
  %101 = add nsw i32 %100, 1
  store i32 %101, ptr %5, align 4, !tbaa !9
  br label %68, !llvm.loop !20

102:                                              ; preds = %97, %68
  %103 = load ptr, ptr %6, align 8, !tbaa !5
  %104 = load i32, ptr %5, align 4, !tbaa !9
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds i8, ptr %103, i64 %105
  store i8 0, ptr %106, align 1, !tbaa !19
  %107 = load i32, ptr %5, align 4, !tbaa !9
  %108 = icmp slt i32 %107, 14
  br i1 %108, label %109, label %116

109:                                              ; preds = %102
  %110 = load ptr, ptr %3, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.knetFile_s, ptr %110, i32 0, i32 1
  %112 = load i32, ptr %111, align 4, !tbaa !11
  %113 = call i32 @close(i32 noundef %112)
  %114 = load ptr, ptr %3, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.knetFile_s, ptr %114, i32 0, i32 1
  store i32 -1, ptr %115, align 4, !tbaa !11
  store i32 -1, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %174

116:                                              ; preds = %102
  %117 = load ptr, ptr %6, align 8, !tbaa !5
  %118 = getelementptr inbounds i8, ptr %117, i64 8
  %119 = call i64 @strtol(ptr noundef %118, ptr noundef %7, i32 noundef 0) #6
  %120 = trunc i64 %119 to i32
  store i32 %120, ptr %4, align 4, !tbaa !9
  %121 = load i32, ptr %4, align 4, !tbaa !9
  %122 = icmp eq i32 %121, 200
  br i1 %122, label %123, label %152

123:                                              ; preds = %116
  %124 = load ptr, ptr %3, align 8, !tbaa !5
  %125 = getelementptr inbounds %struct.knetFile_s, ptr %124, i32 0, i32 2
  %126 = load i64, ptr %125, align 8, !tbaa !18
  %127 = icmp sgt i64 %126, 0
  br i1 %127, label %128, label %152

128:                                              ; preds = %123
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %129 = load ptr, ptr %3, align 8, !tbaa !5
  %130 = getelementptr inbounds %struct.knetFile_s, ptr %129, i32 0, i32 2
  %131 = load i64, ptr %130, align 8, !tbaa !18
  store i64 %131, ptr %9, align 8, !tbaa !22
  br label %132

132:                                              ; preds = %141, %128
  %133 = load i64, ptr %9, align 8, !tbaa !22
  %134 = icmp ne i64 %133, 0
  br i1 %134, label %135, label %151

135:                                              ; preds = %132
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %136 = load i64, ptr %9, align 8, !tbaa !22
  %137 = icmp slt i64 %136, 65536
  br i1 %137, label %138, label %140

138:                                              ; preds = %135
  %139 = load i64, ptr %9, align 8, !tbaa !22
  br label %141

140:                                              ; preds = %135
  br label %141

141:                                              ; preds = %140, %138
  %142 = phi i64 [ %139, %138 ], [ 65536, %140 ]
  store i64 %142, ptr %10, align 8, !tbaa !22
  %143 = load ptr, ptr %3, align 8, !tbaa !5
  %144 = getelementptr inbounds %struct.knetFile_s, ptr %143, i32 0, i32 1
  %145 = load i32, ptr %144, align 4, !tbaa !11
  %146 = load ptr, ptr %6, align 8, !tbaa !5
  %147 = load i64, ptr %10, align 8, !tbaa !22
  %148 = call i64 @my_netread(i32 noundef %145, ptr noundef %146, i64 noundef %147)
  %149 = load i64, ptr %9, align 8, !tbaa !22
  %150 = sub nsw i64 %149, %148
  store i64 %150, ptr %9, align 8, !tbaa !22
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  br label %132, !llvm.loop !23

151:                                              ; preds = %132
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  br label %170

152:                                              ; preds = %123, %116
  %153 = load i32, ptr %4, align 4, !tbaa !9
  %154 = icmp ne i32 %153, 206
  br i1 %154, label %155, label %169

155:                                              ; preds = %152
  %156 = load i32, ptr %4, align 4, !tbaa !9
  %157 = icmp ne i32 %156, 200
  br i1 %157, label %158, label %169

158:                                              ; preds = %155
  %159 = load ptr, ptr %6, align 8, !tbaa !5
  call void @free(ptr noundef %159) #6
  %160 = load ptr, ptr @stderr, align 8, !tbaa !5
  %161 = load i32, ptr %4, align 4, !tbaa !9
  %162 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %160, ptr noundef @.str.18, i32 noundef %161) #6
  %163 = load ptr, ptr %3, align 8, !tbaa !5
  %164 = getelementptr inbounds %struct.knetFile_s, ptr %163, i32 0, i32 1
  %165 = load i32, ptr %164, align 4, !tbaa !11
  %166 = call i32 @close(i32 noundef %165)
  %167 = load ptr, ptr %3, align 8, !tbaa !5
  %168 = getelementptr inbounds %struct.knetFile_s, ptr %167, i32 0, i32 1
  store i32 -1, ptr %168, align 4, !tbaa !11
  store i32 -1, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %174

169:                                              ; preds = %155, %152
  br label %170

170:                                              ; preds = %169, %151
  %171 = load ptr, ptr %6, align 8, !tbaa !5
  call void @free(ptr noundef %171) #6
  %172 = load ptr, ptr %3, align 8, !tbaa !5
  %173 = getelementptr inbounds %struct.knetFile_s, ptr %172, i32 0, i32 10
  store i32 1, ptr %173, align 8, !tbaa !24
  store i32 0, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %174

174:                                              ; preds = %170, %158, %109
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  %175 = load i32, ptr %2, align 4
  ret i32 %175
}

declare i64 @write(i32 noundef, ptr noundef, i64 noundef) #1

declare i64 @read(i32 noundef, ptr noundef, i64 noundef) #1

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strncmp(ptr noundef, ptr noundef, i64 noundef) #5

; Function Attrs: nounwind
declare i64 @strtol(ptr noundef, ptr noundef, i32 noundef) #4

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

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

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 = { "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 nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nounwind allocsize(0,1) "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 "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 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 #6 = { nounwind }
attributes #7 = { nounwind allocsize(0,1) }
attributes #8 = { nounwind willreturn memory(read) }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 4}
!12 = !{!"knetFile_s", !10, i64 0, !10, i64 4, !13, i64 8, !6, i64 16, !6, i64 24, !10, i64 32, !7, i64 36, !10, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !13, i64 96, !13, i64 104, !6, i64 112, !6, i64 120}
!13 = !{!"long", !7, i64 0}
!14 = !{!12, !6, i64 16}
!15 = !{!12, !6, i64 24}
!16 = !{!12, !6, i64 112}
!17 = !{!12, !6, i64 120}
!18 = !{!12, !13, i64 8}
!19 = !{!7, !7, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{!13, !13, i64 0}
!23 = distinct !{!23, !21}
!24 = !{!12, !10, i64 64}


; 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.14 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [57 x i8], align 1

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

declare i32 @close(i32 noundef) local_unnamed_addr #1

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

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @sprintf(ptr noalias nocapture noundef writeonly, ptr nocapture noundef readonly, ...) local_unnamed_addr #4

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

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @khttp_connect_file(ptr nocapture noundef %0) local_unnamed_addr #0 {
  %2 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #10
  %3 = getelementptr inbounds i8, ptr %0, i64 4
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %.not = icmp eq i32 %4, -1
  br i1 %.not, label %7, label %5

5:                                                ; preds = %1
  %6 = tail call i32 @close(i32 noundef %4) #10
  br label %7

7:                                                ; preds = %5, %1
  %8 = getelementptr inbounds i8, ptr %0, i64 16
  %9 = load ptr, ptr %8, align 8, !tbaa !12
  %10 = getelementptr inbounds i8, ptr %0, i64 24
  %11 = load ptr, ptr %10, align 8, !tbaa !13
  %12 = tail call i32 @socket_connect(ptr noundef %9, ptr noundef %11)
  store i32 %12, ptr %3, align 4, !tbaa !5
  %13 = tail call noalias dereferenceable_or_null(65536) ptr @calloc(i64 noundef 65536, i64 noundef 1) #11
  %14 = getelementptr inbounds i8, ptr %0, i64 112
  %15 = load ptr, ptr %14, align 8, !tbaa !14
  %16 = getelementptr inbounds i8, ptr %0, i64 120
  %17 = load ptr, ptr %16, align 8, !tbaa !15
  %18 = tail call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %13, ptr noundef nonnull dereferenceable(1) @.str.14, ptr noundef %15, ptr noundef %17) #10
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds i8, ptr %13, i64 %19
  %21 = getelementptr inbounds i8, ptr %0, i64 8
  %22 = load i64, ptr %21, align 8, !tbaa !16
  %23 = tail call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %20, ptr noundef nonnull dereferenceable(1) @.str.15, i64 noundef %22) #10
  %24 = add nsw i32 %23, %18
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds i8, ptr %13, i64 %25
  %27 = tail call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %26, ptr noundef nonnull dereferenceable(1) @.str.16) #10
  %28 = add nsw i32 %24, %27
  %29 = load i32, ptr %3, align 4, !tbaa !5
  %30 = sext i32 %28 to i64
  %31 = tail call i64 @write(i32 noundef %29, ptr noundef %13, i64 noundef %30) #10
  %32 = load i32, ptr %3, align 4, !tbaa !5
  %33 = tail call i64 @read(i32 noundef %32, ptr noundef %13, i64 noundef 1) #10
  %.not6163 = icmp eq i64 %33, 0
  br i1 %.not6163, label %._crit_edge.thread, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %7
  %34 = load i32, ptr %3, align 4, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %13, i64 1
  %36 = tail call i64 @read(i32 noundef %34, ptr noundef nonnull %35, i64 noundef 1) #10
  %.not61.peel = icmp eq i64 %36, 0
  br i1 %.not61.peel, label %._crit_edge.thread, label %.lr.ph.peel.next

.lr.ph.peel.next:                                 ; preds = %.lr.ph.preheader
  %37 = load i32, ptr %3, align 4, !tbaa !5
  %38 = getelementptr inbounds i8, ptr %13, i64 2
  %39 = tail call i64 @read(i32 noundef %37, ptr noundef nonnull %38, i64 noundef 1) #10
  %.not61.peel76 = icmp eq i64 %39, 0
  br i1 %.not61.peel76, label %._crit_edge.thread, label %.lr.ph.peel.next71

.lr.ph.peel.next71:                               ; preds = %.lr.ph.peel.next
  %40 = load i32, ptr %3, align 4, !tbaa !5
  %41 = getelementptr inbounds i8, ptr %13, i64 3
  %42 = tail call i64 @read(i32 noundef %40, ptr noundef nonnull %41, i64 noundef 1) #10
  %.not61.peel82 = icmp eq i64 %42, 0
  br i1 %.not61.peel82, label %._crit_edge.thread, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.peel.next71, %50
  %indvars.iv = phi i64 [ %indvars.iv.next, %50 ], [ 3, %.lr.ph.peel.next71 ]
  %43 = phi ptr [ %52, %50 ], [ %41, %.lr.ph.peel.next71 ]
  %44 = load i8, ptr %43, align 1, !tbaa !17
  %45 = icmp eq i8 %44, 10
  br i1 %45, label %46, label %50

46:                                               ; preds = %.lr.ph
  %47 = getelementptr inbounds i8, ptr %43, i64 -3
  %48 = tail call i32 @strncmp(ptr noundef nonnull dereferenceable(1) %47, ptr noundef nonnull dereferenceable(1) @.str.17, i64 noundef 4) #12
  %49 = icmp eq i32 %48, 0
  br i1 %49, label %._crit_edge, label %50

50:                                               ; preds = %46, %.lr.ph
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %51 = load i32, ptr %3, align 4, !tbaa !5
  %52 = getelementptr inbounds i8, ptr %13, i64 %indvars.iv.next
  %53 = tail call i64 @read(i32 noundef %51, ptr noundef nonnull %52, i64 noundef 1) #10
  %.not61 = icmp eq i64 %53, 0
  br i1 %.not61, label %._crit_edge, label %.lr.ph, !llvm.loop !18

._crit_edge.thread:                               ; preds = %7, %.lr.ph.preheader, %.lr.ph.peel.next, %.lr.ph.peel.next71
  %.lcssa.ph = phi ptr [ %41, %.lr.ph.peel.next71 ], [ %38, %.lr.ph.peel.next ], [ %35, %.lr.ph.preheader ], [ %13, %7 ]
  store i8 0, ptr %.lcssa.ph, align 1, !tbaa !17
  br label %55

._crit_edge:                                      ; preds = %46, %50
  %.057.lcssa.ph.ph.in = phi i64 [ %indvars.iv, %46 ], [ %indvars.iv.next, %50 ]
  %.lcssa.ph.ph = phi ptr [ %43, %46 ], [ %52, %50 ]
  %.057.lcssa.ph.ph = trunc i64 %.057.lcssa.ph.ph.in to i32
  %54 = icmp ult i32 %.057.lcssa.ph.ph, 14
  store i8 0, ptr %.lcssa.ph.ph, align 1, !tbaa !17
  br i1 %54, label %55, label %58

55:                                               ; preds = %._crit_edge.thread, %._crit_edge
  %56 = load i32, ptr %3, align 4, !tbaa !5
  %57 = tail call i32 @close(i32 noundef %56) #10
  store i32 -1, ptr %3, align 4, !tbaa !5
  br label %75

58:                                               ; preds = %._crit_edge
  %59 = getelementptr inbounds i8, ptr %13, i64 8
  %60 = call i64 @strtol(ptr noundef nonnull %59, ptr noundef nonnull %2, i32 noundef 0) #10
  %61 = trunc i64 %60 to i32
  switch i32 %61, label %69 [
    i32 200, label %62
    i32 206, label %.loopexit
  ]

62:                                               ; preds = %58
  %63 = load i64, ptr %21, align 8, !tbaa !16
  %64 = icmp sgt i64 %63, 0
  br i1 %64, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %62, %.preheader
  %.05669 = phi i64 [ %68, %.preheader ], [ %63, %62 ]
  %65 = tail call i64 @llvm.smin.i64(i64 %.05669, i64 65536)
  %66 = load i32, ptr %3, align 4, !tbaa !5
  %67 = tail call i64 @my_netread(i32 noundef %66, ptr noundef %13, i64 noundef %65)
  %68 = sub nsw i64 %.05669, %67
  %.not62 = icmp eq i64 %68, 0
  br i1 %.not62, label %.loopexit, label %.preheader, !llvm.loop !21

69:                                               ; preds = %58
  tail call void @free(ptr noundef nonnull %13) #10
  %70 = load ptr, ptr @stderr, align 8, !tbaa !22
  %71 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %70, ptr noundef nonnull @.str.18, i32 noundef %61) #13
  %72 = load i32, ptr %3, align 4, !tbaa !5
  %73 = tail call i32 @close(i32 noundef %72) #10
  store i32 -1, ptr %3, align 4, !tbaa !5
  br label %75

.loopexit:                                        ; preds = %.preheader, %62, %58
  tail call void @free(ptr noundef %13) #10
  %74 = getelementptr inbounds i8, ptr %0, i64 64
  store i32 1, ptr %74, align 8, !tbaa !23
  br label %75

75:                                               ; preds = %.loopexit, %69, %55
  %.0 = phi i32 [ -1, %55 ], [ 0, %.loopexit ], [ -1, %69 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #10
  ret i32 %.0
}

; Function Attrs: nofree
declare noundef i64 @write(i32 noundef, ptr nocapture noundef readonly, i64 noundef) local_unnamed_addr #5

; Function Attrs: nofree
declare noundef i64 @read(i32 noundef, ptr nocapture noundef, i64 noundef) local_unnamed_addr #5

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strncmp(ptr nocapture noundef, ptr nocapture noundef, i64 noundef) local_unnamed_addr #6

; Function Attrs: mustprogress nofree nounwind willreturn
declare i64 @strtol(ptr noundef readonly, ptr nocapture noundef, i32 noundef) local_unnamed_addr #7

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smin.i64(i64, i64) #9

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 = { "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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) 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 #4 = { 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 #5 = { nofree "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 = { 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 #7 = { mustprogress nofree nounwind willreturn "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 #8 = { 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 #9 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #10 = { nounwind }
attributes #11 = { nounwind allocsize(0,1) }
attributes #12 = { nounwind willreturn memory(read) }
attributes #13 = { 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 4}
!6 = !{!"knetFile_s", !7, i64 0, !7, i64 4, !10, i64 8, !11, i64 16, !11, i64 24, !7, i64 32, !8, i64 36, !7, i64 52, !7, i64 56, !7, i64 60, !7, i64 64, !11, i64 72, !11, i64 80, !11, i64 88, !10, i64 96, !10, i64 104, !11, i64 112, !11, i64 120}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!6, !11, i64 16}
!13 = !{!6, !11, i64 24}
!14 = !{!6, !11, i64 112}
!15 = !{!6, !11, i64 120}
!16 = !{!6, !10, i64 8}
!17 = !{!8, !8, i64 0}
!18 = distinct !{!18, !19, !20}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!"llvm.loop.peeled.count", i32 3}
!21 = distinct !{!21, !19}
!22 = !{!11, !11, i64 0}
!23 = !{!6, !7, i64 64}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopFullUnrollPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass