; LLVM IR from littlefs-project/littlefs :: bd (lfs_emubd)

; 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.lfs_config = type { ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, i32, i32, i32, i32, i32 }
%struct.lfs_emubd = type { ptr, i64, i64, i64, i32, i32, ptr, ptr, ptr }
%struct.lfs_emubd_config = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, ptr, i8, ptr, i64, i64, i64 }
%struct.lfs_emubd_disk = type { i32, i32, ptr }

; Function Attrs: nounwind uwtable
define dso_local i32 @lfs_emubd_create(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.lfs_config, ptr %12, i32 0, i32 0
  %14 = load ptr, ptr %13, align 8, !tbaa !9
  store ptr %14, ptr %6, align 8, !tbaa !5
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.lfs_emubd, ptr %16, i32 0, i32 8
  store ptr %15, ptr %17, align 8, !tbaa !12
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.lfs_emubd, ptr %18, i32 0, i32 8
  %20 = load ptr, ptr %19, align 8, !tbaa !12
  %21 = getelementptr inbounds %struct.lfs_emubd_config, ptr %20, i32 0, i32 3
  %22 = load i32, ptr %21, align 4, !tbaa !15
  %23 = zext i32 %22 to i64
  %24 = mul i64 %23, 8
  %25 = call noalias ptr @malloc(i64 noundef %24) #7
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.lfs_emubd, ptr %26, i32 0, i32 0
  store ptr %25, ptr %27, align 8, !tbaa !18
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.lfs_emubd, ptr %28, i32 0, i32 0
  %30 = load ptr, ptr %29, align 8, !tbaa !18
  %31 = icmp ne ptr %30, null
  br i1 %31, label %33, label %32

32:                                               ; preds = %2
  store i32 -12, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %199

33:                                               ; preds = %2
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.lfs_emubd, ptr %34, i32 0, i32 0
  %36 = load ptr, ptr %35, align 8, !tbaa !18
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.lfs_emubd, ptr %37, i32 0, i32 8
  %39 = load ptr, ptr %38, align 8, !tbaa !12
  %40 = getelementptr inbounds %struct.lfs_emubd_config, ptr %39, i32 0, i32 3
  %41 = load i32, ptr %40, align 4, !tbaa !15
  %42 = zext i32 %41 to i64
  %43 = mul i64 %42, 8
  call void @llvm.memset.p0.i64(ptr align 8 %36, i8 0, i64 %43, i1 false)
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.lfs_emubd, ptr %44, i32 0, i32 1
  store i64 0, ptr %45, align 8, !tbaa !19
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.lfs_emubd, ptr %46, i32 0, i32 2
  store i64 0, ptr %47, align 8, !tbaa !20
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.lfs_emubd, ptr %48, i32 0, i32 3
  store i64 0, ptr %49, align 8, !tbaa !21
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.lfs_emubd, ptr %50, i32 0, i32 8
  %52 = load ptr, ptr %51, align 8, !tbaa !12
  %53 = getelementptr inbounds %struct.lfs_emubd_config, ptr %52, i32 0, i32 7
  %54 = load i32, ptr %53, align 4, !tbaa !22
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.lfs_emubd, ptr %55, i32 0, i32 4
  store i32 %54, ptr %56, align 8, !tbaa !23
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.lfs_emubd, ptr %57, i32 0, i32 5
  store i32 -1, ptr %58, align 4, !tbaa !24
  %59 = load ptr, ptr %6, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.lfs_emubd, ptr %59, i32 0, i32 6
  store ptr null, ptr %60, align 8, !tbaa !25
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.lfs_emubd, ptr %61, i32 0, i32 7
  store ptr null, ptr %62, align 8, !tbaa !26
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.lfs_emubd, ptr %63, i32 0, i32 8
  %65 = load ptr, ptr %64, align 8, !tbaa !12
  %66 = getelementptr inbounds %struct.lfs_emubd_config, ptr %65, i32 0, i32 12
  %67 = load ptr, ptr %66, align 8, !tbaa !27
  %68 = icmp ne ptr %67, null
  br i1 %68, label %69, label %198

69:                                               ; preds = %33
  %70 = call noalias ptr @malloc(i64 noundef 16) #7
  %71 = load ptr, ptr %6, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.lfs_emubd, ptr %71, i32 0, i32 7
  store ptr %70, ptr %72, align 8, !tbaa !26
  %73 = load ptr, ptr %6, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.lfs_emubd, ptr %73, i32 0, i32 7
  %75 = load ptr, ptr %74, align 8, !tbaa !26
  %76 = icmp ne ptr %75, null
  br i1 %76, label %78, label %77

77:                                               ; preds = %69
  store i32 -12, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %199

78:                                               ; preds = %69
  %79 = load ptr, ptr %6, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.lfs_emubd, ptr %79, i32 0, i32 7
  %81 = load ptr, ptr %80, align 8, !tbaa !26
  %82 = getelementptr inbounds %struct.lfs_emubd_disk, ptr %81, i32 0, i32 0
  store i32 1, ptr %82, align 8, !tbaa !28
  %83 = load ptr, ptr %6, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.lfs_emubd, ptr %83, i32 0, i32 7
  %85 = load ptr, ptr %84, align 8, !tbaa !26
  %86 = getelementptr inbounds %struct.lfs_emubd_disk, ptr %85, i32 0, i32 2
  store ptr null, ptr %86, align 8, !tbaa !30
  %87 = load ptr, ptr %6, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.lfs_emubd, ptr %87, i32 0, i32 8
  %89 = load ptr, ptr %88, align 8, !tbaa !12
  %90 = getelementptr inbounds %struct.lfs_emubd_config, ptr %89, i32 0, i32 12
  %91 = load ptr, ptr %90, align 8, !tbaa !27
  %92 = call i32 (ptr, i32, ...) @open(ptr noundef %91, i32 noundef 66, i32 noundef 438)
  %93 = load ptr, ptr %6, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.lfs_emubd, ptr %93, i32 0, i32 7
  %95 = load ptr, ptr %94, align 8, !tbaa !26
  %96 = getelementptr inbounds %struct.lfs_emubd_disk, ptr %95, i32 0, i32 1
  store i32 %92, ptr %96, align 4, !tbaa !31
  %97 = load ptr, ptr %6, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.lfs_emubd, ptr %97, i32 0, i32 7
  %99 = load ptr, ptr %98, align 8, !tbaa !26
  %100 = getelementptr inbounds %struct.lfs_emubd_disk, ptr %99, i32 0, i32 1
  %101 = load i32, ptr %100, align 4, !tbaa !31
  %102 = icmp slt i32 %101, 0
  br i1 %102, label %103, label %108

103:                                              ; preds = %78
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  %104 = call ptr @__errno_location() #8
  %105 = load i32, ptr %104, align 4, !tbaa !32
  %106 = sub nsw i32 0, %105
  store i32 %106, ptr %8, align 4, !tbaa !32
  %107 = load i32, ptr %8, align 4, !tbaa !32
  store i32 %107, ptr %3, align 4
  store i32 1, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  br label %199

108:                                              ; preds = %78
  %109 = load ptr, ptr %6, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct.lfs_emubd, ptr %109, i32 0, i32 8
  %111 = load ptr, ptr %110, align 8, !tbaa !12
  %112 = getelementptr inbounds %struct.lfs_emubd_config, ptr %111, i32 0, i32 4
  %113 = load i32, ptr %112, align 8, !tbaa !33
  %114 = icmp ne i32 %113, -1
  br i1 %114, label %115, label %197

115:                                              ; preds = %108
  %116 = load ptr, ptr %6, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.lfs_emubd, ptr %116, i32 0, i32 8
  %118 = load ptr, ptr %117, align 8, !tbaa !12
  %119 = getelementptr inbounds %struct.lfs_emubd_config, ptr %118, i32 0, i32 2
  %120 = load i32, ptr %119, align 8, !tbaa !34
  %121 = zext i32 %120 to i64
  %122 = call noalias ptr @malloc(i64 noundef %121) #7
  %123 = load ptr, ptr %6, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.lfs_emubd, ptr %123, i32 0, i32 7
  %125 = load ptr, ptr %124, align 8, !tbaa !26
  %126 = getelementptr inbounds %struct.lfs_emubd_disk, ptr %125, i32 0, i32 2
  store ptr %122, ptr %126, align 8, !tbaa !30
  %127 = load ptr, ptr %6, align 8, !tbaa !5
  %128 = getelementptr inbounds %struct.lfs_emubd, ptr %127, i32 0, i32 7
  %129 = load ptr, ptr %128, align 8, !tbaa !26
  %130 = getelementptr inbounds %struct.lfs_emubd_disk, ptr %129, i32 0, i32 2
  %131 = load ptr, ptr %130, align 8, !tbaa !30
  %132 = icmp ne ptr %131, null
  br i1 %132, label %134, label %133

133:                                              ; preds = %115
  store i32 -12, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %199

134:                                              ; preds = %115
  %135 = load ptr, ptr %6, align 8, !tbaa !5
  %136 = getelementptr inbounds %struct.lfs_emubd, ptr %135, i32 0, i32 7
  %137 = load ptr, ptr %136, align 8, !tbaa !26
  %138 = getelementptr inbounds %struct.lfs_emubd_disk, ptr %137, i32 0, i32 2
  %139 = load ptr, ptr %138, align 8, !tbaa !30
  %140 = load ptr, ptr %6, align 8, !tbaa !5
  %141 = getelementptr inbounds %struct.lfs_emubd, ptr %140, i32 0, i32 8
  %142 = load ptr, ptr %141, align 8, !tbaa !12
  %143 = getelementptr inbounds %struct.lfs_emubd_config, ptr %142, i32 0, i32 4
  %144 = load i32, ptr %143, align 8, !tbaa !33
  %145 = trunc i32 %144 to i8
  %146 = load ptr, ptr %6, align 8, !tbaa !5
  %147 = getelementptr inbounds %struct.lfs_emubd, ptr %146, i32 0, i32 8
  %148 = load ptr, ptr %147, align 8, !tbaa !12
  %149 = getelementptr inbounds %struct.lfs_emubd_config, ptr %148, i32 0, i32 2
  %150 = load i32, ptr %149, align 8, !tbaa !34
  %151 = zext i32 %150 to i64
  call void @llvm.memset.p0.i64(ptr align 1 %139, i8 %145, i64 %151, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  store i64 0, ptr %9, align 8, !tbaa !35
  br label %152

152:                                              ; preds = %191, %134
  %153 = load i64, ptr %9, align 8, !tbaa !35
  %154 = load ptr, ptr %6, align 8, !tbaa !5
  %155 = getelementptr inbounds %struct.lfs_emubd, ptr %154, i32 0, i32 8
  %156 = load ptr, ptr %155, align 8, !tbaa !12
  %157 = getelementptr inbounds %struct.lfs_emubd_config, ptr %156, i32 0, i32 3
  %158 = load i32, ptr %157, align 4, !tbaa !15
  %159 = zext i32 %158 to i64
  %160 = icmp ult i64 %153, %159
  br i1 %160, label %162, label %161

161:                                              ; preds = %152
  store i32 2, ptr %7, align 4
  br label %194

162:                                              ; preds = %152
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %163 = load ptr, ptr %6, align 8, !tbaa !5
  %164 = getelementptr inbounds %struct.lfs_emubd, ptr %163, i32 0, i32 7
  %165 = load ptr, ptr %164, align 8, !tbaa !26
  %166 = getelementptr inbounds %struct.lfs_emubd_disk, ptr %165, i32 0, i32 1
  %167 = load i32, ptr %166, align 4, !tbaa !31
  %168 = load ptr, ptr %6, align 8, !tbaa !5
  %169 = getelementptr inbounds %struct.lfs_emubd, ptr %168, i32 0, i32 7
  %170 = load ptr, ptr %169, align 8, !tbaa !26
  %171 = getelementptr inbounds %struct.lfs_emubd_disk, ptr %170, i32 0, i32 2
  %172 = load ptr, ptr %171, align 8, !tbaa !30
  %173 = load ptr, ptr %6, align 8, !tbaa !5
  %174 = getelementptr inbounds %struct.lfs_emubd, ptr %173, i32 0, i32 8
  %175 = load ptr, ptr %174, align 8, !tbaa !12
  %176 = getelementptr inbounds %struct.lfs_emubd_config, ptr %175, i32 0, i32 2
  %177 = load i32, ptr %176, align 8, !tbaa !34
  %178 = zext i32 %177 to i64
  %179 = call i64 @write(i32 noundef %167, ptr noundef %172, i64 noundef %178)
  store i64 %179, ptr %10, align 8, !tbaa !35
  %180 = load i64, ptr %10, align 8, !tbaa !35
  %181 = icmp slt i64 %180, 0
  br i1 %181, label %182, label %187

182:                                              ; preds = %162
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  %183 = call ptr @__errno_location() #8
  %184 = load i32, ptr %183, align 4, !tbaa !32
  %185 = sub nsw i32 0, %184
  store i32 %185, ptr %11, align 4, !tbaa !32
  %186 = load i32, ptr %11, align 4, !tbaa !32
  store i32 %186, ptr %3, align 4
  store i32 1, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  br label %188

187:                                              ; preds = %162
  store i32 0, ptr %7, align 4
  br label %188

188:                                              ; preds = %187, %182
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  %189 = load i32, ptr %7, align 4
  switch i32 %189, label %194 [
    i32 0, label %190
  ]

190:                                              ; preds = %188
  br label %191

191:                                              ; preds = %190
  %192 = load i64, ptr %9, align 8, !tbaa !35
  %193 = add i64 %192, 1
  store i64 %193, ptr %9, align 8, !tbaa !35
  br label %152, !llvm.loop !36

194:                                              ; preds = %188, %161
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  %195 = load i32, ptr %7, align 4
  switch i32 %195, label %199 [
    i32 2, label %196
  ]

196:                                              ; preds = %194
  br label %197

197:                                              ; preds = %196, %108
  br label %198

198:                                              ; preds = %197, %33
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %199

199:                                              ; preds = %198, %194, %133, %103, %77, %32
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  %200 = load i32, ptr %3, align 4
  ret i32 %200
}

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

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

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

declare i32 @open(ptr noundef, i32 noundef, ...) #4

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__errno_location() #5

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

declare i64 @write(i32 noundef, ptr noundef, i64 noundef) #4

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

!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, !6, i64 0}
!10 = !{!"lfs_config", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !11, i64 40, !11, i64 44, !11, i64 48, !11, i64 52, !11, i64 56, !11, i64 60, !11, i64 64, !11, i64 68, !6, i64 72, !6, i64 80, !6, i64 88, !11, i64 96, !11, i64 100, !11, i64 104, !11, i64 108, !11, i64 112}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !6, i64 56}
!13 = !{!"lfs_emubd", !6, i64 0, !14, i64 8, !14, i64 16, !14, i64 24, !11, i64 32, !11, i64 36, !6, i64 40, !6, i64 48, !6, i64 56}
!14 = !{!"long", !7, i64 0}
!15 = !{!16, !11, i64 12}
!16 = !{!"lfs_emubd_config", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !6, i64 40, !6, i64 48, !17, i64 56, !6, i64 64, !14, i64 72, !14, i64 80, !14, i64 88}
!17 = !{!"_Bool", !7, i64 0}
!18 = !{!13, !6, i64 0}
!19 = !{!13, !14, i64 8}
!20 = !{!13, !14, i64 16}
!21 = !{!13, !14, i64 24}
!22 = !{!16, !11, i64 28}
!23 = !{!13, !11, i64 32}
!24 = !{!13, !11, i64 36}
!25 = !{!13, !6, i64 40}
!26 = !{!13, !6, i64 48}
!27 = !{!16, !6, i64 64}
!28 = !{!29, !11, i64 0}
!29 = !{!"lfs_emubd_disk", !11, i64 0, !11, i64 4, !6, i64 8}
!30 = !{!29, !6, i64 8}
!31 = !{!29, !11, i64 4}
!32 = !{!11, !11, i64 0}
!33 = !{!16, !11, i64 16}
!34 = !{!16, !11, i64 8}
!35 = !{!14, !14, i64 0}
!36 = distinct !{!36, !37}
!37 = !{!"llvm.loop.mustprogress"}


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

; Function Attrs: nofree nounwind uwtable
define dso_local i32 @lfs_emubd_create(ptr nocapture noundef readonly %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = load ptr, ptr %0, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %3, i64 56
  store ptr %1, ptr %4, align 8, !tbaa !11
  %5 = getelementptr inbounds i8, ptr %1, i64 12
  %6 = load i32, ptr %5, align 4, !tbaa !14
  %7 = zext i32 %6 to i64
  %8 = shl nuw nsw i64 %7, 3
  %calloc = tail call ptr @calloc(i64 1, i64 %8)
  store ptr %calloc, ptr %3, align 8, !tbaa !17
  %.not = icmp eq ptr %calloc, null
  br i1 %.not, label %.loopexit, label %9

9:                                                ; preds = %2
  %10 = getelementptr inbounds i8, ptr %3, i64 8
  %11 = getelementptr inbounds i8, ptr %1, i64 28
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %10, i8 0, i64 24, i1 false)
  %12 = load i32, ptr %11, align 4, !tbaa !18
  %13 = getelementptr inbounds i8, ptr %3, i64 32
  store i32 %12, ptr %13, align 8, !tbaa !19
  %14 = getelementptr inbounds i8, ptr %3, i64 36
  store i32 -1, ptr %14, align 4, !tbaa !20
  %15 = getelementptr inbounds i8, ptr %3, i64 40
  %16 = getelementptr inbounds i8, ptr %3, i64 48
  %17 = getelementptr inbounds i8, ptr %1, i64 64
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %15, i8 0, i64 16, i1 false)
  %18 = load ptr, ptr %17, align 8, !tbaa !21
  %.not49 = icmp eq ptr %18, null
  br i1 %.not49, label %.loopexit, label %19

19:                                               ; preds = %9
  %20 = tail call noalias dereferenceable_or_null(16) ptr @malloc(i64 noundef 16) #6
  store ptr %20, ptr %16, align 8, !tbaa !22
  %.not50 = icmp eq ptr %20, null
  br i1 %.not50, label %.loopexit, label %21

21:                                               ; preds = %19
  store i32 1, ptr %20, align 8, !tbaa !23
  %22 = getelementptr inbounds i8, ptr %20, i64 8
  store ptr null, ptr %22, align 8, !tbaa !25
  %23 = tail call i32 (ptr, i32, ...) @open(ptr noundef nonnull %18, i32 noundef 66, i32 noundef 438) #7
  %24 = load ptr, ptr %16, align 8, !tbaa !22
  %25 = getelementptr inbounds i8, ptr %24, i64 4
  store i32 %23, ptr %25, align 4, !tbaa !26
  %26 = icmp slt i32 %23, 0
  br i1 %26, label %.loopexit.sink.split, label %27

27:                                               ; preds = %21
  %28 = load ptr, ptr %4, align 8, !tbaa !11
  %29 = getelementptr inbounds i8, ptr %28, i64 16
  %30 = load i32, ptr %29, align 8, !tbaa !27
  %.not51 = icmp eq i32 %30, -1
  br i1 %.not51, label %.loopexit, label %31

31:                                               ; preds = %27
  %32 = getelementptr inbounds i8, ptr %28, i64 8
  %33 = load i32, ptr %32, align 8, !tbaa !28
  %34 = zext i32 %33 to i64
  %35 = tail call noalias ptr @malloc(i64 noundef %34) #6
  %36 = getelementptr inbounds i8, ptr %24, i64 8
  store ptr %35, ptr %36, align 8, !tbaa !25
  %.not52 = icmp eq ptr %35, null
  br i1 %.not52, label %.loopexit, label %37

37:                                               ; preds = %31
  %38 = trunc i32 %30 to i8
  tail call void @llvm.memset.p0.i64(ptr nonnull align 1 %35, i8 %38, i64 %34, i1 false)
  %39 = getelementptr inbounds i8, ptr %28, i64 12
  %40 = load i32, ptr %39, align 4, !tbaa !14
  %.not5358.not = icmp eq i32 %40, 0
  br i1 %.not5358.not, label %.loopexit, label %.lr.ph

41:                                               ; preds = %.lr.ph
  %42 = add nuw nsw i64 %.04559, 1
  %43 = load ptr, ptr %4, align 8, !tbaa !11
  %44 = getelementptr inbounds i8, ptr %43, i64 12
  %45 = load i32, ptr %44, align 4, !tbaa !14
  %46 = zext i32 %45 to i64
  %.not53 = icmp ult i64 %42, %46
  br i1 %.not53, label %.lr.ph, label %.loopexit, !llvm.loop !29

.lr.ph:                                           ; preds = %37, %41
  %47 = phi ptr [ %43, %41 ], [ %28, %37 ]
  %.04559 = phi i64 [ %42, %41 ], [ 0, %37 ]
  %48 = load ptr, ptr %16, align 8, !tbaa !22
  %49 = getelementptr inbounds i8, ptr %48, i64 4
  %50 = load i32, ptr %49, align 4, !tbaa !26
  %51 = getelementptr inbounds i8, ptr %48, i64 8
  %52 = load ptr, ptr %51, align 8, !tbaa !25
  %53 = getelementptr inbounds i8, ptr %47, i64 8
  %54 = load i32, ptr %53, align 8, !tbaa !28
  %55 = zext i32 %54 to i64
  %56 = tail call i64 @write(i32 noundef %50, ptr noundef %52, i64 noundef %55) #7
  %57 = icmp sgt i64 %56, -1
  br i1 %57, label %41, label %.loopexit.sink.split

.loopexit.sink.split:                             ; preds = %.lr.ph, %21
  %58 = tail call ptr @__errno_location() #8
  %59 = load i32, ptr %58, align 4, !tbaa !31
  %60 = sub nsw i32 0, %59
  br label %.loopexit

.loopexit:                                        ; preds = %41, %.loopexit.sink.split, %37, %9, %27, %31, %19, %2
  %.3 = phi i32 [ -12, %2 ], [ -12, %19 ], [ -12, %31 ], [ 0, %27 ], [ 0, %9 ], [ 0, %37 ], [ %60, %.loopexit.sink.split ], [ 0, %41 ]
  ret i32 %.3
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(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) #2

; Function Attrs: nofree
declare noundef i32 @open(ptr nocapture noundef readonly, i32 noundef, ...) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__errno_location() local_unnamed_addr #4

; Function Attrs: nofree
declare noundef i64 @write(i32 noundef, ptr nocapture noundef readonly, i64 noundef) local_unnamed_addr #3

; Function Attrs: nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #5

attributes #0 = { nofree 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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { nofree "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress nofree nosync nounwind willreturn memory(none) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #6 = { nounwind allocsize(0) }
attributes #7 = { nounwind }
attributes #8 = { nounwind willreturn memory(none) }

!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 = !{!"lfs_config", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !7, i64 72, !7, i64 80, !7, i64 88, !10, i64 96, !10, i64 100, !10, i64 104, !10, i64 108, !10, i64 112}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!12, !7, i64 56}
!12 = !{!"lfs_emubd", !7, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !10, i64 32, !10, i64 36, !7, i64 40, !7, i64 48, !7, i64 56}
!13 = !{!"long", !8, i64 0}
!14 = !{!15, !10, i64 12}
!15 = !{!"lfs_emubd_config", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !7, i64 40, !7, i64 48, !16, i64 56, !7, i64 64, !13, i64 72, !13, i64 80, !13, i64 88}
!16 = !{!"_Bool", !8, i64 0}
!17 = !{!12, !7, i64 0}
!18 = !{!15, !10, i64 28}
!19 = !{!12, !10, i64 32}
!20 = !{!12, !10, i64 36}
!21 = !{!15, !7, i64 64}
!22 = !{!12, !7, i64 48}
!23 = !{!24, !10, i64 0}
!24 = !{!"lfs_emubd_disk", !10, i64 0, !10, i64 4, !7, i64 8}
!25 = !{!24, !7, i64 8}
!26 = !{!24, !10, i64 4}
!27 = !{!15, !10, i64 16}
!28 = !{!15, !10, i64 8}
!29 = distinct !{!29, !30}
!30 = !{!"llvm.loop.mustprogress"}
!31 = !{!10, !10, i64 0}


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