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

; 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: nounwind uwtable
define dso_local i32 @time_base(ptr noundef %0, ptr noundef %1) #0 {
  %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
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = 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) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  store i32 10, ptr %7, align 4, !tbaa !9
  store i32 0, ptr %9, align 4, !tbaa !9
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %14

14:                                               ; preds = %149, %2
  %15 = load i32, ptr %9, align 4, !tbaa !9
  %16 = icmp ne i32 %15, 0
  %17 = xor i1 %16, true
  br i1 %17, label %18, label %150

18:                                               ; preds = %14
  store double 0.000000e+00, ptr %12, align 8, !tbaa !11
  store double 0.000000e+00, ptr %11, align 8, !tbaa !11
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %19

19:                                               ; preds = %36, %18
  %20 = load i32, ptr %6, align 4, !tbaa !9
  %21 = icmp slt i32 %20, 1000
  br i1 %21, label %22, label %39

22:                                               ; preds = %19
  %23 = call i64 @read_tsc()
  %24 = uitofp i64 %23 to double
  store double %24, ptr %10, align 8, !tbaa !11
  %25 = call i64 @read_tsc()
  %26 = uitofp i64 %25 to double
  %27 = load double, ptr %10, align 8, !tbaa !11
  %28 = fsub double %26, %27
  store double %28, ptr %10, align 8, !tbaa !11
  %29 = load double, ptr %10, align 8, !tbaa !11
  %30 = load double, ptr %11, align 8, !tbaa !11
  %31 = fadd double %30, %29
  store double %31, ptr %11, align 8, !tbaa !11
  %32 = load double, ptr %10, align 8, !tbaa !11
  %33 = load double, ptr %10, align 8, !tbaa !11
  %34 = load double, ptr %12, align 8, !tbaa !11
  %35 = call double @llvm.fmuladd.f64(double %32, double %33, double %34)
  store double %35, ptr %12, align 8, !tbaa !11
  br label %36

36:                                               ; preds = %22
  %37 = load i32, ptr %6, align 4, !tbaa !9
  %38 = add nsw i32 %37, 1
  store i32 %38, ptr %6, align 4, !tbaa !9
  br label %19, !llvm.loop !13

39:                                               ; preds = %19
  %40 = load double, ptr %11, align 8, !tbaa !11
  %41 = fdiv double %40, 1.000000e+03
  store double %41, ptr %11, align 8, !tbaa !11
  %42 = load double, ptr %12, align 8, !tbaa !11
  %43 = load double, ptr %11, align 8, !tbaa !11
  %44 = load double, ptr %11, align 8, !tbaa !11
  %45 = fmul double %43, %44
  %46 = fneg double %45
  %47 = call double @llvm.fmuladd.f64(double %46, double 1.000000e+03, double %42)
  %48 = fdiv double %47, 1.000000e+03
  %49 = call double @sqrt(double noundef %48) #5
  store double %49, ptr %12, align 8, !tbaa !11
  %50 = load double, ptr %12, align 8, !tbaa !11
  %51 = load double, ptr %11, align 8, !tbaa !11
  %52 = fmul double 5.000000e-02, %51
  %53 = fcmp olt double %50, %52
  br i1 %53, label %54, label %57

54:                                               ; preds = %39
  %55 = load double, ptr %11, align 8, !tbaa !11
  %56 = fmul double 5.000000e-02, %55
  br label %59

57:                                               ; preds = %39
  %58 = load double, ptr %12, align 8, !tbaa !11
  br label %59

59:                                               ; preds = %57, %54
  %60 = phi double [ %56, %54 ], [ %58, %57 ]
  store double %60, ptr %12, align 8, !tbaa !11
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  store double 0.000000e+00, ptr %61, align 8, !tbaa !11
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  store double 0.000000e+00, ptr %62, align 8, !tbaa !11
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %63

63:                                               ; preds = %97, %59
  %64 = load i32, ptr %6, align 4, !tbaa !9
  %65 = icmp slt i32 %64, 10000
  br i1 %65, label %66, label %100

