; LLVM IR from cvra/robot-software :: lib/fatfs (ff)

; 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.DIR = type { ptr, i16, i16, i64, i64, i64, ptr, ptr }
%struct.FILINFO = type { i64, i16, i16, i8, [13 x i8] }
%struct.FATFS = type { i8, i8, i8, i8, i8, i8, i16, i16, i64, i64, i64, i64, i64, i64, i64, i64, i64, [512 x i8] }

; 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 hidden i32 @find_volume(ptr noundef, ptr noundef, i8 noundef zeroext) #1

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

; Function Attrs: nounwind uwtable
declare hidden i32 @sync_fs(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @f_utime(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca %struct.DIR, align 8
  %7 = alloca ptr, align 8
  %8 = alloca [12 x i8], align 1
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 56, ptr %6) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.start.p0(i64 12, ptr %8) #2
  %9 = getelementptr inbounds %struct.DIR, ptr %6, i32 0, i32 0
  %10 = call i32 @find_volume(ptr noundef %9, ptr noundef %3, i8 noundef zeroext 1)
  store i32 %10, ptr %5, align 4, !tbaa !9
  %11 = load i32, ptr %5, align 4, !tbaa !9
  %12 = icmp eq i32 %11, 0
  br i1 %12, label %13, label %65

13:                                               ; preds = %2
  %14 = getelementptr inbounds [12 x i8], ptr %8, i64 0, i64 0
  %15 = getelementptr inbounds %struct.DIR, ptr %6, i32 0, i32 7
  store ptr %14, ptr %15, align 8, !tbaa !11
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = call i32 @follow_path(ptr noundef %6, ptr noundef %16)
  store i32 %17, ptr %5, align 4, !tbaa !9
  %18 = load i32, ptr %5, align 4, !tbaa !9
  %19 = icmp eq i32 %18, 0
  br i1 %19, label %20, label %64

20:                                               ; preds = %13
  %21 = getelementptr inbounds %struct.DIR, ptr %6, i32 0, i32 6
  %22 = load ptr, ptr %21, align 8, !tbaa !15
  store ptr %22, ptr %7, align 8, !tbaa !5
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = icmp ne ptr %23, null
  br i1 %24, label %26, label %25

25:                                               ; preds = %20
  store i32 6, ptr %5, align 4, !tbaa !9
  br label %63

26:                                               ; preds = %20
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.FILINFO, ptr %27, i32 0, i32 2
  %29 = load i16, ptr %28, align 2, !tbaa !16
  %30 = trunc i16 %29 to i8
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %31, i64 22
  store i8 %30, ptr %32, align 1, !tbaa !18
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.FILINFO, ptr %33, i32 0, i32 2
  %35 = load i16, ptr %34, align 2, !tbaa !16
  %36 = zext i16 %35 to i32
  %37 = ashr i32 %36, 8
  %38 = trunc i32 %37 to i8
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = getelementptr inbounds i8, ptr %39, i64 22
  %41 = getelementptr inbounds i8, ptr %40, i64 1
  store i8 %38, ptr %41, align 1, !tbaa !18
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.FILINFO, ptr %42, i32 0, i32 1
  %44 = load i16, ptr %43, align 8, !tbaa !19
  %45 = trunc i16 %44 to i8
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = getelementptr inbounds i8, ptr %46, i64 24
  store i8 %45, ptr %47, align 1, !tbaa !18
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.FILINFO, ptr %48, i32 0, i32 1
  %50 = load i16, ptr %49, align 8, !tbaa !19
  %51 = zext i16 %50 to i32
  %52 = ashr i32 %51, 8
  %53 = trunc i32 %52 to i8
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  %55 = getelementptr inbounds i8, ptr %54, i64 24
  %56 = getelementptr inbounds i8, ptr %55, i64 1
  store i8 %53, ptr %56, align 1, !tbaa !18
  %57 = getelementptr inbounds %struct.DIR, ptr %6, i32 0, i32 0
  %58 = load ptr, ptr %57, align 8, !tbaa !20
  %59 = getelementptr inbounds %struct.FATFS, ptr %58, i32 0, i32 4
  store i8 1, ptr %59, align 4, !tbaa !21
  %60 = getelementptr inbounds %struct.DIR, ptr %6, i32 0, i32 0
  %61 = load ptr, ptr %60, align 8, !tbaa !20
  %62 = call i32 @sync_fs(ptr noundef %61)
  store i32 %62, ptr %5, align 4, !tbaa !9
  br label %63

63:                                               ; preds = %26, %25
  br label %64

64:                                               ; preds = %63, %13
  br label %65

65:                                               ; preds = %64, %2
  %66 = load i32, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 12, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 56, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret i32 %66
}

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 = { 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, !6, i64 48}
!12 = !{!"", !6, i64 0, !13, i64 8, !13, i64 10, !14, i64 16, !14, i64 24, !14, i64 32, !6, i64 40, !6, i64 48}
!13 = !{!"short", !7, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!12, !6, i64 40}
!16 = !{!17, !13, i64 10}
!17 = !{!"", !14, i64 0, !13, i64 8, !13, i64 10, !7, i64 12, !7, i64 13}
!18 = !{!7, !7, i64 0}
!19 = !{!17, !13, i64 8}
!20 = !{!12, !6, i64 0}
!21 = !{!22, !7, i64 4}
!22 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4, !7, i64 5, !13, i64 6, !13, i64 8, !14, i64 16, !14, i64 24, !14, i64 32, !14, i64 40, !14, i64 48, !14, i64 56, !14, i64 64, !14, i64 72, !14, i64 80, !7, i64 88}


; 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.DIR = type { ptr, i16, i16, i64, i64, i64, ptr, ptr }

; 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 hidden i32 @find_volume(ptr noundef, ptr noundef, i8 noundef zeroext) local_unnamed_addr #1

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @f_utime(ptr noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #1 {
  %3 = alloca ptr, align 8
  %4 = alloca %struct.DIR, align 8
  %5 = alloca [12 x i8], align 1
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 56, ptr nonnull %4) #2
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %5) #2
  %6 = call i32 @find_volume(ptr noundef nonnull %4, ptr noundef nonnull %3, i8 noundef zeroext 1)
  %7 = icmp eq i32 %6, 0
  br i1 %7, label %8, label %36

8:                                                ; preds = %2
  %9 = getelementptr inbounds i8, ptr %4, i64 48
  store ptr %5, ptr %9, align 8, !tbaa !9
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = call i32 @follow_path(ptr noundef nonnull %4, ptr noundef %10)
  %12 = icmp eq i32 %11, 0
  br i1 %12, label %13, label %36

13:                                               ; preds = %8
  %14 = getelementptr inbounds i8, ptr %4, i64 40
  %15 = load ptr, ptr %14, align 8, !tbaa !13
  %.not = icmp eq ptr %15, null
  br i1 %.not, label %36, label %16

16:                                               ; preds = %13
  %17 = getelementptr inbounds i8, ptr %1, i64 10
  %18 = load i16, ptr %17, align 2, !tbaa !14
  %19 = trunc i16 %18 to i8
  %20 = getelementptr inbounds i8, ptr %15, i64 22
  store i8 %19, ptr %20, align 1, !tbaa !16
  %21 = load i16, ptr %17, align 2, !tbaa !14
  %22 = lshr i16 %21, 8
  %23 = trunc nuw i16 %22 to i8
  %24 = getelementptr inbounds i8, ptr %15, i64 23
  store i8 %23, ptr %24, align 1, !tbaa !16
  %25 = getelementptr inbounds i8, ptr %1, i64 8
  %26 = load i16, ptr %25, align 8, !tbaa !17
  %27 = trunc i16 %26 to i8
  %28 = getelementptr inbounds i8, ptr %15, i64 24
  store i8 %27, ptr %28, align 1, !tbaa !16
  %29 = load i16, ptr %25, align 8, !tbaa !17
  %30 = lshr i16 %29, 8
  %31 = trunc nuw i16 %30 to i8
  %32 = getelementptr inbounds i8, ptr %15, i64 25
  store i8 %31, ptr %32, align 1, !tbaa !16
  %33 = load ptr, ptr %4, align 8, !tbaa !18
  %34 = getelementptr inbounds i8, ptr %33, i64 4
  store i8 1, ptr %34, align 4, !tbaa !19
  %35 = call i32 @sync_fs(ptr noundef %33)
  br label %36

36:                                               ; preds = %13, %8, %16, %2
  %.0 = phi i32 [ %35, %16 ], [ %11, %8 ], [ %6, %2 ], [ 6, %13 ]
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %5) #2
  call void @llvm.lifetime.end.p0(i64 56, ptr nonnull %4) #2
  ret i32 %.0
}

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 = { 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, !6, i64 48}
!10 = !{!"", !6, i64 0, !11, i64 8, !11, i64 10, !12, i64 16, !12, i64 24, !12, i64 32, !6, i64 40, !6, i64 48}
!11 = !{!"short", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!10, !6, i64 40}
!14 = !{!15, !11, i64 10}
!15 = !{!"", !12, i64 0, !11, i64 8, !11, i64 10, !7, i64 12, !7, i64 13}
!16 = !{!7, !7, i64 0}
!17 = !{!15, !11, i64 8}
!18 = !{!10, !6, i64 0}
!19 = !{!20, !7, i64 4}
!20 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4, !7, i64 5, !11, i64 6, !11, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !12, i64 56, !12, i64 64, !12, i64 72, !12, i64 80, !7, i64 88}


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