; LLVM IR from jingweizhanghuai/Morn :: src/util (morn_CRC)

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

@morn_reverse_data = external dso_local global [256 x i8], align 16

; 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 i32 @Reverse32(i32 noundef %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store i32 %0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  store ptr %2, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  store ptr %3, ptr %5, align 8, !tbaa !9
  %6 = load ptr, ptr %4, align 8, !tbaa !9
  %7 = getelementptr inbounds i8, ptr %6, i64 3
  %8 = load i8, ptr %7, align 1, !tbaa !11
  %9 = zext i8 %8 to i64
  %10 = getelementptr inbounds [256 x i8], ptr @morn_reverse_data, i64 0, i64 %9
  %11 = load i8, ptr %10, align 1, !tbaa !11
  %12 = load ptr, ptr %5, align 8, !tbaa !9
  %13 = getelementptr inbounds i8, ptr %12, i64 0
  store i8 %11, ptr %13, align 1, !tbaa !11
  %14 = load ptr, ptr %4, align 8, !tbaa !9
  %15 = getelementptr inbounds i8, ptr %14, i64 2
  %16 = load i8, ptr %15, align 1, !tbaa !11
  %17 = zext i8 %16 to i64
  %18 = getelementptr inbounds [256 x i8], ptr @morn_reverse_data, i64 0, i64 %17
  %19 = load i8, ptr %18, align 1, !tbaa !11
  %20 = load ptr, ptr %5, align 8, !tbaa !9
  %21 = getelementptr inbounds i8, ptr %20, i64 1
  store i8 %19, ptr %21, align 1, !tbaa !11
  %22 = load ptr, ptr %4, align 8, !tbaa !9
  %23 = getelementptr inbounds i8, ptr %22, i64 1
  %24 = load i8, ptr %23, align 1, !tbaa !11
  %25 = zext i8 %24 to i64
  %26 = getelementptr inbounds [256 x i8], ptr @morn_reverse_data, i64 0, i64 %25
  %27 = load i8, ptr %26, align 1, !tbaa !11
  %28 = load ptr, ptr %5, align 8, !tbaa !9
  %29 = getelementptr inbounds i8, ptr %28, i64 2
  store i8 %27, ptr %29, align 1, !tbaa !11
  %30 = load ptr, ptr %4, align 8, !tbaa !9
  %31 = getelementptr inbounds i8, ptr %30, i64 0
  %32 = load i8, ptr %31, align 1, !tbaa !11
  %33 = zext i8 %32 to i64
  %34 = getelementptr inbounds [256 x i8], ptr @morn_reverse_data, i64 0, i64 %33
  %35 = load i8, ptr %34, align 1, !tbaa !11
  %36 = load ptr, ptr %5, align 8, !tbaa !9
  %37 = getelementptr inbounds i8, ptr %36, i64 3
  store i8 %35, ptr %37, align 1, !tbaa !11
  %38 = load i32, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  ret i32 %38
}

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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!7, !7, i64 0}


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

@morn_reverse_data = external dso_local local_unnamed_addr global [256 x i8], align 16

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: none, inaccessiblemem: none) uwtable
define dso_local i32 @Reverse32(i32 noundef %0) local_unnamed_addr #0 {
  %.sroa.2.0.extract.shift = lshr i32 %0, 8
  %.sroa.3.0.extract.shift = lshr i32 %0, 16
  %.sroa.4.0.extract.shift = lshr i32 %0, 24
  %.sroa.4.0.extract.trunc = zext nneg i32 %.sroa.4.0.extract.shift to i64
  %2 = getelementptr inbounds [256 x i8], ptr @morn_reverse_data, i64 0, i64 %.sroa.4.0.extract.trunc
  %3 = load i8, ptr %2, align 1, !tbaa !5
  %4 = and i32 %.sroa.3.0.extract.shift, 255
  %5 = zext nneg i32 %4 to i64
  %6 = getelementptr inbounds [256 x i8], ptr @morn_reverse_data, i64 0, i64 %5
  %7 = load i8, ptr %6, align 1, !tbaa !5
  %8 = and i32 %.sroa.2.0.extract.shift, 255
  %9 = zext nneg i32 %8 to i64
  %10 = getelementptr inbounds [256 x i8], ptr @morn_reverse_data, i64 0, i64 %9
  %11 = load i8, ptr %10, align 1, !tbaa !5
  %12 = and i32 %0, 255
  %13 = zext nneg i32 %12 to i64
  %14 = getelementptr inbounds [256 x i8], ptr @morn_reverse_data, i64 0, i64 %13
  %15 = load i8, ptr %14, align 1, !tbaa !5
  %.sroa.6.0.insert.ext = zext i8 %15 to i32
  %.sroa.6.0.insert.shift = shl nuw i32 %.sroa.6.0.insert.ext, 24
  %.sroa.5.0.insert.ext = zext i8 %11 to i32
  %.sroa.5.0.insert.shift = shl nuw nsw i32 %.sroa.5.0.insert.ext, 16
  %.sroa.49.0.insert.ext = zext i8 %7 to i32
  %.sroa.49.0.insert.shift = shl nuw nsw i32 %.sroa.49.0.insert.ext, 8
  %.sroa.08.0.insert.ext = zext i8 %3 to i32
  %.sroa.5.0.insert.insert = or disjoint i32 %.sroa.49.0.insert.shift, %.sroa.08.0.insert.ext
  %.sroa.49.0.insert.insert = or disjoint i32 %.sroa.5.0.insert.insert, %.sroa.5.0.insert.shift
  %.sroa.08.0.insert.insert = or disjoint i32 %.sroa.49.0.insert.insert, %.sroa.6.0.insert.shift
  ret i32 %.sroa.08.0.insert.insert
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: none, inaccessiblemem: none) 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" }

!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,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass