; LLVM IR from square/subzero :: core/external-crypto/aes (aesaux)

; 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
declare dso_local ptr @pos(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @to_hex(i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @block_in(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !9
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  %7 = call ptr @pos(ptr noundef %6)
  store ptr %7, ptr %4, align 8, !tbaa !5
  br label %8

8:                                                ; preds = %46, %2
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = load i8, ptr %9, align 1, !tbaa !11
  %11 = sext i8 %10 to i32
  %12 = icmp ne i32 %11, 0
  br i1 %12, label %13, label %44

13:                                               ; preds = %8
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %14, i64 1
  %16 = load i8, ptr %15, align 1, !tbaa !11
  %17 = sext i8 %16 to i32
  %18 = icmp ne i32 %17, 0
  br i1 %18, label %19, label %44

19:                                               ; preds = %13
  %20 = call ptr @__ctype_b_loc() #4
  %21 = load ptr, ptr %20, align 8, !tbaa !5
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = load i8, ptr %22, align 1, !tbaa !11
  %24 = sext i8 %23 to i32
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds i16, ptr %21, i64 %25
  %27 = load i16, ptr %26, align 2, !tbaa !12
  %28 = zext i16 %27 to i32
  %29 = and i32 %28, 4096
  %30 = icmp ne i32 %29, 0
  br i1 %30, label %31, label %44

31:                                               ; preds = %19
  %32 = call ptr @__ctype_b_loc() #4
  %33 = load ptr, ptr %32, align 8, !tbaa !5
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %34, i64 1
  %36 = load i8, ptr %35, align 1, !tbaa !11
  %37 = sext i8 %36 to i32
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds i16, ptr %33, i64 %38
  %40 = load i16, ptr %39, align 2, !tbaa !12
  %41 = zext i16 %40 to i32
  %42 = and i32 %41, 4096
  %43 = icmp ne i32 %42, 0
  br label %44

44:                                               ; preds = %31, %19, %13, %8
  %45 = phi i1 [ false, %19 ], [ false, %13 ], [ false, %8 ], [ %43, %31 ]
  br i1 %45, label %46, label %66

46:                                               ; preds = %44
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = load i8, ptr %47, align 1, !tbaa !11
  %49 = sext i8 %48 to i32
  %50 = call i32 @to_hex(i32 noundef %49)
  %51 = shl i32 %50, 4
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds i8, ptr %52, i64 1
  %54 = load i8, ptr %53, align 1, !tbaa !11
  %55 = sext i8 %54 to i32
  %56 = call i32 @to_hex(i32 noundef %55)
  %57 = add nsw i32 %51, %56
  %58 = trunc i32 %57 to i8
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = load i32, ptr %5, align 4, !tbaa !9
  %61 = add nsw i32 %60, 1
  store i32 %61, ptr %5, align 4, !tbaa !9
  %62 = sext i32 %60 to i64
  %63 = getelementptr inbounds i8, ptr %59, i64 %62
  store i8 %58, ptr %63, align 1, !tbaa !11
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = getelementptr inbounds i8, ptr %64, i64 2
  store ptr %65, ptr %4, align 8, !tbaa !5
  br label %8, !llvm.loop !14

66:                                               ; preds = %44
  %67 = load i32, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret i32 %67
}

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__ctype_b_loc() #2

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 willreturn memory(none) "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 #3 = { nounwind }
attributes #4 = { nounwind 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 = !{!"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 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"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: nounwind uwtable
declare dso_local ptr @pos(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @to_hex(i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i32 @block_in(ptr nocapture noundef writeonly %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = tail call ptr @pos(ptr noundef %1)
  %4 = load i8, ptr %3, align 1, !tbaa !5
  %.not16 = icmp eq i8 %4, 0
  br i1 %.not16, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %2, %21
  %indvars.iv = phi i64 [ %indvars.iv.next, %21 ], [ 0, %2 ]
  %5 = phi i8 [ %32, %21 ], [ %4, %2 ]
  %.018 = phi i32 [ %29, %21 ], [ 0, %2 ]
  %.01017 = phi ptr [ %31, %21 ], [ %3, %2 ]
  %6 = sext i8 %5 to i32
  %7 = getelementptr inbounds i8, ptr %.01017, i64 1
  %8 = load i8, ptr %7, align 1, !tbaa !5
  %.not13 = icmp eq i8 %8, 0
  br i1 %.not13, label %.critedge.loopexit.split.loop.exit25, label %9

9:                                                ; preds = %.lr.ph
  %10 = tail call ptr @__ctype_b_loc() #2
  %11 = load ptr, ptr %10, align 8, !tbaa !8
  %12 = sext i8 %5 to i64
  %13 = getelementptr inbounds i16, ptr %11, i64 %12
  %14 = load i16, ptr %13, align 2, !tbaa !10
  %15 = and i16 %14, 4096
  %.not14 = icmp eq i16 %15, 0
  br i1 %.not14, label %.critedge.loopexit.split.loop.exit, label %16

16:                                               ; preds = %9
  %17 = sext i8 %8 to i64
  %18 = getelementptr inbounds i16, ptr %11, i64 %17
  %19 = load i16, ptr %18, align 2, !tbaa !10
  %20 = and i16 %19, 4096
  %.not15 = icmp eq i16 %20, 0
  br i1 %.not15, label %.critedge.loopexit.split.loop.exit29, label %21

21:                                               ; preds = %16
  %22 = tail call i32 @to_hex(i32 noundef %6)
  %23 = shl i32 %22, 4
  %24 = load i8, ptr %7, align 1, !tbaa !5
  %25 = sext i8 %24 to i32
  %26 = tail call i32 @to_hex(i32 noundef %25)
  %27 = add nsw i32 %26, %23
  %28 = trunc i32 %27 to i8
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %29 = add nuw nsw i32 %.018, 1
  %30 = getelementptr inbounds i8, ptr %0, i64 %indvars.iv
  store i8 %28, ptr %30, align 1, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %.01017, i64 2
  %32 = load i8, ptr %31, align 1, !tbaa !5
  %.not = icmp eq i8 %32, 0
  br i1 %.not, label %.critedge, label %.lr.ph, !llvm.loop !12

.critedge.loopexit.split.loop.exit:               ; preds = %9
  %33 = trunc nuw nsw i64 %indvars.iv to i32
  br label %.critedge

.critedge.loopexit.split.loop.exit25:             ; preds = %.lr.ph
  %34 = trunc nuw nsw i64 %indvars.iv to i32
  br label %.critedge

.critedge.loopexit.split.loop.exit29:             ; preds = %16
  %35 = trunc nuw nsw i64 %indvars.iv to i32
  br label %.critedge

.critedge:                                        ; preds = %21, %.critedge.loopexit.split.loop.exit, %.critedge.loopexit.split.loop.exit25, %.critedge.loopexit.split.loop.exit29, %2
  %.0.lcssa = phi i32 [ 0, %2 ], [ %33, %.critedge.loopexit.split.loop.exit ], [ %34, %.critedge.loopexit.split.loop.exit25 ], [ %35, %.critedge.loopexit.split.loop.exit29 ], [ %29, %21 ]
  ret i32 %.0.lcssa
}

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__ctype_b_loc() 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 = { mustprogress nofree nosync nounwind willreturn memory(none) "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 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !6, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"short", !6, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass