; 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: 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 void @gamma(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca [3 x i64], align 16
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr %3) #2
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  %5 = getelementptr inbounds i64, ptr %4, i64 0
  %6 = load i64, ptr %5, align 8, !tbaa !9
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = getelementptr inbounds i64, ptr %7, i64 1
  %9 = load i64, ptr %8, align 8, !tbaa !9
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds i64, ptr %10, i64 2
  %12 = load i64, ptr %11, align 8, !tbaa !9
  %13 = xor i64 %12, -1
  %14 = or i64 %9, %13
  %15 = xor i64 %6, %14
  %16 = getelementptr inbounds [3 x i64], ptr %3, i64 0, i64 0
  store i64 %15, ptr %16, align 16, !tbaa !9
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds i64, ptr %17, i64 1
  %19 = load i64, ptr %18, align 8, !tbaa !9
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = getelementptr inbounds i64, ptr %20, i64 2
  %22 = load i64, ptr %21, align 8, !tbaa !9
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  %24 = getelementptr inbounds i64, ptr %23, i64 0
  %25 = load i64, ptr %24, align 8, !tbaa !9
  %26 = xor i64 %25, -1
  %27 = or i64 %22, %26
  %28 = xor i64 %19, %27
  %29 = getelementptr inbounds [3 x i64], ptr %3, i64 0, i64 1
  store i64 %28, ptr %29, align 8, !tbaa !9
  %30 = load ptr, ptr %2, align 8, !tbaa !5
  %31 = getelementptr inbounds i64, ptr %30, i64 2
  %32 = load i64, ptr %31, align 8, !tbaa !9
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = getelementptr inbounds i64, ptr %33, i64 0
  %35 = load i64, ptr %34, align 8, !tbaa !9
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = getelementptr inbounds i64, ptr %36, i64 1
  %38 = load i64, ptr %37, align 8, !tbaa !9
  %39 = xor i64 %38, -1
  %40 = or i64 %35, %39
  %41 = xor i64 %32, %40
  %42 = getelementptr inbounds [3 x i64], ptr %3, i64 0, i64 2
  store i64 %41, ptr %42, align 16, !tbaa !9
  %43 = getelementptr inbounds [3 x i64], ptr %3, i64 0, i64 0
  %44 = load i64, ptr %43, align 16, !tbaa !9
  %45 = load ptr, ptr %2, align 8, !tbaa !5
  %46 = getelementptr inbounds i64, ptr %45, i64 0
  store i64 %44, ptr %46, align 8, !tbaa !9
  %47 = getelementptr inbounds [3 x i64], ptr %3, i64 0, i64 1
  %48 = load i64, ptr %47, align 8, !tbaa !9
  %49 = load ptr, ptr %2, align 8, !tbaa !5
  %50 = getelementptr inbounds i64, ptr %49, i64 1
  store i64 %48, ptr %50, align 8, !tbaa !9
  %51 = getelementptr inbounds [3 x i64], ptr %3, i64 0, i64 2
  %52 = load i64, ptr %51, align 16, !tbaa !9
  %53 = load ptr, ptr %2, align 8, !tbaa !5
  %54 = getelementptr inbounds i64, ptr %53, i64 2
  store i64 %52, ptr %54, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 24, ptr %3) #2
  ret void
}

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 = !{!"long", !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"

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @gamma(ptr nocapture noundef %0) local_unnamed_addr #0 {
  %2 = load i64, ptr %0, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load i64, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = load i64, ptr %5, align 8, !tbaa !5
  %7 = xor i64 %6, -1
  %8 = or i64 %4, %7
  %9 = xor i64 %8, %2
  %10 = xor i64 %2, -1
  %11 = or i64 %6, %10
  %12 = xor i64 %11, %4
  %13 = xor i64 %4, -1
  %14 = or i64 %2, %13
  %15 = xor i64 %6, %14
  store i64 %9, ptr %0, align 8, !tbaa !5
  store i64 %12, ptr %3, align 8, !tbaa !5
  store i64 %15, ptr %5, align 8, !tbaa !5
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn 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" }

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