; LLVM IR from stamparm/cryptospecs :: symmetrical/sources (3-way)

; 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: nounwind uwtable
define dso_local void @mu(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca [3 x i64], align 16
  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 24, ptr %4) #2
  %5 = getelementptr inbounds [3 x i64], ptr %4, i64 0, i64 2
  store i64 0, ptr %5, align 16, !tbaa !9
  %6 = getelementptr inbounds [3 x i64], ptr %4, i64 0, i64 1
  store i64 0, ptr %6, align 8, !tbaa !9
  %7 = getelementptr inbounds [3 x i64], ptr %4, i64 0, i64 0
  store i64 0, ptr %7, align 16, !tbaa !9
  store i32 0, ptr %3, align 4, !tbaa !11
  br label %8

8:                                                ; preds = %63, %1
  %9 = load i32, ptr %3, align 4, !tbaa !11
  %10 = icmp slt i32 %9, 32
  br i1 %10, label %11, label %66

11:                                               ; preds = %8
  %12 = getelementptr inbounds [3 x i64], ptr %4, i64 0, i64 0
  %13 = load i64, ptr %12, align 16, !tbaa !9
  %14 = shl i64 %13, 1
  store i64 %14, ptr %12, align 16, !tbaa !9
  %15 = getelementptr inbounds [3 x i64], ptr %4, i64 0, i64 1
  %16 = load i64, ptr %15, align 8, !tbaa !9
  %17 = shl i64 %16, 1
  store i64 %17, ptr %15, align 8, !tbaa !9
  %18 = getelementptr inbounds [3 x i64], ptr %4, i64 0, i64 2
  %19 = load i64, ptr %18, align 16, !tbaa !9
  %20 = shl i64 %19, 1
  store i64 %20, ptr %18, align 16, !tbaa !9
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds i64, ptr %21, i64 0
  %23 = load i64, ptr %22, align 8, !tbaa !9
  %24 = and i64 %23, 1
  %25 = icmp ne i64 %24, 0
  br i1 %25, label %26, label %30

26:                                               ; preds = %11
  %27 = getelementptr inbounds [3 x i64], ptr %4, i64 0, i64 2
  %28 = load i64, ptr %27, align 16, !tbaa !9
  %29 = or i64 %28, 1
  store i64 %29, ptr %27, align 16, !tbaa !9
  br label %30

30:                                               ; preds = %26, %11
  %31 = load ptr, ptr %2, align 8, !tbaa !5
  %32 = getelementptr inbounds i64, ptr %31, i64 1
  %33 = load i64, ptr %32, align 8, !tbaa !9
  %34 = and i64 %33, 1
  %35 = icmp ne i64 %34, 0
  br i1 %35, label %36, label %40

36:                                               ; preds = %30
  %37 = getelementptr inbounds [3 x i64], ptr %4, i64 0, i64 1
  %38 = load i64, ptr %37, align 8, !tbaa !9
  %39 = or i64 %38, 1
  store i64 %39, ptr %37, align 8, !tbaa !9
  br label %40

40:                                               ; preds = %36, %30
  %41 = load ptr, ptr %2, align 8, !tbaa !5
  %42 = getelementptr inbounds i64, ptr %41, i64 2
  %43 = load i64, ptr %42, align 8, !tbaa !9
  %44 = and i64 %43, 1
  %45 = icmp ne i64 %44, 0
  br i1 %45, label %46, label %50

46:                                               ; preds = %40
  %47 = getelementptr inbounds [3 x i64], ptr %4, i64 0, i64 0
  %48 = load i64, ptr %47, align 16, !tbaa !9
  %49 = or i64 %48, 1
  store i64 %49, ptr %47, align 16, !tbaa !9
  br label %50

50:                                               ; preds = %46, %40
  %51 = load ptr, ptr %2, align 8, !tbaa !5
  %52 = getelementptr inbounds i64, ptr %51, i64 0
  %53 = load i64, ptr %52, align 8, !tbaa !9
  %54 = lshr i64 %53, 1
  store i64 %54, ptr %52, align 8, !tbaa !9
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  %56 = getelementptr inbounds i64, ptr %55, i64 1
  %57 = load i64, ptr %56, align 8, !tbaa !9
  %58 = lshr i64 %57, 1
  store i64 %58, ptr %56, align 8, !tbaa !9
  %59 = load ptr, ptr %2, align 8, !tbaa !5
  %60 = getelementptr inbounds i64, ptr %59, i64 2
  %61 = load i64, ptr %60, align 8, !tbaa !9
  %62 = lshr i64 %61, 1
  store i64 %62, ptr %60, align 8, !tbaa !9
  br label %63

63:                                               ; preds = %50
  %64 = load i32, ptr %3, align 4, !tbaa !11
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %3, align 4, !tbaa !11
  br label %8, !llvm.loop !13

66:                                               ; preds = %8
  %67 = getelementptr inbounds [3 x i64], ptr %4, i64 0, i64 0
  %68 = load i64, ptr %67, align 16, !tbaa !9
  %69 = load ptr, ptr %2, align 8, !tbaa !5
  %70 = getelementptr inbounds i64, ptr %69, i64 0
  store i64 %68, ptr %70, align 8, !tbaa !9
  %71 = getelementptr inbounds [3 x i64], ptr %4, i64 0, i64 1
  %72 = load i64, ptr %71, align 8, !tbaa !9
  %73 = load ptr, ptr %2, align 8, !tbaa !5
  %74 = getelementptr inbounds i64, ptr %73, i64 1
  store i64 %72, ptr %74, align 8, !tbaa !9
  %75 = getelementptr inbounds [3 x i64], ptr %4, i64 0, i64 2
  %76 = load i64, ptr %75, align 16, !tbaa !9
  %77 = load ptr, ptr %2, align 8, !tbaa !5
  %78 = getelementptr inbounds i64, ptr %77, i64 2
  store i64 %76, ptr %78, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 24, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  ret void
}

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

; 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 = { 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", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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: nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local void @mu(ptr nocapture noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load <2 x i64>, ptr %2, align 8, !tbaa !5
  %4 = shufflevector <2 x i64> %3, <2 x i64> poison, <2 x i32> <i32 1, i32 0>
  %.promoted = load i64, ptr %0, align 8, !tbaa !5
  %trunc = trunc i64 %.promoted to i32
  %rev = tail call i32 @llvm.bitreverse.i32(i32 %trunc)
  %spec.select.31 = zext i32 %rev to i64
  %trunc108 = trunc <2 x i64> %4 to <2 x i32>
  %rev109 = tail call <2 x i32> @llvm.bitreverse.v2i32(<2 x i32> %trunc108)
  %5 = zext <2 x i32> %rev109 to <2 x i64>
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  store <2 x i64> %5, ptr %0, align 8, !tbaa !5
  store i64 %spec.select.31, ptr %6, align 8, !tbaa !5
  ret void
}

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x i32> @llvm.bitreverse.v2i32(<2 x i32>) #1

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


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalDCEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LICMPass,LoopRotatePass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass