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

@fstr = external dso_local global [8 x ptr], align 16

; 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 i32 @get_line(ptr noundef, ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @find_string(ptr noundef, ptr noundef) #1

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

8:                                                ; preds = %31, %2
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = call i32 @get_line(ptr noundef %9, ptr noundef %10, i32 noundef 128)
  %12 = icmp eq i32 %11, 0
  br i1 %12, label %13, label %32

13:                                               ; preds = %8
  store i32 1, ptr %6, align 4, !tbaa !9
  br label %14

14:                                               ; preds = %28, %13
  %15 = load i32, ptr %6, align 4, !tbaa !9
  %16 = icmp slt i32 %15, 8
  br i1 %16, label %17, label %31

17:                                               ; preds = %14
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = load i32, ptr %6, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [8 x ptr], ptr @fstr, i64 0, i64 %20
  %22 = load ptr, ptr %21, align 8, !tbaa !5
  %23 = call i32 @find_string(ptr noundef %18, ptr noundef %22)
  %24 = icmp sge i32 %23, 0
  br i1 %24, label %25, label %27

25:                                               ; preds = %17
  %26 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %26, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %33

27:                                               ; preds = %17
  br label %28

28:                                               ; preds = %27
  %29 = load i32, ptr %6, align 4, !tbaa !9
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %6, align 4, !tbaa !9
  br label %14, !llvm.loop !11

31:                                               ; preds = %14
  br label %8, !llvm.loop !13

32:                                               ; preds = %8
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %33

33:                                               ; preds = %32, %25
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  %34 = load i32, ptr %3, align 4
  ret i32 %34
}

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 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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

@fstr = external dso_local local_unnamed_addr global [8 x ptr], align 16

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

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @find_line(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = tail call i32 @get_line(ptr noundef %0, ptr noundef %1, i32 noundef 128)
  %4 = icmp eq i32 %3, 0
  br i1 %4, label %.preheader, label %.loopexit8

.preheader:                                       ; preds = %2, %.loopexit
  %5 = load ptr, ptr getelementptr inbounds (i8, ptr @fstr, i64 8), align 8, !tbaa !5
  %6 = tail call i32 @find_string(ptr noundef %1, ptr noundef %5)
  %7 = icmp sgt i32 %6, -1
  br i1 %7, label %.loopexit8, label %8

8:                                                ; preds = %.preheader
  %9 = load ptr, ptr getelementptr inbounds (i8, ptr @fstr, i64 16), align 16, !tbaa !5
  %10 = tail call i32 @find_string(ptr noundef %1, ptr noundef %9)
  %11 = icmp sgt i32 %10, -1
  br i1 %11, label %.loopexit8, label %12

12:                                               ; preds = %8
  %13 = load ptr, ptr getelementptr inbounds (i8, ptr @fstr, i64 24), align 8, !tbaa !5
  %14 = tail call i32 @find_string(ptr noundef %1, ptr noundef %13)
  %15 = icmp sgt i32 %14, -1
  br i1 %15, label %.loopexit8, label %16

16:                                               ; preds = %12
  %17 = load ptr, ptr getelementptr inbounds (i8, ptr @fstr, i64 32), align 16, !tbaa !5
  %18 = tail call i32 @find_string(ptr noundef %1, ptr noundef %17)
  %19 = icmp sgt i32 %18, -1
  br i1 %19, label %.loopexit8, label %20

20:                                               ; preds = %16
  %21 = load ptr, ptr getelementptr inbounds (i8, ptr @fstr, i64 40), align 8, !tbaa !5
  %22 = tail call i32 @find_string(ptr noundef %1, ptr noundef %21)
  %23 = icmp sgt i32 %22, -1
  br i1 %23, label %.loopexit8, label %24

24:                                               ; preds = %20
  %25 = load ptr, ptr getelementptr inbounds (i8, ptr @fstr, i64 48), align 16, !tbaa !5
  %26 = tail call i32 @find_string(ptr noundef %1, ptr noundef %25)
  %27 = icmp sgt i32 %26, -1
  br i1 %27, label %.loopexit8, label %28

28:                                               ; preds = %24
  %29 = load ptr, ptr getelementptr inbounds (i8, ptr @fstr, i64 56), align 8, !tbaa !5
  %30 = tail call i32 @find_string(ptr noundef %1, ptr noundef %29)
  %31 = icmp sgt i32 %30, -1
  br i1 %31, label %.loopexit8, label %.loopexit

.loopexit:                                        ; preds = %28
  %32 = tail call i32 @get_line(ptr noundef %0, ptr noundef %1, i32 noundef 128)
  %33 = icmp eq i32 %32, 0
  br i1 %33, label %.preheader, label %.loopexit8, !llvm.loop !9

.loopexit8:                                       ; preds = %.loopexit, %.preheader, %8, %12, %16, %20, %24, %28, %2
  %.07 = phi i32 [ 0, %2 ], [ 0, %.loopexit ], [ 7, %28 ], [ 6, %24 ], [ 5, %20 ], [ 4, %16 ], [ 3, %12 ], [ 2, %8 ], [ 1, %.preheader ]
  ret i32 %.07
}

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

!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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass