; LLVM IR from li-xilin/axe :: sample/core (forvalues)

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

%struct.foo = type { i32 }

@constinit = external hidden constant [10 x i32], align 4
@.str = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca [10 x i32], align 4
  %6 = alloca i64, align 8
  %7 = alloca %struct.foo, align 4
  %8 = alloca [3 x %struct.foo], align 4
  %9 = alloca [1 x %struct.foo], align 4
  %10 = alloca [1 x %struct.foo], align 4
  %11 = alloca [1 x %struct.foo], align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #5
  store i64 1, ptr %2, align 8, !tbaa !5
  br label %12

12:                                               ; preds = %32, %0
  %13 = load i64, ptr %2, align 8, !tbaa !5
  %14 = icmp ule i64 %13, 10
  br i1 %14, label %16, label %15

15:                                               ; preds = %12
  store i32 2, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #5
  br label %37

16:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %5, ptr align 4 @constinit, i64 40, i1 false), !tbaa.struct !9
  %17 = load i64, ptr %2, align 8, !tbaa !5
  %18 = sub nsw i64 %17, 1
  %19 = getelementptr inbounds [10 x i32], ptr %5, i64 0, i64 %18
  %20 = load i32, ptr %19, align 4, !tbaa !11
  store i32 %20, ptr %4, align 4, !tbaa !11
  br label %21

21:                                               ; preds = %28, %16
  %22 = load i64, ptr %2, align 8, !tbaa !5
  %23 = icmp sgt i64 %22, 0
  br i1 %23, label %25, label %24

24:                                               ; preds = %21
  store i32 5, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %31

25:                                               ; preds = %21
  %26 = load i32, ptr %4, align 4, !tbaa !11
  %27 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %26)
  br label %28

28:                                               ; preds = %25
  %29 = load i64, ptr %2, align 8, !tbaa !5
  %30 = sub nsw i64 0, %29
  store i64 %30, ptr %2, align 8, !tbaa !5
  br label %21, !llvm.loop !13

31:                                               ; preds = %24
  br label %32

32:                                               ; preds = %31
  %33 = load i64, ptr %2, align 8, !tbaa !5
  %34 = sub nsw i64 0, %33
  store i64 %34, ptr %2, align 8, !tbaa !5
  %35 = load i64, ptr %2, align 8, !tbaa !5
  %36 = add nsw i64 %35, 1
  store i64 %36, ptr %2, align 8, !tbaa !5
  br label %12, !llvm.loop !15

37:                                               ; preds = %15
  %38 = call i32 @putchar(i32 noundef 10)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  store i64 1, ptr %6, align 8, !tbaa !5
  br label %39

39:                                               ; preds = %67, %37
  %40 = load i64, ptr %6, align 8, !tbaa !5
  %41 = icmp ule i64 %40, 3
  br i1 %41, label %43, label %42

42:                                               ; preds = %39
  store i32 8, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  br label %72

43:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %44 = getelementptr inbounds %struct.foo, ptr %9, i32 0, i32 0
  store i32 1, ptr %44, align 4, !tbaa !16
  %45 = getelementptr inbounds [1 x %struct.foo], ptr %9, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %8, ptr align 4 %45, i64 4, i1 false), !tbaa.struct !18
  %46 = getelementptr inbounds %struct.foo, ptr %8, i64 1
  %47 = getelementptr inbounds %struct.foo, ptr %10, i32 0, i32 0
  store i32 2, ptr %47, align 4, !tbaa !16
  %48 = getelementptr inbounds [1 x %struct.foo], ptr %10, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %46, ptr align 4 %48, i64 4, i1 false), !tbaa.struct !18
  %49 = getelementptr inbounds %struct.foo, ptr %8, i64 2
  %50 = getelementptr inbounds %struct.foo, ptr %11, i32 0, i32 0
  store i32 3, ptr %50, align 4, !tbaa !16
  %51 = getelementptr inbounds [1 x %struct.foo], ptr %11, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %49, ptr align 4 %51, i64 4, i1 false), !tbaa.struct !18
  %52 = load i64, ptr %6, align 8, !tbaa !5
  %53 = sub nsw i64 %52, 1
  %54 = getelementptr inbounds [3 x %struct.foo], ptr %8, i64 0, i64 %53
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %7, ptr align 4 %54, i64 4, i1 false), !tbaa.struct !18
  br label %55

55:                                               ; preds = %63, %43
  %56 = load i64, ptr %6, align 8, !tbaa !5
  %57 = icmp sgt i64 %56, 0
  br i1 %57, label %59, label %58

58:                                               ; preds = %55
  store i32 11, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %66

59:                                               ; preds = %55
  %60 = getelementptr inbounds %struct.foo, ptr %7, i32 0, i32 0
  %61 = load i32, ptr %60, align 4, !tbaa !16
  %62 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %61)
  br label %63

63:                                               ; preds = %59
  %64 = load i64, ptr %6, align 8, !tbaa !5
  %65 = sub nsw i64 0, %64
  store i64 %65, ptr %6, align 8, !tbaa !5
  br label %55, !llvm.loop !19

66:                                               ; preds = %58
  br label %67

67:                                               ; preds = %66
  %68 = load i64, ptr %6, align 8, !tbaa !5
  %69 = sub nsw i64 0, %68
  store i64 %69, ptr %6, align 8, !tbaa !5
  %70 = load i64, ptr %6, align 8, !tbaa !5
  %71 = add nsw i64 %70, 1
  store i64 %71, ptr %6, align 8, !tbaa !5
  br label %39, !llvm.loop !20

72:                                               ; preds = %42
  %73 = call i32 @putchar(i32 noundef 10)
  ret i32 0
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

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

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

; Function Attrs: inlinehint nounwind uwtable
declare i32 @putchar(i32 noundef) #4

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{i64 0, i64 40, !10}
!10 = !{!7, !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = !{!17, !12, i64 0}
!17 = !{!"", !12, i64 0}
!18 = !{i64 0, i64 4, !11}
!19 = distinct !{!19, !14}
!20 = distinct !{!20, !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"

@constinit = external hidden local_unnamed_addr constant [10 x i32], align 4
@.str = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: nofree nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
._crit_edge:
  %0 = load i32, ptr @constinit, align 4, !tbaa !5
  %1 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %0)
  %2 = load i32, ptr getelementptr inbounds (i8, ptr @constinit, i64 4), align 4, !tbaa !5
  %3 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %2)
  %4 = load i32, ptr getelementptr inbounds (i8, ptr @constinit, i64 8), align 4, !tbaa !5
  %5 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %4)
  %6 = load i32, ptr getelementptr inbounds (i8, ptr @constinit, i64 12), align 4, !tbaa !5
  %7 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %6)
  %8 = load i32, ptr getelementptr inbounds (i8, ptr @constinit, i64 16), align 4, !tbaa !5
  %9 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %8)
  %10 = load i32, ptr getelementptr inbounds (i8, ptr @constinit, i64 20), align 4, !tbaa !5
  %11 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %10)
  %12 = load i32, ptr getelementptr inbounds (i8, ptr @constinit, i64 24), align 4, !tbaa !5
  %13 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %12)
  %14 = load i32, ptr getelementptr inbounds (i8, ptr @constinit, i64 28), align 4, !tbaa !5
  %15 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %14)
  %16 = load i32, ptr getelementptr inbounds (i8, ptr @constinit, i64 32), align 4, !tbaa !5
  %17 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %16)
  %18 = load i32, ptr getelementptr inbounds (i8, ptr @constinit, i64 36), align 4, !tbaa !5
  %19 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %18)
  %20 = tail call i32 @putchar(i32 noundef 10)
  %21 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 1)
  %22 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 2)
  %23 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 3)
  %24 = tail call i32 @putchar(i32 noundef 10)
  ret i32 0
}

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

; Function Attrs: inlinehint nofree nounwind uwtable
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #2

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 = { inlinehint 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" }

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


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