; LLVM IR from ryansturmer/thinfat32 :: src (thinfat32)

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

; 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
define dso_local zeroext i8 @tf_lfn_checksum(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i8, align 1
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  call void @llvm.lifetime.start.p0(i64 1, ptr %4) #2
  store i8 0, ptr %4, align 1, !tbaa !9
  store i32 11, ptr %3, align 4, !tbaa !10
  br label %5

5:                                                ; preds = %23, %1
  %6 = load i32, ptr %3, align 4, !tbaa !10
  %7 = icmp ne i32 %6, 0
  br i1 %7, label %8, label %26

8:                                                ; preds = %5
  %9 = load i8, ptr %4, align 1, !tbaa !9
  %10 = zext i8 %9 to i32
  %11 = and i32 %10, 1
  %12 = shl i32 %11, 7
  %13 = load i8, ptr %4, align 1, !tbaa !9
  %14 = zext i8 %13 to i32
  %15 = ashr i32 %14, 1
  %16 = add nsw i32 %12, %15
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %17, i32 1
  store ptr %18, ptr %2, align 8, !tbaa !5
  %19 = load i8, ptr %17, align 1, !tbaa !9
  %20 = zext i8 %19 to i32
  %21 = add nsw i32 %16, %20
  %22 = trunc i32 %21 to i8
  store i8 %22, ptr %4, align 1, !tbaa !9
  br label %23

23:                                               ; preds = %8
  %24 = load i32, ptr %3, align 4, !tbaa !10
  %25 = add nsw i32 %24, -1
  store i32 %25, ptr %3, align 4, !tbaa !10
  br label %5, !llvm.loop !12

26:                                               ; preds = %5
  %27 = load i8, ptr %4, align 1, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  ret i8 %27
}

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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"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: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local zeroext i8 @tf_lfn_checksum(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 1
  %3 = load i8, ptr %0, align 1, !tbaa !5
  %4 = tail call i8 @llvm.fshl.i8(i8 %3, i8 %3, i8 7)
  %5 = getelementptr inbounds i8, ptr %0, i64 2
  %6 = load i8, ptr %2, align 1, !tbaa !5
  %7 = add i8 %6, %4
  %8 = tail call i8 @llvm.fshl.i8(i8 %7, i8 %7, i8 7)
  %9 = getelementptr inbounds i8, ptr %0, i64 3
  %10 = load i8, ptr %5, align 1, !tbaa !5
  %11 = add i8 %10, %8
  %12 = tail call i8 @llvm.fshl.i8(i8 %11, i8 %11, i8 7)
  %13 = getelementptr inbounds i8, ptr %0, i64 4
  %14 = load i8, ptr %9, align 1, !tbaa !5
  %15 = add i8 %14, %12
  %16 = tail call i8 @llvm.fshl.i8(i8 %15, i8 %15, i8 7)
  %17 = getelementptr inbounds i8, ptr %0, i64 5
  %18 = load i8, ptr %13, align 1, !tbaa !5
  %19 = add i8 %18, %16
  %20 = tail call i8 @llvm.fshl.i8(i8 %19, i8 %19, i8 7)
  %21 = getelementptr inbounds i8, ptr %0, i64 6
  %22 = load i8, ptr %17, align 1, !tbaa !5
  %23 = add i8 %22, %20
  %24 = tail call i8 @llvm.fshl.i8(i8 %23, i8 %23, i8 7)
  %25 = getelementptr inbounds i8, ptr %0, i64 7
  %26 = load i8, ptr %21, align 1, !tbaa !5
  %27 = add i8 %26, %24
  %28 = tail call i8 @llvm.fshl.i8(i8 %27, i8 %27, i8 7)
  %29 = getelementptr inbounds i8, ptr %0, i64 8
  %30 = load i8, ptr %25, align 1, !tbaa !5
  %31 = add i8 %30, %28
  %32 = tail call i8 @llvm.fshl.i8(i8 %31, i8 %31, i8 7)
  %33 = getelementptr inbounds i8, ptr %0, i64 9
  %34 = load i8, ptr %29, align 1, !tbaa !5
  %35 = add i8 %34, %32
  %36 = tail call i8 @llvm.fshl.i8(i8 %35, i8 %35, i8 7)
  %37 = getelementptr inbounds i8, ptr %0, i64 10
  %38 = load i8, ptr %33, align 1, !tbaa !5
  %39 = add i8 %38, %36
  %40 = tail call i8 @llvm.fshl.i8(i8 %39, i8 %39, i8 7)
  %41 = load i8, ptr %37, align 1, !tbaa !5
  %42 = add i8 %41, %40
  ret i8 %42
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i8 @llvm.fshl.i8(i8, i8, i8) #1

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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 speculatable 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}


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