; LLVM IR from fhanau/Efficient-Compression-Tool :: src/gztools.ll (Z6IsGzipPKcPPc)

; 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.stat = type { i64, i64, i64, i32, i32, i32, i32, i64, i64, i64, i64, %struct.timespec, %struct.timespec, %struct.timespec, [3 x i64] }
%struct.timespec = type { i64, i64 }

@.str = external hidden unnamed_addr constant [3 x i8], align 1
@stderr = external global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [24 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z6IsGzipPKcPPc(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca %struct.stat, align 8
  %7 = alloca i32, align 4
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca [10 x i8], align 1
  %11 = alloca i8, align 1
  %12 = alloca i8, align 1
  %13 = alloca i8, align 1
  %14 = alloca i16, align 2
  %15 = alloca i64, align 8
  %16 = alloca i32, align 4
  %17 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 144, ptr %6) #6
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = call i32 @stat(ptr noundef %18, ptr noundef %6) #6
  %20 = icmp ne i32 %19, 0
  br i1 %20, label %21, label %22

21:                                               ; preds = %2
  store i32 2, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %186

22:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %23 = getelementptr inbounds %struct.stat, ptr %6, i32 0, i32 8
  %24 = load i64, ptr %23, align 8, !tbaa !9
  store i64 %24, ptr %8, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = call noalias ptr @fopen(ptr noundef %25, ptr noundef @.str)
  store ptr %26, ptr %9, align 8, !tbaa !5
  %27 = load ptr, ptr %9, align 8, !tbaa !5
  %28 = icmp ne ptr %27, null
  br i1 %28, label %30, label %29

29:                                               ; preds = %22
  store i32 2, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %185

30:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 10, ptr %10) #6
  %31 = load ptr, ptr %9, align 8, !tbaa !5
  %32 = call i64 @fread(ptr noundef %10, i64 noundef 1, i64 noundef 10, ptr noundef %31)
  %33 = icmp ne i64 %32, 10
  br i1 %33, label %34, label %37

34:                                               ; preds = %30
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  %36 = call i32 @fclose(ptr noundef %35)
  store i32 2, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %184

37:                                               ; preds = %30
  %38 = getelementptr inbounds [10 x i8], ptr %10, i64 0, i64 0
  %39 = load i8, ptr %38, align 1, !tbaa !15
  %40 = zext i8 %39 to i32
  %41 = icmp eq i32 %40, 31
  br i1 %41, label %42, label %181

42:                                               ; preds = %37
  %43 = getelementptr inbounds [10 x i8], ptr %10, i64 0, i64 1
  %44 = load i8, ptr %43, align 1, !tbaa !15
  %45 = zext i8 %44 to i32
  %46 = icmp eq i32 %45, 139
  br i1 %46, label %47, label %181

47:                                               ; preds = %42
  %48 = getelementptr inbounds [10 x i8], ptr %10, i64 0, i64 2
  %49 = load i8, ptr %48, align 1, !tbaa !15
  %50 = zext i8 %49 to i32
  %51 = icmp eq i32 %50, 8
  br i1 %51, label %52, label %181

52:                                               ; preds = %47
  %53 = getelementptr inbounds [10 x i8], ptr %10, i64 0, i64 3
  %54 = load i8, ptr %53, align 1, !tbaa !15
  %55 = zext i8 %54 to i32
  %56 = and i32 %55, 32
  %57 = icmp ne i32 %56, 0
  br i1 %57, label %58, label %64

58:                                               ; preds = %52
  %59 = load ptr, ptr @stderr, align 8, !tbaa !5
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %59, ptr noundef @.str.1, ptr noundef %60) #6
  %62 = load ptr, ptr %9, align 8, !tbaa !5
  %63 = call i32 @fclose(ptr noundef %62)
  store i32 2, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %184

64:                                               ; preds = %52
  call void @llvm.lifetime.start.p0(i64 1, ptr %11) #6
  %65 = getelementptr inbounds [10 x i8], ptr %10, i64 0, i64 3
  %66 = load i8, ptr %65, align 1, !tbaa !15
  %67 = zext i8 %66 to i32
  %68 = and i32 %67, 4
  %69 = trunc i32 %68 to i8
  store i8 %69, ptr %11, align 1, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 1, ptr %12) #6
  %70 = getelementptr inbounds [10 x i8], ptr %10, i64 0, i64 3
  %71 = load i8, ptr %70, align 1, !tbaa !15
  %72 = zext i8 %71 to i32
  %73 = and i32 %72, 8
  %74 = trunc i32 %73 to i8
  store i8 %74, ptr %12, align 1, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 1, ptr %13) #6
  %75 = getelementptr inbounds [10 x i8], ptr %10, i64 0, i64 3
  %76 = load i8, ptr %75, align 1, !tbaa !15
  %77 = zext i8 %76 to i32
  %78 = and i32 %77, 16
  %79 = trunc i32 %78 to i8
  store i8 %79, ptr %13, align 1, !tbaa !15
  %80 = load i8, ptr %12, align 1, !tbaa !15
  %81 = icmp ne i8 %80, 0
  br i1 %81, label %82, label %170

82:                                               ; preds = %64
  call void @llvm.lifetime.start.p0(i64 2, ptr %14) #6
  store i16 0, ptr %14, align 2, !tbaa !16
  %83 = load i8, ptr %11, align 1, !tbaa !15
  %84 = icmp ne i8 %83, 0
  br i1 %84, label %85, label %109

85:                                               ; preds = %82
  %86 = load ptr, ptr %9, align 8, !tbaa !5
  %87 = call i64 @fread(ptr noundef %14, i64 noundef 1, i64 noundef 2, ptr noundef %86)
  %88 = icmp ne i64 %87, 2
  br i1 %88, label %89, label %92

89:                                               ; preds = %85
  %90 = load ptr, ptr %9, align 8, !tbaa !5
  %91 = call i32 @fclose(ptr noundef %90)
  store i32 2, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %167

92:                                               ; preds = %85
  %93 = load i16, ptr %14, align 2, !tbaa !16
  %94 = zext i16 %93 to i32
  %95 = add nsw i32 12, %94
  %96 = sext i32 %95 to i64
  %97 = load i64, ptr %8, align 8, !tbaa !14
  %98 = icmp ugt i64 %96, %97
  br i1 %98, label %105, label %99

99:                                               ; preds = %92
  %100 = load ptr, ptr %9, align 8, !tbaa !5
  %101 = load i16, ptr %14, align 2, !tbaa !16
  %102 = zext i16 %101 to i64
  %103 = call i32 @fseek(ptr noundef %100, i64 noundef %102, i32 noundef 1)
  %104 = icmp ne i32 %103, 0
  br i1 %104, label %105, label %108

105:                                              ; preds = %99, %92
  %106 = load ptr, ptr %9, align 8, !tbaa !5
  %107 = call i32 @fclose(ptr noundef %106)
  store i32 2, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %167

108:                                              ; preds = %99
  br label %109

109:                                              ; preds = %108, %82
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  %110 = load i16, ptr %14, align 2, !tbaa !16
  %111 = icmp ne i16 %110, 0
  br i1 %111, label %112, label %113

112:                                              ; preds = %109
  br label %117

113:                                              ; preds = %109
  %114 = load i16, ptr %14, align 2, !tbaa !16
  %115 = zext i16 %114 to i32
  %116 = add nsw i32 12, %115
  br label %117

117:                                              ; preds = %113, %112
  %118 = phi i32 [ 10, %112 ], [ %116, %113 ]
  %119 = sext i32 %118 to i64
  store i64 %119, ptr %15, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  store i32 2048, ptr %16, align 4, !tbaa !18
  %120 = load i64, ptr %8, align 8, !tbaa !14
  %121 = load i64, ptr %15, align 8, !tbaa !14
  %122 = sub i64 %120, %121
  %123 = load i32, ptr %16, align 4, !tbaa !18
  %124 = zext i32 %123 to i64
  %125 = icmp ult i64 %122, %124
  br i1 %125, label %126, label %131

126:                                              ; preds = %117
  %127 = load i64, ptr %8, align 8, !tbaa !14
  %128 = load i64, ptr %15, align 8, !tbaa !14
  %129 = sub i64 %127, %128
  %130 = trunc i64 %129 to i32
  store i32 %130, ptr %16, align 4, !tbaa !18
  br label %131

