; LLVM IR from ryansturmer/thinfat32 :: src (thinfat32)

; 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.struct_BPB_struct = type <{ [3 x i8], [8 x i8], i16, i8, i16, i8, i16, i16, i8, i16, i16, i16, i32, i32, %union.anon }>
%union.anon = type { %struct.struct_BPBFAT32_struct }
%struct.struct_BPBFAT32_struct = type <{ i32, i16, i16, i32, i16, i16, [12 x i8], i8, i8, i8, i32, [11 x i8], [8 x i8] }>

@.str.10 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [130 x i8], align 1
@tf_initializeMediaNoBlock.scl = external hidden global i32, align 4
@tf_initializeMediaNoBlock.ssa = external hidden global i32, align 4
@tf_initializeMediaNoBlock.sectors_per_cluster = external hidden global i32, align 4

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

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @tf_initializeMediaNoBlock(i32 noundef %0, i32 noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca [512 x i8], align 16
  %7 = alloca [512 x i8], align 16
  %8 = alloca %struct.struct_BPB_struct, align 1
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 512, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 512, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 90, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %13 = load i32, ptr %5, align 4, !tbaa !5
  %14 = icmp ne i32 %13, 0
  br i1 %14, label %15, label %129

15:                                               ; preds = %2
  %16 = getelementptr inbounds [512 x i8], ptr %6, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 16 %16, i8 0, i64 512, i1 false)
  call void @llvm.memset.p0.i64(ptr align 1 %8, i8 0, i64 90, i1 false)
  %17 = getelementptr inbounds %struct.struct_BPB_struct, ptr %8, i32 0, i32 0
  %18 = getelementptr inbounds [3 x i8], ptr %17, i64 0, i64 0
  store i8 -21, ptr %18, align 1, !tbaa !9
  %19 = getelementptr inbounds %struct.struct_BPB_struct, ptr %8, i32 0, i32 0
  %20 = getelementptr inbounds [3 x i8], ptr %19, i64 0, i64 1
  store i8 88, ptr %20, align 1, !tbaa !9
  %21 = getelementptr inbounds %struct.struct_BPB_struct, ptr %8, i32 0, i32 0
  %22 = getelementptr inbounds [3 x i8], ptr %21, i64 0, i64 2
  store i8 -112, ptr %22, align 1, !tbaa !9
  %23 = getelementptr inbounds %struct.struct_BPB_struct, ptr %8, i32 0, i32 1
  %24 = getelementptr inbounds [8 x i8], ptr %23, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %24, ptr align 1 @.str.10, i64 8, i1 false)
  %25 = getelementptr inbounds %struct.struct_BPB_struct, ptr %8, i32 0, i32 2
  store i16 512, ptr %25, align 1, !tbaa !10
  %26 = getelementptr inbounds %struct.struct_BPB_struct, ptr %8, i32 0, i32 3
  store i8 32, ptr %26, align 1, !tbaa !13
  store i32 32, ptr @tf_initializeMediaNoBlock.sectors_per_cluster, align 4, !tbaa !5
  %27 = getelementptr inbounds %struct.struct_BPB_struct, ptr %8, i32 0, i32 4
  store i16 32, ptr %27, align 1, !tbaa !14
  %28 = getelementptr inbounds %struct.struct_BPB_struct, ptr %8, i32 0, i32 5
  store i8 2, ptr %28, align 1, !tbaa !15
  %29 = getelementptr inbounds %struct.struct_BPB_struct, ptr %8, i32 0, i32 8
  store i8 -8, ptr %29, align 1, !tbaa !16
  %30 = getelementptr inbounds %struct.struct_BPB_struct, ptr %8, i32 0, i32 10
  store i16 32, ptr %30, align 1, !tbaa !17
  %31 = getelementptr inbounds %struct.struct_BPB_struct, ptr %8, i32 0, i32 11
  store i16 64, ptr %31, align 1, !tbaa !18
  %32 = load i32, ptr %4, align 4, !tbaa !5
  %33 = getelementptr inbounds %struct.struct_BPB_struct, ptr %8, i32 0, i32 13
  store i32 %32, ptr %33, align 1, !tbaa !19
  %34 = load i32, ptr %4, align 4, !tbaa !5
  %35 = udiv i32 %34, 4095
  %36 = getelementptr inbounds %struct.struct_BPB_struct, ptr %8, i32 0, i32 14
  %37 = getelementptr inbounds %struct.struct_BPBFAT32_struct, ptr %36, i32 0, i32 0
  store i32 %35, ptr %37, align 1, !tbaa !9
  %38 = getelementptr inbounds %struct.struct_BPB_struct, ptr %8, i32 0, i32 14
  %39 = getelementptr inbounds %struct.struct_BPBFAT32_struct, ptr %38, i32 0, i32 3
  store i32 2, ptr %39, align 1, !tbaa !9
  %40 = getelementptr inbounds %struct.struct_BPB_struct, ptr %8, i32 0, i32 14
  %41 = getelementptr inbounds %struct.struct_BPBFAT32_struct, ptr %40, i32 0, i32 4
  store i16 1, ptr %41, align 1, !tbaa !9
  %42 = getelementptr inbounds %struct.struct_BPB_struct, ptr %8, i32 0, i32 14
  %43 = getelementptr inbounds %struct.struct_BPBFAT32_struct, ptr %42, i32 0, i32 5
  store i16 6, ptr %43, align 1, !tbaa !9
  %44 = getelementptr inbounds %struct.struct_BPB_struct, ptr %8, i32 0, i32 14
  %45 = getelementptr inbounds %struct.struct_BPBFAT32_struct, ptr %44, i32 0, i32 9
  store i8 41, ptr %45, align 1, !tbaa !9
  %46 = getelementptr inbounds %struct.struct_BPB_struct, ptr %8, i32 0, i32 14
  %47 = getelementptr inbounds %struct.struct_BPBFAT32_struct, ptr %46, i32 0, i32 10
  store i32 -212279871, ptr %47, align 1, !tbaa !9
  %48 = getelementptr inbounds %struct.struct_BPB_struct, ptr %8, i32 0, i32 14
  %49 = getelementptr inbounds %struct.struct_BPBFAT32_struct, ptr %48, i32 0, i32 11
  %50 = getelementptr inbounds [11 x i8], ptr %49, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 1 %50, i8 32, i64 11, i1 false)
  %51 = getelementptr inbounds %struct.struct_BPB_struct, ptr %8, i32 0, i32 14
  %52 = getelementptr inbounds %struct.struct_BPBFAT32_struct, ptr %51, i32 0, i32 12
  %53 = getelementptr inbounds [8 x i8], ptr %52, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %53, ptr align 1 @.str.11, i64 8, i1 false)
  %54 = getelementptr inbounds [512 x i8], ptr %6, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %54, ptr align 1 %8, i64 90, i1 false)
  %55 = getelementptr inbounds [512 x i8], ptr %6, i64 0, i64 0
  %56 = getelementptr inbounds i8, ptr %55, i64 90
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %56, ptr align 1 @.str.12, i64 129, i1 false)
  %57 = getelementptr inbounds %struct.struct_BPB_struct, ptr %8, i32 0, i32 4
  %58 = load i16, ptr %57, align 1, !tbaa !14
  %59 = zext i16 %58 to i32
  store i32 %59, ptr %9, align 4, !tbaa !5
  %60 = getelementptr inbounds [512 x i8], ptr %6, i64 0, i64 510
  store i8 85, ptr %60, align 2, !tbaa !9
  %61 = getelementptr inbounds [512 x i8], ptr %6, i64 0, i64 511
  store i8 -86, ptr %61, align 1, !tbaa !9
  %62 = getelementptr inbounds [512 x i8], ptr %6, i64 0, i64 0
  %63 = call i32 @write_sector(ptr noundef %62, i32 noundef 0)
  %64 = getelementptr inbounds %struct.struct_BPB_struct, ptr %8, i32 0, i32 5
  %65 = load i8, ptr %64, align 1, !tbaa !15
  %66 = zext i8 %65 to i32
  %67 = getelementptr inbounds %struct.struct_BPB_struct, ptr %8, i32 0, i32 14
  %68 = getelementptr inbounds %struct.struct_BPBFAT32_struct, ptr %67, i32 0, i32 0
  %69 = load i32, ptr %68, align 1, !tbaa !9
  %70 = mul i32 %66, %69
  %71 = load i32, ptr %9, align 4, !tbaa !5
  %72 = add i32 %70, %71
  store i32 %72, ptr @tf_initializeMediaNoBlock.ssa, align 4, !tbaa !5
  %73 = getelementptr inbounds [512 x i8], ptr %7, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 16 %73, i8 0, i64 512, i1 false)
  %74 = getelementptr inbounds [512 x i8], ptr %7, i64 0, i64 0
  store i32 1096897106, ptr %74, align 16, !tbaa !5
  %75 = getelementptr inbounds [512 x i8], ptr %7, i64 0, i64 0
  %76 = getelementptr inbounds i8, ptr %75, i64 484
  store i32 1631679090, ptr %76, align 4, !tbaa !5
  %77 = getelementptr inbounds [512 x i8], ptr %7, i64 0, i64 0
  %78 = getelementptr inbounds i8, ptr %77, i64 488
  store i32 -1, ptr %78, align 4, !tbaa !5
  %79 = getelementptr inbounds [512 x i8], ptr %7, i64 0, i64 0
  %80 = getelementptr inbounds i8, ptr %79, i64 492
  store i32 -1, ptr %80, align 4, !tbaa !5
  %81 = getelementptr inbounds [512 x i8], ptr %7, i64 0, i64 0
  %82 = getelementptr inbounds i8, ptr %81, i64 496
  store i32 0, ptr %82, align 4, !tbaa !5
  %83 = getelementptr inbounds [512 x i8], ptr %7, i64 0, i64 0
  %84 = getelementptr inbounds i8, ptr %83, i64 500
  store i32 0, ptr %84, align 4, !tbaa !5
  %85 = getelementptr inbounds [512 x i8], ptr %7, i64 0, i64 0
  %86 = getelementptr inbounds i8, ptr %85, i64 504
  store i32 0, ptr %86, align 4, !tbaa !5
  %87 = getelementptr inbounds [512 x i8], ptr %7, i64 0, i64 0
  %88 = getelementptr inbounds i8, ptr %87, i64 508
  store i32 -1437270016, ptr %88, align 4, !tbaa !5
  %89 = getelementptr inbounds [512 x i8], ptr %7, i64 0, i64 0
  %90 = call i32 @write_sector(ptr noundef %89, i32 noundef 1)
  %91 = getelementptr inbounds %struct.struct_BPB_struct, ptr %8, i32 0, i32 4
  %92 = load i16, ptr %91, align 1, !tbaa !14
  %93 = zext i16 %92 to i32
  store i32 %93, ptr %9, align 4, !tbaa !5
  %94 = getelementptr inbounds [512 x i8], ptr %7, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 16 %94, i8 0, i64 512, i1 false)
  store i32 2, ptr @tf_initializeMediaNoBlock.scl, align 4, !tbaa !5
  br label %95