66:                                               ; preds = %63
  %67 = call i64 @read_tsc()
  %68 = uitofp i64 %67 to double
  store double %68, ptr %10, align 8, !tbaa !11
  %69 = call i64 @read_tsc()
  %70 = uitofp i64 %69 to double
  %71 = load double, ptr %10, align 8, !tbaa !11
  %72 = fsub double %70, %71
  store double %72, ptr %10, align 8, !tbaa !11
  %73 = load double, ptr %10, align 8, !tbaa !11
  %74 = load double, ptr %11, align 8, !tbaa !11
  %75 = load double, ptr %12, align 8, !tbaa !11
  %76 = fsub double %74, %75
  %77 = fcmp ogt double %73, %76
  br i1 %77, label %78, label %96

78:                                               ; preds = %66
  %79 = load double, ptr %10, align 8, !tbaa !11
  %80 = load double, ptr %11, align 8, !tbaa !11
  %81 = load double, ptr %12, align 8, !tbaa !11
  %82 = fadd double %80, %81
  %83 = fcmp olt double %79, %82
  br i1 %83, label %84, label %96

84:                                               ; preds = %78
  %85 = load double, ptr %10, align 8, !tbaa !11
  %86 = load ptr, ptr %4, align 8, !tbaa !5
  %87 = load double, ptr %86, align 8, !tbaa !11
  %88 = fadd double %87, %85
  store double %88, ptr %86, align 8, !tbaa !11
  %89 = load double, ptr %10, align 8, !tbaa !11
  %90 = load double, ptr %10, align 8, !tbaa !11
  %91 = load ptr, ptr %5, align 8, !tbaa !5
  %92 = load double, ptr %91, align 8, !tbaa !11
  %93 = call double @llvm.fmuladd.f64(double %89, double %90, double %92)
  store double %93, ptr %91, align 8, !tbaa !11
  %94 = load i32, ptr %9, align 4, !tbaa !9
  %95 = add nsw i32 %94, 1
  store i32 %95, ptr %9, align 4, !tbaa !9
  br label %96

96:                                               ; preds = %84, %78, %66
  br label %97

97:                                               ; preds = %96
  %98 = load i32, ptr %6, align 4, !tbaa !9
  %99 = add nsw i32 %98, 1
  store i32 %99, ptr %6, align 4, !tbaa !9
  br label %63, !llvm.loop !15

100:                                              ; preds = %63
  %101 = load i32, ptr %9, align 4, !tbaa !9
  %102 = mul nsw i32 10, %101
  %103 = icmp sgt i32 %102, 90000
  br i1 %103, label %104, label %137

104:                                              ; preds = %100
  %105 = load i32, ptr %9, align 4, !tbaa !9
  %106 = sitofp i32 %105 to double
  %107 = load ptr, ptr %4, align 8, !tbaa !5
  %108 = load double, ptr %107, align 8, !tbaa !11
  %109 = fdiv double %108, %106
  store double %109, ptr %107, align 8, !tbaa !11
  %110 = load ptr, ptr %5, align 8, !tbaa !5
  %111 = load double, ptr %110, align 8, !tbaa !11
  %112 = load ptr, ptr %4, align 8, !tbaa !5
  %113 = load double, ptr %112, align 8, !tbaa !11
  %114 = load ptr, ptr %4, align 8, !tbaa !5
  %115 = load double, ptr %114, align 8, !tbaa !11
  %116 = fmul double %113, %115
  %117 = load i32, ptr %9, align 4, !tbaa !9
  %118 = sitofp i32 %117 to double
  %119 = fneg double %116
  %120 = call double @llvm.fmuladd.f64(double %119, double %118, double %111)
  %121 = load i32, ptr %9, align 4, !tbaa !9
  %122 = sitofp i32 %121 to double
  %123 = fdiv double %120, %122
  %124 = call double @sqrt(double noundef %123) #5
  %125 = load ptr, ptr %5, align 8, !tbaa !5
  store double %124, ptr %125, align 8, !tbaa !11
  %126 = load ptr, ptr %5, align 8, !tbaa !5
  %127 = load double, ptr %126, align 8, !tbaa !11
  %128 = load i32, ptr %7, align 4, !tbaa !9
  %129 = sitofp i32 %128 to double
  %130 = fdiv double %129, 1.000000e+02
  %131 = load ptr, ptr %4, align 8, !tbaa !5
  %132 = load double, ptr %131, align 8, !tbaa !11
  %133 = fmul double %130, %132
  %134 = fcmp ogt double %127, %133
  br i1 %134, label %135, label %136

135:                                              ; preds = %104
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %136

136:                                              ; preds = %135, %104
  br label %149

137:                                              ; preds = %100
  %138 = load i32, ptr %8, align 4, !tbaa !9
  %139 = add nsw i32 %138, 1
  store i32 %139, ptr %8, align 4, !tbaa !9
  %140 = icmp eq i32 %138, 10
  br i1 %140, label %141, label %148

141:                                              ; preds = %137
  store i32 0, ptr %8, align 4, !tbaa !9
  %142 = load i32, ptr %7, align 4, !tbaa !9
  %143 = add nsw i32 %142, 5
  store i32 %143, ptr %7, align 4, !tbaa !9
  %144 = load i32, ptr %7, align 4, !tbaa !9
  %145 = icmp sgt i32 %144, 30
  br i1 %145, label %146, label %147

146:                                              ; preds = %141
  store i32 0, ptr %3, align 4
  store i32 1, ptr %13, align 4
  br label %151

147:                                              ; preds = %141
  br label %148

148:                                              ; preds = %147, %137
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %149

149:                                              ; preds = %148, %136
  br label %14, !llvm.loop !16

150:                                              ; preds = %14
  store i32 1, ptr %3, align 4
  store i32 1, ptr %13, align 4
  br label %151

151:                                              ; preds = %150, %146
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  %152 = load i32, ptr %3, align 4
  ret i32 %152
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @read_tsc() #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

; Function Attrs: nounwind
declare double @sqrt(double noundef) #4

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nounwind "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 #5 = { 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 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}


; 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, 2) i32 @time_base(ptr nocapture noundef %0, ptr nocapture noundef %1) local_unnamed_addr #0 {
  br label %.preheader.outer.outer

.preheader.outer.outer:                           ; preds = %2, %60
  %.05468.ph.ph = phi i32 [ 10, %2 ], [ %61, %60 ]
  %3 = uitofp nneg i32 %.05468.ph.ph to double
  %4 = fdiv double %3, 1.000000e+02
  br label %.preheader.outer

.preheader.outer:                                 ; preds = %.preheader.outer.outer, %57
  %.05169.ph = phi i32 [ %58, %57 ], [ 0, %.preheader.outer.outer ]
  br label %.preheader

.preheader:                                       ; preds = %.preheader.outer, %44
  br label %5

5:                                                ; preds = %.preheader, %5
  %.065 = phi double [ 0.000000e+00, %.preheader ], [ %12, %5 ]
  %.04964 = phi double [ 0.000000e+00, %.preheader ], [ %11, %5 ]
  %.05763 = phi i32 [ 0, %.preheader ], [ %13, %5 ]
  %6 = tail call i64 @read_tsc()
  %7 = uitofp i64 %6 to double
  %8 = tail call i64 @read_tsc()
  %9 = uitofp i64 %8 to double
  %10 = fsub double %9, %7
  %11 = fadd double %.04964, %10
  %12 = tail call double @llvm.fmuladd.f64(double %10, double %10, double %.065)
  %13 = add nuw nsw i32 %.05763, 1
  %exitcond.not = icmp eq i32 %13, 1000
  br i1 %exitcond.not, label %14, label %5, !llvm.loop !5

14:                                               ; preds = %5
  %15 = fdiv double %11, 1.000000e+03
  %16 = fneg double %15
  %17 = fmul double %15, %16
  %18 = tail call double @llvm.fmuladd.f64(double %17, double 1.000000e+03, double %12)
  %19 = fdiv double %18, 1.000000e+03
  %20 = tail call double @sqrt(double noundef %19) #4
  %21 = fmul double %15, 5.000000e-02
  %22 = fcmp olt double %20, %21
  %23 = select i1 %22, double %21, double %20
  store double 0.000000e+00, ptr %1, align 8, !tbaa !7
  store double 0.000000e+00, ptr %0, align 8, !tbaa !7
  %24 = fsub double %15, %23
  %25 = fadd double %15, %23
  br label %26

26:                                               ; preds = %14, %40
  %.167 = phi i32 [ 0, %14 ], [ %.2, %40 ]
  %.15866 = phi i32 [ 0, %14 ], [ %41, %40 ]
  %27 = tail call i64 @read_tsc()
  %28 = uitofp i64 %27 to double
  %29 = tail call i64 @read_tsc()
  %30 = uitofp i64 %29 to double
  %31 = fsub double %30, %28
  %32 = fcmp ogt double %31, %24
  %33 = fcmp olt double %31, %25
  %or.cond = and i1 %32, %33
  br i1 %or.cond, label %34, label %40

34:                                               ; preds = %26
  %35 = load double, ptr %0, align 8, !tbaa !7
  %36 = fadd double %31, %35
  store double %36, ptr %0, align 8, !tbaa !7
  %37 = load double, ptr %1, align 8, !tbaa !7
  %38 = tail call double @llvm.fmuladd.f64(double %31, double %31, double %37)
  store double %38, ptr %1, align 8, !tbaa !7
  %39 = add nsw i32 %.167, 1
  br label %40

40:                                               ; preds = %26, %34
  %.2 = phi i32 [ %39, %34 ], [ %.167, %26 ]
  %41 = add nuw nsw i32 %.15866, 1
  %exitcond72.not = icmp eq i32 %41, 10000
  br i1 %exitcond72.not, label %42, label %26, !llvm.loop !11

42:                                               ; preds = %40
  %43 = icmp sgt i32 %.2, 9000
  br i1 %43, label %44, label %57

44:                                               ; preds = %42
  %45 = uitofp nneg i32 %.2 to double
  %46 = load double, ptr %0, align 8, !tbaa !7
  %47 = fdiv double %46, %45
  store double %47, ptr %0, align 8, !tbaa !7
  %48 = load double, ptr %1, align 8, !tbaa !7
  %49 = fneg double %47
  %50 = fmul double %47, %49
  %51 = tail call double @llvm.fmuladd.f64(double %50, double %45, double %48)
  %52 = fdiv double %51, %45
  %53 = tail call double @sqrt(double noundef %52) #4
  store double %53, ptr %1, align 8, !tbaa !7
  %54 = load double, ptr %0, align 8, !tbaa !7
  %55 = fmul double %4, %54
  %56 = fcmp ogt double %53, %55
  br i1 %56, label %.preheader, label %.thread, !llvm.loop !12

57:                                               ; preds = %42
  %58 = add nuw nsw i32 %.05169.ph, 1
  %59 = icmp eq i32 %.05169.ph, 10
  br i1 %59, label %60, label %.preheader.outer, !llvm.loop !12

60:                                               ; preds = %57
  %61 = add nuw nsw i32 %.05468.ph.ph, 5
  %62 = icmp ugt i32 %.05468.ph.ph, 25
  br i1 %62, label %.thread, label %.preheader.outer.outer, !llvm.loop !12

.thread:                                          ; preds = %60, %44
  %.059 = phi i32 [ 1, %44 ], [ 0, %60 ]
  ret i32 %.059
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @read_tsc() local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sqrt(double noundef) local_unnamed_addr #3

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 = { inlinehint 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { mustprogress nofree nounwind willreturn memory(write) "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 #4 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"double", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = distinct !{!11, !6}
!12 = distinct !{!12, !6}


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