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

@.str = external hidden unnamed_addr constant [14 x i8], align 1
@kl = external hidden global [3 x i64], align 16
@.str.1 = external hidden unnamed_addr constant [27 x i8], align 1
@ekt = external hidden global [3 x double], align 16
@dkt = external hidden global [3 x double], align 16
@et = external hidden global [3 x double], align 16
@.str.2 = external hidden unnamed_addr constant [48 x i8], align 1
@dt = external hidden global [3 x double], align 16
@.str.3 = external hidden unnamed_addr constant [48 x i8], align 1

; 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
define dso_local void @output(ptr noundef %0, i64 noundef %1, i64 noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i8, align 1
  %9 = alloca i8, align 1
  %10 = alloca i8, align 1
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  store i64 %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #3
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = load i64, ptr %5, align 8, !tbaa !9
  %13 = getelementptr inbounds [3 x i64], ptr @kl, i64 0, i64 %12
  %14 = load i64, ptr %13, align 8, !tbaa !9
  %15 = mul i64 8, %14
  %16 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef @.str, i64 noundef %15) #3
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = load i64, ptr %5, align 8, !tbaa !9
  %19 = getelementptr inbounds [3 x double], ptr @ekt, i64 0, i64 %18
  %20 = load double, ptr %19, align 8, !tbaa !11
  %21 = load i64, ptr %5, align 8, !tbaa !9
  %22 = getelementptr inbounds [3 x double], ptr @dkt, i64 0, i64 %21
  %23 = load double, ptr %22, align 8, !tbaa !11
  %24 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %17, ptr noundef @.str.1, double noundef %20, double noundef %23) #3
  %25 = load i64, ptr %6, align 8, !tbaa !9
  %26 = mul i64 1000, %25
  %27 = uitofp i64 %26 to double
  %28 = load i64, ptr %5, align 8, !tbaa !9
  %29 = getelementptr inbounds [3 x double], ptr @et, i64 0, i64 %28
  %30 = load double, ptr %29, align 8, !tbaa !11
  %31 = fdiv double %30, 2.000000e+00
  %32 = fadd double %27, %31
  %33 = load i64, ptr %5, align 8, !tbaa !9
  %34 = getelementptr inbounds [3 x double], ptr @et, i64 0, i64 %33
  %35 = load double, ptr %34, align 8, !tbaa !11
  %36 = fdiv double %32, %35
  %37 = fptoui double %36 to i64
  store i64 %37, ptr %7, align 8, !tbaa !9
  %38 = load i64, ptr %7, align 8, !tbaa !9
  %39 = udiv i64 %38, 100
  %40 = add i64 48, %39
  %41 = trunc i64 %40 to i8
  store i8 %41, ptr %8, align 1, !tbaa !13
  %42 = load i64, ptr %7, align 8, !tbaa !9
  %43 = udiv i64 %42, 10
  %44 = urem i64 %43, 10
  %45 = add i64 48, %44
  %46 = trunc i64 %45 to i8
  store i8 %46, ptr %9, align 1, !tbaa !13
  %47 = load i64, ptr %7, align 8, !tbaa !9
  %48 = urem i64 %47, 10
  %49 = add i64 48, %48
  %50 = trunc i64 %49 to i8
  store i8 %50, ptr %10, align 1, !tbaa !13
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = load i64, ptr %5, align 8, !tbaa !9
  %53 = getelementptr inbounds [3 x double], ptr @et, i64 0, i64 %52
  %54 = load double, ptr %53, align 8, !tbaa !11
  %55 = load i8, ptr %8, align 1, !tbaa !13
  %56 = zext i8 %55 to i32
  %57 = load i8, ptr %9, align 1, !tbaa !13
  %58 = zext i8 %57 to i32
  %59 = load i8, ptr %10, align 1, !tbaa !13
  %60 = zext i8 %59 to i32
  %61 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %51, ptr noundef @.str.2, double noundef %54, i32 noundef %56, i32 noundef %58, i32 noundef %60) #3
  %62 = load i64, ptr %6, align 8, !tbaa !9
  %63 = mul i64 1000, %62
  %64 = uitofp i64 %63 to double
  %65 = load i64, ptr %5, align 8, !tbaa !9
  %66 = getelementptr inbounds [3 x double], ptr @dt, i64 0, i64 %65
  %67 = load double, ptr %66, align 8, !tbaa !11
  %68 = fdiv double %67, 2.000000e+00
  %69 = fadd double %64, %68
  %70 = load i64, ptr %5, align 8, !tbaa !9
  %71 = getelementptr inbounds [3 x double], ptr @dt, i64 0, i64 %70
  %72 = load double, ptr %71, align 8, !tbaa !11
  %73 = fdiv double %69, %72
  %74 = fptoui double %73 to i64
  store i64 %74, ptr %7, align 8, !tbaa !9
  %75 = load i64, ptr %7, align 8, !tbaa !9
  %76 = udiv i64 %75, 100
  %77 = add i64 48, %76
  %78 = trunc i64 %77 to i8
  store i8 %78, ptr %8, align 1, !tbaa !13
  %79 = load i64, ptr %7, align 8, !tbaa !9
  %80 = udiv i64 %79, 10
  %81 = urem i64 %80, 10
  %82 = add i64 48, %81
  %83 = trunc i64 %82 to i8
  store i8 %83, ptr %9, align 1, !tbaa !13
  %84 = load i64, ptr %7, align 8, !tbaa !9
  %85 = urem i64 %84, 10
  %86 = add i64 48, %85
  %87 = trunc i64 %86 to i8
  store i8 %87, ptr %10, align 1, !tbaa !13
  %88 = load ptr, ptr %4, align 8, !tbaa !5
  %89 = load i64, ptr %5, align 8, !tbaa !9
  %90 = getelementptr inbounds [3 x double], ptr @dt, i64 0, i64 %89
  %91 = load double, ptr %90, align 8, !tbaa !11
  %92 = load i8, ptr %8, align 1, !tbaa !13
  %93 = zext i8 %92 to i32
  %94 = load i8, ptr %9, align 1, !tbaa !13
  %95 = zext i8 %94 to i32
  %96 = load i8, ptr %10, align 1, !tbaa !13
  %97 = zext i8 %96 to i32
  %98 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %88, ptr noundef @.str.3, double noundef %91, i32 noundef %93, i32 noundef %95, i32 noundef %97) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret void
}

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #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 "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 }

!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", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!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"

@.str = external hidden unnamed_addr constant [14 x i8], align 1
@kl = external hidden local_unnamed_addr global [3 x i64], align 16
@.str.1 = external hidden unnamed_addr constant [27 x i8], align 1
@ekt = external hidden local_unnamed_addr global [3 x double], align 16
@dkt = external hidden local_unnamed_addr global [3 x double], align 16
@et = external hidden local_unnamed_addr global [3 x double], align 16
@.str.2 = external hidden unnamed_addr constant [48 x i8], align 1
@dt = external hidden local_unnamed_addr global [3 x double], align 16
@.str.3 = external hidden unnamed_addr constant [48 x i8], align 1

; Function Attrs: nofree nounwind uwtable
define dso_local void @output(ptr nocapture noundef %0, i64 noundef %1, i64 noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds [3 x i64], ptr @kl, i64 0, i64 %1
  %5 = load i64, ptr %4, align 8, !tbaa !5
  %6 = shl i64 %5, 3
  %7 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %0, ptr noundef nonnull @.str, i64 noundef %6) #2
  %8 = getelementptr inbounds [3 x double], ptr @ekt, i64 0, i64 %1
  %9 = load double, ptr %8, align 8, !tbaa !9
  %10 = getelementptr inbounds [3 x double], ptr @dkt, i64 0, i64 %1
  %11 = load double, ptr %10, align 8, !tbaa !9
  %12 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %0, ptr noundef nonnull @.str.1, double noundef %9, double noundef %11) #2
  %13 = mul i64 %2, 1000
  %14 = uitofp i64 %13 to double
  %15 = getelementptr inbounds [3 x double], ptr @et, i64 0, i64 %1
  %16 = load double, ptr %15, align 8, !tbaa !9
  %17 = fmul double %16, 5.000000e-01
  %18 = fadd double %17, %14
  %19 = fdiv double %18, %16
  %20 = fptoui double %19 to i64
  %21 = udiv i64 %20, 100
  %22 = trunc i64 %21 to i32
  %23 = add i32 %22, 48
  %24 = udiv i64 %20, 10
  %25 = urem i64 %24, 10
  %26 = trunc nuw nsw i64 %25 to i32
  %27 = or disjoint i32 %26, 48
  %28 = urem i64 %20, 10
  %29 = trunc nuw nsw i64 %28 to i32
  %30 = or disjoint i32 %29, 48
  %31 = and i32 %23, 255
  %32 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %0, ptr noundef nonnull @.str.2, double noundef %16, i32 noundef %31, i32 noundef %27, i32 noundef %30) #2
  %33 = getelementptr inbounds [3 x double], ptr @dt, i64 0, i64 %1
  %34 = load double, ptr %33, align 8, !tbaa !9
  %35 = fmul double %34, 5.000000e-01
  %36 = fadd double %35, %14
  %37 = fdiv double %36, %34
  %38 = fptoui double %37 to i64
  %39 = udiv i64 %38, 100
  %40 = trunc i64 %39 to i32
  %41 = add i32 %40, 48
  %42 = udiv i64 %38, 10
  %43 = urem i64 %42, 10
  %44 = trunc nuw nsw i64 %43 to i32
  %45 = or disjoint i32 %44, 48
  %46 = urem i64 %38, 10
  %47 = trunc nuw nsw i64 %46 to i32
  %48 = or disjoint i32 %47, 48
  %49 = and i32 %41, 255
  %50 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %0, ptr noundef nonnull @.str.3, double noundef %34, i32 noundef %49, i32 noundef %45, i32 noundef %48) #2
  ret void
}

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

attributes #0 = { nofree 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 = { nofree 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 #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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}


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