; LLVM IR from AngelPn/DBMS-Simulator :: src (SHT)

; 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.SHT_info = type { i32, i32, ptr, ptr, i32, i64, i32 }

@.str = external hidden unnamed_addr constant [20 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [20 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @SHT_CreateSecondaryIndex(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4) #0 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca %struct.SHT_info, align 8
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca ptr, align 8
  %19 = alloca ptr, align 8
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  %24 = alloca i32, align 4
  %25 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store i32 %2, ptr %9, align 4, !tbaa !9
  store i32 %3, ptr %10, align 4, !tbaa !9
  store ptr %4, ptr %11, align 8, !tbaa !5
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = call i32 @BF_CreateFile(ptr noundef %26)
  %28 = icmp slt i32 %27, 0
  br i1 %28, label %29, label %30

29:                                               ; preds = %5
  call void @BF_PrintError(ptr noundef @.str)
  store i32 -1, ptr %6, align 4
  br label %188

30:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = call i32 @BF_OpenFile(ptr noundef %31)
  store i32 %32, ptr %12, align 4, !tbaa !9
  %33 = icmp slt i32 %32, 0
  br i1 %33, label %34, label %35

34:                                               ; preds = %30
  call void @BF_PrintError(ptr noundef @.str.1)
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %187

35:                                               ; preds = %30
  %36 = load i32, ptr %12, align 4, !tbaa !9
  %37 = call i32 @BF_AllocateBlock(i32 noundef %36)
  %38 = icmp slt i32 %37, 0
  br i1 %38, label %39, label %40

39:                                               ; preds = %35
  call void @BF_PrintError(ptr noundef @.str.2)
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %187

40:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  store ptr null, ptr %14, align 8, !tbaa !5
  %41 = load i32, ptr %12, align 4, !tbaa !9
  %42 = load i32, ptr %12, align 4, !tbaa !9
  %43 = call i32 @BF_GetBlockCounter(i32 noundef %42)
  %44 = sub nsw i32 %43, 1
  %45 = call i32 @BF_ReadBlock(i32 noundef %41, i32 noundef %44, ptr noundef %14)
  %46 = icmp slt i32 %45, 0
  br i1 %46, label %47, label %48

47:                                               ; preds = %40
  call void @BF_PrintError(ptr noundef @.str.3)
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %186

48:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 48, ptr %15) #7
  %49 = getelementptr inbounds %struct.SHT_info, ptr %15, i32 0, i32 0
  store i32 2, ptr %49, align 8, !tbaa !11
  %50 = getelementptr inbounds %struct.SHT_info, ptr %15, i32 0, i32 1
  %51 = load i32, ptr %12, align 4, !tbaa !9
  store i32 %51, ptr %50, align 4, !tbaa !14
  %52 = getelementptr inbounds %struct.SHT_info, ptr %15, i32 0, i32 2
  %53 = load ptr, ptr %11, align 8, !tbaa !5
  %54 = call i64 @strlen(ptr noundef %53) #8
  %55 = add i64 %54, 1
  %56 = mul i64 1, %55
  %57 = call noalias ptr @malloc(i64 noundef %56) #9
  store ptr %57, ptr %52, align 8, !tbaa !15
  %58 = getelementptr inbounds %struct.SHT_info, ptr %15, i32 0, i32 3
  %59 = load ptr, ptr %8, align 8, !tbaa !5
  %60 = call i64 @strlen(ptr noundef %59) #8
  %61 = add i64 %60, 1
  %62 = mul i64 1, %61
  %63 = call noalias ptr @malloc(i64 noundef %62) #9
  store ptr %63, ptr %58, align 8, !tbaa !16
  %64 = getelementptr inbounds %struct.SHT_info, ptr %15, i32 0, i32 4
  %65 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %65, ptr %64, align 8, !tbaa !17
  %66 = getelementptr inbounds %struct.SHT_info, ptr %15, i32 0, i32 5
  %67 = load i32, ptr %10, align 4, !tbaa !9
  %68 = sext i32 %67 to i64
  store i64 %68, ptr %66, align 8, !tbaa !18
  %69 = getelementptr inbounds %struct.SHT_info, ptr %15, i32 0, i32 6
  %70 = load i32, ptr %12, align 4, !tbaa !9
  %71 = call i32 @BF_GetBlockCounter(i32 noundef %70)
  %72 = sub nsw i32 %71, 1
  store i32 %72, ptr %69, align 8, !tbaa !19
  %73 = getelementptr inbounds %struct.SHT_info, ptr %15, i32 0, i32 2
  %74 = load ptr, ptr %73, align 8, !tbaa !15
  %75 = load ptr, ptr %11, align 8, !tbaa !5
  %76 = call ptr @strcpy(ptr noundef %74, ptr noundef %75) #7
  %77 = getelementptr inbounds %struct.SHT_info, ptr %15, i32 0, i32 3
  %78 = load ptr, ptr %77, align 8, !tbaa !16
  %79 = load ptr, ptr %8, align 8, !tbaa !5
  %80 = call ptr @strcpy(ptr noundef %78, ptr noundef %79) #7
  %81 = load ptr, ptr %14, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %81, ptr align 8 %15, i64 48, i1 false)
  %82 = load i32, ptr %12, align 4, !tbaa !9
  %83 = load i32, ptr %12, align 4, !tbaa !9
  %84 = call i32 @BF_GetBlockCounter(i32 noundef %83)
  %85 = sub nsw i32 %84, 1
  %86 = call i32 @BF_WriteBlock(i32 noundef %82, i32 noundef %85)
  %87 = icmp slt i32 %86, 0
  br i1 %87, label %88, label %89

88:                                               ; preds = %48
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %185

89:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #7
  %90 = load i32, ptr %10, align 4, !tbaa !9
  %91 = sext i32 %90 to i64
  %92 = mul i64 %91, 4
  %93 = udiv i64 %92, 508
  %94 = trunc i64 %93 to i32
  store i32 %94, ptr %16, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #7
  %95 = load i32, ptr %10, align 4, !tbaa !9
  %96 = sext i32 %95 to i64
  %97 = mul i64 %96, 4
  %98 = urem i64 %97, 508
  %99 = trunc i64 %98 to i32
  store i32 %99, ptr %17, align 4, !tbaa !9
  %100 = load i32, ptr %17, align 4, !tbaa !9
  %101 = icmp sgt i32 %100, 0
  br i1 %101, label %102, label %105

102:                                              ; preds = %89
  %103 = load i32, ptr %16, align 4, !tbaa !9
  %104 = add nsw i32 %103, 1
  store i32 %104, ptr %16, align 4, !tbaa !9
  br label %105

105:                                              ; preds = %102, %89
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #7
  store ptr null, ptr %18, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #7
  %106 = load ptr, ptr %14, align 8, !tbaa !5
  store ptr %106, ptr %19, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #7
  %107 = load i32, ptr %12, align 4, !tbaa !9
  %108 = call i32 @BF_GetBlockCounter(i32 noundef %107)
  %109 = sub nsw i32 %108, 1
  store i32 %109, ptr %21, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #7
  store i32 1, ptr %22, align 4, !tbaa !9
  br label %110

110:                                              ; preds = %178, %105
  %111 = load i32, ptr %22, align 4, !tbaa !9
  %112 = load i32, ptr %16, align 4, !tbaa !9
  %113 = icmp sle i32 %111, %112
  br i1 %113, label %115, label %114

114:                                              ; preds = %110
  store i32 2, ptr %13, align 4
  br label %181

115:                                              ; preds = %110
  %116 = load i32, ptr %12, align 4, !tbaa !9
  %117 = call i32 @BF_AllocateBlock(i32 noundef %116)
  %118 = icmp slt i32 %117, 0
  br i1 %118, label %119, label %120

119:                                              ; preds = %115
  call void @BF_PrintError(ptr noundef @.str.2)
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %181

120:                                              ; preds = %115
  %121 = load i32, ptr %12, align 4, !tbaa !9
  %122 = call i32 @BF_GetBlockCounter(i32 noundef %121)
  %123 = sub nsw i32 %122, 1
  store i32 %123, ptr %20, align 4, !tbaa !9
  %124 = load i32, ptr %12, align 4, !tbaa !9
  %125 = load i32, ptr %20, align 4, !tbaa !9
  %126 = call i32 @BF_ReadBlock(i32 noundef %124, i32 noundef %125, ptr noundef %18)
  %127 = icmp slt i32 %126, 0
  br i1 %127, label %128, label %129

128:                                              ; preds = %120
  call void @BF_PrintError(ptr noundef @.str.3)
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %181

129:                                              ; preds = %120
  %130 = load ptr, ptr %19, align 8, !tbaa !5
  %131 = getelementptr inbounds i8, ptr %130, i64 512
  %132 = getelementptr inbounds i8, ptr %131, i64 -4
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %132, ptr align 4 %20, i64 4, i1 false)
  %133 = load i32, ptr %12, align 4, !tbaa !9
  %134 = load i32, ptr %21, align 4, !tbaa !9
  %135 = call i32 @BF_WriteBlock(i32 noundef %133, i32 noundef %134)
  %136 = icmp slt i32 %135, 0
  br i1 %136, label %137, label %138

137:                                              ; preds = %129
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %181

138:                                              ; preds = %129
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #7
  %139 = load i32, ptr %22, align 4, !tbaa !9
  %140 = load i32, ptr %16, align 4, !tbaa !9
  %141 = icmp eq i32 %139, %140
  br i1 %141, label %142, label %150

142:                                              ; preds = %138
  %143 = load i32, ptr %17, align 4, !tbaa !9
  %144 = icmp sgt i32 %143, 0
  br i1 %144, label %145, label %150

145:                                              ; preds = %142
  %146 = load i32, ptr %17, align 4, !tbaa !9
  %147 = sext i32 %146 to i64
  %148 = udiv i64 %147, 4
  %149 = trunc i64 %148 to i32
  store i32 %149, ptr %23, align 4, !tbaa !9
  br label %151

150:                                              ; preds = %142, %138
  store i32 127, ptr %23, align 4, !tbaa !9
  br label %151

151:                                              ; preds = %150, %145
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #7
  store i32 -1, ptr %24, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #7
  store i32 0, ptr %25, align 4, !tbaa !9
  br label %152

152:                                              ; preds = %163, %151
  %153 = load i32, ptr %25, align 4, !tbaa !9
  %154 = load i32, ptr %23, align 4, !tbaa !9
  %155 = icmp slt i32 %153, %154
  br i1 %155, label %157, label %156

156:                                              ; preds = %152
  store i32 5, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #7
  br label %166

157:                                              ; preds = %152
  %158 = load ptr, ptr %18, align 8, !tbaa !5
  %159 = load i32, ptr %25, align 4, !tbaa !9
  %160 = sext i32 %159 to i64
  %161 = mul i64 %160, 4
  %162 = getelementptr inbounds i8, ptr %158, i64 %161
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %162, ptr align 4 %24, i64 4, i1 false)
  br label %163

163:                                              ; preds = %157
  %164 = load i32, ptr %25, align 4, !tbaa !9
  %165 = add nsw i32 %164, 1
  store i32 %165, ptr %25, align 4, !tbaa !9
  br label %152, !llvm.loop !20

166:                                              ; preds = %156
  %167 = load i32, ptr %12, align 4, !tbaa !9
  %168 = load i32, ptr %20, align 4, !tbaa !9
  %169 = call i32 @BF_WriteBlock(i32 noundef %167, i32 noundef %168)
  %170 = icmp slt i32 %169, 0
  br i1 %170, label %171, label %172

171:                                              ; preds = %166
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %175

172:                                              ; preds = %166
  %173 = load ptr, ptr %18, align 8, !tbaa !5
  store ptr %173, ptr %19, align 8, !tbaa !5
  %174 = load i32, ptr %20, align 4, !tbaa !9
  store i32 %174, ptr %21, align 4, !tbaa !9
  store i32 0, ptr %13, align 4
  br label %175

175:                                              ; preds = %172, %171
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #7
  %176 = load i32, ptr %13, align 4
  switch i32 %176, label %181 [
    i32 0, label %177
  ]

177:                                              ; preds = %175
  br label %178

178:                                              ; preds = %177
  %179 = load i32, ptr %22, align 4, !tbaa !9
  %180 = add nsw i32 %179, 1
  store i32 %180, ptr %22, align 4, !tbaa !9
  br label %110, !llvm.loop !22

181:                                              ; preds = %175, %137, %128, %119, %114
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #7
  %182 = load i32, ptr %13, align 4
  switch i32 %182, label %184 [
    i32 2, label %183
  ]

183:                                              ; preds = %181
  store i32 0, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %184

184:                                              ; preds = %183, %181
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #7
  br label %185

185:                                              ; preds = %184, %88
  call void @llvm.lifetime.end.p0(i64 48, ptr %15) #7
  br label %186

186:                                              ; preds = %185, %47
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  br label %187

187:                                              ; preds = %186, %39, %34
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  br label %188

188:                                              ; preds = %187, %29
  %189 = load i32, ptr %6, align 4
  ret i32 %189
}

declare i32 @BF_CreateFile(ptr noundef) #1

declare void @BF_PrintError(ptr noundef) #1

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

declare i32 @BF_OpenFile(ptr noundef) #1

declare i32 @BF_AllocateBlock(i32 noundef) #1

declare i32 @BF_ReadBlock(i32 noundef, i32 noundef, ptr noundef) #1

declare i32 @BF_GetBlockCounter(i32 noundef) #1

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

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

; Function Attrs: nounwind
declare ptr @strcpy(ptr noundef, ptr noundef) #5

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

declare i32 @BF_WriteBlock(i32 noundef, i32 noundef) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { "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) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind willreturn memory(read) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nounwind "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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #7 = { nounwind }
attributes #8 = { nounwind willreturn memory(read) }
attributes #9 = { nounwind allocsize(0) }

!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 0}
!12 = !{!"SHT_info", !10, i64 0, !10, i64 4, !6, i64 8, !6, i64 16, !10, i64 24, !13, i64 32, !10, i64 40}
!13 = !{!"long", !7, i64 0}
!14 = !{!12, !10, i64 4}
!15 = !{!12, !6, i64 8}
!16 = !{!12, !6, i64 16}
!17 = !{!12, !10, i64 24}
!18 = !{!12, !13, i64 32}
!19 = !{!12, !10, i64 40}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !21}


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

