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

; 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.11 = external hidden unnamed_addr constant [2 x i8], align 1
@f_ptr = external dso_local global [8 x ptr], align 16
@.str.26 = external hidden unnamed_addr constant [66 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [38 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @header(ptr noundef, i32 noundef, i64 noundef, i64 noundef) #0

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

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #2

declare ptr @file_name(ptr noundef, i64 noundef, i64 noundef, i64 noundef, i64 noundef) #3

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

declare i32 @printf(ptr noundef, ...) #3

; Function Attrs: nounwind uwtable
declare dso_local void @comp_vecs(ptr noundef, ptr noundef) #0

declare i32 @fopen_s(ptr noundef, ptr noundef, ptr noundef) #3

declare i32 @fclose(ptr noundef) #3

; Function Attrs: nounwind uwtable
define dso_local void @do_tests(i32 noundef %0, ptr noundef %1, ptr noundef %2, i64 noundef %3, i64 noundef %4) #0 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca [128 x i8], align 16
  %12 = alloca [128 x i8], align 16
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  store i32 %0, ptr %6, align 4, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !9
  store i64 %3, ptr %9, align 8, !tbaa !11
  store i64 %4, ptr %10, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 128, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 128, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  %17 = load i32, ptr %6, align 4, !tbaa !5
  %18 = icmp ne i32 %17, 0
  %19 = zext i1 %18 to i64
  %20 = select i1 %18, ptr @.str.27, ptr @.str.28
  %21 = load i64, ptr %9, align 8, !tbaa !11
  %22 = mul i64 8, %21
  %23 = load i64, ptr %10, align 8, !tbaa !11
  %24 = mul i64 8, %23
  %25 = call i32 (ptr, ...) @printf(ptr noundef @.str.26, ptr noundef %20, i64 noundef %22, i64 noundef %24)
  store i32 0, ptr %15, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %86, %5
  %27 = load i32, ptr %15, align 4, !tbaa !5
  %28 = icmp slt i32 %27, 8
  br i1 %28, label %29, label %89

29:                                               ; preds = %26
  %30 = load ptr, ptr %7, align 8, !tbaa !9
  %31 = load i32, ptr %15, align 4, !tbaa !5
  %32 = sdiv i32 %31, 2
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds i32, ptr %30, i64 %33
  %35 = load i32, ptr %34, align 4, !tbaa !5
  %36 = icmp ne i32 %35, 0
  br i1 %36, label %37, label %85

37:                                               ; preds = %29
  %38 = getelementptr inbounds [128 x i8], ptr %11, i64 0, i64 0
  %39 = call ptr @copy_str(ptr noundef %38, ptr noundef @.str.29)
  store ptr %39, ptr %13, align 8, !tbaa !9
  %40 = load ptr, ptr %13, align 8, !tbaa !9
  %41 = call ptr @copy_str(ptr noundef %40, ptr noundef @.str.30)
  store ptr %41, ptr %13, align 8, !tbaa !9
  %42 = getelementptr inbounds [128 x i8], ptr %12, i64 0, i64 0
  %43 = call ptr @copy_str(ptr noundef %42, ptr noundef @.str.29)
  store ptr %43, ptr %14, align 8, !tbaa !9
  %44 = load ptr, ptr %14, align 8, !tbaa !9
  %45 = call ptr @copy_str(ptr noundef %44, ptr noundef @.str.31)
  store ptr %45, ptr %14, align 8, !tbaa !9
  %46 = load ptr, ptr %13, align 8, !tbaa !9
  %47 = load i32, ptr %15, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = load i64, ptr %9, align 8, !tbaa !11
  %50 = load i64, ptr %10, align 8, !tbaa !11
  %51 = call ptr @file_name(ptr noundef %46, i64 noundef 128, i64 noundef %48, i64 noundef %49, i64 noundef %50)
  %52 = load ptr, ptr %14, align 8, !tbaa !9
  %53 = load ptr, ptr %13, align 8, !tbaa !9
  %54 = call ptr @copy_str(ptr noundef %52, ptr noundef %53)
  %55 = getelementptr inbounds [128 x i8], ptr %11, i64 0, i64 0
  %56 = call i32 @fopen_s(ptr noundef %16, ptr noundef %55, ptr noundef @.str.32)
  %57 = icmp ne i32 %56, 0
  br i1 %57, label %81, label %58

58:                                               ; preds = %37
  %59 = load ptr, ptr %16, align 8, !tbaa !9
  %60 = load i32, ptr %15, align 4, !tbaa !5
  %61 = load i64, ptr %9, align 8, !tbaa !11
  %62 = load i64, ptr %10, align 8, !tbaa !11
  call void @header(ptr noundef %59, i32 noundef %60, i64 noundef %61, i64 noundef %62)
  %63 = load i32, ptr %15, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [8 x ptr], ptr @f_ptr, i64 0, i64 %64
  %66 = load ptr, ptr %65, align 8, !tbaa !9
  %67 = load ptr, ptr %16, align 8, !tbaa !9
  %68 = load ptr, ptr %8, align 8, !tbaa !9
  %69 = load i64, ptr %9, align 8, !tbaa !11
  %70 = load i64, ptr %10, align 8, !tbaa !11
  call void %66(ptr noundef %67, ptr noundef %68, i64 noundef %69, i64 noundef %70)
  %71 = load ptr, ptr %16, align 8, !tbaa !9
  %72 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %71, ptr noundef @.str.11) #4
  %73 = load ptr, ptr %16, align 8, !tbaa !9
  %74 = call i32 @fclose(ptr noundef %73)
  %75 = load i32, ptr %6, align 4, !tbaa !5
  %76 = icmp ne i32 %75, 0
  br i1 %76, label %77, label %80

77:                                               ; preds = %58
  %78 = getelementptr inbounds [128 x i8], ptr %12, i64 0, i64 0
  %79 = getelementptr inbounds [128 x i8], ptr %11, i64 0, i64 0
  call void @comp_vecs(ptr noundef %78, ptr noundef %79)
  br label %80

80:                                               ; preds = %77, %58
  br label %84

81:                                               ; preds = %37
  %82 = getelementptr inbounds [128 x i8], ptr %11, i64 0, i64 0
  %83 = call i32 (ptr, ...) @printf(ptr noundef @.str.33, ptr noundef %82)
  br label %84

84:                                               ; preds = %81, %80
  br label %85

85:                                               ; preds = %84, %29
  br label %86

86:                                               ; preds = %85
  %87 = load i32, ptr %15, align 4, !tbaa !5
  %88 = add nsw i32 %87, 1
  store i32 %88, ptr %15, align 4, !tbaa !5
  br label %26, !llvm.loop !13

89:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 128, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 128, ptr %11) #4
  ret void
}

