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

%union.struct_FatFileEntry = type { %struct.struct_FatFile83 }
%struct.struct_FatFile83 = type { [8 x i8], [3 x i8], i8, i8, i8, i16, i16, i16, i16, i16, i16, i16, i32 }
%struct.struct_TFFILE = type { i32, i32, i32, i32, i16, i16, i32, i8, i8, i8, i32, [256 x i8] }

@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [12 x i8], align 1

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

; Function Attrs: 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 ptr @tf_fopen(ptr noundef, ptr noundef) #1

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @tf_release_handle(ptr noundef) #1

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

; Function Attrs: nounwind uwtable
declare dso_local void @tf_choose_sfn(ptr noundef, ptr noundef, ptr 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: nounwind willreturn memory(read)
declare ptr @strrchr(ptr noundef, i32 noundef) #3

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

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @tf_mkdir(ptr noundef %0, i32 noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca [256 x i8], align 16
  %7 = alloca ptr, align 8
  %8 = alloca %union.struct_FatFileEntry, align 1
  %9 = alloca %union.struct_FatFileEntry, align 1
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 256, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 32, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 32, ptr %9) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %14 = getelementptr inbounds [256 x i8], ptr %6, i64 0, i64 0
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = call ptr @strncpy(ptr noundef %14, ptr noundef %15, i64 noundef 255) #6
  %17 = getelementptr inbounds [256 x i8], ptr %6, i64 0, i64 255
  store i8 0, ptr %17, align 1, !tbaa !11
  call void @llvm.memset.p0.i64(ptr align 1 %9, i8 0, i64 32, i1 false)
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = call ptr @tf_fopen(ptr noundef %18, ptr noundef @.str.4)
  store ptr %19, ptr %7, align 8, !tbaa !5
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = icmp ne ptr %20, null
  br i1 %21, label %22, label %30

22:                                               ; preds = %2
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = call i32 @tf_fclose(ptr noundef %23)
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  call void @tf_release_handle(ptr noundef %25)
  %26 = load i32, ptr %5, align 4, !tbaa !9
  %27 = icmp ne i32 %26, 0
  br i1 %27, label %28, label %29

28:                                               ; preds = %22
  store i32 0, ptr %3, align 4
  store i32 1, ptr %13, align 4
  br label %111

29:                                               ; preds = %22
  store i32 1, ptr %3, align 4
  store i32 1, ptr %13, align 4
  br label %111

30:                                               ; preds = %2
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = load i32, ptr %5, align 4, !tbaa !9
  %33 = call ptr @tf_parent(ptr noundef %31, ptr noundef @.str.2, i32 noundef %32)
  store ptr %33, ptr %7, align 8, !tbaa !5
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = icmp ne ptr %34, null
  br i1 %35, label %37, label %36

36:                                               ; preds = %30
  store i32 1, ptr %3, align 4
  store i32 1, ptr %13, align 4
  br label %111

37:                                               ; preds = %30
  br label %38

38:                                               ; preds = %41, %37
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = call i32 @tf_fread(ptr noundef %8, i32 noundef 32, ptr noundef %39)
  br label %41

41:                                               ; preds = %38
  %42 = getelementptr inbounds %struct.struct_FatFile83, ptr %8, i32 0, i32 0
  %43 = getelementptr inbounds [8 x i8], ptr %42, i64 0, i64 0
  %44 = load i8, ptr %43, align 1, !tbaa !11
  %45 = zext i8 %44 to i32
  %46 = icmp ne i32 %45, 0
  br i1 %46, label %38, label %47, !llvm.loop !12

47:                                               ; preds = %41
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.struct_TFFILE, ptr %49, i32 0, i32 6
  %51 = load i32, ptr %50, align 4, !tbaa !14
  %52 = zext i32 %51 to i64
  %53 = call i32 @tf_fseek(ptr noundef %48, i32 noundef -32, i64 noundef %52)
  %54 = call i32 @tf_find_free_cluster()
  store i32 %54, ptr %11, align 4, !tbaa !9
  %55 = load i32, ptr %11, align 4, !tbaa !9
  %56 = call i32 @tf_set_fat_entry(i32 noundef %55, i32 noundef 268435448)
  %57 = getelementptr inbounds %struct.struct_FatFile83, ptr %8, i32 0, i32 2
  store i8 16, ptr %57, align 1, !tbaa !11
  %58 = getelementptr inbounds %struct.struct_FatFile83, ptr %8, i32 0, i32 4
  store i8 37, ptr %58, align 1, !tbaa !11
  %59 = getelementptr inbounds %struct.struct_FatFile83, ptr %8, i32 0, i32 5
  store i16 32316, ptr %59, align 1, !tbaa !11
  %60 = getelementptr inbounds %struct.struct_FatFile83, ptr %8, i32 0, i32 6
  store i16 16994, ptr %60, align 1, !tbaa !11
  %61 = getelementptr inbounds %struct.struct_FatFile83, ptr %8, i32 0, i32 7
  store i16 16994, ptr %61, align 1, !tbaa !11
  %62 = load i32, ptr %11, align 4, !tbaa !9
  %63 = lshr i32 %62, 16
  %64 = and i32 %63, 65535
  %65 = trunc i32 %64 to i16
  %66 = getelementptr inbounds %struct.struct_FatFile83, ptr %8, i32 0, i32 8
  store i16 %65, ptr %66, align 1, !tbaa !11
  %67 = getelementptr inbounds %struct.struct_FatFile83, ptr %8, i32 0, i32 9
  store i16 32316, ptr %67, align 1, !tbaa !11
  %68 = getelementptr inbounds %struct.struct_FatFile83, ptr %8, i32 0, i32 10
  store i16 16994, ptr %68, align 1, !tbaa !11
  %69 = load i32, ptr %11, align 4, !tbaa !9
  %70 = and i32 %69, 65535
  %71 = trunc i32 %70 to i16
  %72 = getelementptr inbounds %struct.struct_FatFile83, ptr %8, i32 0, i32 11
  store i16 %71, ptr %72, align 1, !tbaa !11
  %73 = getelementptr inbounds %struct.struct_FatFile83, ptr %8, i32 0, i32 12
  store i32 0, ptr %73, align 1, !tbaa !11
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = call ptr @strrchr(ptr noundef %74, i32 noundef 47) #7
  %76 = getelementptr inbounds i8, ptr %75, i64 1
  store ptr %76, ptr %12, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.struct_FatFile83, ptr %8, i32 0, i32 0
  %78 = getelementptr inbounds [8 x i8], ptr %77, i64 0, i64 0
  %79 = load ptr, ptr %12, align 8, !tbaa !5
  %80 = load ptr, ptr %7, align 8, !tbaa !5
  call void @tf_choose_sfn(ptr noundef %78, ptr noundef %79, ptr noundef %80)
  %81 = load ptr, ptr %7, align 8, !tbaa !5
  %82 = load ptr, ptr %12, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.struct_FatFile83, ptr %8, i32 0, i32 0
  %84 = getelementptr inbounds [8 x i8], ptr %83, i64 0, i64 0
  %85 = call i32 @tf_place_lfn_chain(ptr noundef %81, ptr noundef %82, ptr noundef %84)
  %86 = load ptr, ptr %7, align 8, !tbaa !5
  %87 = call i32 @tf_fwrite(ptr noundef %8, i32 noundef 32, i32 noundef 1, ptr noundef %86)
  %88 = load ptr, ptr %7, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.struct_TFFILE, ptr %88, i32 0, i32 1
  %90 = load i32, ptr %89, align 4, !tbaa !17
  store i32 %90, ptr %10, align 4, !tbaa !9
  %91 = load ptr, ptr %7, align 8, !tbaa !5
  %92 = call i32 @tf_fwrite(ptr noundef %9, i32 noundef 32, i32 noundef 1, ptr noundef %91)
  %93 = load ptr, ptr %7, align 8, !tbaa !5
  %94 = call i32 @tf_fclose(ptr noundef %93)
  %95 = load ptr, ptr %7, align 8, !tbaa !5
  call void @tf_release_handle(ptr noundef %95)
  %96 = getelementptr inbounds [256 x i8], ptr %6, i64 0, i64 0
  %97 = call ptr @tf_fopen(ptr noundef %96, ptr noundef @.str.6)
  store ptr %97, ptr %7, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.struct_FatFile83, ptr %8, i32 0, i32 0
  %99 = getelementptr inbounds [8 x i8], ptr %98, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %99, ptr align 1 @.str.7, i64 11, i1 false)
  %100 = load ptr, ptr %7, align 8, !tbaa !5
  %101 = call i32 @tf_fwrite(ptr noundef %8, i32 noundef 32, i32 noundef 1, ptr noundef %100)
  %102 = getelementptr inbounds %struct.struct_FatFile83, ptr %8, i32 0, i32 0
  %103 = getelementptr inbounds [8 x i8], ptr %102, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %103, ptr align 1 @.str.8, i64 11, i1 false)
  %104 = load ptr, ptr %7, align 8, !tbaa !5
  %105 = call i32 @tf_fwrite(ptr noundef %8, i32 noundef 32, i32 noundef 1, ptr noundef %104)
  %106 = load ptr, ptr %7, align 8, !tbaa !5
  %107 = call i32 @tf_fwrite(ptr noundef %9, i32 noundef 32, i32 noundef 1, ptr noundef %106)
  %108 = load ptr, ptr %7, align 8, !tbaa !5
  %109 = call i32 @tf_fclose(ptr noundef %108)
  %110 = load ptr, ptr %7, align 8, !tbaa !5
  call void @tf_release_handle(ptr noundef %110)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %13, align 4
  br label %111

111:                                              ; preds = %47, %36, %29, %28
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 256, ptr %6) #6
  %112 = load i32, ptr %3, align 4
  ret i32 %112
}

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @tf_find_free_cluster() #1

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 = { nounwind willreturn memory(read) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nounwind }
attributes #7 = { nounwind willreturn memory(read) }

!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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!15, !10, i64 20}
!15 = !{!"struct_TFFILE", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !16, i64 16, !16, i64 18, !10, i64 20, !7, i64 24, !7, i64 25, !7, i64 26, !10, i64 28, !7, i64 32}
!16 = !{!"short", !7, i64 0}
!17 = !{!15, !10, 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"

%union.struct_FatFileEntry = type { %struct.struct_FatFile83 }
%struct.struct_FatFile83 = type { [8 x i8], [3 x i8], i8, i8, i8, i16, i16, i16, i16, i16, i16, i16, i32 }

@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [12 x i8], align 1

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

; Function Attrs: 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 ptr @tf_fopen(ptr noundef, ptr noundef) local_unnamed_addr #1

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @tf_release_handle(ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare dso_local void @tf_choose_sfn(ptr noundef, ptr noundef, ptr 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 nofree nounwind willreturn memory(argmem: read)
declare ptr @strrchr(ptr noundef, i32 noundef) local_unnamed_addr #3

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

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @tf_mkdir(ptr noundef %0, i32 noundef %1) local_unnamed_addr #1 {
  %3 = alloca [256 x i8], align 16
  %4 = alloca %union.struct_FatFileEntry, align 1
  %5 = alloca %union.struct_FatFileEntry, align 1
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %3) #6
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %4) #6
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %5) #6
  %6 = call ptr @strncpy(ptr noundef nonnull dereferenceable(1) %3, ptr noundef nonnull dereferenceable(1) %0, i64 noundef 255) #6
  %7 = getelementptr inbounds i8, ptr %3, i64 255
  store i8 0, ptr %7, align 1, !tbaa !5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(32) %5, i8 0, i64 32, i1 false)
  %8 = call ptr @tf_fopen(ptr noundef %0, ptr noundef nonnull @.str.4)
  %.not = icmp eq ptr %8, null
  br i1 %.not, label %11, label %9

9:                                                ; preds = %2
  %10 = call i32 @tf_fclose(ptr noundef nonnull %8)
  call void @tf_release_handle(ptr noundef nonnull %8)
  %.not33 = icmp eq i32 %1, 0
  %. = zext i1 %.not33 to i32
  br label %46

11:                                               ; preds = %2
  %12 = call ptr @tf_parent(ptr noundef %0, ptr noundef nonnull @.str.2, i32 noundef %1)
  %.not31 = icmp eq ptr %12, null
  br i1 %.not31, label %46, label %.preheader

.preheader:                                       ; preds = %11, %.preheader
  %13 = call i32 @tf_fread(ptr noundef nonnull %4, i32 noundef 32, ptr noundef nonnull %12)
  %14 = load i8, ptr %4, align 1, !tbaa !5
  %.not32 = icmp eq i8 %14, 0
  br i1 %.not32, label %15, label %.preheader, !llvm.loop !8

15:                                               ; preds = %.preheader
  %16 = getelementptr inbounds i8, ptr %12, i64 20
  %17 = load i32, ptr %16, align 4, !tbaa !10
  %18 = zext i32 %17 to i64
  %19 = call i32 @tf_fseek(ptr noundef nonnull %12, i32 noundef -32, i64 noundef %18)
  %20 = call i32 @tf_find_free_cluster()
  %21 = call i32 @tf_set_fat_entry(i32 noundef %20, i32 noundef 268435448)
  %22 = getelementptr inbounds i8, ptr %4, i64 11
  store i8 16, ptr %22, align 1, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %4, i64 13
  store i8 37, ptr %23, align 1, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %4, i64 14
  store i16 32316, ptr %24, align 1, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %4, i64 16
  store i16 16994, ptr %25, align 1, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %4, i64 18
  store i16 16994, ptr %26, align 1, !tbaa !5
  %27 = lshr i32 %20, 16
  %28 = trunc nuw i32 %27 to i16
  %29 = getelementptr inbounds i8, ptr %4, i64 20
  store i16 %28, ptr %29, align 1, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %4, i64 22
  store i16 32316, ptr %30, align 1, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %4, i64 24
  store i16 16994, ptr %31, align 1, !tbaa !5
  %32 = trunc i32 %20 to i16
  %33 = getelementptr inbounds i8, ptr %4, i64 26
  store i16 %32, ptr %33, align 1, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %4, i64 28
  store i32 0, ptr %34, align 1, !tbaa !5
  %35 = call ptr @strrchr(ptr noundef nonnull dereferenceable(1) %0, i32 noundef 47) #7
  %36 = getelementptr inbounds i8, ptr %35, i64 1
  call void @tf_choose_sfn(ptr noundef nonnull %4, ptr noundef nonnull %36, ptr noundef nonnull %12)
  %37 = call i32 @tf_place_lfn_chain(ptr noundef nonnull %12, ptr noundef nonnull %36, ptr noundef nonnull %4)
  %38 = call i32 @tf_fwrite(ptr noundef nonnull %4, i32 noundef 32, i32 noundef 1, ptr noundef nonnull %12)
  %39 = call i32 @tf_fwrite(ptr noundef nonnull %5, i32 noundef 32, i32 noundef 1, ptr noundef nonnull %12)
  %40 = call i32 @tf_fclose(ptr noundef nonnull %12)
  call void @tf_release_handle(ptr noundef nonnull %12)
  %41 = call ptr @tf_fopen(ptr noundef nonnull %3, ptr noundef nonnull @.str.6)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(11) %4, ptr noundef nonnull align 1 dereferenceable(11) @.str.7, i64 11, i1 false)
  %42 = call i32 @tf_fwrite(ptr noundef nonnull %4, i32 noundef 32, i32 noundef 1, ptr noundef %41)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(11) %4, ptr noundef nonnull align 1 dereferenceable(11) @.str.8, i64 11, i1 false)
  %43 = call i32 @tf_fwrite(ptr noundef nonnull %4, i32 noundef 32, i32 noundef 1, ptr noundef %41)
  %44 = call i32 @tf_fwrite(ptr noundef nonnull %5, i32 noundef 32, i32 noundef 1, ptr noundef %41)
  %45 = call i32 @tf_fclose(ptr noundef %41)
  call void @tf_release_handle(ptr noundef %41)
  br label %46

46:                                               ; preds = %11, %9, %15
  %.0 = phi i32 [ 0, %15 ], [ %., %9 ], [ 1, %11 ]
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %3) #6
  ret i32 %.0
}

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @tf_find_free_cluster() local_unnamed_addr #1

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 nofree nounwind willreturn memory(argmem: read) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { mustprogress nofree nounwind willreturn memory(argmem: readwrite) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nounwind }
attributes #7 = { nounwind willreturn memory(read) }

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = !{!11, !12, i64 20}
!11 = !{!"struct_TFFILE", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !13, i64 16, !13, i64 18, !12, i64 20, !6, i64 24, !6, i64 25, !6, i64 26, !12, i64 28, !6, i64 32}
!12 = !{!"int", !6, i64 0}
!13 = !{!"short", !6, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass