; LLVM IR from gem5/gem5 :: util/term (term)

; 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.fd_set = type { [16 x i64] }
%struct.timeval = type { i64, i64 }

@stdin = external global ptr, align 8
@stdout = external global ptr, align 8
@.str.11 = external hidden unnamed_addr constant [13 x i8], align 1
@__const.readwrite.buf2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [7 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: nounwind uwtable
define dso_local void @readwrite(i32 noundef %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca %struct.fd_set, align 8
  %4 = alloca [8192 x i8], align 16
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca %struct.timeval, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca [2 x i8], align 1
  store i32 %0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 128, ptr %3) #6
  call void @llvm.lifetime.start.p0(i64 8192, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  %16 = load ptr, ptr @stdin, align 8, !tbaa !9
  %17 = call i32 @fileno(ptr noundef %16) #6
  store i32 %17, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  %18 = load ptr, ptr @stdout, align 8, !tbaa !9
  %19 = call i32 @fileno(ptr noundef %18) #6
  store i32 %19, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 0, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %11) #6
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = icmp eq i32 %20, -1
  br i1 %21, label %22, label %23

22:                                               ; preds = %1
  store i32 1, ptr %12, align 4
  br label %208

23:                                               ; preds = %1
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = add nsw i32 %24, 1
  store i32 %25, ptr %8, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %207, %192, %85, %23
  br label %27

27:                                               ; preds = %26
  br label %28

28:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  store ptr %3, ptr %14, align 8, !tbaa !9
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %39, %28
  %30 = load i32, ptr %13, align 4, !tbaa !5
  %31 = zext i32 %30 to i64
  %32 = icmp ult i64 %31, 16
  br i1 %32, label %33, label %42

33:                                               ; preds = %29
  %34 = load ptr, ptr %14, align 8, !tbaa !9
  %35 = getelementptr inbounds %struct.fd_set, ptr %34, i32 0, i32 0
  %36 = load i32, ptr %13, align 4, !tbaa !5
  %37 = zext i32 %36 to i64
  %38 = getelementptr inbounds [16 x i64], ptr %35, i64 0, i64 %37
  store i64 0, ptr %38, align 8, !tbaa !11
  br label %39

39:                                               ; preds = %33
  %40 = load i32, ptr %13, align 4, !tbaa !5
  %41 = add i32 %40, 1
  store i32 %41, ptr %13, align 4, !tbaa !5
  br label %29, !llvm.loop !13

42:                                               ; preds = %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  br label %43

43:                                               ; preds = %42
  br label %44

44:                                               ; preds = %43
  %45 = load i32, ptr %5, align 4, !tbaa !5
  %46 = srem i32 %45, 64
  %47 = zext i32 %46 to i64
  %48 = shl i64 1, %47
  %49 = getelementptr inbounds %struct.fd_set, ptr %3, i32 0, i32 0
  %50 = load i32, ptr %5, align 4, !tbaa !5
  %51 = sdiv i32 %50, 64
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [16 x i64], ptr %49, i64 0, i64 %52
  %54 = load i64, ptr %53, align 8, !tbaa !11
  %55 = or i64 %54, %48
  store i64 %55, ptr %53, align 8, !tbaa !11
  %56 = load i32, ptr %2, align 4, !tbaa !5
  %57 = srem i32 %56, 64
  %58 = zext i32 %57 to i64
  %59 = shl i64 1, %58
  %60 = getelementptr inbounds %struct.fd_set, ptr %3, i32 0, i32 0
  %61 = load i32, ptr %2, align 4, !tbaa !5
  %62 = sdiv i32 %61, 64
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [16 x i64], ptr %60, i64 0, i64 %63
  %65 = load i64, ptr %64, align 8, !tbaa !11
  %66 = or i64 %65, %59
  store i64 %66, ptr %64, align 8, !tbaa !11
  %67 = getelementptr inbounds %struct.timeval, ptr %11, i32 0, i32 0
  store i64 1, ptr %67, align 8, !tbaa !15
  %68 = getelementptr inbounds %struct.timeval, ptr %11, i32 0, i32 1
  store i64 0, ptr %68, align 8, !tbaa !17
  %69 = load i32, ptr %8, align 4, !tbaa !5
  %70 = call i32 @select(i32 noundef %69, ptr noundef %3, ptr noundef null, ptr noundef null, ptr noundef %11)
  store i32 %70, ptr %6, align 4, !tbaa !5
  %71 = load i32, ptr %6, align 4, !tbaa !5
  %72 = icmp slt i32 %71, 0
  br i1 %72, label %73, label %76

73:                                               ; preds = %44
  %74 = load i32, ptr %2, align 4, !tbaa !5
  %75 = call i32 @close(i32 noundef %74)
  call void @perror(ptr noundef @.str.11)
  call void @exit(i32 noundef 1) #7
  unreachable

76:                                               ; preds = %44
  %77 = load i32, ptr %6, align 4, !tbaa !5
  %78 = icmp eq i32 %77, 0
  br i1 %78, label %79, label %86

79:                                               ; preds = %76
  %80 = load i32, ptr %2, align 4, !tbaa !5
  %81 = getelementptr inbounds [8192 x i8], ptr %4, i64 0, i64 0
  %82 = call i64 @read(i32 noundef %80, ptr noundef %81, i64 noundef 0)
  %83 = icmp slt i64 %82, 0
  br i1 %83, label %84, label %85

84:                                               ; preds = %79
  store i32 1, ptr %12, align 4
  br label %208

85:                                               ; preds = %79
  br label %26

86:                                               ; preds = %76
  %87 = load i32, ptr %2, align 4, !tbaa !5
  %88 = getelementptr inbounds [8192 x i8], ptr %4, i64 0, i64 0
  %89 = call i64 @read(i32 noundef %87, ptr noundef %88, i64 noundef 0)
  %90 = icmp slt i64 %89, 0
  br i1 %90, label %91, label %92

91:                                               ; preds = %86
  store i32 1, ptr %12, align 4
  br label %208

92:                                               ; preds = %86
  %93 = getelementptr inbounds %struct.fd_set, ptr %3, i32 0, i32 0
  %94 = load i32, ptr %2, align 4, !tbaa !5
  %95 = sdiv i32 %94, 64
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [16 x i64], ptr %93, i64 0, i64 %96
  %98 = load i64, ptr %97, align 8, !tbaa !11
  %99 = load i32, ptr %2, align 4, !tbaa !5
  %100 = srem i32 %99, 64
  %101 = zext i32 %100 to i64
  %102 = shl i64 1, %101
  %103 = and i64 %98, %102
  %104 = icmp ne i64 %103, 0
  br i1 %104, label %105, label %131

105:                                              ; preds = %92
  %106 = load i32, ptr %2, align 4, !tbaa !5
  %107 = getelementptr inbounds [8192 x i8], ptr %4, i64 0, i64 0
  %108 = call i64 @read(i32 noundef %106, ptr noundef %107, i64 noundef 8192)
  %109 = trunc i64 %108 to i32
  store i32 %109, ptr %6, align 4, !tbaa !5
  %110 = icmp slt i32 %109, 0
  br i1 %110, label %111, label %112

111:                                              ; preds = %105
  store i32 1, ptr %12, align 4
  br label %208

112:                                              ; preds = %105
  %113 = load i32, ptr %6, align 4, !tbaa !5
  %114 = icmp eq i32 %113, 0
  br i1 %114, label %115, label %118

115:                                              ; preds = %112
  %116 = load i32, ptr %2, align 4, !tbaa !5
  %117 = call i32 @shutdown(i32 noundef %116, i32 noundef 0) #6
  store i32 1, ptr %12, align 4
  br label %208

118:                                              ; preds = %112
  %119 = load i32, ptr %9, align 4, !tbaa !5
  %120 = getelementptr inbounds [8192 x i8], ptr %4, i64 0, i64 0
  %121 = load i32, ptr %6, align 4, !tbaa !5
  %122 = sext i32 %121 to i64
  %123 = call i64 @atomicio(ptr noundef @write, i32 noundef %119, ptr noundef %120, i64 noundef %122)
  %124 = trunc i64 %123 to i32
  store i32 %124, ptr %7, align 4, !tbaa !5
  %125 = load i32, ptr %6, align 4, !tbaa !5
  %126 = icmp ne i32 %124, %125
  br i1 %126, label %127, label %128

127:                                              ; preds = %118
  store i32 1, ptr %12, align 4
  br label %208

128:                                              ; preds = %118
  br label %129

129:                                              ; preds = %128
  br label %130

130:                                              ; preds = %129
  br label %131

131:                                              ; preds = %130, %92
  %132 = getelementptr inbounds %struct.fd_set, ptr %3, i32 0, i32 0
  %133 = load i32, ptr %5, align 4, !tbaa !5
  %134 = sdiv i32 %133, 64
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds [16 x i64], ptr %132, i64 0, i64 %135
  %137 = load i64, ptr %136, align 8, !tbaa !11
  %138 = load i32, ptr %5, align 4, !tbaa !5
  %139 = srem i32 %138, 64
  %140 = zext i32 %139 to i64
  %141 = shl i64 1, %140
  %142 = and i64 %137, %141
  %143 = icmp ne i64 %142, 0
  br i1 %143, label %144, label %207

144:                                              ; preds = %131
  %145 = load i32, ptr %5, align 4, !tbaa !5
  %146 = getelementptr inbounds [8192 x i8], ptr %4, i64 0, i64 0
  %147 = call i64 @read(i32 noundef %145, ptr noundef %146, i64 noundef 8192)
  %148 = trunc i64 %147 to i32
  store i32 %148, ptr %6, align 4, !tbaa !5
  %149 = icmp slt i32 %148, 0
  br i1 %149, label %150, label %151

150:                                              ; preds = %144
  store i32 1, ptr %12, align 4
  br label %208

151:                                              ; preds = %144
  %152 = load i32, ptr %6, align 4, !tbaa !5
  %153 = icmp eq i32 %152, 0
  br i1 %153, label %154, label %157

154:                                              ; preds = %151
  %155 = load i32, ptr %2, align 4, !tbaa !5
  %156 = call i32 @shutdown(i32 noundef %155, i32 noundef 1) #6
  br label %205

157:                                              ; preds = %151
  %158 = load i32, ptr %10, align 4, !tbaa !5
  %159 = icmp ne i32 %158, 0
  br i1 %159, label %160, label %184

160:                                              ; preds = %157
  call void @llvm.lifetime.start.p0(i64 2, ptr %15) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %15, ptr align 1 @__const.readwrite.buf2, i64 2, i1 false)
  %161 = getelementptr inbounds [8192 x i8], ptr %4, i64 0, i64 0
  %162 = load i8, ptr %161, align 16, !tbaa !18
  %163 = sext i8 %162 to i32
  %164 = icmp eq i32 %163, 46
  br i1 %164, label %165, label %167

165:                                              ; preds = %160
  %166 = call i32 (ptr, ...) @printf(ptr noundef @.str.12)
  store i32 1, ptr %12, align 4
  br label %181

167:                                              ; preds = %160
  store i32 0, ptr %10, align 4, !tbaa !5
  %168 = getelementptr inbounds [8192 x i8], ptr %4, i64 0, i64 0
  %169 = load i8, ptr %168, align 16, !tbaa !18
  %170 = sext i8 %169 to i32
  %171 = icmp ne i32 %170, 126
  br i1 %171, label %172, label %180

172:                                              ; preds = %167
  %173 = load i32, ptr %2, align 4, !tbaa !5
  %174 = getelementptr inbounds [2 x i8], ptr %15, i64 0, i64 0
  %175 = call i64 @atomicio(ptr noundef @write, i32 noundef %173, ptr noundef %174, i64 noundef 1)
  %176 = trunc i64 %175 to i32
  store i32 %176, ptr %7, align 4, !tbaa !5
  %177 = load i32, ptr %6, align 4, !tbaa !5
  %178 = icmp ne i32 %176, %177
  br i1 %178, label %179, label %180

179:                                              ; preds = %172
  store i32 1, ptr %12, align 4
  br label %181

180:                                              ; preds = %172, %167
  store i32 0, ptr %12, align 4
  br label %181

181:                                              ; preds = %180, %179, %165
  call void @llvm.lifetime.end.p0(i64 2, ptr %15) #6
  %182 = load i32, ptr %12, align 4
  switch i32 %182, label %208 [
    i32 0, label %183
  ]

183:                                              ; preds = %181
  br label %194

184:                                              ; preds = %157
  %185 = getelementptr inbounds [8192 x i8], ptr %4, i64 0, i64 0
  %186 = load i8, ptr %185, align 16, !tbaa !18
  %187 = sext i8 %186 to i32
  %188 = icmp eq i32 %187, 126
  %189 = zext i1 %188 to i32
  store i32 %189, ptr %10, align 4, !tbaa !5
  %190 = load i32, ptr %10, align 4, !tbaa !5
  %191 = icmp ne i32 %190, 0
  br i1 %191, label %192, label %193

192:                                              ; preds = %184
  br label %26

193:                                              ; preds = %184
  br label %194

194:                                              ; preds = %193, %183
  %195 = load i32, ptr %2, align 4, !tbaa !5
  %196 = getelementptr inbounds [8192 x i8], ptr %4, i64 0, i64 0
  %197 = load i32, ptr %6, align 4, !tbaa !5
  %198 = sext i32 %197 to i64
  %199 = call i64 @atomicio(ptr noundef @write, i32 noundef %195, ptr noundef %196, i64 noundef %198)
  %200 = trunc i64 %199 to i32
  store i32 %200, ptr %7, align 4, !tbaa !5
  %201 = load i32, ptr %6, align 4, !tbaa !5
  %202 = icmp ne i32 %200, %201
  br i1 %202, label %203, label %204

203:                                              ; preds = %194
  store i32 1, ptr %12, align 4
  br label %208

204:                                              ; preds = %194
  br label %205

205:                                              ; preds = %204, %154
  br label %206

206:                                              ; preds = %205
  br label %207

207:                                              ; preds = %206, %131
  br label %26

208:                                              ; preds = %203, %181, %150, %127, %115, %111, %91, %84, %22
  call void @llvm.lifetime.end.p0(i64 16, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 8192, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 128, ptr %3) #6
  ret void
}

declare i32 @close(i32 noundef) #2

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #3

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

declare void @perror(ptr noundef) #2

; Function Attrs: nounwind
declare i32 @fileno(ptr noundef) #4

declare i32 @select(i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #2

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

; Function Attrs: nounwind
declare i32 @shutdown(i32 noundef, i32 noundef) #4

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

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

; 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) #5

declare i32 @printf(ptr noundef, ...) #2

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 = { "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 = { 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 #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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { nounwind }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !12, i64 0}
!16 = !{!"timeval", !12, i64 0, !12, i64 8}
!17 = !{!16, !12, i64 8}
!18 = !{!7, !7, 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.fd_set = type { [16 x i64] }
%struct.timeval = type { i64, i64 }

@stdin = external local_unnamed_addr global ptr, align 8
@stdout = external local_unnamed_addr global ptr, align 8
@.str.11 = external hidden unnamed_addr constant [13 x i8], align 1
@__const.readwrite.buf2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [7 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local void @readwrite(i32 noundef %0) local_unnamed_addr #1 {
  %2 = alloca %struct.fd_set, align 8
  %3 = alloca [8192 x i8], align 16
  %4 = alloca %struct.timeval, align 8
  %5 = alloca [2 x i8], align 2
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %2) #8
  call void @llvm.lifetime.start.p0(i64 8192, ptr nonnull %3) #8
  %6 = load ptr, ptr @stdin, align 8, !tbaa !5
  %7 = tail call i32 @fileno(ptr noundef %6) #8
  %8 = load ptr, ptr @stdout, align 8, !tbaa !5
  %9 = tail call i32 @fileno(ptr noundef %8) #8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #8
  %10 = icmp eq i32 %0, -1
  br i1 %10, label %.loopexit, label %11

11:                                               ; preds = %1
  %12 = add nuw nsw i32 %0, 1
  %13 = srem i32 %7, 64
  %14 = zext nneg i32 %13 to i64
  %15 = shl nuw i64 1, %14
  %16 = sdiv i32 %7, 64
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [16 x i64], ptr %2, i64 0, i64 %17
  %19 = srem i32 %0, 64
  %20 = zext nneg i32 %19 to i64
  %21 = shl nuw i64 1, %20
  %22 = sdiv i32 %0, 64
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [16 x i64], ptr %2, i64 0, i64 %23
  %25 = getelementptr inbounds i8, ptr %4, i64 8
  %26 = load i16, ptr @__const.readwrite.buf2, align 1
  br label %.outer.outer

.outer.outer:                                     ; preds = %.outer.outer.backedge, %11
  %.037.ph.ph = phi i32 [ 0, %11 ], [ %.037.ph.ph.be, %.outer.outer.backedge ]
  br label %.outer

.outer:                                           ; preds = %.outer.backedge, %.outer.outer
  br label %27

27:                                               ; preds = %.outer, %40
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(128) %2, i8 0, i64 128, i1 false), !tbaa !9
  %28 = load i64, ptr %18, align 8, !tbaa !9
  %29 = or i64 %28, %15
  store i64 %29, ptr %18, align 8, !tbaa !9
  %30 = load i64, ptr %24, align 8, !tbaa !9
  %31 = or i64 %30, %21
  store i64 %31, ptr %24, align 8, !tbaa !9
  store i64 1, ptr %4, align 8, !tbaa !11
  store i64 0, ptr %25, align 8, !tbaa !13
  %32 = call i32 @select(i32 noundef %12, ptr noundef nonnull %2, ptr noundef null, ptr noundef null, ptr noundef nonnull %4) #8
  %33 = icmp slt i32 %32, 0
  br i1 %33, label %34, label %36

34:                                               ; preds = %27
  %35 = call i32 @close(i32 noundef %0) #8
  call void @perror(ptr noundef nonnull @.str.11) #9
  call void @exit(i32 noundef 1) #10
  unreachable

36:                                               ; preds = %27
  %37 = icmp eq i32 %32, 0
  %38 = call i64 @read(i32 noundef %0, ptr noundef nonnull %3, i64 noundef 0) #8
  %39 = icmp slt i64 %38, 0
  br i1 %37, label %40, label %41

40:                                               ; preds = %36
  br i1 %39, label %.loopexit, label %27

41:                                               ; preds = %36
  br i1 %39, label %.loopexit, label %42

42:                                               ; preds = %41
  %43 = load i64, ptr %24, align 8, !tbaa !9
  %44 = and i64 %43, %21
  %.not = icmp eq i64 %44, 0
  br i1 %.not, label %57, label %45

45:                                               ; preds = %42
  %46 = call i64 @read(i32 noundef %0, ptr noundef nonnull %3, i64 noundef 8192) #8
  %47 = trunc i64 %46 to i32
  %48 = icmp slt i32 %47, 0
  br i1 %48, label %.loopexit, label %49

49:                                               ; preds = %45
  %50 = icmp eq i32 %47, 0
  br i1 %50, label %51, label %53

51:                                               ; preds = %49
  %52 = call i32 @shutdown(i32 noundef %0, i32 noundef 0) #8
  br label %.loopexit

53:                                               ; preds = %49
  %54 = and i64 %46, 2147483647
  %55 = call i64 @atomicio(ptr noundef nonnull @write, i32 noundef %9, ptr noundef nonnull %3, i64 noundef %54)
  %56 = trunc i64 %55 to i32
  %.not44 = icmp eq i32 %56, %47
  br i1 %.not44, label %57, label %.loopexit

57:                                               ; preds = %53, %42
  %58 = load i64, ptr %18, align 8, !tbaa !9
  %59 = and i64 %58, %15
  %.not45 = icmp eq i64 %59, 0
  br i1 %.not45, label %.outer.backedge, label %60

.outer.backedge:                                  ; preds = %57, %66
  br label %.outer

60:                                               ; preds = %57
  %61 = call i64 @read(i32 noundef %7, ptr noundef nonnull %3, i64 noundef 8192) #8
  %62 = trunc i64 %61 to i32
  %63 = icmp slt i32 %62, 0
  br i1 %63, label %.loopexit, label %64

64:                                               ; preds = %60
  %65 = icmp eq i32 %62, 0
  br i1 %65, label %66, label %68

66:                                               ; preds = %64
  %67 = call i32 @shutdown(i32 noundef %0, i32 noundef 1) #8
  br label %.outer.backedge

68:                                               ; preds = %64
  %.not46 = icmp eq i32 %.037.ph.ph, 0
  br i1 %.not46, label %77, label %69

69:                                               ; preds = %68
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %5) #8
  store i16 %26, ptr %5, align 2
  %70 = load i8, ptr %3, align 16, !tbaa !14
  switch i8 %70, label %73 [
    i8 46, label %71
    i8 126, label %76
  ]

71:                                               ; preds = %69
  %72 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12)
  br label %.thread

73:                                               ; preds = %69
  %74 = call i64 @atomicio(ptr noundef nonnull @write, i32 noundef %0, ptr noundef nonnull %5, i64 noundef 1)
  %75 = trunc i64 %74 to i32
  %.not48 = icmp eq i32 %75, %62
  br i1 %.not48, label %76, label %.thread

.thread:                                          ; preds = %73, %71
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %5) #8
  br label %.loopexit

76:                                               ; preds = %73, %69
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %5) #8
  br label %80

77:                                               ; preds = %68
  %78 = load i8, ptr %3, align 16, !tbaa !14
  %79 = icmp eq i8 %78, 126
  br i1 %79, label %.outer.outer.backedge, label %80

.outer.outer.backedge:                            ; preds = %77, %80
  %.037.ph.ph.be = phi i32 [ 0, %80 ], [ 1, %77 ]
  br label %.outer.outer

80:                                               ; preds = %76, %77
  %81 = and i64 %61, 2147483647
  %82 = call i64 @atomicio(ptr noundef nonnull @write, i32 noundef %0, ptr noundef nonnull %3, i64 noundef %81)
  %83 = trunc i64 %82 to i32
  %.not49 = icmp eq i32 %83, %62
  br i1 %.not49, label %.outer.outer.backedge, label %.loopexit

.loopexit:                                        ; preds = %60, %53, %45, %41, %80, %40, %.thread, %1, %51
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #8
  call void @llvm.lifetime.end.p0(i64 8192, ptr nonnull %3) #8
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %2) #8
  ret void
}

declare i32 @close(i32 noundef) local_unnamed_addr #2

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #3

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

; Function Attrs: nofree nounwind
declare void @perror(ptr nocapture noundef readonly) local_unnamed_addr #4

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

declare i32 @select(i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind
declare i32 @shutdown(i32 noundef, i32 noundef) local_unnamed_addr #6

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

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #7

attributes #0 = { mustprogress 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 = { "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 = { 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 #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 = { 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 #7 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #8 = { nounwind }
attributes #9 = { cold }
attributes #10 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"timeval", !10, i64 0, !10, i64 8}
!13 = !{!12, !10, i64 8}
!14 = !{!7, !7, i64 0}


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