131:                                              ; preds = %126, %117
  %132 = load i32, ptr %16, align 4, !tbaa !18
  %133 = zext i32 %132 to i64
  %134 = call noalias ptr @malloc(i64 noundef %133) #7
  %135 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %134, ptr %135, align 8, !tbaa !5
  %136 = load ptr, ptr %5, align 8, !tbaa !5
  %137 = load ptr, ptr %136, align 8, !tbaa !5
  %138 = load i32, ptr %16, align 4, !tbaa !18
  %139 = zext i32 %138 to i64
  %140 = load ptr, ptr %9, align 8, !tbaa !5
  %141 = call i64 @fread(ptr noundef %137, i64 noundef 1, i64 noundef %139, ptr noundef %140)
  %142 = load i32, ptr %16, align 4, !tbaa !18
  %143 = zext i32 %142 to i64
  %144 = icmp ne i64 %141, %143
  br i1 %144, label %145, label %148

145:                                              ; preds = %131
  %146 = load ptr, ptr %9, align 8, !tbaa !5
  %147 = call i32 @fclose(ptr noundef %146)
  store i32 2, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %166

148:                                              ; preds = %131
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #6
  %149 = load ptr, ptr %5, align 8, !tbaa !5
  %150 = load ptr, ptr %149, align 8, !tbaa !5
  %151 = load i32, ptr %16, align 4, !tbaa !18
  %152 = zext i32 %151 to i64
  %153 = call i64 @strnlen(ptr noundef %150, i64 noundef %152) #8
  store i64 %153, ptr %17, align 8, !tbaa !14
  %154 = load i64, ptr %17, align 8, !tbaa !14
  %155 = load i32, ptr %16, align 4, !tbaa !18
  %156 = zext i32 %155 to i64
  %157 = icmp uge i64 %154, %156
  br i1 %157, label %158, label %164

158:                                              ; preds = %148
  %159 = load ptr, ptr @stderr, align 8, !tbaa !5
  %160 = load ptr, ptr %4, align 8, !tbaa !5
  %161 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %159, ptr noundef @.str.2, ptr noundef %160) #6
  %162 = load ptr, ptr %9, align 8, !tbaa !5
  %163 = call i32 @fclose(ptr noundef %162)
  store i32 2, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %165

164:                                              ; preds = %148
  store i32 0, ptr %7, align 4
  br label %165

165:                                              ; preds = %164, %158
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #6
  br label %166

166:                                              ; preds = %165, %145
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  br label %167

167:                                              ; preds = %166, %105, %89
  call void @llvm.lifetime.end.p0(i64 2, ptr %14) #6
  %168 = load i32, ptr %7, align 4
  switch i32 %168, label %180 [
    i32 0, label %169
  ]

169:                                              ; preds = %167
  br label %170

170:                                              ; preds = %169, %64
  %171 = load ptr, ptr %9, align 8, !tbaa !5
  %172 = call i32 @fclose(ptr noundef %171)
  %173 = load i8, ptr %11, align 1, !tbaa !15
  %174 = icmp ne i8 %173, 0
  br i1 %174, label %178, label %175

175:                                              ; preds = %170
  %176 = load i8, ptr %13, align 1, !tbaa !15
  %177 = icmp ne i8 %176, 0
  br i1 %177, label %178, label %179

178:                                              ; preds = %175, %170
  store i32 3, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %180

179:                                              ; preds = %175
  store i32 1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %180

180:                                              ; preds = %179, %178, %167
  call void @llvm.lifetime.end.p0(i64 1, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #6
  br label %184

181:                                              ; preds = %47, %42, %37
  %182 = load ptr, ptr %9, align 8, !tbaa !5
  %183 = call i32 @fclose(ptr noundef %182)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %184

184:                                              ; preds = %181, %180, %58, %34
  call void @llvm.lifetime.end.p0(i64 10, ptr %10) #6
  br label %185

185:                                              ; preds = %184, %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  br label %186

186:                                              ; preds = %185, %21
  call void @llvm.lifetime.end.p0(i64 144, ptr %6) #6
  %187 = load i32, ptr %3, align 4
  ret i32 %187
}

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

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

declare noalias ptr @fopen(ptr noundef, ptr noundef) #3

declare i64 @fread(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #3

declare i32 @fclose(ptr noundef) #3

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

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #4

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

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

attributes #0 = { mustprogress 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 #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) }
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++ TBAA"}
!9 = !{!10, !11, i64 48}
!10 = !{!"_ZTS4stat", !11, i64 0, !11, i64 8, !11, i64 16, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !13, i64 72, !13, i64 88, !13, i64 104, !7, i64 120}
!11 = !{!"long", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"_ZTS8timespec", !11, i64 0, !11, i64 8}
!14 = !{!11, !11, i64 0}
!15 = !{!7, !7, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"short", !7, i64 0}
!18 = !{!12, !12, i64 0}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.stat = type { i64, i64, i64, i32, i32, i32, i32, i64, i64, i64, i64, %struct.timespec, %struct.timespec, %struct.timespec, [3 x i64] }
%struct.timespec = type { i64, i64 }

@.str = external hidden unnamed_addr constant [3 x i8], align 1
@stderr = external local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [24 x i8], align 1

; Function Attrs: mustprogress nofree nounwind uwtable
define dso_local noundef range(i32 0, 4) i32 @_Z6IsGzipPKcPPc(ptr noundef %0, ptr nocapture noundef %1) local_unnamed_addr #0 {
  %3 = alloca %struct.stat, align 8
  %4 = alloca [10 x i8], align 1
  %5 = alloca i16, align 2
  call void @llvm.lifetime.start.p0(i64 144, ptr nonnull %3) #6
  %6 = call i32 @stat(ptr noundef %0, ptr noundef nonnull %3) #6
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %7, label %65

7:                                                ; preds = %2
  %8 = getelementptr inbounds i8, ptr %3, i64 48
  %9 = load i64, ptr %8, align 8, !tbaa !5
  %10 = tail call noalias ptr @fopen(ptr noundef %0, ptr noundef nonnull @.str)
  %.not52 = icmp eq ptr %10, null
  br i1 %.not52, label %65, label %11

11:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 10, ptr nonnull %4) #6
  %12 = call i64 @fread(ptr noundef nonnull %4, i64 noundef 1, i64 noundef 10, ptr noundef nonnull %10)
  %.not53 = icmp eq i64 %12, 10
  br i1 %.not53, label %15, label %13

13:                                               ; preds = %11
  %14 = tail call i32 @fclose(ptr noundef nonnull %10)
  br label %64

15:                                               ; preds = %11
  %16 = load i8, ptr %4, align 1, !tbaa !12
  %17 = icmp eq i8 %16, 31
  %18 = getelementptr inbounds i8, ptr %4, i64 1
  %19 = load i8, ptr %18, align 1
  %20 = icmp eq i8 %19, -117
  %or.cond = select i1 %17, i1 %20, i1 false
  %21 = getelementptr inbounds i8, ptr %4, i64 2
  %22 = load i8, ptr %21, align 1
  %23 = icmp eq i8 %22, 8
  %or.cond7 = select i1 %or.cond, i1 %23, i1 false
  br i1 %or.cond7, label %24, label %62

24:                                               ; preds = %15
  %25 = getelementptr inbounds i8, ptr %4, i64 3
  %26 = load i8, ptr %25, align 1, !tbaa !12
  %27 = and i8 %26, 32
  %.not54 = icmp eq i8 %27, 0
  br i1 %.not54, label %32, label %28

28:                                               ; preds = %24
  %29 = load ptr, ptr @stderr, align 8, !tbaa !13
  %30 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %29, ptr noundef nonnull @.str.1, ptr noundef %0) #7
  %31 = tail call i32 @fclose(ptr noundef nonnull %10)
  br label %64

32:                                               ; preds = %24
  %33 = and i8 %26, 8
  %.not55 = icmp eq i8 %33, 0
  br i1 %.not55, label %58, label %34

34:                                               ; preds = %32
  %35 = and i8 %26, 4
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %5) #6
  store i16 0, ptr %5, align 2, !tbaa !15
  %.not56 = icmp eq i8 %35, 0
  br i1 %.not56, label %.thread, label %36

36:                                               ; preds = %34
  %37 = call i64 @fread(ptr noundef nonnull %5, i64 noundef 1, i64 noundef 2, ptr noundef nonnull %10)
  %.not57 = icmp eq i64 %37, 2
  br i1 %.not57, label %38, label %.critedge

38:                                               ; preds = %36
  %39 = load i16, ptr %5, align 2
  %.fr = freeze i16 %39
  %40 = zext i16 %.fr to i64
  %41 = add nuw nsw i64 %40, 12
  %42 = icmp ugt i64 %41, %9
  br i1 %42, label %.critedge, label %43

43:                                               ; preds = %38
  %44 = tail call i32 @fseek(ptr noundef nonnull %10, i64 noundef %40, i32 noundef 1)
  %.not58 = icmp eq i32 %44, 0
  br i1 %.not58, label %45, label %.critedge

45:                                               ; preds = %43
  %.not59 = icmp eq i16 %.fr, 0
  br i1 %.not59, label %.thread, label %46

.thread:                                          ; preds = %34, %45
  br label %46

46:                                               ; preds = %45, %.thread
  %47 = phi i64 [ -12, %.thread ], [ -10, %45 ]
  %48 = add i64 %47, %9
  %spec.select = tail call i64 @llvm.umin.i64(i64 %48, i64 2048)
  %49 = tail call noalias ptr @malloc(i64 noundef %spec.select) #8
  store ptr %49, ptr %1, align 8, !tbaa !13
  %50 = tail call i64 @fread(ptr noundef %49, i64 noundef 1, i64 noundef %spec.select, ptr noundef nonnull %10)
  %.not60 = icmp eq i64 %50, %spec.select
  br i1 %.not60, label %51, label %.critedge

51:                                               ; preds = %46
  %52 = load ptr, ptr %1, align 8, !tbaa !13
  %53 = tail call i64 @strnlen(ptr noundef %52, i64 noundef %spec.select) #9
  %.not61 = icmp ult i64 %53, %spec.select
  br i1 %.not61, label %.critedge63, label %54

54:                                               ; preds = %51
  %55 = load ptr, ptr @stderr, align 8, !tbaa !13
  %56 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %55, ptr noundef nonnull @.str.2, ptr noundef %0) #7
  %57 = tail call i32 @fclose(ptr noundef nonnull %10)
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %5) #6
  br label %64

.critedge63:                                      ; preds = %51
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %5) #6
  br label %58

58:                                               ; preds = %.critedge63, %32
  %59 = tail call i32 @fclose(ptr noundef nonnull %10)
  %60 = and i8 %26, 20
  %or.cond9.not = icmp eq i8 %60, 0
  %. = select i1 %or.cond9.not, i32 1, i32 3
  br label %64

.critedge:                                        ; preds = %46, %38, %43, %36
  %61 = tail call i32 @fclose(ptr noundef nonnull %10)
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %5) #6
  br label %64

62:                                               ; preds = %15
  %63 = tail call i32 @fclose(ptr noundef nonnull %10)
  br label %64

64:                                               ; preds = %54, %.critedge, %58, %62, %28, %13
  %.4 = phi i32 [ 2, %13 ], [ 2, %28 ], [ 0, %62 ], [ 2, %54 ], [ 2, %.critedge ], [ %., %58 ]
  call void @llvm.lifetime.end.p0(i64 10, ptr nonnull %4) #6
  br label %65

65:                                               ; preds = %64, %7, %2
  %.6 = phi i32 [ 2, %2 ], [ %.4, %64 ], [ 2, %7 ]
  call void @llvm.lifetime.end.p0(i64 144, ptr nonnull %3) #6
  ret i32 %.6
}

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

; Function Attrs: nofree nounwind
declare noundef i32 @stat(ptr nocapture noundef readonly, ptr nocapture noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i64 @fread(ptr nocapture noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #2

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

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

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strnlen(ptr nocapture noundef, i64 noundef) 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) #1

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

attributes #0 = { mustprogress nofree 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 nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #4 = { 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 #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { nounwind }
attributes #7 = { cold nounwind }
attributes #8 = { nounwind allocsize(0) }
attributes #9 = { 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, !7, i64 48}
!6 = !{!"_ZTS4stat", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !11, i64 72, !11, i64 88, !11, i64 104, !8, i64 120}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"_ZTS8timespec", !7, i64 0, !7, i64 8}
!12 = !{!8, !8, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"any pointer", !8, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"short", !8, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass