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

; 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 [21 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [28 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 i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca [1 x i64], align 8
  %6 = alloca [1 x i64], align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca [2 x i64], align 8
  %10 = alloca [2 x i64], align 8
  %11 = alloca [2 x i64], align 8
  %12 = alloca [2 x i64], align 8
  %13 = alloca [2 x i64], align 8
  %14 = alloca [2 x i64], align 8
  %15 = alloca [2 x i64], align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #3
  store i64 0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  store i64 1, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  store i64 101, ptr %5, align 8, !tbaa !5
  %16 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 0
  %17 = load i64, ptr %16, align 8, !tbaa !5
  store i64 101, ptr %6, align 8, !tbaa !5
  %18 = getelementptr inbounds [1 x i64], ptr %6, i64 0, i64 0
  %19 = load i64, ptr %18, align 8, !tbaa !5
  %20 = sub nsw i64 %19, 1
  %21 = add nsw i64 %20, -1
  %22 = srem i64 %21, 1
  %23 = sub nsw i64 %17, %22
  %24 = add nsw i64 %23, 1
  %25 = add nsw i64 %24, -1
  store i64 %25, ptr %4, align 8, !tbaa !5
  br label %26

26:                                               ; preds = %35, %0
  %27 = load i64, ptr %3, align 8, !tbaa !5
  %28 = load i64, ptr %4, align 8, !tbaa !5
  %29 = icmp ne i64 %27, %28
  br i1 %29, label %31, label %30

30:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  br label %38

31:                                               ; preds = %26
  %32 = load i64, ptr %3, align 8, !tbaa !5
  %33 = load i64, ptr %2, align 8, !tbaa !5
  %34 = add i64 %33, %32
  store i64 %34, ptr %2, align 8, !tbaa !5
  br label %35

35:                                               ; preds = %31
  %36 = load i64, ptr %3, align 8, !tbaa !5
  %37 = add nsw i64 %36, 1
  store i64 %37, ptr %3, align 8, !tbaa !5
  br label %26, !llvm.loop !9

38:                                               ; preds = %30
  %39 = load i64, ptr %2, align 8, !tbaa !5
  %40 = call i32 (ptr, ...) @printf(ptr noundef @.str, i64 noundef %39)
  store i64 0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  store i64 10, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store i64 1, ptr %9, align 8, !tbaa !5
  %41 = getelementptr inbounds i64, ptr %9, i64 1
  store i64 -2, ptr %41, align 8, !tbaa !5
  %42 = getelementptr inbounds [2 x i64], ptr %9, i64 0, i64 0
  %43 = load i64, ptr %42, align 8, !tbaa !5
  store i64 1, ptr %10, align 8, !tbaa !5
  %44 = getelementptr inbounds i64, ptr %10, i64 1
  store i64 -2, ptr %44, align 8, !tbaa !5
  %45 = getelementptr inbounds [2 x i64], ptr %10, i64 0, i64 0
  %46 = load i64, ptr %45, align 8, !tbaa !5
  %47 = sub nsw i64 %46, 10
  store i64 1, ptr %11, align 8, !tbaa !5
  %48 = getelementptr inbounds i64, ptr %11, i64 1
  store i64 -2, ptr %48, align 8, !tbaa !5
  %49 = getelementptr inbounds [2 x i64], ptr %11, i64 0, i64 1
  %50 = load i64, ptr %49, align 8, !tbaa !5
  %51 = icmp sgt i64 %50, 0
  %52 = zext i1 %51 to i64
  %53 = select i1 %51, i32 -1, i32 1
  %54 = sext i32 %53 to i64
  %55 = add nsw i64 %47, %54
  store i64 1, ptr %12, align 8, !tbaa !5
  %56 = getelementptr inbounds i64, ptr %12, i64 1
  store i64 -2, ptr %56, align 8, !tbaa !5
  %57 = getelementptr inbounds [2 x i64], ptr %12, i64 0, i64 1
  %58 = load i64, ptr %57, align 8, !tbaa !5
  %59 = srem i64 %55, %58
  %60 = sub nsw i64 %43, %59
  store i64 1, ptr %13, align 8, !tbaa !5
  %61 = getelementptr inbounds i64, ptr %13, i64 1
  store i64 -2, ptr %61, align 8, !tbaa !5
  %62 = getelementptr inbounds [2 x i64], ptr %13, i64 0, i64 1
  %63 = load i64, ptr %62, align 8, !tbaa !5
  %64 = add nsw i64 %60, %63
  store i64 1, ptr %14, align 8, !tbaa !5
  %65 = getelementptr inbounds i64, ptr %14, i64 1
  store i64 -2, ptr %65, align 8, !tbaa !5
  %66 = getelementptr inbounds [2 x i64], ptr %14, i64 0, i64 1
  %67 = load i64, ptr %66, align 8, !tbaa !5
  %68 = icmp sgt i64 %67, 0
  %69 = zext i1 %68 to i64
  %70 = select i1 %68, i32 -1, i32 1
  %71 = sext i32 %70 to i64
  %72 = add nsw i64 %64, %71
  store i64 %72, ptr %8, align 8, !tbaa !5
  br label %73

73:                                               ; preds = %82, %38
  %74 = load i64, ptr %7, align 8, !tbaa !5
  %75 = load i64, ptr %8, align 8, !tbaa !5
  %76 = icmp ne i64 %74, %75
  br i1 %76, label %78, label %77

77:                                               ; preds = %73
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  br label %88

78:                                               ; preds = %73
  %79 = load i64, ptr %7, align 8, !tbaa !5
  %80 = load i64, ptr %2, align 8, !tbaa !5
  %81 = add i64 %80, %79
  store i64 %81, ptr %2, align 8, !tbaa !5
  br label %82

82:                                               ; preds = %78
  store i64 1, ptr %15, align 8, !tbaa !5
  %83 = getelementptr inbounds i64, ptr %15, i64 1
  store i64 -2, ptr %83, align 8, !tbaa !5
  %84 = getelementptr inbounds [2 x i64], ptr %15, i64 0, i64 1
  %85 = load i64, ptr %84, align 8, !tbaa !5
  %86 = load i64, ptr %7, align 8, !tbaa !5
  %87 = add nsw i64 %86, %85
  store i64 %87, ptr %7, align 8, !tbaa !5
  br label %73, !llvm.loop !11

88:                                               ; preds = %77
  %89 = load i64, ptr %2, align 8, !tbaa !5
  %90 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i64 noundef %89)
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #3
  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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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

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 = { "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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


; 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 [21 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [28 x i8], align 1

; Function Attrs: nofree nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i64 noundef 5050)
  %2 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef 30)
  ret i32 0
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(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" }

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


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