@.str = external hidden unnamed_addr constant [20 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [20 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @SHT_CreateSecondaryIndex(ptr noundef %0, ptr nocapture noundef readonly %1, i32 noundef %2, i32 noundef %3, ptr nocapture noundef readonly %4) local_unnamed_addr #0 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = tail call i32 @BF_CreateFile(ptr noundef %0) #7
  %9 = icmp slt i32 %8, 0
  br i1 %9, label %10, label %11

10:                                               ; preds = %5
  tail call void @BF_PrintError(ptr noundef nonnull @.str) #7
  br label %117

11:                                               ; preds = %5
  %12 = tail call i32 @BF_OpenFile(ptr noundef %0) #7
  %13 = icmp slt i32 %12, 0
  br i1 %13, label %14, label %15

14:                                               ; preds = %11
  tail call void @BF_PrintError(ptr noundef nonnull @.str.1) #7
  br label %117

15:                                               ; preds = %11
  %16 = tail call i32 @BF_AllocateBlock(i32 noundef %12) #7
  %17 = icmp slt i32 %16, 0
  br i1 %17, label %18, label %19

18:                                               ; preds = %15
  tail call void @BF_PrintError(ptr noundef nonnull @.str.2) #7
  br label %117

19:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #7
  store ptr null, ptr %6, align 8, !tbaa !5
  %20 = tail call i32 @BF_GetBlockCounter(i32 noundef %12) #7
  %21 = add nsw i32 %20, -1
  %22 = call i32 @BF_ReadBlock(i32 noundef %12, i32 noundef %21, ptr noundef nonnull %6) #7
  %23 = icmp slt i32 %22, 0
  br i1 %23, label %24, label %25

24:                                               ; preds = %19
  call void @BF_PrintError(ptr noundef nonnull @.str.3) #7
  br label %116

25:                                               ; preds = %19
  %26 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %4) #8
  %27 = add i64 %26, 1
  %28 = call noalias ptr @malloc(i64 noundef %27) #9
  %29 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %1) #8
  %30 = add i64 %29, 1
  %31 = call noalias ptr @malloc(i64 noundef %30) #9
  %32 = sext i32 %3 to i64
  %33 = call i32 @BF_GetBlockCounter(i32 noundef %12) #7
  %34 = add nsw i32 %33, -1
  %35 = call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %28, ptr noundef nonnull dereferenceable(1) %4) #7
  %36 = call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %31, ptr noundef nonnull dereferenceable(1) %1) #7
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  store i32 2, ptr %37, align 1
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %37, i64 4
  store i32 %12, ptr %.sroa.4.0..sroa_idx, align 1
  %.sroa.5.0..sroa_idx = getelementptr inbounds i8, ptr %37, i64 8
  store ptr %28, ptr %.sroa.5.0..sroa_idx, align 1
  %.sroa.7.0..sroa_idx = getelementptr inbounds i8, ptr %37, i64 16
  store ptr %31, ptr %.sroa.7.0..sroa_idx, align 1
  %.sroa.9.0..sroa_idx = getelementptr inbounds i8, ptr %37, i64 24
  store i32 %2, ptr %.sroa.9.0..sroa_idx, align 1
  %.sroa.1020.0..sroa_idx = getelementptr inbounds i8, ptr %37, i64 32
  store i64 %32, ptr %.sroa.1020.0..sroa_idx, align 1
  %.sroa.11.0..sroa_idx = getelementptr inbounds i8, ptr %37, i64 40
  store i32 %34, ptr %.sroa.11.0..sroa_idx, align 1
  %38 = call i32 @BF_GetBlockCounter(i32 noundef %12) #7
  %39 = add nsw i32 %38, -1
  %40 = call i32 @BF_WriteBlock(i32 noundef %12, i32 noundef %39) #7
  %41 = icmp slt i32 %40, 0
  br i1 %41, label %116, label %42

42:                                               ; preds = %25
  %43 = shl nsw i64 %32, 2
  %44 = udiv i64 %43, 508
  %45 = trunc i64 %44 to i32
  %46 = urem i64 %43, 508
  %47 = icmp ne i64 %46, 0
  %48 = zext i1 %47 to i32
  %spec.select = add i32 %48, %45
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #7
  store ptr null, ptr %7, align 8, !tbaa !5
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = call i32 @BF_GetBlockCounter(i32 noundef %12) #7
  %.not64 = icmp sgt i32 %spec.select, 0
  br i1 %.not64, label %.lr.ph70, label %.loopexit

.lr.ph70:                                         ; preds = %42
  %51 = add nsw i32 %50, -1
  br i1 %47, label %.lr.ph70.split.preheader, label %.lr.ph70.split.us

.lr.ph70.split.preheader:                         ; preds = %.lr.ph70
  %52 = lshr exact i64 %46, 2
  %53 = trunc nuw nsw i64 %52 to i32
  %54 = call i32 @llvm.umax.i32(i32 %53, i32 1)
  br label %.lr.ph70.split

.lr.ph70.split.us:                                ; preds = %.lr.ph70, %66
  %.not68.us = phi i1 [ %.not.us, %66 ], [ true, %.lr.ph70 ]
  %.04967.us = phi i32 [ %68, %66 ], [ 1, %.lr.ph70 ]
  %.05066.us = phi i32 [ %59, %66 ], [ %51, %.lr.ph70 ]
  %.05465.us = phi ptr [ %67, %66 ], [ %49, %.lr.ph70 ]
  %55 = call i32 @BF_AllocateBlock(i32 noundef %12) #7
  %56 = icmp slt i32 %55, 0
  br i1 %56, label %.loopexit.sink.split, label %57

57:                                               ; preds = %.lr.ph70.split.us
  %58 = call i32 @BF_GetBlockCounter(i32 noundef %12) #7
  %59 = add nsw i32 %58, -1
  %60 = call i32 @BF_ReadBlock(i32 noundef %12, i32 noundef %59, ptr noundef nonnull %7) #7
  %61 = icmp slt i32 %60, 0
  br i1 %61, label %.loopexit.sink.split, label %62

62:                                               ; preds = %57
  %63 = getelementptr inbounds i8, ptr %.05465.us, i64 508
  store i32 %59, ptr %63, align 1
  %64 = call i32 @BF_WriteBlock(i32 noundef %12, i32 noundef %.05066.us) #7
  %65 = icmp slt i32 %64, 0
  br i1 %65, label %.loopexit, label %.lr.ph.us

66:                                               ; preds = %._crit_edge.us
  %67 = load ptr, ptr %7, align 8
  %68 = add nuw i32 %.04967.us, 1
  %.not.us = icmp slt i32 %.04967.us, %spec.select
  %exitcond92.not = icmp eq i32 %.04967.us, %spec.select
  br i1 %exitcond92.not, label %.loopexit, label %.lr.ph70.split.us, !llvm.loop !9

.lr.ph.us:                                        ; preds = %62, %.lr.ph.us.3
  %indvars.iv = phi i64 [ %indvars.iv.next.3, %.lr.ph.us.3 ], [ 0, %62 ]
  %69 = load ptr, ptr %7, align 8, !tbaa !5
  %70 = shl nuw nsw i64 %indvars.iv, 2
  %71 = getelementptr inbounds i8, ptr %69, i64 %70
  store i32 -1, ptr %71, align 1
  %72 = load ptr, ptr %7, align 8, !tbaa !5
  %indvars.iv.next = shl i64 %indvars.iv, 2
  %73 = or disjoint i64 %indvars.iv.next, 4
  %74 = getelementptr inbounds i8, ptr %72, i64 %73
  store i32 -1, ptr %74, align 1
  %75 = load ptr, ptr %7, align 8, !tbaa !5
  %indvars.iv.next.1 = shl i64 %indvars.iv, 2
  %76 = or disjoint i64 %indvars.iv.next.1, 8
  %77 = getelementptr inbounds i8, ptr %75, i64 %76
  store i32 -1, ptr %77, align 1
  %exitcond.not.2 = icmp eq i64 %indvars.iv, 124
  br i1 %exitcond.not.2, label %._crit_edge.us, label %.lr.ph.us.3, !llvm.loop !11

.lr.ph.us.3:                                      ; preds = %.lr.ph.us
  %78 = load ptr, ptr %7, align 8, !tbaa !5
  %indvars.iv.next.2 = shl i64 %indvars.iv, 2
  %79 = or disjoint i64 %indvars.iv.next.2, 12
  %80 = getelementptr inbounds i8, ptr %78, i64 %79
  store i32 -1, ptr %80, align 1
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  br label %.lr.ph.us

._crit_edge.us:                                   ; preds = %.lr.ph.us
  %81 = call i32 @BF_WriteBlock(i32 noundef %12, i32 noundef %59) #7
  %82 = icmp sgt i32 %81, -1
  br i1 %82, label %66, label %.loopexit

.lr.ph70.split:                                   ; preds = %.lr.ph70.split.preheader, %113
  %.not68 = phi i1 [ %.not, %113 ], [ true, %.lr.ph70.split.preheader ]
  %.04967 = phi i32 [ %115, %113 ], [ 1, %.lr.ph70.split.preheader ]
  %.05066 = phi i32 [ %87, %113 ], [ %51, %.lr.ph70.split.preheader ]
  %.05465 = phi ptr [ %114, %113 ], [ %49, %.lr.ph70.split.preheader ]
  %83 = call i32 @BF_AllocateBlock(i32 noundef %12) #7
  %84 = icmp slt i32 %83, 0
  br i1 %84, label %.loopexit.sink.split, label %85

85:                                               ; preds = %.lr.ph70.split
  %86 = call i32 @BF_GetBlockCounter(i32 noundef %12) #7
  %87 = add nsw i32 %86, -1
  %88 = call i32 @BF_ReadBlock(i32 noundef %12, i32 noundef %87, ptr noundef nonnull %7) #7
  %89 = icmp slt i32 %88, 0
  br i1 %89, label %.loopexit.sink.split, label %90

90:                                               ; preds = %85
  %91 = getelementptr inbounds i8, ptr %.05465, i64 508
  store i32 %87, ptr %91, align 1
  %92 = call i32 @BF_WriteBlock(i32 noundef %12, i32 noundef %.05066) #7
  %93 = icmp slt i32 %92, 0
  br i1 %93, label %.loopexit, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %90
  %94 = icmp eq i32 %.04967, %spec.select
  %umax = select i1 %94, i32 %54, i32 127
  %wide.trip.count = zext nneg i32 %umax to i64
  %xtraiter = and i64 %wide.trip.count, 3
  %95 = icmp ult i32 %umax, 4
  br i1 %95, label %._crit_edge.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %wide.trip.count, 2147483644
  br label %.lr.ph

._crit_edge.unr-lcssa:                            ; preds = %.lr.ph, %.lr.ph.preheader
  %indvars.iv93.unr = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next94.3, %.lr.ph ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge.unr-lcssa, %.lr.ph.epil
  %indvars.iv93.epil = phi i64 [ %indvars.iv.next94.epil, %.lr.ph.epil ], [ %indvars.iv93.unr, %._crit_edge.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %._crit_edge.unr-lcssa ]
  %96 = load ptr, ptr %7, align 8, !tbaa !5
  %97 = shl nuw nsw i64 %indvars.iv93.epil, 2
  %98 = getelementptr inbounds i8, ptr %96, i64 %97
  store i32 -1, ptr %98, align 1
  %indvars.iv.next94.epil = add nuw nsw i64 %indvars.iv93.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.lr.ph.epil, !llvm.loop !12

._crit_edge:                                      ; preds = %.lr.ph.epil, %._crit_edge.unr-lcssa
  %99 = call i32 @BF_WriteBlock(i32 noundef %12, i32 noundef %87) #7
  %100 = icmp sgt i32 %99, -1
  br i1 %100, label %113, label %.loopexit

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %indvars.iv93 = phi i64 [ 0, %.lr.ph.preheader.new ], [ %indvars.iv.next94.3, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.3, %.lr.ph ]
  %101 = load ptr, ptr %7, align 8, !tbaa !5
  %102 = shl nuw nsw i64 %indvars.iv93, 2
  %103 = getelementptr inbounds i8, ptr %101, i64 %102
  store i32 -1, ptr %103, align 1
  %104 = load ptr, ptr %7, align 8, !tbaa !5
  %indvars.iv.next94 = shl i64 %indvars.iv93, 2
  %105 = or disjoint i64 %indvars.iv.next94, 4
  %106 = getelementptr inbounds i8, ptr %104, i64 %105
  store i32 -1, ptr %106, align 1
  %107 = load ptr, ptr %7, align 8, !tbaa !5
  %indvars.iv.next94.1 = shl i64 %indvars.iv93, 2
  %108 = or disjoint i64 %indvars.iv.next94.1, 8
  %109 = getelementptr inbounds i8, ptr %107, i64 %108
  store i32 -1, ptr %109, align 1
  %110 = load ptr, ptr %7, align 8, !tbaa !5
  %indvars.iv.next94.2 = shl i64 %indvars.iv93, 2
  %111 = or disjoint i64 %indvars.iv.next94.2, 12
  %112 = getelementptr inbounds i8, ptr %110, i64 %111
  store i32 -1, ptr %112, align 1
  %indvars.iv.next94.3 = add nuw nsw i64 %indvars.iv93, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.unr-lcssa, label %.lr.ph, !llvm.loop !11

113:                                              ; preds = %._crit_edge
  %114 = load ptr, ptr %7, align 8
  %115 = add nuw i32 %.04967, 1
  %.not = icmp slt i32 %.04967, %spec.select
  %exitcond97.not = icmp eq i32 %.04967, %spec.select
  br i1 %exitcond97.not, label %.loopexit, label %.lr.ph70.split, !llvm.loop !9

.loopexit.sink.split:                             ; preds = %57, %.lr.ph70.split.us, %85, %.lr.ph70.split
  %.str.3.sink = phi ptr [ @.str.2, %.lr.ph70.split ], [ @.str.3, %85 ], [ @.str.2, %.lr.ph70.split.us ], [ @.str.3, %57 ]
  %.not62.ph = phi i1 [ %.not68, %.lr.ph70.split ], [ %.not68, %85 ], [ %.not68.us, %.lr.ph70.split.us ], [ %.not68.us, %57 ]
  call void @BF_PrintError(ptr noundef nonnull %.str.3.sink) #7
  br label %.loopexit

.loopexit:                                        ; preds = %._crit_edge.us, %66, %62, %._crit_edge, %113, %90, %.loopexit.sink.split, %42
  %.not62 = phi i1 [ false, %42 ], [ %.not62.ph, %.loopexit.sink.split ], [ %.not68, %._crit_edge ], [ %.not, %113 ], [ %.not68, %90 ], [ %.not68.us, %._crit_edge.us ], [ %.not.us, %66 ], [ %.not68.us, %62 ]
  %spec.select59 = sext i1 %.not62 to i32
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #7
  br label %116

116:                                              ; preds = %.loopexit, %25, %24
  %.5 = phi i32 [ -1, %24 ], [ %spec.select59, %.loopexit ], [ -1, %25 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #7
  br label %117

117:                                              ; preds = %14, %18, %116, %10
  %.7 = phi i32 [ -1, %10 ], [ -1, %14 ], [ -1, %18 ], [ %.5, %116 ]
  ret i32 %.7
}

declare i32 @BF_CreateFile(ptr noundef) local_unnamed_addr #1

declare void @BF_PrintError(ptr 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

declare i32 @BF_OpenFile(ptr noundef) local_unnamed_addr #1

declare i32 @BF_AllocateBlock(i32 noundef) local_unnamed_addr #1

declare i32 @BF_ReadBlock(i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

declare i32 @BF_GetBlockCounter(i32 noundef) local_unnamed_addr #1

; 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 @strlen(ptr nocapture noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strcpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly) local_unnamed_addr #5

declare i32 @BF_WriteBlock(i32 noundef, i32 noundef) local_unnamed_addr #1

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umax.i32(i32, i32) #6

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,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 = { mustprogress nofree nounwind willreturn memory(argmem: readwrite) "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #7 = { nounwind }
attributes #8 = { nounwind willreturn memory(read) }
attributes #9 = { nounwind allocsize(0) }

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

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


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