; LLVM IR from mlcommons/tiny :: benchmark/interface/Middlewares/ST/filex/common/src/fx_file_extended_relative/7eecc401 (seek)

; 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_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 }
%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_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_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 }

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

14:                                               ; preds = %3
  store i32 7, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %77

15:                                               ; preds = %3
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.FX_FILE_STRUCT, ptr %16, i32 0, i32 16
  %18 = load ptr, ptr %17, align 8, !tbaa !17
  store ptr %18, ptr %8, align 8, !tbaa !5
  %19 = load ptr, ptr %8, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.FX_MEDIA_STRUCT, ptr %19, i32 0, i32 78
  %21 = load i64, ptr %20, align 8, !tbaa !18
  %22 = add i64 %21, 1
  store i64 %22, ptr %20, align 8, !tbaa !18
  %23 = load i32, ptr %7, align 4, !tbaa !11
  %24 = icmp eq i32 %23, 0
  br i1 %24, label %25, label %29

25:                                               ; preds = %15
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = load i64, ptr %6, align 8, !tbaa !9
  %28 = call i32 @_fx_file_extended_seek(ptr noundef %26, i64 noundef %27)
  store i32 %28, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %77

29:                                               ; preds = %15
  %30 = load i32, ptr %7, align 4, !tbaa !11
  %31 = icmp eq i32 %30, 1
  br i1 %31, label %32, label %49

32:                                               ; preds = %29
  %33 = load i64, ptr %6, align 8, !tbaa !9
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.FX_FILE_STRUCT, ptr %34, i32 0, i32 14
  %36 = load i64, ptr %35, align 8, !tbaa !22
  %37 = icmp uge i64 %33, %36
  br i1 %37, label %38, label %41

38:                                               ; preds = %32
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = call i32 @_fx_file_extended_seek(ptr noundef %39, i64 noundef 0)
  store i32 %40, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %77

41:                                               ; preds = %32
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.FX_FILE_STRUCT, ptr %43, i32 0, i32 14
  %45 = load i64, ptr %44, align 8, !tbaa !22
  %46 = load i64, ptr %6, align 8, !tbaa !9
  %47 = sub i64 %45, %46
  %48 = call i32 @_fx_file_extended_seek(ptr noundef %42, i64 noundef %47)
  store i32 %48, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %77

49:                                               ; preds = %29
  %50 = load i32, ptr %7, align 4, !tbaa !11
  %51 = icmp eq i32 %50, 2
  br i1 %51, label %52, label %60

52:                                               ; preds = %49
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.FX_FILE_STRUCT, ptr %54, i32 0, i32 13
  %56 = load i64, ptr %55, align 8, !tbaa !23
  %57 = load i64, ptr %6, align 8, !tbaa !9
  %58 = add i64 %56, %57
  %59 = call i32 @_fx_file_extended_seek(ptr noundef %53, i64 noundef %58)
  store i32 %59, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %77

60:                                               ; preds = %49
  %61 = load i64, ptr %6, align 8, !tbaa !9
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.FX_FILE_STRUCT, ptr %62, i32 0, i32 13
  %64 = load i64, ptr %63, align 8, !tbaa !23
  %65 = icmp uge i64 %61, %64
  br i1 %65, label %66, label %69

66:                                               ; preds = %60
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = call i32 @_fx_file_extended_seek(ptr noundef %67, i64 noundef 0)
  store i32 %68, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %77

69:                                               ; preds = %60
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.FX_FILE_STRUCT, ptr %71, i32 0, i32 13
  %73 = load i64, ptr %72, align 8, !tbaa !23
  %74 = load i64, ptr %6, align 8, !tbaa !9
  %75 = sub i64 %73, %74
  %76 = call i32 @_fx_file_extended_seek(ptr noundef %70, i64 noundef %75)
  store i32 %76, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %77

77:                                               ; preds = %69, %66, %52, %41, %38, %25, %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  %78 = load i32, ptr %4, align 4
  ret i32 %78
}

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

declare i32 @_fx_file_extended_seek(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

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 = { 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 = !{!"long long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !15, i64 0}
!14 = !{!"FX_FILE_STRUCT", !15, i64 0, !6, i64 8, !15, i64 16, !7, i64 24, !15, i64 32, !15, i64 40, !15, i64 48, !15, i64 56, !15, i64 64, !10, i64 72, !15, i64 80, !15, i64 88, !15, i64 96, !10, i64 104, !10, i64 112, !10, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !16, i64 152, !7, i64 288, !15, i64 544, !6, i64 552}
!15 = !{!"long", !7, i64 0}
!16 = !{!"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, !15, i64 56, !10, i64 64, !10, i64 72, !15, i64 80, !15, i64 88, !15, i64 96, !15, i64 104, !10, i64 112, !15, i64 120, !10, i64 128}
!17 = !{!14, !6, i64 128}
!18 = !{!19, !15, i64 552}
!19 = !{!"FX_MEDIA_STRUCT", !15, i64 0, !6, i64 8, !6, i64 16, !15, i64 24, !12, i64 32, !15, i64 40, !6, i64 48, !6, i64 56, !15, i64 64, !15, i64 72, !12, i64 80, !12, i64 84, !12, i64 88, !10, i64 96, !15, 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, !15, i64 152, !12, i64 160, !15, i64 168, !15, i64 176, !12, i64 184, !15, i64 192, !15, i64 200, !6, i64 208, !12, i64 216, !12, i64 220, !6, i64 224, !15, i64 232, !15, i64 240, !15, 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, !15, i64 320, !6, i64 328, !6, i64 336, !15, i64 344, !15, i64 352, !15, i64 360, !15, i64 368, !15, i64 376, !15, i64 384, !15, i64 392, !15, i64 400, !15, i64 408, !15, i64 416, !15, i64 424, !15, i64 432, !15, i64 440, !15, i64 448, !15, i64 456, !15, i64 464, !15, i64 472, !15, i64 480, !15, i64 488, !15, i64 496, !15, i64 504, !15, i64 512, !15, i64 520, !15, i64 528, !15, i64 536, !15, i64 544, !15, i64 552, !15, i64 560, !15, i64 568, !15, i64 576, !15, i64 584, !15, i64 592, !15, i64 600, !15, i64 608, !15, i64 616, !15, i64 624, !15, i64 632, !15, i64 640, !15, i64 648, !15, i64 656, !15, i64 664, !15, i64 672, !15, i64 680, !15, i64 688, !15, i64 696, !15, i64 704, !15, i64 712, !15, i64 720, !15, i64 728, !15, i64 736, !15, i64 744, !15, i64 752, !15, i64 760, !15, i64 768, !15, i64 776, !15, i64 784, !15, i64 792, !15, i64 800, !15, i64 808, !15, i64 816, !20, i64 824, !12, i64 920, !16, i64 928, !16, i64 1064, !7, i64 1200, !7, i64 1456, !21, i64 1712, !7, i64 2368, !7, i64 2752, !15, i64 2880, !7, i64 2888, !7, i64 3912, !15, i64 12104, !15, i64 12112, !15, i64 12120, !15, i64 12128, !7, i64 12136}
!20 = !{!"TX_MUTEX_STRUCT", !15, 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}
!21 = !{!"FX_PATH_STRUCT", !16, i64 0, !7, i64 136, !7, i64 392, !15, i64 648}
!22 = !{!14, !10, i64 112}
!23 = !{!14, !10, i64 104}


; 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: nounwind uwtable
define dso_local i32 @_fx_file_extended_relative_seek(ptr noundef %0, i64 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = load i64, ptr %0, align 8, !tbaa !5
  %.not = icmp eq i64 %4, 1179208773
  br i1 %.not, label %5, label %22

5:                                                ; preds = %3
  %6 = getelementptr inbounds i8, ptr %0, i64 128
  %7 = load ptr, ptr %6, align 8, !tbaa !14
  %8 = getelementptr inbounds i8, ptr %7, i64 552
  %9 = load i64, ptr %8, align 8, !tbaa !15
  %10 = add i64 %9, 1
  store i64 %10, ptr %8, align 8, !tbaa !15
  switch i32 %2, label %18 [
    i32 0, label %.sink.split
    i32 1, label %11
    i32 2, label %14
  ]

11:                                               ; preds = %5
  %12 = getelementptr inbounds i8, ptr %0, i64 112
  %13 = load i64, ptr %12, align 8, !tbaa !19
  %spec.select = tail call i64 @llvm.usub.sat.i64(i64 %13, i64 %1)
  br label %.sink.split

14:                                               ; preds = %5
  %15 = getelementptr inbounds i8, ptr %0, i64 104
  %16 = load i64, ptr %15, align 8, !tbaa !20
  %17 = add i64 %16, %1
  br label %.sink.split

18:                                               ; preds = %5
  %19 = getelementptr inbounds i8, ptr %0, i64 104
  %20 = load i64, ptr %19, align 8, !tbaa !20
  %spec.select29 = tail call i64 @llvm.usub.sat.i64(i64 %20, i64 %1)
  br label %.sink.split

.sink.split:                                      ; preds = %18, %11, %5, %14
  %.sink = phi i64 [ %17, %14 ], [ %1, %5 ], [ %spec.select, %11 ], [ %spec.select29, %18 ]
  %21 = tail call i32 @_fx_file_extended_seek(ptr noundef nonnull %0, i64 noundef %.sink) #3
  br label %22

22:                                               ; preds = %.sink.split, %3
  %.0 = phi i32 [ 7, %3 ], [ %21, %.sink.split ]
  ret i32 %.0
}

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.usub.sat.i64(i64, i64) #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 speculatable willreturn memory(none) }
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_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, !11, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !11, i64 104, !11, i64 112, !11, i64 120, !10, i64 128, !10, i64 136, !10, i64 144, !12, i64 152, !8, i64 288, !7, i64 544, !10, i64 552}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"long long", !8, i64 0}
!12 = !{!"FX_DIR_ENTRY_STRUCT", !10, i64 0, !8, i64 8, !13, i64 24, !13, i64 28, !8, i64 32, !8, i64 33, !8, i64 34, !13, i64 36, !13, i64 40, !13, i64 44, !13, i64 48, !13, i64 52, !7, i64 56, !11, i64 64, !11, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !7, i64 104, !11, i64 112, !7, i64 120, !11, i64 128}
!13 = !{!"int", !8, i64 0}
!14 = !{!6, !10, i64 128}
!15 = !{!16, !7, i64 552}
!16 = !{!"FX_MEDIA_STRUCT", !7, i64 0, !10, i64 8, !10, i64 16, !7, i64 24, !13, i64 32, !7, i64 40, !10, i64 48, !10, i64 56, !7, i64 64, !7, i64 72, !13, i64 80, !13, i64 84, !13, i64 88, !11, i64 96, !7, i64 104, !13, i64 112, !13, i64 116, !13, i64 120, !13, i64 124, !13, i64 128, !13, i64 132, !13, i64 136, !13, i64 140, !13, i64 144, !7, i64 152, !13, i64 160, !7, i64 168, !7, i64 176, !13, i64 184, !7, i64 192, !7, i64 200, !10, i64 208, !13, i64 216, !13, i64 220, !10, i64 224, !7, i64 232, !7, i64 240, !7, i64 248, !13, i64 256, !13, i64 260, !13, i64 264, !13, i64 268, !13, i64 272, !13, i64 276, !13, 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, !17, i64 824, !13, i64 920, !12, i64 928, !12, i64 1064, !8, i64 1200, !8, i64 1456, !18, 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}
!17 = !{!"TX_MUTEX_STRUCT", !7, i64 0, !10, i64 8, !13, i64 16, !10, i64 24, !13, i64 32, !13, i64 36, !10, i64 40, !13, i64 48, !10, i64 56, !10, i64 64, !13, i64 72, !10, i64 80, !10, i64 88}
!18 = !{!"FX_PATH_STRUCT", !12, i64 0, !8, i64 136, !8, i64 392, !7, i64 648}
!19 = !{!6, !11, i64 112}
!20 = !{!6, !11, i64 104}


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