95:                                               ; preds = %104, %15
  %96 = load i32, ptr @tf_initializeMediaNoBlock.scl, align 4, !tbaa !5
  %97 = load i32, ptr @tf_initializeMediaNoBlock.sectors_per_cluster, align 4, !tbaa !5
  %98 = icmp ult i32 %96, %97
  br i1 %98, label %99, label %107

99:                                               ; preds = %95
  %100 = getelementptr inbounds [512 x i8], ptr %7, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 16 %100, i8 0, i64 512, i1 false)
  %101 = getelementptr inbounds [512 x i8], ptr %7, i64 0, i64 0
  %102 = load i32, ptr @tf_initializeMediaNoBlock.scl, align 4, !tbaa !5
  %103 = call i32 @write_sector(ptr noundef %101, i32 noundef %102)
  br label %104

104:                                              ; preds = %99
  %105 = load i32, ptr @tf_initializeMediaNoBlock.scl, align 4, !tbaa !5
  %106 = add i32 %105, 1
  store i32 %106, ptr @tf_initializeMediaNoBlock.scl, align 4, !tbaa !5
  br label %95, !llvm.loop !20

107:                                              ; preds = %95
  %108 = getelementptr inbounds [512 x i8], ptr %6, i64 0, i64 0
  %109 = call i32 @write_sector(ptr noundef %108, i32 noundef 6)
  %110 = getelementptr inbounds [512 x i8], ptr %7, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 16 %110, i8 0, i64 512, i1 false)
  %111 = load i32, ptr @tf_initializeMediaNoBlock.ssa, align 4, !tbaa !5
  %112 = getelementptr inbounds %struct.struct_BPB_struct, ptr %8, i32 0, i32 3
  %113 = load i8, ptr %112, align 1, !tbaa !13
  %114 = zext i8 %113 to i32
  %115 = add i32 %111, %114
  store i32 %115, ptr @tf_initializeMediaNoBlock.scl, align 4, !tbaa !5
  br label %116

116:                                              ; preds = %124, %107
  %117 = load i32, ptr @tf_initializeMediaNoBlock.scl, align 4, !tbaa !5
  %118 = load i32, ptr @tf_initializeMediaNoBlock.ssa, align 4, !tbaa !5
  %119 = icmp uge i32 %117, %118
  br i1 %119, label %120, label %127

120:                                              ; preds = %116
  %121 = getelementptr inbounds [512 x i8], ptr %7, i64 0, i64 0
  %122 = load i32, ptr @tf_initializeMediaNoBlock.scl, align 4, !tbaa !5
  %123 = call i32 @write_sector(ptr noundef %121, i32 noundef %122)
  br label %124

124:                                              ; preds = %120
  %125 = load i32, ptr @tf_initializeMediaNoBlock.scl, align 4, !tbaa !5
  %126 = add i32 %125, -1
  store i32 %126, ptr @tf_initializeMediaNoBlock.scl, align 4, !tbaa !5
  br label %116, !llvm.loop !22

127:                                              ; preds = %116
  %128 = load i32, ptr %9, align 4, !tbaa !5
  store i32 %128, ptr @tf_initializeMediaNoBlock.scl, align 4, !tbaa !5
  store i32 1, ptr %3, align 4
  store i32 1, ptr %11, align 4
  br label %178

129:                                              ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %130 = load i32, ptr @tf_initializeMediaNoBlock.scl, align 4, !tbaa !5
  %131 = add i32 %130, 100
  store i32 %131, ptr %12, align 4, !tbaa !5
  %132 = load i32, ptr %12, align 4, !tbaa !5
  %133 = load i32, ptr @tf_initializeMediaNoBlock.ssa, align 4, !tbaa !5
  %134 = udiv i32 %133, 2
  %135 = icmp uge i32 %132, %134
  br i1 %135, label %136, label %139

136:                                              ; preds = %129
  %137 = load i32, ptr @tf_initializeMediaNoBlock.ssa, align 4, !tbaa !5
  %138 = udiv i32 %137, 2
  store i32 %138, ptr %12, align 4, !tbaa !5
  br label %139

139:                                              ; preds = %136, %129
  %140 = getelementptr inbounds [512 x i8], ptr %7, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 16 %140, i8 0, i64 512, i1 false)
  br label %141

141:                                              ; preds = %155, %139
  %142 = load i32, ptr @tf_initializeMediaNoBlock.scl, align 4, !tbaa !5
  %143 = load i32, ptr %12, align 4, !tbaa !5
  %144 = icmp ult i32 %142, %143
  br i1 %144, label %145, label %158

145:                                              ; preds = %141
  %146 = getelementptr inbounds [512 x i8], ptr %7, i64 0, i64 0
  %147 = load i32, ptr @tf_initializeMediaNoBlock.scl, align 4, !tbaa !5
  %148 = call i32 @write_sector(ptr noundef %146, i32 noundef %147)
  %149 = getelementptr inbounds [512 x i8], ptr %7, i64 0, i64 0
  %150 = load i32, ptr @tf_initializeMediaNoBlock.scl, align 4, !tbaa !5
  %151 = load i32, ptr @tf_initializeMediaNoBlock.ssa, align 4, !tbaa !5
  %152 = udiv i32 %151, 2
  %153 = add i32 %150, %152
  %154 = call i32 @write_sector(ptr noundef %149, i32 noundef %153)
  br label %155

155:                                              ; preds = %145
  %156 = load i32, ptr @tf_initializeMediaNoBlock.scl, align 4, !tbaa !5
  %157 = add i32 %156, 1
  store i32 %157, ptr @tf_initializeMediaNoBlock.scl, align 4, !tbaa !5
  br label %141, !llvm.loop !23

158:                                              ; preds = %141
  %159 = load i32, ptr @tf_initializeMediaNoBlock.scl, align 4, !tbaa !5
  %160 = load i32, ptr @tf_initializeMediaNoBlock.ssa, align 4, !tbaa !5
  %161 = udiv i32 %160, 2
  %162 = icmp ult i32 %159, %161
  br i1 %162, label %163, label %164

163:                                              ; preds = %158
  store i32 0, ptr %3, align 4
  store i32 1, ptr %11, align 4
  br label %174

164:                                              ; preds = %158
  %165 = getelementptr inbounds [512 x i8], ptr %7, i64 0, i64 0
  %166 = getelementptr inbounds i8, ptr %165, i64 0
  store i32 268435448, ptr %166, align 4, !tbaa !5
  %167 = getelementptr inbounds [512 x i8], ptr %7, i64 0, i64 0
  %168 = getelementptr inbounds i8, ptr %167, i64 4
  store i32 268435455, ptr %168, align 4, !tbaa !5
  %169 = getelementptr inbounds [512 x i8], ptr %7, i64 0, i64 0
  %170 = getelementptr inbounds i8, ptr %169, i64 8
  store i32 268435448, ptr %170, align 4, !tbaa !5
  %171 = getelementptr inbounds [512 x i8], ptr %7, i64 0, i64 0
  %172 = load i32, ptr @tf_initializeMediaNoBlock.sectors_per_cluster, align 4, !tbaa !5
  %173 = call i32 @write_sector(ptr noundef %171, i32 noundef %172)
  store i32 0, ptr %11, align 4
  br label %174

174:                                              ; preds = %164, %163
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  %175 = load i32, ptr %11, align 4
  switch i32 %175, label %178 [
    i32 0, label %176
  ]

176:                                              ; preds = %174
  br label %177

177:                                              ; preds = %176
  store i32 1, ptr %3, align 4
  store i32 1, ptr %11, align 4
  br label %178

178:                                              ; preds = %177, %174, %127
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 90, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 512, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 512, ptr %6) #4
  %179 = load i32, ptr %3, align 4
  ret i32 %179
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 = !{!7, !7, i64 0}
!10 = !{!11, !12, i64 11}
!11 = !{!"struct_BPB_struct", !7, i64 0, !7, i64 3, !12, i64 11, !7, i64 13, !12, i64 14, !7, i64 16, !12, i64 17, !12, i64 19, !7, i64 21, !12, i64 22, !12, i64 24, !12, i64 26, !6, i64 28, !6, i64 32, !7, i64 36}
!12 = !{!"short", !7, i64 0}
!13 = !{!11, !7, i64 13}
!14 = !{!11, !12, i64 14}
!15 = !{!11, !7, i64 16}
!16 = !{!11, !7, i64 21}
!17 = !{!11, !12, i64 24}
!18 = !{!11, !12, i64 26}
!19 = !{!11, !6, i64 32}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !21}
!23 = distinct !{!23, !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.10 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [130 x i8], align 1
@tf_initializeMediaNoBlock.scl = external hidden local_unnamed_addr global i32, align 4
@tf_initializeMediaNoBlock.ssa = external hidden local_unnamed_addr global i32, align 4
@tf_initializeMediaNoBlock.sectors_per_cluster = external hidden local_unnamed_addr global i32, align 4

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

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @tf_initializeMediaNoBlock(i32 noundef %0, i32 noundef %1) local_unnamed_addr #1 {
  %3 = alloca [512 x i8], align 16
  %4 = alloca [512 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 512, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 512, ptr nonnull %4) #5
  %.not = icmp eq i32 %1, 0
  br i1 %.not, label %33, label %5

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %3, i64 208
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(512) %6, i8 0, i64 304, i1 false)
  %.sroa.7.3.copyload = load i64, ptr @.str.10, align 1
  store i32 32, ptr @tf_initializeMediaNoBlock.sectors_per_cluster, align 4, !tbaa !5
  %7 = udiv i32 %0, 4095
  %.sroa.28.82.copyload = load i64, ptr @.str.11, align 1
  store i8 -21, ptr %3, align 16
  %.sroa.5.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 1
  store i8 88, ptr %.sroa.5.0..sroa_idx, align 1
  %.sroa.6.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 2
  store i8 -112, ptr %.sroa.6.0..sroa_idx, align 2
  %.sroa.7.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 3
  store i64 %.sroa.7.3.copyload, ptr %.sroa.7.0..sroa_idx, align 1
  %.sroa.8.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 11
  store i16 512, ptr %.sroa.8.0..sroa_idx, align 1
  %.sroa.9.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 13
  store i8 32, ptr %.sroa.9.0..sroa_idx, align 1
  %.sroa.11.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 14
  store i16 32, ptr %.sroa.11.0..sroa_idx, align 2
  %.sroa.14.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 16
  store i8 2, ptr %.sroa.14.0..sroa_idx, align 16
  %.sroa.16.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 17
  store i32 0, ptr %.sroa.16.0..sroa_idx, align 1
  %.sroa.166.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 21
  store i8 -8, ptr %.sroa.166.0..sroa_idx, align 1
  %.sroa.17.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 22
  store i16 0, ptr %.sroa.17.0..sroa_idx, align 2
  %.sroa.177.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 24
  store i16 32, ptr %.sroa.177.0..sroa_idx, align 8
  %.sroa.18.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 26
  store i16 64, ptr %.sroa.18.0..sroa_idx, align 2
  %.sroa.19.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 28
  store i32 0, ptr %.sroa.19.0..sroa_idx, align 4
  %.sroa.198.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 32
  store i32 %0, ptr %.sroa.198.0..sroa_idx, align 16
  %.sroa.20.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 36
  store i32 %7, ptr %.sroa.20.0..sroa_idx, align 4
  %.sroa.22.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 40
  store i32 0, ptr %.sroa.22.0..sroa_idx, align 8
  %.sroa.229.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 44
  store i32 2, ptr %.sroa.229.0..sroa_idx, align 4
  %.sroa.23.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 48
  store i16 1, ptr %.sroa.23.0..sroa_idx, align 16
  %.sroa.24.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 50
  store i16 6, ptr %.sroa.24.0..sroa_idx, align 2
  %.sroa.25.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 52
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(14) %.sroa.25.0..sroa_idx, i8 0, i64 14, i1 false)
  %.sroa.2510.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 66
  store i8 41, ptr %.sroa.2510.0..sroa_idx, align 2
  %.sroa.26.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 67
  store i32 -212279871, ptr %.sroa.26.0..sroa_idx, align 1
  %.sroa.27.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 71
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(11) %.sroa.27.0..sroa_idx, i8 32, i64 11, i1 false)
  %.sroa.28.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 82
  store i64 %.sroa.28.82.copyload, ptr %.sroa.28.0..sroa_idx, align 2
  %8 = getelementptr inbounds i8, ptr %3, i64 90
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 2 dereferenceable(129) %8, ptr noundef nonnull align 1 dereferenceable(129) @.str.12, i64 129, i1 false)
  %9 = getelementptr inbounds i8, ptr %3, i64 510
  store i8 85, ptr %9, align 2, !tbaa !9
  %10 = getelementptr inbounds i8, ptr %3, i64 511
  store i8 -86, ptr %10, align 1, !tbaa !9
  %11 = call i32 @write_sector(ptr noundef nonnull %3, i32 noundef 0)
  %12 = shl nuw nsw i32 %7, 1
  %13 = add nuw nsw i32 %12, 32
  store i32 %13, ptr @tf_initializeMediaNoBlock.ssa, align 4, !tbaa !5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(512) %4, i8 0, i64 496, i1 false)
  store i32 1096897106, ptr %4, align 16, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %4, i64 484
  store <4 x i32> <i32 1631679090, i32 -1, i32 -1, i32 0>, ptr %14, align 4, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %4, i64 500
  store i32 0, ptr %15, align 4, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %4, i64 504
  store i32 0, ptr %16, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %4, i64 508
  store i32 -1437270016, ptr %17, align 4, !tbaa !5
  %18 = call i32 @write_sector(ptr noundef nonnull %4, i32 noundef 1)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(512) %4, i8 0, i64 512, i1 false)
  store i32 2, ptr @tf_initializeMediaNoBlock.scl, align 4, !tbaa !5
  %19 = load i32, ptr @tf_initializeMediaNoBlock.sectors_per_cluster, align 4, !tbaa !5
  %20 = icmp ugt i32 %19, 2
  br i1 %20, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %5, %.lr.ph
  %storemerge32 = phi i32 [ %23, %.lr.ph ], [ 2, %5 ]
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(512) %4, i8 0, i64 512, i1 false)
  %21 = call i32 @write_sector(ptr noundef nonnull %4, i32 noundef %storemerge32)
  %22 = load i32, ptr @tf_initializeMediaNoBlock.scl, align 4, !tbaa !5
  %23 = add i32 %22, 1
  store i32 %23, ptr @tf_initializeMediaNoBlock.scl, align 4, !tbaa !5
  %24 = load i32, ptr @tf_initializeMediaNoBlock.sectors_per_cluster, align 4, !tbaa !5
  %25 = icmp ult i32 %23, %24
  br i1 %25, label %.lr.ph, label %._crit_edge, !llvm.loop !10

._crit_edge:                                      ; preds = %.lr.ph, %5
  %26 = call i32 @write_sector(ptr noundef nonnull %3, i32 noundef 6)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(512) %4, i8 0, i64 512, i1 false)
  %27 = load i32, ptr @tf_initializeMediaNoBlock.ssa, align 4, !tbaa !5
  %28 = add i32 %27, 32
  store i32 %28, ptr @tf_initializeMediaNoBlock.scl, align 4, !tbaa !5
  %.not3033 = icmp ugt i32 %27, -33
  br i1 %.not3033, label %._crit_edge37, label %.lr.ph36

.lr.ph36:                                         ; preds = %._crit_edge, %.lr.ph36
  %storemerge2934 = phi i32 [ %31, %.lr.ph36 ], [ %28, %._crit_edge ]
  %29 = call i32 @write_sector(ptr noundef nonnull %4, i32 noundef %storemerge2934)
  %30 = load i32, ptr @tf_initializeMediaNoBlock.scl, align 4, !tbaa !5
  %31 = add i32 %30, -1
  store i32 %31, ptr @tf_initializeMediaNoBlock.scl, align 4, !tbaa !5
  %32 = load i32, ptr @tf_initializeMediaNoBlock.ssa, align 4, !tbaa !5
  %.not30 = icmp ult i32 %31, %32
  br i1 %.not30, label %._crit_edge37, label %.lr.ph36, !llvm.loop !12

._crit_edge37:                                    ; preds = %.lr.ph36, %._crit_edge
  store i32 32, ptr @tf_initializeMediaNoBlock.scl, align 4, !tbaa !5
  br label %55

33:                                               ; preds = %2
  %34 = load i32, ptr @tf_initializeMediaNoBlock.scl, align 4, !tbaa !5
  %35 = add i32 %34, 100
  %36 = load i32, ptr @tf_initializeMediaNoBlock.ssa, align 4, !tbaa !5
  %37 = lshr i32 %36, 1
  %spec.select = tail call i32 @llvm.umin.i32(i32 %35, i32 %37)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(512) %4, i8 0, i64 512, i1 false)
  %38 = icmp ult i32 %34, %spec.select
  br i1 %38, label %.lr.ph39, label %._crit_edge40

.lr.ph39:                                         ; preds = %33, %.lr.ph39
  %39 = phi i32 [ %47, %.lr.ph39 ], [ %34, %33 ]
  %40 = call i32 @write_sector(ptr noundef nonnull %4, i32 noundef %39)
  %41 = load i32, ptr @tf_initializeMediaNoBlock.scl, align 4, !tbaa !5
  %42 = load i32, ptr @tf_initializeMediaNoBlock.ssa, align 4, !tbaa !5
  %43 = lshr i32 %42, 1
  %44 = add i32 %43, %41
  %45 = call i32 @write_sector(ptr noundef nonnull %4, i32 noundef %44)
  %46 = load i32, ptr @tf_initializeMediaNoBlock.scl, align 4, !tbaa !5
  %47 = add i32 %46, 1
  store i32 %47, ptr @tf_initializeMediaNoBlock.scl, align 4, !tbaa !5
  %48 = icmp ult i32 %47, %spec.select
  br i1 %48, label %.lr.ph39, label %._crit_edge40.loopexit, !llvm.loop !13

._crit_edge40.loopexit:                           ; preds = %.lr.ph39
  %.pre = load i32, ptr @tf_initializeMediaNoBlock.ssa, align 4, !tbaa !5
  %.pre42 = lshr i32 %.pre, 1
  br label %._crit_edge40

._crit_edge40:                                    ; preds = %._crit_edge40.loopexit, %33
  %.pre-phi = phi i32 [ %.pre42, %._crit_edge40.loopexit ], [ %37, %33 ]
  %.lcssa = phi i32 [ %47, %._crit_edge40.loopexit ], [ %34, %33 ]
  %.not28 = icmp uge i32 %.lcssa, %.pre-phi
  br i1 %.not28, label %49, label %54

49:                                               ; preds = %._crit_edge40
  store i32 268435448, ptr %4, align 16, !tbaa !5
  %50 = getelementptr inbounds i8, ptr %4, i64 4
  store i32 268435455, ptr %50, align 4, !tbaa !5
  %51 = getelementptr inbounds i8, ptr %4, i64 8
  store i32 268435448, ptr %51, align 8, !tbaa !5
  %52 = load i32, ptr @tf_initializeMediaNoBlock.sectors_per_cluster, align 4, !tbaa !5
  %53 = call i32 @write_sector(ptr noundef nonnull %4, i32 noundef %52)
  br label %54

54:                                               ; preds = %._crit_edge40, %49
  %spec.select31 = zext i1 %.not28 to i32
  br label %55

55:                                               ; preds = %54, %._crit_edge37
  %.1 = phi i32 [ 1, %._crit_edge37 ], [ %spec.select31, %54 ]
  call void @llvm.lifetime.end.p0(i64 512, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 512, ptr nonnull %3) #5
  ret i32 %.1
}

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

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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}
!13 = distinct !{!13, !11}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,MemCpyOptPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass