; LLVM IR from jingweizhanghuai/Morn :: src/math (morn_math_common)

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

@.str = external hidden unnamed_addr constant [83 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [14 x i8], align 1
@__FUNCTION__.m_Hash = external hidden unnamed_addr constant [7 x i8], align 1

; 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

declare void @m_Exception(i32 noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @m_Hash(ptr noundef %0, i32 noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  br label %8

8:                                                ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = icmp eq ptr %9, null
  br i1 %10, label %15, label %11

11:                                               ; preds = %8
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = ptrtoint ptr %12 to i64
  %14 = icmp eq i64 %13, -1
  br label %15

15:                                               ; preds = %11, %8
  %16 = phi i1 [ true, %8 ], [ %14, %11 ]
  %17 = zext i1 %16 to i32
  store i32 %17, ptr %7, align 4, !tbaa !9
  %18 = load i32, ptr %7, align 4, !tbaa !9
  %19 = icmp ne i32 %18, 0
  br i1 %19, label %20, label %22

20:                                               ; preds = %15
  %21 = load i32, ptr %7, align 4, !tbaa !9
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %21, i32 noundef -1, ptr noundef @.str, i32 noundef 457, ptr noundef @__FUNCTION__.m_Hash, ptr noundef @.str.1)
  br label %22

22:                                               ; preds = %20, %15
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %23

23:                                               ; preds = %22
  br label %24

24:                                               ; preds = %23
  store i32 -2128831035, ptr %5, align 4, !tbaa !9
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %25

25:                                               ; preds = %73, %24
  %26 = load i32, ptr %4, align 4, !tbaa !9
  %27 = icmp sle i32 %26, 0
  br i1 %27, label %28, label %37

28:                                               ; preds = %25
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = load i32, ptr %6, align 4, !tbaa !9
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds i8, ptr %29, i64 %31
  %33 = load i8, ptr %32, align 1, !tbaa !11
  %34 = sext i8 %33 to i32
  %35 = icmp ne i32 %34, 0
  %36 = zext i1 %35 to i32
  br label %42

37:                                               ; preds = %25
  %38 = load i32, ptr %6, align 4, !tbaa !9
  %39 = load i32, ptr %4, align 4, !tbaa !9
  %40 = icmp sle i32 %38, %39
  %41 = zext i1 %40 to i32
  br label %42

42:                                               ; preds = %37, %28
  %43 = phi i32 [ %36, %28 ], [ %41, %37 ]
  %44 = icmp ne i32 %43, 0
  br i1 %44, label %45, label %76

45:                                               ; preds = %42
  %46 = load i32, ptr %5, align 4, !tbaa !9
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = load i32, ptr %6, align 4, !tbaa !9
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds i8, ptr %47, i64 %49
  %51 = load i8, ptr %50, align 1, !tbaa !11
  %52 = sext i8 %51 to i32
  %53 = xor i32 %46, %52
  store i32 %53, ptr %5, align 4, !tbaa !9
  %54 = load i32, ptr %5, align 4, !tbaa !9
  %55 = shl i32 %54, 24
  %56 = load i32, ptr %5, align 4, !tbaa !9
  %57 = shl i32 %56, 8
  %58 = add i32 %55, %57
  %59 = load i32, ptr %5, align 4, !tbaa !9
  %60 = shl i32 %59, 6
  %61 = add i32 %58, %60
  %62 = load i32, ptr %5, align 4, !tbaa !9
  %63 = shl i32 %62, 4
  %64 = add i32 %61, %63
  %65 = load i32, ptr %5, align 4, !tbaa !9
  %66 = shl i32 %65, 3
  %67 = add i32 %64, %66
  %68 = load i32, ptr %5, align 4, !tbaa !9
  %69 = shl i32 %68, 2
  %70 = add i32 %67, %69
  %71 = load i32, ptr %5, align 4, !tbaa !9
  %72 = add i32 %70, %71
  store i32 %72, ptr %5, align 4, !tbaa !9
  br label %73

73:                                               ; preds = %45
  %74 = load i32, ptr %6, align 4, !tbaa !9
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr %6, align 4, !tbaa !9
  br label %25, !llvm.loop !12

76:                                               ; preds = %42
  %77 = load i32, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret i32 %77
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { 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 = !{!7, !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"

@.str = external hidden unnamed_addr constant [83 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [14 x i8], align 1
@__FUNCTION__.m_Hash = external hidden unnamed_addr constant [7 x i8], align 1

declare void @m_Exception(i32 noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ...) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i32 @m_Hash(ptr noundef %0, i32 noundef %1) local_unnamed_addr #1 {
  %magicptr = ptrtoint ptr %0 to i64
  switch i64 %magicptr, label %8 [
    i64 -1, label %3
    i64 0, label %3
  ]

3:                                                ; preds = %2, %2
  %4 = icmp eq ptr %0, null
  %5 = icmp eq ptr %0, inttoptr (i64 -1 to ptr)
  %6 = or i1 %4, %5
  %7 = zext i1 %6 to i32
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %7, i32 noundef -1, ptr noundef nonnull @.str, i32 noundef 457, ptr noundef nonnull @__FUNCTION__.m_Hash, ptr noundef nonnull @.str.1) #2
  br label %8

8:                                                ; preds = %2, %3
  %9 = icmp slt i32 %1, 1
  br i1 %9, label %.split.us, label %.split.preheader

.split.preheader:                                 ; preds = %8
  %10 = add nuw i32 %1, 1
  %wide.trip.count = zext i32 %10 to i64
  %xtraiter = and i64 %wide.trip.count, 3
  %11 = icmp ult i32 %1, 3
  br i1 %11, label %.split24.us.loopexit40.unr-lcssa, label %.split.preheader.new

.split.preheader.new:                             ; preds = %.split.preheader
  %unroll_iter = and i64 %wide.trip.count, 4294967292
  br label %.split

.split.us:                                        ; preds = %8
  %12 = load i8, ptr %0, align 1, !tbaa !5
  %.not22.us27 = icmp eq i8 %12, 0
  br i1 %.not22.us27, label %.split24.us, label %.lr.ph

.lr.ph:                                           ; preds = %.split.us, %.lr.ph
  %13 = phi i8 [ %18, %.lr.ph ], [ %12, %.split.us ]
  %indvars.iv33 = phi i64 [ %indvars.iv.next34, %.lr.ph ], [ 0, %.split.us ]
  %.0.us29 = phi i32 [ %16, %.lr.ph ], [ -2128831035, %.split.us ]
  %14 = sext i8 %13 to i32
  %15 = xor i32 %.0.us29, %14
  %16 = mul i32 %15, 16777565
  %indvars.iv.next34 = add nuw nsw i64 %indvars.iv33, 1
  %17 = getelementptr inbounds i8, ptr %0, i64 %indvars.iv.next34
  %18 = load i8, ptr %17, align 1, !tbaa !5
  %.not22.us = icmp eq i8 %18, 0
  br i1 %.not22.us, label %.split24.us, label %.lr.ph, !llvm.loop !8

.split:                                           ; preds = %.split, %.split.preheader.new
  %indvars.iv = phi i64 [ 0, %.split.preheader.new ], [ %indvars.iv.next.3, %.split ]
  %.026 = phi i32 [ -2128831035, %.split.preheader.new ], [ %38, %.split ]
  %niter = phi i64 [ 0, %.split.preheader.new ], [ %niter.next.3, %.split ]
  %19 = getelementptr inbounds i8, ptr %0, i64 %indvars.iv
  %20 = load i8, ptr %19, align 1, !tbaa !5
  %21 = sext i8 %20 to i32
  %22 = xor i32 %.026, %21
  %23 = mul i32 %22, 16777565
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %24 = getelementptr inbounds i8, ptr %0, i64 %indvars.iv.next
  %25 = load i8, ptr %24, align 1, !tbaa !5
  %26 = sext i8 %25 to i32
  %27 = xor i32 %23, %26
  %28 = mul i32 %27, 16777565
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %29 = getelementptr inbounds i8, ptr %0, i64 %indvars.iv.next.1
  %30 = load i8, ptr %29, align 1, !tbaa !5
  %31 = sext i8 %30 to i32
  %32 = xor i32 %28, %31
  %33 = mul i32 %32, 16777565
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %34 = getelementptr inbounds i8, ptr %0, i64 %indvars.iv.next.2
  %35 = load i8, ptr %34, align 1, !tbaa !5
  %36 = sext i8 %35 to i32
  %37 = xor i32 %33, %36
  %38 = mul i32 %37, 16777565
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %.split24.us.loopexit40.unr-lcssa, label %.split, !llvm.loop !8

.split24.us.loopexit40.unr-lcssa:                 ; preds = %.split, %.split.preheader
  %.lcssa41.ph = phi i32 [ poison, %.split.preheader ], [ %38, %.split ]
  %indvars.iv.unr = phi i64 [ 0, %.split.preheader ], [ %indvars.iv.next.3, %.split ]
  %.026.unr = phi i32 [ -2128831035, %.split.preheader ], [ %38, %.split ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.split24.us, label %.split.epil

.split.epil:                                      ; preds = %.split24.us.loopexit40.unr-lcssa, %.split.epil
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.split.epil ], [ %indvars.iv.unr, %.split24.us.loopexit40.unr-lcssa ]
  %.026.epil = phi i32 [ %43, %.split.epil ], [ %.026.unr, %.split24.us.loopexit40.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.split.epil ], [ 0, %.split24.us.loopexit40.unr-lcssa ]
  %39 = getelementptr inbounds i8, ptr %0, i64 %indvars.iv.epil
  %40 = load i8, ptr %39, align 1, !tbaa !5
  %41 = sext i8 %40 to i32
  %42 = xor i32 %.026.epil, %41
  %43 = mul i32 %42, 16777565
  %indvars.iv.next.epil = add nuw nsw i64 %indvars.iv.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %.split24.us, label %.split.epil, !llvm.loop !10

.split24.us:                                      ; preds = %.split24.us.loopexit40.unr-lcssa, %.split.epil, %.lr.ph, %.split.us
  %.us-phi = phi i32 [ -2128831035, %.split.us ], [ %16, %.lr.ph ], [ %.lcssa41.ph, %.split24.us.loopexit40.unr-lcssa ], [ %43, %.split.epil ]
  ret i32 %.us-phi
}

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 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.unroll.disable"}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass