; LLVM IR from rweather/lightweight-crypto :: src/combined (internal-subterranean)

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

%struct.subterranean_state_t = type { [9 x i32] }

; 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 @subterranean_absorb_1(ptr noundef %0, i8 noundef zeroext %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i8 %1, ptr %4, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  %6 = load i8, ptr %4, align 1, !tbaa !9
  %7 = zext i8 %6 to i32
  store i32 %7, ptr %5, align 4, !tbaa !10
  %8 = load i32, ptr %5, align 4, !tbaa !10
  %9 = shl i32 %8, 1
  %10 = and i32 %9, 2
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.subterranean_state_t, ptr %11, i32 0, i32 0
  %13 = getelementptr inbounds [9 x i32], ptr %12, i64 0, i64 0
  %14 = load i32, ptr %13, align 4, !tbaa !10
  %15 = xor i32 %14, %10
  store i32 %15, ptr %13, align 4, !tbaa !10
  %16 = load i32, ptr %5, align 4, !tbaa !10
  %17 = and i32 %16, 8
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.subterranean_state_t, ptr %18, i32 0, i32 0
  %20 = getelementptr inbounds [9 x i32], ptr %19, i64 0, i64 1
  %21 = load i32, ptr %20, align 4, !tbaa !10
  %22 = xor i32 %21, %17
  store i32 %22, ptr %20, align 4, !tbaa !10
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.subterranean_state_t, ptr %23, i32 0, i32 0
  %25 = getelementptr inbounds [9 x i32], ptr %24, i64 0, i64 2
  %26 = load i32, ptr %25, align 4, !tbaa !10
  %27 = xor i32 %26, 1
  store i32 %27, ptr %25, align 4, !tbaa !10
  %28 = load i32, ptr %5, align 4, !tbaa !10
  %29 = shl i32 %28, 6
  %30 = and i32 %29, 256
  %31 = load i32, ptr %5, align 4, !tbaa !10
  %32 = shl i32 %31, 1
  %33 = and i32 %32, 64
  %34 = xor i32 %30, %33
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.subterranean_state_t, ptr %35, i32 0, i32 0
  %37 = getelementptr inbounds [9 x i32], ptr %36, i64 0, i64 4
  %38 = load i32, ptr %37, align 4, !tbaa !10
  %39 = xor i32 %38, %34
  store i32 %39, ptr %37, align 4, !tbaa !10
  %40 = load i32, ptr %5, align 4, !tbaa !10
  %41 = shl i32 %40, 15
  %42 = and i32 %41, 65536
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.subterranean_state_t, ptr %43, i32 0, i32 0
  %45 = getelementptr inbounds [9 x i32], ptr %44, i64 0, i64 5
  %46 = load i32, ptr %45, align 4, !tbaa !10
  %47 = xor i32 %46, %42
  store i32 %47, ptr %45, align 4, !tbaa !10
  %48 = load i32, ptr %5, align 4, !tbaa !10
  %49 = lshr i32 %48, 1
  %50 = and i32 %49, 32
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.subterranean_state_t, ptr %51, i32 0, i32 0
  %53 = getelementptr inbounds [9 x i32], ptr %52, i64 0, i64 6
  %54 = load i32, ptr %53, align 4, !tbaa !10
  %55 = xor i32 %54, %50
  store i32 %55, ptr %53, align 4, !tbaa !10
  %56 = load i32, ptr %5, align 4, !tbaa !10
  %57 = shl i32 %56, 21
  %58 = and i32 %57, 33554432
  %59 = load i32, ptr %5, align 4, !tbaa !10
  %60 = shl i32 %59, 3
  %61 = and i32 %60, 1024
  %62 = xor i32 %58, %61
  %63 = load ptr, ptr %3, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.subterranean_state_t, ptr %63, i32 0, i32 0
  %65 = getelementptr inbounds [9 x i32], ptr %64, i64 0, i64 7
  %66 = load i32, ptr %65, align 4, !tbaa !10
  %67 = xor i32 %66, %62
  store i32 %67, ptr %65, align 4, !tbaa !10
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !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 @subterranean_absorb_1(ptr nocapture noundef %0, i8 noundef zeroext %1) local_unnamed_addr #0 {
  %3 = zext i8 %1 to i32
  %4 = shl nuw nsw i32 %3, 1
  %5 = insertelement <2 x i32> poison, i32 %4, i64 0
  %6 = insertelement <2 x i32> %5, i32 %3, i64 1
  %7 = and <2 x i32> %6, <i32 2, i32 8>
  %8 = load <2 x i32>, ptr %0, align 4, !tbaa !5
  %9 = xor <2 x i32> %8, %7
  store <2 x i32> %9, ptr %0, align 4, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load i32, ptr %10, align 4, !tbaa !5
  %12 = xor i32 %11, 1
  store i32 %12, ptr %10, align 4, !tbaa !5
  %13 = shl nuw nsw i32 %3, 6
  %14 = and i32 %13, 256
  %15 = and i32 %4, 64
  %16 = or disjoint i32 %14, %15
  %17 = getelementptr inbounds i8, ptr %0, i64 16
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %19 = xor i32 %18, %16
  store i32 %19, ptr %17, align 4, !tbaa !5
  %20 = shl nuw nsw i32 %3, 15
  %21 = getelementptr inbounds i8, ptr %0, i64 20
  %22 = lshr i32 %3, 1
  %23 = insertelement <2 x i32> poison, i32 %20, i64 0
  %24 = insertelement <2 x i32> %23, i32 %22, i64 1
  %25 = and <2 x i32> %24, <i32 65536, i32 32>
  %26 = load <2 x i32>, ptr %21, align 4, !tbaa !5
  %27 = xor <2 x i32> %26, %25
  store <2 x i32> %27, ptr %21, align 4, !tbaa !5
  %28 = shl nuw nsw i32 %3, 21
  %29 = and i32 %28, 33554432
  %30 = shl nuw nsw i32 %3, 3
  %31 = and i32 %30, 1024
  %32 = or disjoint i32 %29, %31
  %33 = getelementptr inbounds i8, ptr %0, i64 28
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = xor i32 %34, %32
  store i32 %35, ptr %33, align 4, !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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass