; LLVM IR from echfs/echfs :: echfs-fuse/src (part)

; 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.mbr_entry = type { i8, [3 x i8], i8, [3 x i8], i32, i32 }
%struct.part = type { i64, i64 }

; Function Attrs: nounwind uwtable
define dso_local i32 @mbr_get_part(ptr noundef %0, ptr noundef %1, i32 noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca [4 x %struct.mbr_entry], align 16
  %9 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  %10 = load ptr, ptr %6, align 8, !tbaa !5
  %11 = call i32 @fseek(ptr noundef %10, i64 noundef 446, i32 noundef 0)
  call void @llvm.lifetime.start.p0(i64 64, ptr %8) #3
  %12 = getelementptr inbounds [4 x %struct.mbr_entry], ptr %8, i64 0, i64 0
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = call i64 @fread(ptr noundef %12, i64 noundef 16, i64 noundef 4, ptr noundef %13)
  %15 = load i32, ptr %7, align 4, !tbaa !9
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [4 x %struct.mbr_entry], ptr %8, i64 0, i64 %16
  %18 = getelementptr inbounds %struct.mbr_entry, ptr %17, i32 0, i32 2
  %19 = load i8, ptr %18, align 4, !tbaa !11
  %20 = icmp ne i8 %19, 0
  br i1 %20, label %22, label %21

21:                                               ; preds = %3
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %39

22:                                               ; preds = %3
  %23 = load i32, ptr %7, align 4, !tbaa !9
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [4 x %struct.mbr_entry], ptr %8, i64 0, i64 %24
  %26 = getelementptr inbounds %struct.mbr_entry, ptr %25, i32 0, i32 4
  %27 = load i32, ptr %26, align 8, !tbaa !13
  %28 = zext i32 %27 to i64
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.part, ptr %29, i32 0, i32 0
  store i64 %28, ptr %30, align 8, !tbaa !14
  %31 = load i32, ptr %7, align 4, !tbaa !9
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [4 x %struct.mbr_entry], ptr %8, i64 0, i64 %32
  %34 = getelementptr inbounds %struct.mbr_entry, ptr %33, i32 0, i32 5
  %35 = load i32, ptr %34, align 4, !tbaa !17
  %36 = zext i32 %35 to i64
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.part, ptr %37, i32 0, i32 1
  store i64 %36, ptr %38, align 8, !tbaa !18
  store i32 0, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %39

39:                                               ; preds = %22, %21
  call void @llvm.lifetime.end.p0(i64 64, ptr %8) #3
  %40 = load i32, ptr %4, align 4
  ret i32 %40
}

declare i32 @fseek(ptr noundef, i64 noundef, i32 noundef) #1

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

declare i64 @fread(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { "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 nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !7, i64 4}
!12 = !{!"mbr_entry", !7, i64 0, !7, i64 1, !7, i64 4, !7, i64 5, !10, i64 8, !10, i64 12}
!13 = !{!12, !10, i64 8}
!14 = !{!15, !16, i64 0}
!15 = !{!"part", !16, i64 0, !16, i64 8}
!16 = !{!"long", !7, i64 0}
!17 = !{!12, !10, i64 12}
!18 = !{!15, !16, i64 8}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.mbr_entry = type { i8, [3 x i8], i8, [3 x i8], i32, i32 }

; Function Attrs: nofree nounwind uwtable
define dso_local range(i32 -1, 1) i32 @mbr_get_part(ptr nocapture noundef writeonly %0, ptr nocapture noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = alloca [4 x %struct.mbr_entry], align 16
  %5 = tail call i32 @fseek(ptr noundef %1, i64 noundef 446, i32 noundef 0)
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %4) #3
  %6 = call i64 @fread(ptr noundef nonnull %4, i64 noundef 16, i64 noundef 4, ptr noundef %1)
  %7 = sext i32 %2 to i64
  %8 = getelementptr inbounds [4 x %struct.mbr_entry], ptr %4, i64 0, i64 %7
  %9 = getelementptr inbounds i8, ptr %8, i64 4
  %10 = load i8, ptr %9, align 4, !tbaa !5
  %.not = icmp eq i8 %10, 0
  br i1 %.not, label %15, label %11

11:                                               ; preds = %3
  %12 = getelementptr inbounds i8, ptr %8, i64 8
  %13 = load <2 x i32>, ptr %12, align 8, !tbaa !10
  %14 = zext <2 x i32> %13 to <2 x i64>
  store <2 x i64> %14, ptr %0, align 8, !tbaa !11
  br label %15

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

; Function Attrs: nofree nounwind
declare noundef i32 @fseek(ptr nocapture noundef, i64 noundef, i32 noundef) local_unnamed_addr #1

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

; Function Attrs: nofree nounwind
declare noundef i64 @fread(ptr nocapture noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #1

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

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 = { nofree 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 4}
!6 = !{!"mbr_entry", !7, i64 0, !7, i64 1, !7, i64 4, !7, i64 5, !9, i64 8, !9, i64 12}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!9, !9, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass