; LLVM IR from IanHarvey/minicrypt :: src (aesccm_mini)

; 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.AESCCMMini_ctx = type { %struct.AESMini_ctx, i32, i32 }
%struct.AESMini_ctx = type { %struct.AESMini_keys, %struct.AESMini_keys }
%struct.AESMini_keys = type { i32, [60 x i32] }

; Function Attrs: nounwind uwtable
define dso_local i32 @AESCCMMini_Init(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) #0 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store i32 %2, ptr %9, align 4, !tbaa !9
  store i32 %3, ptr %10, align 4, !tbaa !9
  store i32 %4, ptr %11, align 4, !tbaa !9
  %12 = load i32, ptr %11, align 4, !tbaa !9
  %13 = icmp slt i32 %12, 4
  br i1 %13, label %36, label %14

14:                                               ; preds = %5
  %15 = load i32, ptr %11, align 4, !tbaa !9
  %16 = icmp sgt i32 %15, 16
  br i1 %16, label %36, label %17

17:                                               ; preds = %14
  %18 = load i32, ptr %11, align 4, !tbaa !9
  %19 = srem i32 %18, 1
  %20 = icmp ne i32 %19, 0
  br i1 %20, label %36, label %21

21:                                               ; preds = %17
  %22 = load i32, ptr %10, align 4, !tbaa !9
  %23 = icmp slt i32 %22, 2
  br i1 %23, label %36, label %24

24:                                               ; preds = %21
  %25 = load i32, ptr %10, align 4, !tbaa !9
  %26 = icmp sgt i32 %25, 8
  br i1 %26, label %36, label %27

27:                                               ; preds = %24
  %28 = load i32, ptr %9, align 4, !tbaa !9
  %29 = icmp eq i32 %28, 16
  br i1 %29, label %37, label %30

30:                                               ; preds = %27
  %31 = load i32, ptr %9, align 4, !tbaa !9
  %32 = icmp eq i32 %31, 24
  br i1 %32, label %37, label %33

33:                                               ; preds = %30
  %34 = load i32, ptr %9, align 4, !tbaa !9
  %35 = icmp eq i32 %34, 32
  br i1 %35, label %37, label %36

36:                                               ; preds = %33, %24, %21, %17, %14, %5
  store i32 3, ptr %6, align 4
  br label %48

37:                                               ; preds = %33, %30, %27
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.AESCCMMini_ctx, ptr %38, i32 0, i32 0
  %40 = load ptr, ptr %8, align 8, !tbaa !5
  %41 = load i32, ptr %9, align 4, !tbaa !9
  call void @AESMini_Init(ptr noundef %39, ptr noundef %40, i32 noundef %41)
  %42 = load i32, ptr %10, align 4, !tbaa !9
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.AESCCMMini_ctx, ptr %43, i32 0, i32 1
  store i32 %42, ptr %44, align 4, !tbaa !11
  %45 = load i32, ptr %11, align 4, !tbaa !9
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.AESCCMMini_ctx, ptr %46, i32 0, i32 2
  store i32 %45, ptr %47, align 4, !tbaa !15
  store i32 0, ptr %6, align 4
  br label %48

48:                                               ; preds = %37, %36
  %49 = load i32, ptr %6, align 4
  ret i32 %49
}

declare void @AESMini_Init(ptr noundef, ptr noundef, i32 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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 488}
!12 = !{!"", !13, i64 0, !10, i64 488, !10, i64 492}
!13 = !{!"", !14, i64 0, !14, i64 244}
!14 = !{!"", !10, i64 0, !7, i64 4}
!15 = !{!12, !10, i64 492}


; 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 range(i32 0, 4) i32 @AESCCMMini_Init(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #0 {
  %6 = add i32 %4, -17
  %or.cond = icmp ult i32 %6, -13
  %7 = add i32 %3, -9
  %or.cond5 = icmp ult i32 %7, -7
  %or.cond26 = or i1 %or.cond5, %or.cond
  br i1 %or.cond26, label %12, label %8

8:                                                ; preds = %5
  switch i32 %2, label %12 [
    i32 32, label %9
    i32 24, label %9
    i32 16, label %9
  ]

9:                                                ; preds = %8, %8, %8
  tail call void @AESMini_Init(ptr noundef %0, ptr noundef %1, i32 noundef %2) #2
  %10 = getelementptr inbounds i8, ptr %0, i64 488
  store i32 %3, ptr %10, align 4, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %0, i64 492
  store i32 %4, ptr %11, align 4, !tbaa !12
  br label %12

12:                                               ; preds = %5, %8, %9
  %.0 = phi i32 [ 0, %9 ], [ 3, %8 ], [ 3, %5 ]
  ret i32 %.0
}

declare void @AESMini_Init(ptr noundef, ptr noundef, i32 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, !9, i64 488}
!6 = !{!"", !7, i64 0, !9, i64 488, !9, i64 492}
!7 = !{!"", !8, i64 0, !8, i64 244}
!8 = !{!"", !9, i64 0, !10, i64 4}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C/C++ TBAA"}
!12 = !{!6, !9, i64 492}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass