; 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.gpt_table_header = type <{ [8 x i8], i32, i32, i32, i32, i64, i64, i64, i64, %struct.anon, i64, i32, i32, i32 }>
%struct.anon = type { i64, i64 }
%struct.gpt_entry = type { %struct.anon.0, %struct.anon.1, i64, i64, i64, [36 x i16] }
%struct.anon.0 = type { i64, i64 }
%struct.anon.1 = type { i64, i64 }
%struct.part = type { i64, i64 }

@.str = external hidden unnamed_addr constant [9 x i8], align 1

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @gpt_get_part(ptr noundef %0, ptr noundef %1, i32 noundef %2) #2 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca %struct.gpt_table_header, align 1
  %9 = alloca i32, align 4
  %10 = alloca %struct.gpt_entry, align 1
  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
  call void @llvm.lifetime.start.p0(i64 92, ptr %8) #5
  call void @llvm.memset.p0.i64(ptr align 1 %8, i8 0, i64 92, i1 false)
  %11 = load ptr, ptr %6, align 8, !tbaa !5
  %12 = call i32 @fseek(ptr noundef %11, i64 noundef 512, i32 noundef 0)
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = call i64 @fread(ptr noundef %8, i64 noundef 1, i64 noundef 92, ptr noundef %13)
  %15 = getelementptr inbounds %struct.gpt_table_header, ptr %8, i32 0, i32 0
  %16 = getelementptr inbounds [8 x i8], ptr %15, i64 0, i64 0
  %17 = call i32 @strncmp(ptr noundef %16, ptr noundef @.str, i64 noundef 8) #6
  %18 = icmp ne i32 %17, 0
  br i1 %18, label %19, label %20

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

20:                                               ; preds = %3
  %21 = getelementptr inbounds %struct.gpt_table_header, ptr %8, i32 0, i32 1
  %22 = load i32, ptr %21, align 1, !tbaa !11
  %23 = icmp ne i32 %22, 65536
  br i1 %23, label %24, label %25

24:                                               ; preds = %20
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %67

25:                                               ; preds = %20
  %26 = load i32, ptr %7, align 4, !tbaa !9
  %27 = getelementptr inbounds %struct.gpt_table_header, ptr %8, i32 0, i32 11
  %28 = load i32, ptr %27, align 1, !tbaa !15
  %29 = icmp uge i32 %26, %28
  br i1 %29, label %30, label %31

30:                                               ; preds = %25
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %67

31:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 128, ptr %10) #5
  call void @llvm.memset.p0.i64(ptr align 1 %10, i8 0, i64 128, i1 false)
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.gpt_table_header, ptr %8, i32 0, i32 10
  %34 = load i64, ptr %33, align 1, !tbaa !16
  %35 = mul i64 %34, 512
  %36 = load i32, ptr %7, align 4, !tbaa !9
  %37 = sext i32 %36 to i64
  %38 = mul i64 %37, 128
  %39 = add i64 %35, %38
  %40 = call i32 @fseek(ptr noundef %32, i64 noundef %39, i32 noundef 0)
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = call i64 @fread(ptr noundef %10, i64 noundef 1, i64 noundef 128, ptr noundef %41)
  %43 = getelementptr inbounds %struct.gpt_entry, ptr %10, i32 0, i32 1
  %44 = getelementptr inbounds %struct.anon.1, ptr %43, i32 0, i32 0
  %45 = load i64, ptr %44, align 1, !tbaa !17
  %46 = icmp eq i64 %45, 0
  br i1 %46, label %47, label %53

47:                                               ; preds = %31
  %48 = getelementptr inbounds %struct.gpt_entry, ptr %10, i32 0, i32 1
  %49 = getelementptr inbounds %struct.anon.1, ptr %48, i32 0, i32 1
  %50 = load i64, ptr %49, align 1, !tbaa !19
  %51 = icmp eq i64 %50, 0
  br i1 %51, label %52, label %53

52:                                               ; preds = %47
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %66

53:                                               ; preds = %47, %31
  %54 = getelementptr inbounds %struct.gpt_entry, ptr %10, i32 0, i32 2
  %55 = load i64, ptr %54, align 1, !tbaa !20
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.part, ptr %56, i32 0, i32 0
  store i64 %55, ptr %57, align 8, !tbaa !21
  %58 = getelementptr inbounds %struct.gpt_entry, ptr %10, i32 0, i32 3
  %59 = load i64, ptr %58, align 1, !tbaa !23
  %60 = getelementptr inbounds %struct.gpt_entry, ptr %10, i32 0, i32 2
  %61 = load i64, ptr %60, align 1, !tbaa !20
  %62 = sub i64 %59, %61
  %63 = add i64 %62, 1
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.part, ptr %64, i32 0, i32 1
  store i64 %63, ptr %65, align 8, !tbaa !24
  store i32 0, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %66

66:                                               ; preds = %53, %52
  call void @llvm.lifetime.end.p0(i64 128, ptr %10) #5
  br label %67

67:                                               ; preds = %66, %30, %24, %19
  call void @llvm.lifetime.end.p0(i64 92, ptr %8) #5
  %68 = load i32, ptr %4, align 4
  ret i32 %68
}

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

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strncmp(ptr noundef, ptr noundef, i64 noundef) #4

attributes #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 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 #5 = { nounwind }
attributes #6 = { 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 = !{!12, !10, i64 8}
!12 = !{!"gpt_table_header", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !13, i64 24, !13, i64 32, !13, i64 40, !13, i64 48, !14, i64 56, !13, i64 72, !10, i64 80, !10, i64 84, !10, i64 88}
!13 = !{!"long", !7, i64 0}
!14 = !{!"", !13, i64 0, !13, i64 8}
!15 = !{!12, !10, i64 80}
!16 = !{!12, !13, i64 72}
!17 = !{!18, !13, i64 16}
!18 = !{!"gpt_entry", !14, i64 0, !14, i64 16, !13, i64 32, !13, i64 40, !13, i64 48, !7, i64 56}
!19 = !{!18, !13, i64 24}
!20 = !{!18, !13, i64 32}
!21 = !{!22, !13, i64 0}
!22 = !{!"part", !13, i64 0, !13, i64 8}
!23 = !{!18, !13, i64 40}
!24 = !{!22, !13, 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.gpt_table_header = type <{ [8 x i8], i32, i32, i32, i32, i64, i64, i64, i64, %struct.anon, i64, i32, i32, i32 }>
%struct.anon = type { i64, i64 }
%struct.gpt_entry = type { %struct.anon.0, %struct.anon.1, i64, i64, i64, [36 x i16] }
%struct.anon.0 = type { i64, i64 }
%struct.anon.1 = type { i64, i64 }

@.str = external hidden unnamed_addr constant [9 x i8], align 1

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

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

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

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

; Function Attrs: nofree nounwind uwtable
define dso_local range(i32 -1, 1) i32 @gpt_get_part(ptr nocapture noundef writeonly %0, ptr nocapture noundef %1, i32 noundef %2) local_unnamed_addr #2 {
  %4 = alloca %struct.gpt_table_header, align 1
  %5 = alloca %struct.gpt_entry, align 1
  call void @llvm.lifetime.start.p0(i64 92, ptr nonnull %4) #5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(92) %4, i8 0, i64 92, i1 false)
  %6 = tail call i32 @fseek(ptr noundef %1, i64 noundef 512, i32 noundef 0)
  %7 = call i64 @fread(ptr noundef nonnull %4, i64 noundef 1, i64 noundef 92, ptr noundef %1)
  %8 = call i32 @strncmp(ptr noundef nonnull dereferenceable(1) %4, ptr noundef nonnull dereferenceable(1) @.str, i64 noundef 8) #6
  %.not = icmp eq i32 %8, 0
  %9 = getelementptr inbounds i8, ptr %4, i64 8
  %10 = load i32, ptr %9, align 1
  %.not12 = icmp eq i32 %10, 65536
  %or.cond15 = select i1 %.not, i1 %.not12, i1 false
  %11 = getelementptr inbounds i8, ptr %4, i64 80
  %12 = load i32, ptr %11, align 1
  %.not13 = icmp ugt i32 %12, %2
  %or.cond17 = select i1 %or.cond15, i1 %.not13, i1 false
  br i1 %or.cond17, label %13, label %36

13:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %5) #5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(128) %5, i8 0, i64 128, i1 false)
  %14 = getelementptr inbounds i8, ptr %4, i64 72
  %15 = load i64, ptr %14, align 1, !tbaa !5
  %16 = shl i64 %15, 9
  %17 = sext i32 %2 to i64
  %18 = shl nsw i64 %17, 7
  %19 = add i64 %16, %18
  %20 = tail call i32 @fseek(ptr noundef %1, i64 noundef %19, i32 noundef 0)
  %21 = call i64 @fread(ptr noundef nonnull %5, i64 noundef 1, i64 noundef 128, ptr noundef %1)
  %22 = getelementptr inbounds i8, ptr %5, i64 16
  %23 = load i64, ptr %22, align 1, !tbaa !12
  %24 = icmp eq i64 %23, 0
  %25 = getelementptr inbounds i8, ptr %5, i64 24
  %26 = load i64, ptr %25, align 1
  %27 = icmp eq i64 %26, 0
  %or.cond = select i1 %24, i1 %27, i1 false
  br i1 %or.cond, label %35, label %28

28:                                               ; preds = %13
  %29 = getelementptr inbounds i8, ptr %5, i64 32
  %30 = load i64, ptr %29, align 1, !tbaa !14
  store i64 %30, ptr %0, align 8, !tbaa !15
  %31 = getelementptr inbounds i8, ptr %5, i64 40
  %32 = load i64, ptr %31, align 1, !tbaa !17
  %reass.sub = sub i64 %32, %30
  %33 = add i64 %reass.sub, 1
  %34 = getelementptr inbounds i8, ptr %0, i64 8
  store i64 %33, ptr %34, align 8, !tbaa !18
  br label %35

35:                                               ; preds = %13, %28
  %.0 = phi i32 [ 0, %28 ], [ -1, %13 ]
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %5) #5
  br label %36

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

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strncmp(ptr nocapture noundef, ptr nocapture noundef, i64 noundef) local_unnamed_addr #4

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 #5 = { nounwind }
attributes #6 = { 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, !10, i64 72}
!6 = !{!"gpt_table_header", !7, i64 0, !9, i64 8, !9, i64 12, !9, i64 16, !9, i64 20, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !11, i64 56, !10, i64 72, !9, i64 80, !9, i64 84, !9, i64 88}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!"", !10, i64 0, !10, i64 8}
!12 = !{!13, !10, i64 16}
!13 = !{!"gpt_entry", !11, i64 0, !11, i64 16, !10, i64 32, !10, i64 40, !10, i64 48, !7, i64 56}
!14 = !{!13, !10, i64 32}
!15 = !{!16, !10, i64 0}
!16 = !{!"part", !10, i64 0, !10, i64 8}
!17 = !{!13, !10, i64 40}
!18 = !{!16, !10, i64 8}


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