; LLVM IR from rweather/lightweight-crypto :: src/combined (ascon-xof)

; 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.anon = type { [40 x i8], i8, i8 }

; Function Attrs: nounwind uwtable
define dso_local void @ascon_xof_absorb(ptr noundef %0, ptr noundef %1, i64 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i64 %2, ptr %6, align 8, !tbaa !9
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.anon, ptr %7, i32 0, i32 2
  %9 = load i8, ptr %8, align 1, !tbaa !11
  %10 = icmp ne i8 %9, 0
  br i1 %10, label %11, label %25

11:                                               ; preds = %3
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.anon, ptr %12, i32 0, i32 2
  store i8 0, ptr %13, align 1, !tbaa !11
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.anon, ptr %14, i32 0, i32 1
  store i8 0, ptr %15, align 8, !tbaa !11
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.anon, ptr %16, i32 0, i32 0
  %18 = getelementptr inbounds [40 x i8], ptr %17, i64 0, i64 0
  call void @ascon_to_sliced(ptr noundef %18)
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.anon, ptr %19, i32 0, i32 0
  %21 = getelementptr inbounds [40 x i8], ptr %20, i64 0, i64 0
  call void @ascon_permute_sliced(ptr noundef %21, i8 noundef zeroext 0)
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.anon, ptr %22, i32 0, i32 0
  %24 = getelementptr inbounds [40 x i8], ptr %23, i64 0, i64 0
  call void @ascon_from_sliced(ptr noundef %24)
  br label %25

25:                                               ; preds = %11, %3
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = load i64, ptr %6, align 8, !tbaa !9
  call void @ascon_hash_update(ptr noundef %26, ptr noundef %27, i64 noundef %28)
  ret void
}

declare void @ascon_to_sliced(ptr noundef) #1

declare void @ascon_permute_sliced(ptr noundef, i8 noundef zeroext) #1

declare void @ascon_from_sliced(ptr noundef) #1

declare void @ascon_hash_update(ptr noundef, ptr noundef, i64 noundef) #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 = { "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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !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"

; Function Attrs: nounwind uwtable
define dso_local void @ascon_xof_absorb(ptr noundef %0, ptr noundef %1, i64 noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 41
  %5 = load i8, ptr %4, align 1, !tbaa !5
  %.not = icmp eq i8 %5, 0
  br i1 %.not, label %8, label %6

6:                                                ; preds = %3
  store i8 0, ptr %4, align 1, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 40
  store i8 0, ptr %7, align 8, !tbaa !5
  tail call void @ascon_to_sliced(ptr noundef nonnull %0) #2
  tail call void @ascon_permute_sliced(ptr noundef nonnull %0, i8 noundef zeroext 0) #2
  tail call void @ascon_from_sliced(ptr noundef nonnull %0) #2
  br label %8

8:                                                ; preds = %6, %3
  tail call void @ascon_hash_update(ptr noundef nonnull %0, ptr noundef %1, i64 noundef %2) #2
  ret void
}

declare void @ascon_to_sliced(ptr noundef) local_unnamed_addr #1

declare void @ascon_permute_sliced(ptr noundef, i8 noundef zeroext) local_unnamed_addr #1

declare void @ascon_from_sliced(ptr noundef) local_unnamed_addr #1

declare void @ascon_hash_update(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #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 = { "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"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InstCombinePass,SROAPass,TailCallElimPass