declare ptr @copy_str(ptr noundef, ptr noundef) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

@.str.11 = external hidden unnamed_addr constant [2 x i8], align 1
@f_ptr = external dso_local local_unnamed_addr global [8 x ptr], align 16
@.str.26 = external hidden unnamed_addr constant [66 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [38 x i8], align 1

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

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

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

declare ptr @file_name(ptr noundef, i64 noundef, i64 noundef, i64 noundef, i64 noundef) local_unnamed_addr #3

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

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

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

declare i32 @fopen_s(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @do_tests(i32 noundef %0, ptr nocapture noundef readonly %1, ptr noundef %2, i64 noundef %3, i64 noundef %4) local_unnamed_addr #0 {
  %6 = alloca [128 x i8], align 16
  %7 = alloca [128 x i8], align 16
  %8 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %6) #4
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #4
  %.not = icmp eq i32 %0, 0
  %9 = select i1 %.not, ptr @.str.28, ptr @.str.27
  %10 = shl i64 %3, 3
  %11 = shl i64 %4, 3
  %12 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.26, ptr noundef nonnull %9, i64 noundef %10, i64 noundef %11)
  br label %13

13:                                               ; preds = %5, %39
  %indvars.iv = phi i64 [ 0, %5 ], [ %indvars.iv.next, %39 ]
  %14 = trunc nuw nsw i64 %indvars.iv to i32
  %15 = lshr i64 %indvars.iv, 1
  %16 = and i64 %15, 2147483647
  %17 = getelementptr inbounds i32, ptr %1, i64 %16
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %.not22 = icmp eq i32 %18, 0
  br i1 %.not22, label %39, label %19

19:                                               ; preds = %13
  %20 = call ptr @copy_str(ptr noundef nonnull %6, ptr noundef nonnull @.str.29) #4
  %21 = call ptr @copy_str(ptr noundef %20, ptr noundef nonnull @.str.30) #4
  %22 = call ptr @copy_str(ptr noundef nonnull %7, ptr noundef nonnull @.str.29) #4
  %23 = call ptr @copy_str(ptr noundef %22, ptr noundef nonnull @.str.31) #4
  %24 = call ptr @file_name(ptr noundef %21, i64 noundef 128, i64 noundef %indvars.iv, i64 noundef %3, i64 noundef %4) #4
  %25 = call ptr @copy_str(ptr noundef %23, ptr noundef %21) #4
  %26 = call i32 @fopen_s(ptr noundef nonnull %8, ptr noundef nonnull %6, ptr noundef nonnull @.str.32) #4
  %.not23 = icmp eq i32 %26, 0
  br i1 %.not23, label %27, label %37

27:                                               ; preds = %19
  %28 = load ptr, ptr %8, align 8, !tbaa !9
  call void @header(ptr noundef %28, i32 noundef %14, i64 noundef %3, i64 noundef %4)
  %29 = getelementptr inbounds [8 x ptr], ptr @f_ptr, i64 0, i64 %indvars.iv
  %30 = load ptr, ptr %29, align 8, !tbaa !9
  %31 = load ptr, ptr %8, align 8, !tbaa !9
  call void %30(ptr noundef %31, ptr noundef %2, i64 noundef %3, i64 noundef %4) #4
  %32 = load ptr, ptr %8, align 8, !tbaa !9
  %33 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %32, ptr noundef nonnull @.str.11) #4
  %34 = load ptr, ptr %8, align 8, !tbaa !9
  %35 = call i32 @fclose(ptr noundef %34)
  br i1 %.not, label %39, label %36

36:                                               ; preds = %27
  call void @comp_vecs(ptr noundef nonnull %7, ptr noundef nonnull %6)
  br label %39

37:                                               ; preds = %19
  %38 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.33, ptr noundef nonnull %6)
  br label %39

39:                                               ; preds = %13, %27, %36, %37
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 8
  br i1 %exitcond.not, label %40, label %13, !llvm.loop !11

40:                                               ; preds = %39
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #4
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %7) #4
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %6) #4
  ret void
}

declare ptr @copy_str(ptr noundef, ptr 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { "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 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass