; LLVM IR from QiaoLiuHit/LSOTB-TIR :: vlfeat-0.9.19/src (test_sqrti)

; 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 @main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i8, align 1
  %8 = alloca i8, align 1
  %9 = alloca i8, align 1
  %10 = alloca i16, align 2
  %11 = alloca i16, align 2
  %12 = alloca i16, align 2
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  store i64 0, ptr %6, align 8, !tbaa !11
  br label %13

13:                                               ; preds = %33, %2
  %14 = load i64, ptr %6, align 8, !tbaa !11
  %15 = icmp slt i64 %14, 255
  br i1 %15, label %16, label %36

16:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #6
  %17 = load i64, ptr %6, align 8, !tbaa !11
  %18 = trunc i64 %17 to i8
  store i8 %18, ptr %7, align 1, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #6
  %19 = load i8, ptr %7, align 1, !tbaa !13
  %20 = call zeroext i8 @vl_fast_sqrt_ui8(i8 noundef zeroext %19)
  store i8 %20, ptr %8, align 1, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #6
  %21 = load i8, ptr %7, align 1, !tbaa !13
  %22 = uitofp i8 %21 to double
  %23 = call double @sqrt(double noundef %22) #6
  %24 = call double @llvm.floor.f64(double %23)
  %25 = fptoui double %24 to i8
  store i8 %25, ptr %9, align 1, !tbaa !13
  %26 = load i8, ptr %8, align 1, !tbaa !13
  %27 = zext i8 %26 to i32
  %28 = load i8, ptr %9, align 1, !tbaa !13
  %29 = zext i8 %28 to i32
  %30 = icmp ne i32 %27, %29
  br i1 %30, label %31, label %32

31:                                               ; preds = %16
  call void @abort() #7
  unreachable

32:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #6
  br label %33

33:                                               ; preds = %32
  %34 = load i64, ptr %6, align 8, !tbaa !11
  %35 = add nsw i64 %34, 1
  store i64 %35, ptr %6, align 8, !tbaa !11
  br label %13, !llvm.loop !14

36:                                               ; preds = %13
  store i64 0, ptr %6, align 8, !tbaa !11
  br label %37

37:                                               ; preds = %58, %36
  %38 = load i64, ptr %6, align 8, !tbaa !11
  %39 = icmp slt i64 %38, 4294967295
  br i1 %39, label %40, label %61

40:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 2, ptr %10) #6
  %41 = load i64, ptr %6, align 8, !tbaa !11
  %42 = trunc i64 %41 to i16
  store i16 %42, ptr %10, align 2, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 2, ptr %11) #6
  %43 = load i16, ptr %10, align 2, !tbaa !16
  %44 = call zeroext i16 @vl_fast_sqrt_ui16(i16 noundef zeroext %43)
  store i16 %44, ptr %11, align 2, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 2, ptr %12) #6
  %45 = load i16, ptr %10, align 2, !tbaa !16
  %46 = uitofp i16 %45 to double
  %47 = call double @sqrt(double noundef %46) #6
  %48 = call double @llvm.floor.f64(double %47)
  %49 = fptoui double %48 to i8
  %50 = zext i8 %49 to i16
  store i16 %50, ptr %12, align 2, !tbaa !16
  %51 = load i16, ptr %11, align 2, !tbaa !16
  %52 = zext i16 %51 to i32
  %53 = load i16, ptr %12, align 2, !tbaa !16
  %54 = zext i16 %53 to i32
  %55 = icmp ne i32 %52, %54
  br i1 %55, label %56, label %57

56:                                               ; preds = %40
  call void @abort() #7
  unreachable

57:                                               ; preds = %40
  call void @llvm.lifetime.end.p0(i64 2, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 2, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 2, ptr %10) #6
  br label %58

58:                                               ; preds = %57
  %59 = load i64, ptr %6, align 8, !tbaa !11
  %60 = add nsw i64 %59, 1
  store i64 %60, ptr %6, align 8, !tbaa !11
  br label %37, !llvm.loop !18

61:                                               ; preds = %37
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  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: inlinehint nounwind uwtable
declare hidden zeroext i8 @vl_fast_sqrt_ui8(i8 noundef zeroext) #2

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

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

; Function Attrs: noreturn nounwind
declare void @abort() #5

; 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 hidden zeroext i16 @vl_fast_sqrt_ui16(i16 noundef zeroext) #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 = { 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 = { 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 #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { noreturn 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 #6 = { nounwind }
attributes #7 = { noreturn 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 long", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!17, !17, i64 0}
!17 = !{!"short", !7, i64 0}
!18 = distinct !{!18, !15}


; 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 noundef i32 @main(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #0 {
  br label %5

3:                                                ; preds = %5
  %4 = add nuw nsw i64 %.016, 1
  %exitcond.not = icmp eq i64 %4, 255
  br i1 %exitcond.not, label %.preheader, label %5, !llvm.loop !5

5:                                                ; preds = %2, %3
  %.016 = phi i64 [ 0, %2 ], [ %4, %3 ]
  %6 = trunc nuw i64 %.016 to i8
  %7 = tail call zeroext i8 @vl_fast_sqrt_ui8(i8 noundef zeroext %6)
  %8 = uitofp i8 %6 to double
  %sqrt = tail call double @llvm.sqrt.f64(double %8)
  %9 = tail call double @llvm.floor.f64(double %sqrt)
  %10 = fptoui double %9 to i8
  %.not14 = icmp eq i8 %7, %10
  br i1 %.not14, label %3, label %11

11:                                               ; preds = %5
  tail call void @abort() #5
  unreachable

12:                                               ; preds = %.preheader
  %13 = add nuw nsw i64 %.117, 1
  %exitcond18.not = icmp eq i64 %13, 4294967295
  br i1 %exitcond18.not, label %21, label %.preheader, !llvm.loop !7

.preheader:                                       ; preds = %3, %12
  %.117 = phi i64 [ %13, %12 ], [ 0, %3 ]
  %14 = trunc i64 %.117 to i16
  %15 = tail call zeroext i16 @vl_fast_sqrt_ui16(i16 noundef zeroext %14)
  %16 = uitofp i16 %14 to double
  %sqrt15 = tail call double @llvm.sqrt.f64(double %16)
  %17 = tail call double @llvm.floor.f64(double %sqrt15)
  %18 = fptoui double %17 to i8
  %19 = zext i8 %18 to i16
  %.not = icmp eq i16 %15, %19
  br i1 %.not, label %12, label %20

20:                                               ; preds = %.preheader
  tail call void @abort() #5
  unreachable

21:                                               ; preds = %12
  ret i32 0
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i8 @vl_fast_sqrt_ui8(i8 noundef zeroext) local_unnamed_addr #1

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

; Function Attrs: noreturn nounwind
declare void @abort() local_unnamed_addr #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i16 @vl_fast_sqrt_ui16(i16 noundef zeroext) local_unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.sqrt.f64(double) #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 = { 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 = { noreturn 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 #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { noreturn 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 = distinct !{!7, !6}


; Effective O3 passes: AggressiveInstCombinePass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass