; LLVM IR from carlk3/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico :: src/ff15/source (ff)

; 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.DIR = type { %struct.FFOBJID, i32, i32, i64, ptr, [12 x i8], i32, ptr }
%struct.FFOBJID = type { ptr, i16, i8, i8, i32, i64, i32, i32, i32, i32, i32, i32 }
%struct.FIL = type { %struct.FFOBJID, i8, i8, i64, i32, i64, i64, ptr, ptr, [512 x i8] }
%struct.FATFS = type { i8, i8, i8, i8, i8, i8, i16, i16, i16, ptr, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i64, i64, i64, i64, i64, i64, [512 x i8] }

; 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

declare ptr @ff_memalloc(i32 noundef) #1

; Function Attrs: nounwind uwtable
declare hidden void @st_dword(ptr noundef, i32 noundef) #2

declare i32 @get_fattime() #1

; Function Attrs: nounwind uwtable
declare hidden i32 @store_xdir(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden void @st_clust(ptr noundef, ptr noundef, i32 noundef) #2

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

declare void @ff_memfree(ptr noundef) #1

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

declare i32 @disk_write(i8 noundef zeroext, ptr noundef, i64 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @f_sync(ptr noundef %0) #2 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca %struct.DIR, align 8
  %10 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.FIL, ptr %11, i32 0, i32 0
  %13 = call i32 @validate(ptr noundef %12, ptr noundef %5)
  store i32 %13, ptr %4, align 4, !tbaa !9
  %14 = load i32, ptr %4, align 4, !tbaa !9
  %15 = icmp eq i32 %14, 0
  br i1 %15, label %16, label %220

16:                                               ; preds = %1
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.FIL, ptr %17, i32 0, i32 1
  %19 = load i8, ptr %18, align 8, !tbaa !11
  %20 = zext i8 %19 to i32
  %21 = and i32 %20, 64
  %22 = icmp ne i32 %21, 0
  br i1 %22, label %23, label %219

23:                                               ; preds = %16
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.FIL, ptr %24, i32 0, i32 1
  %26 = load i8, ptr %25, align 8, !tbaa !11
  %27 = zext i8 %26 to i32
  %28 = and i32 %27, 128
  %29 = icmp ne i32 %28, 0
  br i1 %29, label %30, label %50

30:                                               ; preds = %23
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.FATFS, ptr %31, i32 0, i32 1
  %33 = load i8, ptr %32, align 1, !tbaa !16
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.FIL, ptr %34, i32 0, i32 9
  %36 = getelementptr inbounds [512 x i8], ptr %35, i64 0, i64 0
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.FIL, ptr %37, i32 0, i32 5
  %39 = load i64, ptr %38, align 8, !tbaa !18
  %40 = call i32 @disk_write(i8 noundef zeroext %33, ptr noundef %36, i64 noundef %39, i32 noundef 1)
  %41 = icmp ne i32 %40, 0
  br i1 %41, label %42, label %43

42:                                               ; preds = %30
  store i32 1, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %222

43:                                               ; preds = %30
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.FIL, ptr %44, i32 0, i32 1
  %46 = load i8, ptr %45, align 8, !tbaa !11
  %47 = zext i8 %46 to i32
  %48 = and i32 %47, 127
  %49 = trunc i32 %48 to i8
  store i8 %49, ptr %45, align 8, !tbaa !11
  br label %50

50:                                               ; preds = %43, %23
  %51 = call i32 @get_fattime()
  store i32 %51, ptr %6, align 4, !tbaa !9
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.FATFS, ptr %52, i32 0, i32 0
  %54 = load i8, ptr %53, align 8, !tbaa !19
  %55 = zext i8 %54 to i32
  %56 = icmp eq i32 %55, 4
  br i1 %56, label %57, label %168

57:                                               ; preds = %50
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.FIL, ptr %58, i32 0, i32 0
  %60 = call i32 @fill_first_frag(ptr noundef %59)
  store i32 %60, ptr %4, align 4, !tbaa !9
  %61 = load i32, ptr %4, align 4, !tbaa !9
  %62 = icmp eq i32 %61, 0
  br i1 %62, label %63, label %70

63:                                               ; preds = %57
  %64 = load ptr, ptr %3, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.FIL, ptr %64, i32 0, i32 0
  %66 = load ptr, ptr %3, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.FIL, ptr %66, i32 0, i32 4
  %68 = load i32, ptr %67, align 8, !tbaa !20
  %69 = call i32 @fill_last_frag(ptr noundef %65, i32 noundef %68, i32 noundef -1)
  store i32 %69, ptr %4, align 4, !tbaa !9
  br label %70

70:                                               ; preds = %63, %57
  %71 = load i32, ptr %4, align 4, !tbaa !9
  %72 = icmp eq i32 %71, 0
  br i1 %72, label %73, label %167

73:                                               ; preds = %70
  call void @llvm.lifetime.start.p0(i64 96, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %74 = call ptr @ff_memalloc(i32 noundef 1120)
  store ptr %74, ptr %10, align 8, !tbaa !5
  %75 = load ptr, ptr %10, align 8, !tbaa !5
  %76 = icmp ne ptr %75, null
  br i1 %76, label %78, label %77

77:                                               ; preds = %73
  store i32 17, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %164

78:                                               ; preds = %73
  %79 = load ptr, ptr %10, align 8, !tbaa !5
  %80 = load ptr, ptr %5, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.FATFS, ptr %80, i32 0, i32 9
  store ptr %79, ptr %81, align 8, !tbaa !21
  %82 = load ptr, ptr %10, align 8, !tbaa !5
  %83 = getelementptr inbounds i16, ptr %82, i64 255
  %84 = getelementptr inbounds i16, ptr %83, i64 1
  %85 = load ptr, ptr %5, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.FATFS, ptr %85, i32 0, i32 10
  store ptr %84, ptr %86, align 8, !tbaa !22
  %87 = load ptr, ptr %3, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.FIL, ptr %87, i32 0, i32 0
  %89 = call i32 @load_obj_xdir(ptr noundef %9, ptr noundef %88)
  store i32 %89, ptr %4, align 4, !tbaa !9
  %90 = load i32, ptr %4, align 4, !tbaa !9
  %91 = icmp eq i32 %90, 0
  br i1 %91, label %92, label %162

92:                                               ; preds = %78
  %93 = load ptr, ptr %5, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.FATFS, ptr %93, i32 0, i32 10
  %95 = load ptr, ptr %94, align 8, !tbaa !22
  %96 = getelementptr inbounds i8, ptr %95, i64 4
  %97 = load i8, ptr %96, align 1, !tbaa !23
  %98 = zext i8 %97 to i32
  %99 = or i32 %98, 32
  %100 = trunc i32 %99 to i8
  store i8 %100, ptr %96, align 1, !tbaa !23
  %101 = load ptr, ptr %3, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.FIL, ptr %101, i32 0, i32 0
  %103 = getelementptr inbounds %struct.FFOBJID, ptr %102, i32 0, i32 3
  %104 = load i8, ptr %103, align 1, !tbaa !24
  %105 = zext i8 %104 to i32
  %106 = or i32 %105, 1
  %107 = trunc i32 %106 to i8
  %108 = load ptr, ptr %5, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.FATFS, ptr %108, i32 0, i32 10
  %110 = load ptr, ptr %109, align 8, !tbaa !22
  %111 = getelementptr inbounds i8, ptr %110, i64 33
  store i8 %107, ptr %111, align 1, !tbaa !23
  %112 = load ptr, ptr %5, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct.FATFS, ptr %112, i32 0, i32 10
  %114 = load ptr, ptr %113, align 8, !tbaa !22
  %115 = getelementptr inbounds i8, ptr %114, i64 52
  %116 = load ptr, ptr %3, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.FIL, ptr %116, i32 0, i32 0
  %118 = getelementptr inbounds %struct.FFOBJID, ptr %117, i32 0, i32 4
  %119 = load i32, ptr %118, align 4, !tbaa !25
  call void @st_dword(ptr noundef %115, i32 noundef %119)
  %120 = load ptr, ptr %5, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct.FATFS, ptr %120, i32 0, i32 10
  %122 = load ptr, ptr %121, align 8, !tbaa !22
  %123 = getelementptr inbounds i8, ptr %122, i64 56
  %124 = load ptr, ptr %3, align 8, !tbaa !5
  %125 = getelementptr inbounds %struct.FIL, ptr %124, i32 0, i32 0
  %126 = getelementptr inbounds %struct.FFOBJID, ptr %125, i32 0, i32 5
  %127 = load i64, ptr %126, align 8, !tbaa !26
  call void @st_qword(ptr noundef %123, i64 noundef %127)
  %128 = load ptr, ptr %5, align 8, !tbaa !5
  %129 = getelementptr inbounds %struct.FATFS, ptr %128, i32 0, i32 10
  %130 = load ptr, ptr %129, align 8, !tbaa !22
  %131 = getelementptr inbounds i8, ptr %130, i64 40
  %132 = load ptr, ptr %3, align 8, !tbaa !5
  %133 = getelementptr inbounds %struct.FIL, ptr %132, i32 0, i32 0
  %134 = getelementptr inbounds %struct.FFOBJID, ptr %133, i32 0, i32 5
  %135 = load i64, ptr %134, align 8, !tbaa !26
  call void @st_qword(ptr noundef %131, i64 noundef %135)
  %136 = load ptr, ptr %5, align 8, !tbaa !5
  %137 = getelementptr inbounds %struct.FATFS, ptr %136, i32 0, i32 10
  %138 = load ptr, ptr %137, align 8, !tbaa !22
  %139 = getelementptr inbounds i8, ptr %138, i64 12
  %140 = load i32, ptr %6, align 4, !tbaa !9
  call void @st_dword(ptr noundef %139, i32 noundef %140)
  %141 = load ptr, ptr %5, align 8, !tbaa !5
  %142 = getelementptr inbounds %struct.FATFS, ptr %141, i32 0, i32 10
  %143 = load ptr, ptr %142, align 8, !tbaa !22
  %144 = getelementptr inbounds i8, ptr %143, i64 21
  store i8 0, ptr %144, align 1, !tbaa !23
  %145 = load ptr, ptr %5, align 8, !tbaa !5
  %146 = getelementptr inbounds %struct.FATFS, ptr %145, i32 0, i32 10
  %147 = load ptr, ptr %146, align 8, !tbaa !22
  %148 = getelementptr inbounds i8, ptr %147, i64 16
  call void @st_dword(ptr noundef %148, i32 noundef 0)
  %149 = call i32 @store_xdir(ptr noundef %9)
  store i32 %149, ptr %4, align 4, !tbaa !9
  %150 = load i32, ptr %4, align 4, !tbaa !9
  %151 = icmp eq i32 %150, 0
  br i1 %151, label %152, label %161

152:                                              ; preds = %92
  %153 = load ptr, ptr %5, align 8, !tbaa !5
  %154 = call i32 @sync_fs(ptr noundef %153)
  store i32 %154, ptr %4, align 4, !tbaa !9
  %155 = load ptr, ptr %3, align 8, !tbaa !5
  %156 = getelementptr inbounds %struct.FIL, ptr %155, i32 0, i32 1
  %157 = load i8, ptr %156, align 8, !tbaa !11
  %158 = zext i8 %157 to i32
  %159 = and i32 %158, 191
  %160 = trunc i32 %159 to i8
  store i8 %160, ptr %156, align 8, !tbaa !11
  br label %161

161:                                              ; preds = %152, %92
  br label %162

162:                                              ; preds = %161, %78
  %163 = load ptr, ptr %10, align 8, !tbaa !5
  call void @ff_memfree(ptr noundef %163)
  store i32 0, ptr %8, align 4
  br label %164

164:                                              ; preds = %162, %77
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 96, ptr %9) #3
  %165 = load i32, ptr %8, align 4
  switch i32 %165, label %222 [
    i32 0, label %166
  ]

166:                                              ; preds = %164
  br label %167

167:                                              ; preds = %166, %70
  br label %218

168:                                              ; preds = %50
  %169 = load ptr, ptr %5, align 8, !tbaa !5
  %170 = load ptr, ptr %3, align 8, !tbaa !5
  %171 = getelementptr inbounds %struct.FIL, ptr %170, i32 0, i32 6
  %172 = load i64, ptr %171, align 8, !tbaa !27
  %173 = call i32 @move_window(ptr noundef %169, i64 noundef %172)
  store i32 %173, ptr %4, align 4, !tbaa !9
  %174 = load i32, ptr %4, align 4, !tbaa !9
  %175 = icmp eq i32 %174, 0
  br i1 %175, label %176, label %217

176:                                              ; preds = %168
  %177 = load ptr, ptr %3, align 8, !tbaa !5
  %178 = getelementptr inbounds %struct.FIL, ptr %177, i32 0, i32 7
  %179 = load ptr, ptr %178, align 8, !tbaa !28
  store ptr %179, ptr %7, align 8, !tbaa !5
  %180 = load ptr, ptr %7, align 8, !tbaa !5
  %181 = getelementptr inbounds i8, ptr %180, i64 11
  %182 = load i8, ptr %181, align 1, !tbaa !23
  %183 = zext i8 %182 to i32
  %184 = or i32 %183, 32
  %185 = trunc i32 %184 to i8
  store i8 %185, ptr %181, align 1, !tbaa !23
  %186 = load ptr, ptr %3, align 8, !tbaa !5
  %187 = getelementptr inbounds %struct.FIL, ptr %186, i32 0, i32 0
  %188 = getelementptr inbounds %struct.FFOBJID, ptr %187, i32 0, i32 0
  %189 = load ptr, ptr %188, align 8, !tbaa !29
  %190 = load ptr, ptr %7, align 8, !tbaa !5
  %191 = load ptr, ptr %3, align 8, !tbaa !5
  %192 = getelementptr inbounds %struct.FIL, ptr %191, i32 0, i32 0
  %193 = getelementptr inbounds %struct.FFOBJID, ptr %192, i32 0, i32 4
  %194 = load i32, ptr %193, align 4, !tbaa !25
  call void @st_clust(ptr noundef %189, ptr noundef %190, i32 noundef %194)
  %195 = load ptr, ptr %7, align 8, !tbaa !5
  %196 = getelementptr inbounds i8, ptr %195, i64 28
  %197 = load ptr, ptr %3, align 8, !tbaa !5
  %198 = getelementptr inbounds %struct.FIL, ptr %197, i32 0, i32 0
  %199 = getelementptr inbounds %struct.FFOBJID, ptr %198, i32 0, i32 5
  %200 = load i64, ptr %199, align 8, !tbaa !26
  %201 = trunc i64 %200 to i32
  call void @st_dword(ptr noundef %196, i32 noundef %201)
  %202 = load ptr, ptr %7, align 8, !tbaa !5
  %203 = getelementptr inbounds i8, ptr %202, i64 22
  %204 = load i32, ptr %6, align 4, !tbaa !9
  call void @st_dword(ptr noundef %203, i32 noundef %204)
  %205 = load ptr, ptr %7, align 8, !tbaa !5
  %206 = getelementptr inbounds i8, ptr %205, i64 18
  call void @st_word(ptr noundef %206, i16 noundef zeroext 0)
  %207 = load ptr, ptr %5, align 8, !tbaa !5
  %208 = getelementptr inbounds %struct.FATFS, ptr %207, i32 0, i32 4
  store i8 1, ptr %208, align 4, !tbaa !30
  %209 = load ptr, ptr %5, align 8, !tbaa !5
  %210 = call i32 @sync_fs(ptr noundef %209)
  store i32 %210, ptr %4, align 4, !tbaa !9
  %211 = load ptr, ptr %3, align 8, !tbaa !5
  %212 = getelementptr inbounds %struct.FIL, ptr %211, i32 0, i32 1
  %213 = load i8, ptr %212, align 8, !tbaa !11
  %214 = zext i8 %213 to i32
  %215 = and i32 %214, 191
  %216 = trunc i32 %215 to i8
  store i8 %216, ptr %212, align 8, !tbaa !11
  br label %217

217:                                              ; preds = %176, %168
  br label %218

218:                                              ; preds = %217, %167
  br label %219

219:                                              ; preds = %218, %16
  br label %220

220:                                              ; preds = %219, %1
  %221 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %221, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %222

222:                                              ; preds = %220, %164, %42
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  %223 = load i32, ptr %2, align 4
  ret i32 %223
}

; Function Attrs: nounwind uwtable
declare hidden i32 @fill_first_frag(ptr noundef) #2

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

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

; Function Attrs: nounwind uwtable
declare hidden void @st_qword(ptr noundef, i64 noundef) #2

; Function Attrs: nounwind uwtable
declare hidden i32 @sync_fs(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden void @st_word(ptr noundef, i16 noundef zeroext) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #3 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !7, i64 48}
!12 = !{!"", !13, i64 0, !7, i64 48, !7, i64 49, !15, i64 56, !10, i64 64, !15, i64 72, !15, i64 80, !6, i64 88, !6, i64 96, !7, i64 104}
!13 = !{!"", !6, i64 0, !14, i64 8, !7, i64 10, !7, i64 11, !10, i64 12, !15, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44}
!14 = !{!"short", !7, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{!17, !7, i64 1}
!17 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4, !7, i64 5, !14, i64 6, !14, i64 8, !14, i64 10, !6, i64 16, !6, i64 24, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !15, i64 64, !15, i64 72, !15, i64 80, !15, i64 88, !15, i64 96, !15, i64 104, !7, i64 112}
!18 = !{!12, !15, i64 72}
!19 = !{!17, !7, i64 0}
!20 = !{!12, !10, i64 64}
!21 = !{!17, !6, i64 16}
!22 = !{!17, !6, i64 24}
!23 = !{!7, !7, i64 0}
!24 = !{!12, !7, i64 11}
!25 = !{!12, !10, i64 12}
!26 = !{!12, !15, i64 16}
!27 = !{!12, !15, i64 80}
!28 = !{!12, !6, i64 88}
!29 = !{!12, !6, i64 0}
!30 = !{!17, !7, i64 4}


; 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.DIR = type { %struct.FFOBJID, i32, i32, i64, ptr, [12 x i8], i32, ptr }
%struct.FFOBJID = type { ptr, i16, i8, i8, i32, i64, i32, i32, i32, i32, i32, i32 }

; 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

declare ptr @ff_memalloc(i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden void @st_dword(ptr noundef, i32 noundef) local_unnamed_addr #2

declare i32 @get_fattime() local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i32 @store_xdir(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden void @st_clust(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

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

declare void @ff_memfree(ptr noundef) local_unnamed_addr #1

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

declare i32 @disk_write(i8 noundef zeroext, ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @f_sync(ptr noundef %0) local_unnamed_addr #2 {
  %2 = alloca ptr, align 8
  %3 = alloca %struct.DIR, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #3
  %4 = call i32 @validate(ptr noundef %0, ptr noundef nonnull %2)
  %5 = icmp eq i32 %4, 0
  br i1 %5, label %6, label %.thread

6:                                                ; preds = %1
  %7 = getelementptr inbounds i8, ptr %0, i64 48
  %8 = load i8, ptr %7, align 8, !tbaa !5
  %9 = and i8 %8, 64
  %.not = icmp eq i8 %9, 0
  br i1 %.not, label %.thread, label %10

10:                                               ; preds = %6
  %.not49 = icmp sgt i8 %8, -1
  br i1 %.not49, label %22, label %11

11:                                               ; preds = %10
  %12 = load ptr, ptr %2, align 8, !tbaa !14
  %13 = getelementptr inbounds i8, ptr %12, i64 1
  %14 = load i8, ptr %13, align 1, !tbaa !15
  %15 = getelementptr inbounds i8, ptr %0, i64 104
  %16 = getelementptr inbounds i8, ptr %0, i64 72
  %17 = load i64, ptr %16, align 8, !tbaa !17
  %18 = call i32 @disk_write(i8 noundef zeroext %14, ptr noundef nonnull %15, i64 noundef %17, i32 noundef 1) #3
  %.not50 = icmp eq i32 %18, 0
  br i1 %.not50, label %19, label %.thread

19:                                               ; preds = %11
  %20 = load i8, ptr %7, align 8, !tbaa !5
  %21 = and i8 %20, 127
  store i8 %21, ptr %7, align 8, !tbaa !5
  br label %22

22:                                               ; preds = %19, %10
  %23 = call i32 @get_fattime() #3
  %24 = load ptr, ptr %2, align 8, !tbaa !14
  %25 = load i8, ptr %24, align 8, !tbaa !18
  %26 = icmp eq i8 %25, 4
  br i1 %26, label %27, label %92

27:                                               ; preds = %22
  %28 = call i32 @fill_first_frag(ptr noundef nonnull %0)
  %29 = icmp eq i32 %28, 0
  br i1 %29, label %30, label %.thread

30:                                               ; preds = %27
  %31 = getelementptr inbounds i8, ptr %0, i64 64
  %32 = load i32, ptr %31, align 8, !tbaa !19
  %33 = call i32 @fill_last_frag(ptr noundef nonnull %0, i32 noundef %32, i32 noundef -1)
  %34 = icmp eq i32 %33, 0
  br i1 %34, label %35, label %.thread

35:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 96, ptr nonnull %3) #3
  %36 = call ptr @ff_memalloc(i32 noundef 1120) #3
  %.not51.not = icmp eq ptr %36, null
  br i1 %.not51.not, label %91, label %37

37:                                               ; preds = %35
  %38 = load ptr, ptr %2, align 8, !tbaa !14
  %39 = getelementptr inbounds i8, ptr %38, i64 16
  store ptr %36, ptr %39, align 8, !tbaa !20
  %40 = getelementptr inbounds i8, ptr %36, i64 512
  %41 = getelementptr inbounds i8, ptr %38, i64 24
  store ptr %40, ptr %41, align 8, !tbaa !21
  %42 = call i32 @load_obj_xdir(ptr noundef nonnull %3, ptr noundef nonnull %0)
  %43 = icmp eq i32 %42, 0
  br i1 %43, label %44, label %90

44:                                               ; preds = %37
  %45 = load ptr, ptr %2, align 8, !tbaa !14
  %46 = getelementptr inbounds i8, ptr %45, i64 24
  %47 = load ptr, ptr %46, align 8, !tbaa !21
  %48 = getelementptr inbounds i8, ptr %47, i64 4
  %49 = load i8, ptr %48, align 1, !tbaa !22
  %50 = or i8 %49, 32
  store i8 %50, ptr %48, align 1, !tbaa !22
  %51 = getelementptr inbounds i8, ptr %0, i64 11
  %52 = load i8, ptr %51, align 1, !tbaa !23
  %53 = or i8 %52, 1
  %54 = load ptr, ptr %2, align 8, !tbaa !14
  %55 = getelementptr inbounds i8, ptr %54, i64 24
  %56 = load ptr, ptr %55, align 8, !tbaa !21
  %57 = getelementptr inbounds i8, ptr %56, i64 33
  store i8 %53, ptr %57, align 1, !tbaa !22
  %58 = load ptr, ptr %55, align 8, !tbaa !21
  %59 = getelementptr inbounds i8, ptr %58, i64 52
  %60 = getelementptr inbounds i8, ptr %0, i64 12
  %61 = load i32, ptr %60, align 4, !tbaa !24
  call void @st_dword(ptr noundef nonnull %59, i32 noundef %61)
  %62 = load ptr, ptr %2, align 8, !tbaa !14
  %63 = getelementptr inbounds i8, ptr %62, i64 24
  %64 = load ptr, ptr %63, align 8, !tbaa !21
  %65 = getelementptr inbounds i8, ptr %64, i64 56
  %66 = getelementptr inbounds i8, ptr %0, i64 16
  %67 = load i64, ptr %66, align 8, !tbaa !25
  call void @st_qword(ptr noundef nonnull %65, i64 noundef %67)
  %68 = load ptr, ptr %2, align 8, !tbaa !14
  %69 = getelementptr inbounds i8, ptr %68, i64 24
  %70 = load ptr, ptr %69, align 8, !tbaa !21
  %71 = getelementptr inbounds i8, ptr %70, i64 40
  %72 = load i64, ptr %66, align 8, !tbaa !25
  call void @st_qword(ptr noundef nonnull %71, i64 noundef %72)
  %73 = load ptr, ptr %2, align 8, !tbaa !14
  %74 = getelementptr inbounds i8, ptr %73, i64 24
  %75 = load ptr, ptr %74, align 8, !tbaa !21
  %76 = getelementptr inbounds i8, ptr %75, i64 12
  call void @st_dword(ptr noundef nonnull %76, i32 noundef %23)
  %77 = load ptr, ptr %2, align 8, !tbaa !14
  %78 = getelementptr inbounds i8, ptr %77, i64 24
  %79 = load ptr, ptr %78, align 8, !tbaa !21
  %80 = getelementptr inbounds i8, ptr %79, i64 21
  store i8 0, ptr %80, align 1, !tbaa !22
  %81 = load ptr, ptr %78, align 8, !tbaa !21
  %82 = getelementptr inbounds i8, ptr %81, i64 16
  call void @st_dword(ptr noundef nonnull %82, i32 noundef 0)
  %83 = call i32 @store_xdir(ptr noundef nonnull %3)
  %84 = icmp eq i32 %83, 0
  br i1 %84, label %85, label %90

85:                                               ; preds = %44
  %86 = load ptr, ptr %2, align 8, !tbaa !14
  %87 = call i32 @sync_fs(ptr noundef %86)
  %88 = load i8, ptr %7, align 8, !tbaa !5
  %89 = and i8 %88, -65
  store i8 %89, ptr %7, align 8, !tbaa !5
  br label %90

90:                                               ; preds = %44, %85, %37
  %.142 = phi i32 [ %87, %85 ], [ %83, %44 ], [ %42, %37 ]
  call void @ff_memfree(ptr noundef nonnull %36) #3
  br label %91

91:                                               ; preds = %35, %90
  %spec.select = phi i32 [ %.142, %90 ], [ 17, %35 ]
  call void @llvm.lifetime.end.p0(i64 96, ptr nonnull %3) #3
  br label %.thread

92:                                               ; preds = %22
  %93 = getelementptr inbounds i8, ptr %0, i64 80
  %94 = load i64, ptr %93, align 8, !tbaa !26
  %95 = call i32 @move_window(ptr noundef nonnull %24, i64 noundef %94)
  %96 = icmp eq i32 %95, 0
  br i1 %96, label %97, label %.thread

97:                                               ; preds = %92
  %98 = getelementptr inbounds i8, ptr %0, i64 88
  %99 = load ptr, ptr %98, align 8, !tbaa !27
  %100 = getelementptr inbounds i8, ptr %99, i64 11
  %101 = load i8, ptr %100, align 1, !tbaa !22
  %102 = or i8 %101, 32
  store i8 %102, ptr %100, align 1, !tbaa !22
  %103 = load ptr, ptr %0, align 8, !tbaa !28
  %104 = getelementptr inbounds i8, ptr %0, i64 12
  %105 = load i32, ptr %104, align 4, !tbaa !24
  call void @st_clust(ptr noundef %103, ptr noundef %99, i32 noundef %105)
  %106 = getelementptr inbounds i8, ptr %99, i64 28
  %107 = getelementptr inbounds i8, ptr %0, i64 16
  %108 = load i64, ptr %107, align 8, !tbaa !25
  %109 = trunc i64 %108 to i32
  call void @st_dword(ptr noundef nonnull %106, i32 noundef %109)
  %110 = getelementptr inbounds i8, ptr %99, i64 22
  call void @st_dword(ptr noundef nonnull %110, i32 noundef %23)
  %111 = getelementptr inbounds i8, ptr %99, i64 18
  call void @st_word(ptr noundef nonnull %111, i16 noundef zeroext 0)
  %112 = load ptr, ptr %2, align 8, !tbaa !14
  %113 = getelementptr inbounds i8, ptr %112, i64 4
  store i8 1, ptr %113, align 4, !tbaa !29
  %114 = call i32 @sync_fs(ptr noundef %112)
  %115 = load i8, ptr %7, align 8, !tbaa !5
  %116 = and i8 %115, -65
  store i8 %116, ptr %7, align 8, !tbaa !5
  br label %.thread

.thread:                                          ; preds = %27, %91, %1, %30, %97, %92, %6, %11
  %.1 = phi i32 [ 1, %11 ], [ %33, %30 ], [ %114, %97 ], [ %95, %92 ], [ 0, %6 ], [ %4, %1 ], [ %spec.select, %91 ], [ %28, %27 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #3
  ret i32 %.1
}

; Function Attrs: nounwind uwtable
declare hidden i32 @fill_first_frag(ptr noundef) local_unnamed_addr #2

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

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

; Function Attrs: nounwind uwtable
declare hidden void @st_qword(ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden i32 @sync_fs(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden void @st_word(ptr noundef, i16 noundef zeroext) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #3 = { 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, !9, i64 48}
!6 = !{!"", !7, i64 0, !9, i64 48, !9, i64 49, !13, i64 56, !12, i64 64, !13, i64 72, !13, i64 80, !8, i64 88, !8, i64 96, !9, i64 104}
!7 = !{!"", !8, i64 0, !11, i64 8, !9, i64 10, !9, i64 11, !12, i64 12, !13, i64 16, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !12, i64 40, !12, i64 44}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"short", !9, i64 0}
!12 = !{!"int", !9, i64 0}
!13 = !{!"long", !9, i64 0}
!14 = !{!8, !8, i64 0}
!15 = !{!16, !9, i64 1}
!16 = !{!"", !9, i64 0, !9, i64 1, !9, i64 2, !9, i64 3, !9, i64 4, !9, i64 5, !11, i64 6, !11, i64 8, !11, i64 10, !8, i64 16, !8, i64 24, !12, i64 32, !12, i64 36, !12, i64 40, !12, i64 44, !12, i64 48, !12, i64 52, !12, i64 56, !12, i64 60, !13, i64 64, !13, i64 72, !13, i64 80, !13, i64 88, !13, i64 96, !13, i64 104, !9, i64 112}
!17 = !{!6, !13, i64 72}
!18 = !{!16, !9, i64 0}
!19 = !{!6, !12, i64 64}
!20 = !{!16, !8, i64 16}
!21 = !{!16, !8, i64 24}
!22 = !{!9, !9, i64 0}
!23 = !{!6, !9, i64 11}
!24 = !{!6, !12, i64 12}
!25 = !{!6, !13, i64 16}
!26 = !{!6, !13, i64 80}
!27 = !{!6, !8, i64 88}
!28 = !{!6, !8, i64 0}
!29 = !{!16, !9, i64 4}


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