; LLVM IR from mlcommons/tiny :: benchmark/interface/Middlewares/ST/filex/common/src/fx_media_close.ll (fx_media_close)

; 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.FX_MEDIA_STRUCT = type { i64, ptr, ptr, i64, i32, i64, ptr, ptr, i64, i64, i32, i32, i32, i64, i64, i32, i32, i32, i32, i32, i32, i32, i32, i32, i64, i32, i64, i64, i32, i64, i64, ptr, i32, i32, ptr, i64, i64, i64, i32, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, i64, ptr, ptr, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, %struct.TX_MUTEX_STRUCT, i32, %struct.FX_DIR_ENTRY_STRUCT, %struct.FX_DIR_ENTRY_STRUCT, [256 x i8], [256 x i8], %struct.FX_PATH_STRUCT, [16 x %struct.FX_FAT_CACHE_ENTRY_STRUCT], [128 x i8], i64, [1024 x i8], [256 x %struct.FX_CACHED_SECTOR_STRUCT], i64, i64, i64, i64, i8 }
%struct.TX_MUTEX_STRUCT = type { i64, ptr, i32, ptr, i32, i32, ptr, i32, ptr, ptr, i32, ptr, ptr }
%struct.FX_DIR_ENTRY_STRUCT = type { ptr, [13 x i8], i32, i32, i8, i8, i8, i32, i32, i32, i32, i32, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 }
%struct.FX_PATH_STRUCT = type { %struct.FX_DIR_ENTRY_STRUCT, [256 x i8], [256 x i8], i64 }
%struct.FX_FAT_CACHE_ENTRY_STRUCT = type { i64, i64, i64 }
%struct.FX_CACHED_SECTOR_STRUCT = type { ptr, i64, i8, i8, i8, i8, ptr }
%struct.FX_FILE_STRUCT = type { i64, ptr, i64, i8, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, ptr, ptr, ptr, %struct.FX_DIR_ENTRY_STRUCT, [256 x i8], i64, ptr }

@_fx_system_time = external global i32, align 4
@_fx_system_date = external global i32, align 4
@_fx_system_media_opened_count = external global i64, align 8
@_fx_system_media_opened_ptr = external global ptr, align 8

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

15:                                               ; preds = %1
  store i32 17, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %318

16:                                               ; preds = %1
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %17, i32 0, i32 0
  %19 = load i64, ptr %18, align 8, !tbaa !9
  %20 = icmp ne i64 %19, 1296385097
  br i1 %20, label %21, label %22

21:                                               ; preds = %16
  store i32 17, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %318

22:                                               ; preds = %16
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %23, i32 0, i32 112
  %25 = call i32 @_tx_mutex_get(ptr noundef %24, i64 noundef 4294967295)
  %26 = icmp ne i32 %25, 0
  br i1 %26, label %27, label %28

27:                                               ; preds = %22
  store i32 17, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %318

28:                                               ; preds = %22
  br label %29

29:                                               ; preds = %28
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %30, i32 0, i32 49
  %32 = load i64, ptr %31, align 8, !tbaa !17
  store i64 %32, ptr %5, align 8, !tbaa !18
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %33, i32 0, i32 48
  %35 = load ptr, ptr %34, align 8, !tbaa !19
  store ptr %35, ptr %6, align 8, !tbaa !5
  br label %36

36:                                               ; preds = %82, %29
  %37 = load i64, ptr %5, align 8, !tbaa !18
  %38 = icmp ne i64 %37, 0
  br i1 %38, label %39, label %90

39:                                               ; preds = %36
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.FX_FILE_STRUCT, ptr %40, i32 0, i32 2
  %42 = load i64, ptr %41, align 8, !tbaa !20
  %43 = icmp eq i64 %42, 1
  br i1 %43, label %44, label %82

44:                                               ; preds = %39
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.FX_FILE_STRUCT, ptr %45, i32 0, i32 3
  %47 = load i8, ptr %46, align 8, !tbaa !22
  %48 = zext i8 %47 to i32
  %49 = icmp ne i32 %48, 0
  br i1 %49, label %50, label %82

50:                                               ; preds = %44
  %51 = call i32 @__disable_interrupts()
  store i32 %51, ptr %4, align 4, !tbaa !23
  %52 = load i32, ptr @_fx_system_time, align 4, !tbaa !23
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.FX_FILE_STRUCT, ptr %53, i32 0, i32 19
  %55 = getelementptr inbounds %struct.FX_DIR_ENTRY_STRUCT, ptr %54, i32 0, i32 10
  store i32 %52, ptr %55, align 8, !tbaa !24
  %56 = load i32, ptr @_fx_system_date, align 4, !tbaa !23
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.FX_FILE_STRUCT, ptr %57, i32 0, i32 19
  %59 = getelementptr inbounds %struct.FX_DIR_ENTRY_STRUCT, ptr %58, i32 0, i32 11
  store i32 %56, ptr %59, align 4, !tbaa !25
  %60 = load i32, ptr %4, align 4, !tbaa !23
  call void @__restore_interrupt(i32 noundef %60)
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.FX_FILE_STRUCT, ptr %61, i32 0, i32 14
  %63 = load i64, ptr %62, align 8, !tbaa !26
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.FX_FILE_STRUCT, ptr %64, i32 0, i32 19
  %66 = getelementptr inbounds %struct.FX_DIR_ENTRY_STRUCT, ptr %65, i32 0, i32 13
  store i64 %63, ptr %66, align 8, !tbaa !27
  %67 = load ptr, ptr %3, align 8, !tbaa !5
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.FX_FILE_STRUCT, ptr %68, i32 0, i32 19
  %70 = call i32 @_fx_directory_entry_write(ptr noundef %67, ptr noundef %69)
  store i32 %70, ptr %7, align 4, !tbaa !23
  %71 = load i32, ptr %7, align 4, !tbaa !23
  %72 = icmp ne i32 %71, 0
  br i1 %72, label %73, label %79

73:                                               ; preds = %50
  %74 = load ptr, ptr %3, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %74, i32 0, i32 112
  %76 = call i32 @_tx_mutex_put(ptr noundef %75)
  %77 = load ptr, ptr %3, align 8, !tbaa !5
  %78 = call i32 @_fx_media_abort(ptr noundef %77)
  store i32 144, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %318

79:                                               ; preds = %50
  %80 = load ptr, ptr %6, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.FX_FILE_STRUCT, ptr %80, i32 0, i32 3
  store i8 0, ptr %81, align 8, !tbaa !22
  br label %82

82:                                               ; preds = %79, %44, %39
  %83 = load ptr, ptr %6, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.FX_FILE_STRUCT, ptr %83, i32 0, i32 0
  store i64 1179208771, ptr %84, align 8, !tbaa !28
  %85 = load ptr, ptr %6, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.FX_FILE_STRUCT, ptr %85, i32 0, i32 17
  %87 = load ptr, ptr %86, align 8, !tbaa !29
  store ptr %87, ptr %6, align 8, !tbaa !5
  %88 = load i64, ptr %5, align 8, !tbaa !18
  %89 = add i64 %88, -1
  store i64 %89, ptr %5, align 8, !tbaa !18
  br label %36, !llvm.loop !30

90:                                               ; preds = %36
  %91 = load ptr, ptr %3, align 8, !tbaa !5
  %92 = call i32 @_fx_utility_FAT_flush(ptr noundef %91)
  %93 = load ptr, ptr %3, align 8, !tbaa !5
  %94 = call i32 @_fx_utility_FAT_map_flush(ptr noundef %93)
  %95 = load ptr, ptr %3, align 8, !tbaa !5
  %96 = load ptr, ptr %3, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %96, i32 0, i32 13
  %98 = load i64, ptr %97, align 8, !tbaa !32
  %99 = call i32 @_fx_utility_logical_sector_flush(ptr noundef %95, i64 noundef 1, i64 noundef %98, i32 noundef 0)
  store i32 %99, ptr %7, align 4, !tbaa !23
  %100 = load i32, ptr %7, align 4, !tbaa !23
  %101 = icmp ne i32 %100, 0
  br i1 %101, label %102, label %108

102:                                              ; preds = %90
  %103 = load ptr, ptr %3, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %103, i32 0, i32 112
  %105 = call i32 @_tx_mutex_put(ptr noundef %104)
  %106 = load ptr, ptr %3, align 8, !tbaa !5
  %107 = call i32 @_fx_media_abort(ptr noundef %106)
  store i32 144, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %318

108:                                              ; preds = %90
  %109 = load ptr, ptr %3, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %109, i32 0, i32 24
  %111 = load i64, ptr %110, align 8, !tbaa !33
  %112 = icmp ne i64 %111, 0
  br i1 %112, label %113, label %251

113:                                              ; preds = %108
  %114 = load ptr, ptr %3, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %114, i32 0, i32 25
  %116 = load i32, ptr %115, align 8, !tbaa !34
  %117 = zext i32 %116 to i64
  %118 = load ptr, ptr %3, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %118, i32 0, i32 29
  %120 = load i64, ptr %119, align 8, !tbaa !35
  %121 = icmp ne i64 %117, %120
  br i1 %121, label %122, label %251

122:                                              ; preds = %113
  %123 = load ptr, ptr %3, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %123, i32 0, i32 40
  %125 = load i32, ptr %124, align 8, !tbaa !36
  %126 = icmp eq i32 %125, 0
  br i1 %126, label %127, label %251

127:                                              ; preds = %122
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %128 = load ptr, ptr %3, align 8, !tbaa !5
  %129 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %128, i32 0, i32 7
  %130 = load ptr, ptr %129, align 8, !tbaa !37
  %131 = getelementptr inbounds %struct.FX_CACHED_SECTOR_STRUCT, ptr %130, i32 0, i32 0
  %132 = load ptr, ptr %131, align 8, !tbaa !38
  store ptr %132, ptr %9, align 8, !tbaa !5
  %133 = load ptr, ptr %3, align 8, !tbaa !5
  %134 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %133, i32 0, i32 7
  %135 = load ptr, ptr %134, align 8, !tbaa !37
  %136 = getelementptr inbounds %struct.FX_CACHED_SECTOR_STRUCT, ptr %135, i32 0, i32 1
  store i64 -1, ptr %136, align 8, !tbaa !40
  %137 = load ptr, ptr %3, align 8, !tbaa !5
  %138 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %137, i32 0, i32 7
  %139 = load ptr, ptr %138, align 8, !tbaa !37
  %140 = getelementptr inbounds %struct.FX_CACHED_SECTOR_STRUCT, ptr %139, i32 0, i32 3
  store i8 0, ptr %140, align 1, !tbaa !41
  %141 = load ptr, ptr %3, align 8, !tbaa !5
  %142 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %141, i32 0, i32 32
  store i32 0, ptr %142, align 8, !tbaa !42
  %143 = load ptr, ptr %3, align 8, !tbaa !5
  %144 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %143, i32 0, i32 33
  store i32 144, ptr %144, align 4, !tbaa !43
  %145 = load ptr, ptr %9, align 8, !tbaa !5
  %146 = load ptr, ptr %3, align 8, !tbaa !5
  %147 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %146, i32 0, i32 34
  store ptr %145, ptr %147, align 8, !tbaa !44
  %148 = load ptr, ptr %3, align 8, !tbaa !5
  %149 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %148, i32 0, i32 24
  %150 = load i64, ptr %149, align 8, !tbaa !33
  %151 = load ptr, ptr %3, align 8, !tbaa !5
  %152 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %151, i32 0, i32 35
  store i64 %150, ptr %152, align 8, !tbaa !45
  %153 = load ptr, ptr %3, align 8, !tbaa !5
  %154 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %153, i32 0, i32 36
  store i64 1, ptr %154, align 8, !tbaa !46
  %155 = load ptr, ptr %3, align 8, !tbaa !5
  %156 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %155, i32 0, i32 44
  store i32 3, ptr %156, align 8, !tbaa !47
  %157 = load ptr, ptr %3, align 8, !tbaa !5
  %158 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %157, i32 0, i32 105
  %159 = load i64, ptr %158, align 8, !tbaa !48
  %160 = add i64 %159, 1
  store i64 %160, ptr %158, align 8, !tbaa !48
  %161 = load ptr, ptr %3, align 8, !tbaa !5
  %162 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %161, i32 0, i32 45
  %163 = load ptr, ptr %162, align 8, !tbaa !49
  %164 = load ptr, ptr %3, align 8, !tbaa !5
  call void %163(ptr noundef %164)
  %165 = load ptr, ptr %3, align 8, !tbaa !5
  %166 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %165, i32 0, i32 33
  %167 = load i32, ptr %166, align 4, !tbaa !43
  %168 = icmp ne i32 %167, 0
  br i1 %168, label %169, label %175

169:                                              ; preds = %127
  %170 = load ptr, ptr %3, align 8, !tbaa !5
  %171 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %170, i32 0, i32 112
  %172 = call i32 @_tx_mutex_put(ptr noundef %171)
  %173 = load ptr, ptr %3, align 8, !tbaa !5
  %174 = call i32 @_fx_media_abort(ptr noundef %173)
  store i32 144, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %248

175:                                              ; preds = %127
  %176 = load ptr, ptr %3, align 8, !tbaa !5
  %177 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %176, i32 0, i32 34
  %178 = load ptr, ptr %177, align 8, !tbaa !44
  store ptr %178, ptr %9, align 8, !tbaa !5
  %179 = load ptr, ptr %9, align 8, !tbaa !5
  %180 = getelementptr inbounds i8, ptr %179, i64 0
  %181 = call i64 @_fx_utility_32_unsigned_read(ptr noundef %180)
  store i64 %181, ptr %10, align 8, !tbaa !18
  %182 = load i64, ptr %10, align 8, !tbaa !18
  %183 = icmp eq i64 %182, 1096897106
  br i1 %183, label %184, label %247

184:                                              ; preds = %175
  %185 = load ptr, ptr %9, align 8, !tbaa !5
  %186 = getelementptr inbounds i8, ptr %185, i64 484
  %187 = call i64 @_fx_utility_32_unsigned_read(ptr noundef %186)
  store i64 %187, ptr %10, align 8, !tbaa !18
  %188 = load i64, ptr %10, align 8, !tbaa !18
  %189 = icmp eq i64 %188, 1631679090
  br i1 %189, label %190, label %246

190:                                              ; preds = %184
  %191 = load ptr, ptr %9, align 8, !tbaa !5
  %192 = getelementptr inbounds i8, ptr %191, i64 488
  %193 = load ptr, ptr %3, align 8, !tbaa !5
  %194 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %193, i32 0, i32 29
  %195 = load i64, ptr %194, align 8, !tbaa !35
  call void @_fx_utility_32_unsigned_write(ptr noundef %192, i64 noundef %195)
  %196 = load ptr, ptr %9, align 8, !tbaa !5
  %197 = getelementptr inbounds i8, ptr %196, i64 492
  %198 = load ptr, ptr %3, align 8, !tbaa !5
  %199 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %198, i32 0, i32 30
  %200 = load i64, ptr %199, align 8, !tbaa !50
  call void @_fx_utility_32_unsigned_write(ptr noundef %197, i64 noundef %200)
  %201 = load ptr, ptr %3, align 8, !tbaa !5
  %202 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %201, i32 0, i32 32
  store i32 1, ptr %202, align 8, !tbaa !42
  %203 = load ptr, ptr %3, align 8, !tbaa !5
  %204 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %203, i32 0, i32 33
  store i32 144, ptr %204, align 4, !tbaa !43
  %205 = load ptr, ptr %9, align 8, !tbaa !5
  %206 = load ptr, ptr %3, align 8, !tbaa !5
  %207 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %206, i32 0, i32 34
  store ptr %205, ptr %207, align 8, !tbaa !44
  %208 = load ptr, ptr %3, align 8, !tbaa !5
  %209 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %208, i32 0, i32 24
  %210 = load i64, ptr %209, align 8, !tbaa !33
  %211 = load ptr, ptr %3, align 8, !tbaa !5
  %212 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %211, i32 0, i32 35
  store i64 %210, ptr %212, align 8, !tbaa !45
  %213 = load ptr, ptr %3, align 8, !tbaa !5
  %214 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %213, i32 0, i32 36
  store i64 1, ptr %214, align 8, !tbaa !46
  %215 = load ptr, ptr %3, align 8, !tbaa !5
  %216 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %215, i32 0, i32 44
  store i32 3, ptr %216, align 8, !tbaa !47
  %217 = load ptr, ptr %3, align 8, !tbaa !5
  %218 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %217, i32 0, i32 42
  store i32 1, ptr %218, align 8, !tbaa !51
  %219 = load ptr, ptr %3, align 8, !tbaa !5
  %220 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %219, i32 0, i32 106
  %221 = load i64, ptr %220, align 8, !tbaa !52
  %222 = add i64 %221, 1
  store i64 %222, ptr %220, align 8, !tbaa !52
  %223 = load ptr, ptr %3, align 8, !tbaa !5
  %224 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %223, i32 0, i32 45
  %225 = load ptr, ptr %224, align 8, !tbaa !49
  %226 = load ptr, ptr %3, align 8, !tbaa !5
  call void %225(ptr noundef %226)
  %227 = load ptr, ptr %3, align 8, !tbaa !5
  %228 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %227, i32 0, i32 42
  store i32 0, ptr %228, align 8, !tbaa !51
  %229 = load ptr, ptr %3, align 8, !tbaa !5
  %230 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %229, i32 0, i32 33
  %231 = load i32, ptr %230, align 4, !tbaa !43
  %232 = icmp ne i32 %231, 0
  br i1 %232, label %233, label %239

233:                                              ; preds = %190
  %234 = load ptr, ptr %3, align 8, !tbaa !5
  %235 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %234, i32 0, i32 112
  %236 = call i32 @_tx_mutex_put(ptr noundef %235)
  %237 = load ptr, ptr %3, align 8, !tbaa !5
  %238 = call i32 @_fx_media_abort(ptr noundef %237)
  store i32 144, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %248

239:                                              ; preds = %190
  %240 = load ptr, ptr %3, align 8, !tbaa !5
  %241 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %240, i32 0, i32 29
  %242 = load i64, ptr %241, align 8, !tbaa !35
  %243 = trunc i64 %242 to i32
  %244 = load ptr, ptr %3, align 8, !tbaa !5
  %245 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %244, i32 0, i32 25
  store i32 %243, ptr %245, align 8, !tbaa !34
  br label %246

246:                                              ; preds = %239, %184
  br label %247

247:                                              ; preds = %246, %175
  store i32 0, ptr %8, align 4
  br label %248

248:                                              ; preds = %247, %233, %169
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  %249 = load i32, ptr %8, align 4
  switch i32 %249, label %318 [
    i32 0, label %250
  ]

250:                                              ; preds = %248
  br label %251

251:                                              ; preds = %250, %122, %113, %108
  %252 = load ptr, ptr %3, align 8, !tbaa !5
  %253 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %252, i32 0, i32 110
  %254 = load i64, ptr %253, align 8, !tbaa !53
  %255 = add i64 %254, 1
  store i64 %255, ptr %253, align 8, !tbaa !53
  %256 = load ptr, ptr %3, align 8, !tbaa !5
  %257 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %256, i32 0, i32 32
  store i32 2, ptr %257, align 8, !tbaa !42
  %258 = load ptr, ptr %3, align 8, !tbaa !5
  %259 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %258, i32 0, i32 33
  store i32 144, ptr %259, align 4, !tbaa !43
  %260 = load ptr, ptr %3, align 8, !tbaa !5
  %261 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %260, i32 0, i32 45
  %262 = load ptr, ptr %261, align 8, !tbaa !49
  %263 = load ptr, ptr %3, align 8, !tbaa !5
  call void %262(ptr noundef %263)
  %264 = load ptr, ptr %3, align 8, !tbaa !5
  %265 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %264, i32 0, i32 32
  store i32 8, ptr %265, align 8, !tbaa !42
  %266 = load ptr, ptr %3, align 8, !tbaa !5
  %267 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %266, i32 0, i32 33
  store i32 144, ptr %267, align 4, !tbaa !43
  %268 = load ptr, ptr %3, align 8, !tbaa !5
  %269 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %268, i32 0, i32 45
  %270 = load ptr, ptr %269, align 8, !tbaa !49
  %271 = load ptr, ptr %3, align 8, !tbaa !5
  call void %270(ptr noundef %271)
  %272 = call i32 @__disable_interrupts()
  store i32 %272, ptr %4, align 4, !tbaa !23
  %273 = load i64, ptr @_fx_system_media_opened_count, align 8, !tbaa !18
  %274 = icmp eq i64 %273, 1
  br i1 %274, label %275, label %276

275:                                              ; preds = %251
  store ptr null, ptr @_fx_system_media_opened_ptr, align 8, !tbaa !5
  br label %299

276:                                              ; preds = %251
  %277 = load ptr, ptr %3, align 8, !tbaa !5
  %278 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %277, i32 0, i32 51
  %279 = load ptr, ptr %278, align 8, !tbaa !54
  %280 = load ptr, ptr %3, align 8, !tbaa !5
  %281 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %280, i32 0, i32 50
  %282 = load ptr, ptr %281, align 8, !tbaa !55
  %283 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %282, i32 0, i32 51
  store ptr %279, ptr %283, align 8, !tbaa !54
  %284 = load ptr, ptr %3, align 8, !tbaa !5
  %285 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %284, i32 0, i32 50
  %286 = load ptr, ptr %285, align 8, !tbaa !55
  %287 = load ptr, ptr %3, align 8, !tbaa !5
  %288 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %287, i32 0, i32 51
  %289 = load ptr, ptr %288, align 8, !tbaa !54
  %290 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %289, i32 0, i32 50
  store ptr %286, ptr %290, align 8, !tbaa !55
  %291 = load ptr, ptr @_fx_system_media_opened_ptr, align 8, !tbaa !5
  %292 = load ptr, ptr %3, align 8, !tbaa !5
  %293 = icmp eq ptr %291, %292
  br i1 %293, label %294, label %298

294:                                              ; preds = %276
  %295 = load ptr, ptr %3, align 8, !tbaa !5
  %296 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %295, i32 0, i32 50
  %297 = load ptr, ptr %296, align 8, !tbaa !55
  store ptr %297, ptr @_fx_system_media_opened_ptr, align 8, !tbaa !5
  br label %298

298:                                              ; preds = %294, %276
  br label %299

299:                                              ; preds = %298, %275
  %300 = load i64, ptr @_fx_system_media_opened_count, align 8, !tbaa !18
  %301 = add i64 %300, -1
  store i64 %301, ptr @_fx_system_media_opened_count, align 8, !tbaa !18
  %302 = load ptr, ptr %3, align 8, !tbaa !5
  %303 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %302, i32 0, i32 0
  store i64 1296385091, ptr %303, align 8, !tbaa !9
  %304 = load i32, ptr %4, align 4, !tbaa !23
  call void @__restore_interrupt(i32 noundef %304)
  %305 = load ptr, ptr %3, align 8, !tbaa !5
  %306 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %305, i32 0, i32 112
  %307 = call i32 @_tx_mutex_delete(ptr noundef %306)
  %308 = load ptr, ptr %3, align 8, !tbaa !5
  %309 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %308, i32 0, i32 47
  %310 = load ptr, ptr %309, align 8, !tbaa !56
  %311 = icmp ne ptr %310, null
  br i1 %311, label %312, label %317

312:                                              ; preds = %299
  %313 = load ptr, ptr %3, align 8, !tbaa !5
  %314 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %313, i32 0, i32 47
  %315 = load ptr, ptr %314, align 8, !tbaa !56
  %316 = load ptr, ptr %3, align 8, !tbaa !5
  call void %315(ptr noundef %316)
  br label %317

317:                                              ; preds = %312, %299
  store i32 0, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %318

318:                                              ; preds = %317, %248, %102, %73, %27, %21, %15
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  %319 = load i32, ptr %2, align 4
  ret i32 %319
}

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

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

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @__disable_interrupts() #3

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @__restore_interrupt(i32 noundef) #3

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

declare i32 @_tx_mutex_put(ptr noundef) #2

declare i32 @_fx_media_abort(ptr noundef) #2

declare i32 @_fx_utility_FAT_flush(ptr noundef) #2

declare i32 @_fx_utility_FAT_map_flush(ptr noundef) #2

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

declare i64 @_fx_utility_32_unsigned_read(ptr noundef) #2

declare void @_fx_utility_32_unsigned_write(ptr noundef, i64 noundef) #2

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

declare i32 @_tx_mutex_delete(ptr noundef) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { alwaysinline 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"FX_MEDIA_STRUCT", !11, i64 0, !6, i64 8, !6, i64 16, !11, i64 24, !12, i64 32, !11, i64 40, !6, i64 48, !6, i64 56, !11, i64 64, !11, i64 72, !12, i64 80, !12, i64 84, !12, i64 88, !13, i64 96, !11, i64 104, !12, i64 112, !12, i64 116, !12, i64 120, !12, i64 124, !12, i64 128, !12, i64 132, !12, i64 136, !12, i64 140, !12, i64 144, !11, i64 152, !12, i64 160, !11, i64 168, !11, i64 176, !12, i64 184, !11, i64 192, !11, i64 200, !6, i64 208, !12, i64 216, !12, i64 220, !6, i64 224, !11, i64 232, !11, i64 240, !11, i64 248, !12, i64 256, !12, i64 260, !12, i64 264, !12, i64 268, !12, i64 272, !12, i64 276, !12, i64 280, !6, i64 288, !6, i64 296, !6, i64 304, !6, i64 312, !11, i64 320, !6, i64 328, !6, i64 336, !11, i64 344, !11, i64 352, !11, i64 360, !11, i64 368, !11, i64 376, !11, i64 384, !11, i64 392, !11, i64 400, !11, i64 408, !11, i64 416, !11, i64 424, !11, i64 432, !11, i64 440, !11, i64 448, !11, i64 456, !11, i64 464, !11, i64 472, !11, i64 480, !11, i64 488, !11, i64 496, !11, i64 504, !11, i64 512, !11, i64 520, !11, i64 528, !11, i64 536, !11, i64 544, !11, i64 552, !11, i64 560, !11, i64 568, !11, i64 576, !11, i64 584, !11, i64 592, !11, i64 600, !11, i64 608, !11, i64 616, !11, i64 624, !11, i64 632, !11, i64 640, !11, i64 648, !11, i64 656, !11, i64 664, !11, i64 672, !11, i64 680, !11, i64 688, !11, i64 696, !11, i64 704, !11, i64 712, !11, i64 720, !11, i64 728, !11, i64 736, !11, i64 744, !11, i64 752, !11, i64 760, !11, i64 768, !11, i64 776, !11, i64 784, !11, i64 792, !11, i64 800, !11, i64 808, !11, i64 816, !14, i64 824, !12, i64 920, !15, i64 928, !15, i64 1064, !7, i64 1200, !7, i64 1456, !16, i64 1712, !7, i64 2368, !7, i64 2752, !11, i64 2880, !7, i64 2888, !7, i64 3912, !11, i64 12104, !11, i64 12112, !11, i64 12120, !11, i64 12128, !7, i64 12136}
!11 = !{!"long", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"long long", !7, i64 0}
!14 = !{!"TX_MUTEX_STRUCT", !11, i64 0, !6, i64 8, !12, i64 16, !6, i64 24, !12, i64 32, !12, i64 36, !6, i64 40, !12, i64 48, !6, i64 56, !6, i64 64, !12, i64 72, !6, i64 80, !6, i64 88}
!15 = !{!"FX_DIR_ENTRY_STRUCT", !6, i64 0, !7, i64 8, !12, i64 24, !12, i64 28, !7, i64 32, !7, i64 33, !7, i64 34, !12, i64 36, !12, i64 40, !12, i64 44, !12, i64 48, !12, i64 52, !11, i64 56, !13, i64 64, !13, i64 72, !11, i64 80, !11, i64 88, !11, i64 96, !11, i64 104, !13, i64 112, !11, i64 120, !13, i64 128}
!16 = !{!"FX_PATH_STRUCT", !15, i64 0, !7, i64 136, !7, i64 392, !11, i64 648}
!17 = !{!10, !11, i64 320}
!18 = !{!11, !11, i64 0}
!19 = !{!10, !6, i64 312}
!20 = !{!21, !11, i64 16}
!21 = !{!"FX_FILE_STRUCT", !11, i64 0, !6, i64 8, !11, i64 16, !7, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !13, i64 72, !11, i64 80, !11, i64 88, !11, i64 96, !13, i64 104, !13, i64 112, !13, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !15, i64 152, !7, i64 288, !11, i64 544, !6, i64 552}
!22 = !{!21, !7, i64 24}
!23 = !{!12, !12, i64 0}
!24 = !{!21, !12, i64 200}
!25 = !{!21, !12, i64 204}
!26 = !{!21, !13, i64 112}
!27 = !{!21, !13, i64 216}
!28 = !{!21, !11, i64 0}
!29 = !{!21, !6, i64 136}
!30 = distinct !{!30, !31}
!31 = !{!"llvm.loop.mustprogress"}
!32 = !{!10, !13, i64 96}
!33 = !{!10, !11, i64 152}
!34 = !{!10, !12, i64 160}
!35 = !{!10, !11, i64 192}
!36 = !{!10, !12, i64 264}
!37 = !{!10, !6, i64 56}
!38 = !{!39, !6, i64 0}
!39 = !{!"FX_CACHED_SECTOR_STRUCT", !6, i64 0, !13, i64 8, !7, i64 16, !7, i64 17, !7, i64 18, !7, i64 19, !6, i64 24}
!40 = !{!39, !13, i64 8}
!41 = !{!39, !7, i64 17}
!42 = !{!10, !12, i64 216}
!43 = !{!10, !12, i64 220}
!44 = !{!10, !6, i64 224}
!45 = !{!10, !11, i64 232}
!46 = !{!10, !11, i64 240}
!47 = !{!10, !12, i64 280}
!48 = !{!10, !11, i64 768}
!49 = !{!10, !6, i64 288}
!50 = !{!10, !11, i64 200}
!51 = !{!10, !12, i64 272}
!52 = !{!10, !11, i64 776}
!53 = !{!10, !11, i64 808}
!54 = !{!10, !6, i64 336}
!55 = !{!10, !6, i64 328}
!56 = !{!10, !6, i64 304}


; 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"

@_fx_system_time = external local_unnamed_addr global i32, align 4
@_fx_system_date = external local_unnamed_addr global i32, align 4
@_fx_system_media_opened_count = external local_unnamed_addr global i64, align 8
@_fx_system_media_opened_ptr = external local_unnamed_addr global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 145) i32 @_fx_media_close(ptr noundef %0) local_unnamed_addr #0 {
  %2 = load i64, ptr %0, align 8, !tbaa !5
  %.not = icmp eq i64 %2, 1296385097
  br i1 %.not, label %3, label %.critedge

3:                                                ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 824
  %5 = tail call i32 @_tx_mutex_get(ptr noundef nonnull %4, i64 noundef 4294967295) #3
  %.not103 = icmp eq i32 %5, 0
  br i1 %.not103, label %6, label %.critedge

6:                                                ; preds = %3
  %7 = getelementptr inbounds i8, ptr %0, i64 320
  %8 = load i64, ptr %7, align 8, !tbaa !16
  %.not104114 = icmp eq i64 %8, 0
  br i1 %.not104114, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %6
  %9 = getelementptr inbounds i8, ptr %0, i64 312
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %31
  %.099116.in = phi ptr [ %32, %31 ], [ %9, %.lr.ph.preheader ]
  %.0100115 = phi i64 [ %33, %31 ], [ %8, %.lr.ph.preheader ]
  %.099116 = load ptr, ptr %.099116.in, align 8, !tbaa !17
  %10 = getelementptr inbounds i8, ptr %.099116, i64 16
  %11 = load i64, ptr %10, align 8, !tbaa !18
  %12 = icmp eq i64 %11, 1
  br i1 %12, label %13, label %31

13:                                               ; preds = %.lr.ph
  %14 = getelementptr inbounds i8, ptr %.099116, i64 24
  %15 = load i8, ptr %14, align 8, !tbaa !20
  %.not111 = icmp eq i8 %15, 0
  br i1 %.not111, label %31, label %16

16:                                               ; preds = %13
  %17 = tail call i32 @__disable_interrupts()
  %18 = load i32, ptr @_fx_system_time, align 4, !tbaa !21
  %19 = getelementptr inbounds i8, ptr %.099116, i64 152
  %20 = getelementptr inbounds i8, ptr %.099116, i64 200
  store i32 %18, ptr %20, align 8, !tbaa !22
  %21 = load i32, ptr @_fx_system_date, align 4, !tbaa !21
  %22 = getelementptr inbounds i8, ptr %.099116, i64 204
  store i32 %21, ptr %22, align 4, !tbaa !23
  tail call void @__restore_interrupt(i32 noundef %17)
  %23 = getelementptr inbounds i8, ptr %.099116, i64 112
  %24 = load i64, ptr %23, align 8, !tbaa !24
  %25 = getelementptr inbounds i8, ptr %.099116, i64 216
  store i64 %24, ptr %25, align 8, !tbaa !25
  %26 = tail call i32 @_fx_directory_entry_write(ptr noundef %0, ptr noundef nonnull %19) #3
  %.not112 = icmp eq i32 %26, 0
  br i1 %.not112, label %30, label %27

27:                                               ; preds = %16
  %28 = tail call i32 @_tx_mutex_put(ptr noundef nonnull %4) #3
  %29 = tail call i32 @_fx_media_abort(ptr noundef %0) #3
  br label %.critedge

30:                                               ; preds = %16
  store i8 0, ptr %14, align 8, !tbaa !20
  br label %31

31:                                               ; preds = %30, %13, %.lr.ph
  store i64 1179208771, ptr %.099116, align 8, !tbaa !26
  %32 = getelementptr inbounds i8, ptr %.099116, i64 136
  %33 = add i64 %.0100115, -1
  %.not104 = icmp eq i64 %33, 0
  br i1 %.not104, label %._crit_edge, label %.lr.ph, !llvm.loop !27

._crit_edge:                                      ; preds = %31, %6
  %34 = tail call i32 @_fx_utility_FAT_flush(ptr noundef nonnull %0) #3
  %35 = tail call i32 @_fx_utility_FAT_map_flush(ptr noundef nonnull %0) #3
  %36 = getelementptr inbounds i8, ptr %0, i64 96
  %37 = load i64, ptr %36, align 8, !tbaa !29
  %38 = tail call i32 @_fx_utility_logical_sector_flush(ptr noundef nonnull %0, i64 noundef 1, i64 noundef %37, i32 noundef 0) #3
  %.not105 = icmp eq i32 %38, 0
  br i1 %.not105, label %42, label %39

39:                                               ; preds = %._crit_edge
  %40 = tail call i32 @_tx_mutex_put(ptr noundef nonnull %4) #3
  %41 = tail call i32 @_fx_media_abort(ptr noundef nonnull %0) #3
  br label %.critedge

42:                                               ; preds = %._crit_edge
  %43 = getelementptr inbounds i8, ptr %0, i64 152
  %44 = load i64, ptr %43, align 8, !tbaa !30
  %.not106 = icmp eq i64 %44, 0
  br i1 %.not106, label %103, label %45

45:                                               ; preds = %42
  %46 = getelementptr inbounds i8, ptr %0, i64 160
  %47 = load i32, ptr %46, align 8, !tbaa !31
  %48 = zext i32 %47 to i64
  %49 = getelementptr inbounds i8, ptr %0, i64 192
  %50 = load i64, ptr %49, align 8, !tbaa !32
  %.not107 = icmp eq i64 %50, %48
  br i1 %.not107, label %103, label %51

51:                                               ; preds = %45
  %52 = getelementptr inbounds i8, ptr %0, i64 264
  %53 = load i32, ptr %52, align 8, !tbaa !33
  %54 = icmp eq i32 %53, 0
  br i1 %54, label %55, label %103

55:                                               ; preds = %51
  %56 = getelementptr inbounds i8, ptr %0, i64 56
  %57 = load ptr, ptr %56, align 8, !tbaa !34
  %58 = load ptr, ptr %57, align 8, !tbaa !35
  %59 = getelementptr inbounds i8, ptr %57, i64 8
  store i64 -1, ptr %59, align 8, !tbaa !37
  %60 = getelementptr inbounds i8, ptr %57, i64 17
  store i8 0, ptr %60, align 1, !tbaa !38
  %61 = getelementptr inbounds i8, ptr %0, i64 216
  store i32 0, ptr %61, align 8, !tbaa !39
  %62 = getelementptr inbounds i8, ptr %0, i64 220
  store i32 144, ptr %62, align 4, !tbaa !40
  %63 = getelementptr inbounds i8, ptr %0, i64 224
  store ptr %58, ptr %63, align 8, !tbaa !41
  %64 = getelementptr inbounds i8, ptr %0, i64 232
  store i64 %44, ptr %64, align 8, !tbaa !42
  %65 = getelementptr inbounds i8, ptr %0, i64 240
  store i64 1, ptr %65, align 8, !tbaa !43
  %66 = getelementptr inbounds i8, ptr %0, i64 280
  store i32 3, ptr %66, align 8, !tbaa !44
  %67 = getelementptr inbounds i8, ptr %0, i64 768
  %68 = load i64, ptr %67, align 8, !tbaa !45
  %69 = add i64 %68, 1
  store i64 %69, ptr %67, align 8, !tbaa !45
  %70 = getelementptr inbounds i8, ptr %0, i64 288
  %71 = load ptr, ptr %70, align 8, !tbaa !46
  tail call void %71(ptr noundef nonnull %0) #3
  %72 = load i32, ptr %62, align 4, !tbaa !40
  %.not108 = icmp eq i32 %72, 0
  br i1 %.not108, label %76, label %73

73:                                               ; preds = %55
  %74 = tail call i32 @_tx_mutex_put(ptr noundef nonnull %4) #3
  %75 = tail call i32 @_fx_media_abort(ptr noundef nonnull %0) #3
  br label %.critedge

76:                                               ; preds = %55
  %77 = load ptr, ptr %63, align 8, !tbaa !41
  %78 = tail call i64 @_fx_utility_32_unsigned_read(ptr noundef %77) #3
  %79 = icmp eq i64 %78, 1096897106
  br i1 %79, label %80, label %103

80:                                               ; preds = %76
  %81 = getelementptr inbounds i8, ptr %77, i64 484
  %82 = tail call i64 @_fx_utility_32_unsigned_read(ptr noundef nonnull %81) #3
  %83 = icmp eq i64 %82, 1631679090
  br i1 %83, label %84, label %103

84:                                               ; preds = %80
  %85 = getelementptr inbounds i8, ptr %77, i64 488
  %86 = load i64, ptr %49, align 8, !tbaa !32
  tail call void @_fx_utility_32_unsigned_write(ptr noundef nonnull %85, i64 noundef %86) #3
  %87 = getelementptr inbounds i8, ptr %77, i64 492
  %88 = getelementptr inbounds i8, ptr %0, i64 200
  %89 = load i64, ptr %88, align 8, !tbaa !47
  tail call void @_fx_utility_32_unsigned_write(ptr noundef nonnull %87, i64 noundef %89) #3
  store i32 1, ptr %61, align 8, !tbaa !39
  store i32 144, ptr %62, align 4, !tbaa !40
  store ptr %77, ptr %63, align 8, !tbaa !41
  %90 = load i64, ptr %43, align 8, !tbaa !30
  store i64 %90, ptr %64, align 8, !tbaa !42
  store i64 1, ptr %65, align 8, !tbaa !43
  store i32 3, ptr %66, align 8, !tbaa !44
  %91 = getelementptr inbounds i8, ptr %0, i64 272
  store i32 1, ptr %91, align 8, !tbaa !48
  %92 = getelementptr inbounds i8, ptr %0, i64 776
  %93 = load i64, ptr %92, align 8, !tbaa !49
  %94 = add i64 %93, 1
  store i64 %94, ptr %92, align 8, !tbaa !49
  %95 = load ptr, ptr %70, align 8, !tbaa !46
  tail call void %95(ptr noundef nonnull %0) #3
  store i32 0, ptr %91, align 8, !tbaa !48
  %96 = load i32, ptr %62, align 4, !tbaa !40
  %.not109 = icmp eq i32 %96, 0
  br i1 %.not109, label %100, label %97

97:                                               ; preds = %84
  %98 = tail call i32 @_tx_mutex_put(ptr noundef nonnull %4) #3
  %99 = tail call i32 @_fx_media_abort(ptr noundef nonnull %0) #3
  br label %.critedge

100:                                              ; preds = %84
  %101 = load i64, ptr %49, align 8, !tbaa !32
  %102 = trunc i64 %101 to i32
  store i32 %102, ptr %46, align 8, !tbaa !31
  br label %103

103:                                              ; preds = %80, %100, %76, %51, %45, %42
  %104 = getelementptr inbounds i8, ptr %0, i64 808
  %105 = load i64, ptr %104, align 8, !tbaa !50
  %106 = add i64 %105, 1
  store i64 %106, ptr %104, align 8, !tbaa !50
  %107 = getelementptr inbounds i8, ptr %0, i64 216
  store i32 2, ptr %107, align 8, !tbaa !39
  %108 = getelementptr inbounds i8, ptr %0, i64 220
  store i32 144, ptr %108, align 4, !tbaa !40
  %109 = getelementptr inbounds i8, ptr %0, i64 288
  %110 = load ptr, ptr %109, align 8, !tbaa !46
  tail call void %110(ptr noundef nonnull %0) #3
  store i32 8, ptr %107, align 8, !tbaa !39
  store i32 144, ptr %108, align 4, !tbaa !40
  %111 = load ptr, ptr %109, align 8, !tbaa !46
  tail call void %111(ptr noundef nonnull %0) #3
  %112 = tail call i32 @__disable_interrupts()
  %113 = load i64, ptr @_fx_system_media_opened_count, align 8, !tbaa !51
  %114 = icmp eq i64 %113, 1
  br i1 %114, label %.sink.split, label %115

115:                                              ; preds = %103
  %116 = getelementptr inbounds i8, ptr %0, i64 336
  %117 = load ptr, ptr %116, align 8, !tbaa !52
  %118 = getelementptr inbounds i8, ptr %0, i64 328
  %119 = load ptr, ptr %118, align 8, !tbaa !53
  %120 = getelementptr inbounds i8, ptr %119, i64 336
  store ptr %117, ptr %120, align 8, !tbaa !52
  %121 = getelementptr inbounds i8, ptr %117, i64 328
  store ptr %119, ptr %121, align 8, !tbaa !53
  %122 = load ptr, ptr @_fx_system_media_opened_ptr, align 8, !tbaa !17
  %123 = icmp eq ptr %122, %0
  br i1 %123, label %.sink.split, label %124

.sink.split:                                      ; preds = %115, %103
  %.sink = phi ptr [ null, %103 ], [ %119, %115 ]
  store ptr %.sink, ptr @_fx_system_media_opened_ptr, align 8, !tbaa !17
  br label %124

124:                                              ; preds = %.sink.split, %115
  %125 = add i64 %113, -1
  store i64 %125, ptr @_fx_system_media_opened_count, align 8, !tbaa !51
  store i64 1296385091, ptr %0, align 8, !tbaa !5
  tail call void @__restore_interrupt(i32 noundef %112)
  %126 = tail call i32 @_tx_mutex_delete(ptr noundef nonnull %4) #3
  %127 = getelementptr inbounds i8, ptr %0, i64 304
  %128 = load ptr, ptr %127, align 8, !tbaa !54
  %.not110 = icmp eq ptr %128, null
  br i1 %.not110, label %.critedge, label %129

129:                                              ; preds = %124
  tail call void %128(ptr noundef nonnull %0) #3
  br label %.critedge

.critedge:                                        ; preds = %73, %97, %124, %129, %3, %1, %39, %27
  %.1 = phi i32 [ 144, %27 ], [ 144, %39 ], [ 17, %1 ], [ 17, %3 ], [ 0, %129 ], [ 0, %124 ], [ 144, %97 ], [ 144, %73 ]
  ret i32 %.1
}

declare i32 @_tx_mutex_get(ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @__disable_interrupts() local_unnamed_addr #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @__restore_interrupt(i32 noundef) local_unnamed_addr #2

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

declare i32 @_tx_mutex_put(ptr noundef) local_unnamed_addr #1

declare i32 @_fx_media_abort(ptr noundef) local_unnamed_addr #1

declare i32 @_fx_utility_FAT_flush(ptr noundef) local_unnamed_addr #1

declare i32 @_fx_utility_FAT_map_flush(ptr noundef) local_unnamed_addr #1

declare i32 @_fx_utility_logical_sector_flush(ptr noundef, i64 noundef, i64 noundef, i32 noundef) local_unnamed_addr #1

declare i64 @_fx_utility_32_unsigned_read(ptr noundef) local_unnamed_addr #1

declare void @_fx_utility_32_unsigned_write(ptr noundef, i64 noundef) local_unnamed_addr #1

declare i32 @_tx_mutex_delete(ptr noundef) local_unnamed_addr #1

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 = { alwaysinline 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, !7, i64 0}
!6 = !{!"FX_MEDIA_STRUCT", !7, i64 0, !10, i64 8, !10, i64 16, !7, i64 24, !11, i64 32, !7, i64 40, !10, i64 48, !10, i64 56, !7, i64 64, !7, i64 72, !11, i64 80, !11, i64 84, !11, i64 88, !12, i64 96, !7, i64 104, !11, i64 112, !11, i64 116, !11, i64 120, !11, i64 124, !11, i64 128, !11, i64 132, !11, i64 136, !11, i64 140, !11, i64 144, !7, i64 152, !11, i64 160, !7, i64 168, !7, i64 176, !11, i64 184, !7, i64 192, !7, i64 200, !10, i64 208, !11, i64 216, !11, i64 220, !10, i64 224, !7, i64 232, !7, i64 240, !7, i64 248, !11, i64 256, !11, i64 260, !11, i64 264, !11, i64 268, !11, i64 272, !11, i64 276, !11, i64 280, !10, i64 288, !10, i64 296, !10, i64 304, !10, i64 312, !7, i64 320, !10, i64 328, !10, i64 336, !7, i64 344, !7, i64 352, !7, i64 360, !7, i64 368, !7, i64 376, !7, i64 384, !7, i64 392, !7, i64 400, !7, i64 408, !7, i64 416, !7, i64 424, !7, i64 432, !7, i64 440, !7, i64 448, !7, i64 456, !7, i64 464, !7, i64 472, !7, i64 480, !7, i64 488, !7, i64 496, !7, i64 504, !7, i64 512, !7, i64 520, !7, i64 528, !7, i64 536, !7, i64 544, !7, i64 552, !7, i64 560, !7, i64 568, !7, i64 576, !7, i64 584, !7, i64 592, !7, i64 600, !7, i64 608, !7, i64 616, !7, i64 624, !7, i64 632, !7, i64 640, !7, i64 648, !7, i64 656, !7, i64 664, !7, i64 672, !7, i64 680, !7, i64 688, !7, i64 696, !7, i64 704, !7, i64 712, !7, i64 720, !7, i64 728, !7, i64 736, !7, i64 744, !7, i64 752, !7, i64 760, !7, i64 768, !7, i64 776, !7, i64 784, !7, i64 792, !7, i64 800, !7, i64 808, !7, i64 816, !13, i64 824, !11, i64 920, !14, i64 928, !14, i64 1064, !8, i64 1200, !8, i64 1456, !15, i64 1712, !8, i64 2368, !8, i64 2752, !7, i64 2880, !8, i64 2888, !8, i64 3912, !7, i64 12104, !7, i64 12112, !7, i64 12120, !7, i64 12128, !8, i64 12136}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!"long long", !8, i64 0}
!13 = !{!"TX_MUTEX_STRUCT", !7, i64 0, !10, i64 8, !11, i64 16, !10, i64 24, !11, i64 32, !11, i64 36, !10, i64 40, !11, i64 48, !10, i64 56, !10, i64 64, !11, i64 72, !10, i64 80, !10, i64 88}
!14 = !{!"FX_DIR_ENTRY_STRUCT", !10, i64 0, !8, i64 8, !11, i64 24, !11, i64 28, !8, i64 32, !8, i64 33, !8, i64 34, !11, i64 36, !11, i64 40, !11, i64 44, !11, i64 48, !11, i64 52, !7, i64 56, !12, i64 64, !12, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !7, i64 104, !12, i64 112, !7, i64 120, !12, i64 128}
!15 = !{!"FX_PATH_STRUCT", !14, i64 0, !8, i64 136, !8, i64 392, !7, i64 648}
!16 = !{!6, !7, i64 320}
!17 = !{!10, !10, i64 0}
!18 = !{!19, !7, i64 16}
!19 = !{!"FX_FILE_STRUCT", !7, i64 0, !10, i64 8, !7, i64 16, !8, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !12, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !12, i64 104, !12, i64 112, !12, i64 120, !10, i64 128, !10, i64 136, !10, i64 144, !14, i64 152, !8, i64 288, !7, i64 544, !10, i64 552}
!20 = !{!19, !8, i64 24}
!21 = !{!11, !11, i64 0}
!22 = !{!19, !11, i64 200}
!23 = !{!19, !11, i64 204}
!24 = !{!19, !12, i64 112}
!25 = !{!19, !12, i64 216}
!26 = !{!19, !7, i64 0}
!27 = distinct !{!27, !28}
!28 = !{!"llvm.loop.mustprogress"}
!29 = !{!6, !12, i64 96}
!30 = !{!6, !7, i64 152}
!31 = !{!6, !11, i64 160}
!32 = !{!6, !7, i64 192}
!33 = !{!6, !11, i64 264}
!34 = !{!6, !10, i64 56}
!35 = !{!36, !10, i64 0}
!36 = !{!"FX_CACHED_SECTOR_STRUCT", !10, i64 0, !12, i64 8, !8, i64 16, !8, i64 17, !8, i64 18, !8, i64 19, !10, i64 24}
!37 = !{!36, !12, i64 8}
!38 = !{!36, !8, i64 17}
!39 = !{!6, !11, i64 216}
!40 = !{!6, !11, i64 220}
!41 = !{!6, !10, i64 224}
!42 = !{!6, !7, i64 232}
!43 = !{!6, !7, i64 240}
!44 = !{!6, !11, i64 280}
!45 = !{!6, !7, i64 768}
!46 = !{!6, !10, i64 288}
!47 = !{!6, !7, i64 200}
!48 = !{!6, !11, i64 272}
!49 = !{!6, !7, i64 776}
!50 = !{!6, !7, i64 808}
!51 = !{!7, !7, i64 0}
!52 = !{!6, !10, i64 336}
!53 = !{!6, !10, i64 328}
!54 = !{!6, !10, i64 304}


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