; LLVM IR from Dovyski/opengl-demos :: libs/glm-0.9.9.3/test/gtc/gtc_ulp.ll (Z20test_ulp_double_stepv)

; 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: 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: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3glm8notEqualIdEEbRKT_S3_i(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3glm5equalIdEEbRKT_S3_i(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i64 @_ZN3glm14float_distanceEdd(double noundef, double noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z20test_ulp_double_stepv() #2 {
  %1 = alloca i32, align 4
  %2 = alloca double, align 8
  %3 = alloca i32, align 4
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #4
  store i32 0, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  store double 1.000000e+00, ptr %2, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 10, ptr %3, align 4, !tbaa !5
  br label %8

8:                                                ; preds = %49, %0
  %9 = load i32, ptr %3, align 4, !tbaa !5
  %10 = icmp slt i32 %9, 1000
  br i1 %10, label %12, label %11

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

12:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %13 = load double, ptr %2, align 8, !tbaa !9
  %14 = load i32, ptr %3, align 4, !tbaa !5
  %15 = call noundef double @_ZN3glm10next_floatIdEET_S1_i(double noundef %13, i32 noundef %14)
  store double %15, ptr %4, align 8, !tbaa !9
  %16 = call noundef zeroext i1 @_ZN3glm8notEqualIdEEbRKT_S3_i(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %4, i32 noundef 0)
  %17 = zext i1 %16 to i64
  %18 = select i1 %16, i32 0, i32 1
  %19 = load i32, ptr %1, align 4, !tbaa !5
  %20 = add nsw i32 %19, %18
  store i32 %20, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %21 = load double, ptr %4, align 8, !tbaa !9
  %22 = load i32, ptr %3, align 4, !tbaa !5
  %23 = call noundef double @_ZN3glm10prev_floatIdEET_S1_i(double noundef %21, i32 noundef %22)
  store double %23, ptr %5, align 8, !tbaa !9
  %24 = call noundef zeroext i1 @_ZN3glm5equalIdEEbRKT_S3_i(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %5, i32 noundef 0)
  %25 = zext i1 %24 to i64
  %26 = select i1 %24, i32 0, i32 1
  %27 = load i32, ptr %1, align 4, !tbaa !5
  %28 = add nsw i32 %27, %26
  store i32 %28, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %29 = load double, ptr %2, align 8, !tbaa !9
  %30 = load double, ptr %4, align 8, !tbaa !9
  %31 = call noundef i64 @_ZN3glm14float_distanceEdd(double noundef %29, double noundef %30)
  store i64 %31, ptr %6, align 8, !tbaa !11
  %32 = load i64, ptr %6, align 8, !tbaa !11
  %33 = load i32, ptr %3, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = icmp eq i64 %32, %34
  %36 = zext i1 %35 to i64
  %37 = select i1 %35, i32 0, i32 1
  %38 = load i32, ptr %1, align 4, !tbaa !5
  %39 = add nsw i32 %38, %37
  store i32 %39, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %40 = load double, ptr %2, align 8, !tbaa !9
  %41 = load double, ptr %5, align 8, !tbaa !9
  %42 = call noundef i64 @_ZN3glm14float_distanceEdd(double noundef %40, double noundef %41)
  store i64 %42, ptr %7, align 8, !tbaa !11
  %43 = load i64, ptr %7, align 8, !tbaa !11
  %44 = icmp eq i64 %43, 0
  %45 = zext i1 %44 to i64
  %46 = select i1 %44, i32 0, i32 1
  %47 = load i32, ptr %1, align 4, !tbaa !5
  %48 = add nsw i32 %47, %46
  store i32 %48, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  br label %49

49:                                               ; preds = %12
  %50 = load i32, ptr %3, align 4, !tbaa !5
  %51 = mul nsw i32 %50, 10
  store i32 %51, ptr %3, align 4, !tbaa !5
  br label %8, !llvm.loop !13

52:                                               ; preds = %11
  %53 = load i32, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #4
  ret i32 %53
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZN3glm10next_floatIdEET_S1_i(double noundef, i32 noundef) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZN3glm10prev_floatIdEET_S1_i(double noundef, i32 noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint mustprogress 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 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 = { inlinehint mustprogress 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 #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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !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"

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3glm8notEqualIdEEbRKT_S3_i(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3glm5equalIdEEbRKT_S3_i(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i64 @_ZN3glm14float_distanceEdd(double noundef, double noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z20test_ulp_double_stepv() local_unnamed_addr #2 {
  %1 = alloca double, align 8
  %2 = alloca double, align 8
  %3 = alloca double, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #4
  store double 1.000000e+00, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  %4 = tail call noundef double @_ZN3glm10next_floatIdEET_S1_i(double noundef 1.000000e+00, i32 noundef 10)
  store double %4, ptr %2, align 8, !tbaa !5
  %5 = call noundef zeroext i1 @_ZN3glm8notEqualIdEEbRKT_S3_i(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 8 dereferenceable(8) %2, i32 noundef 0)
  %not. = xor i1 %5, true
  %6 = zext i1 %not. to i32
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  %7 = load double, ptr %2, align 8, !tbaa !5
  %8 = call noundef double @_ZN3glm10prev_floatIdEET_S1_i(double noundef %7, i32 noundef 10)
  store double %8, ptr %3, align 8, !tbaa !5
  %9 = call noundef zeroext i1 @_ZN3glm5equalIdEEbRKT_S3_i(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 8 dereferenceable(8) %3, i32 noundef 0)
  %not.13 = xor i1 %9, true
  %10 = zext i1 %not.13 to i32
  %11 = add nuw nsw i32 %6, %10
  %12 = load double, ptr %1, align 8, !tbaa !5
  %13 = load double, ptr %2, align 8, !tbaa !5
  %14 = call noundef i64 @_ZN3glm14float_distanceEdd(double noundef %12, double noundef %13)
  %15 = icmp ne i64 %14, 10
  %16 = zext i1 %15 to i32
  %17 = add nuw nsw i32 %11, %16
  %18 = load double, ptr %1, align 8, !tbaa !5
  %19 = load double, ptr %3, align 8, !tbaa !5
  %20 = call noundef i64 @_ZN3glm14float_distanceEdd(double noundef %18, double noundef %19)
  %21 = icmp ne i64 %20, 0
  %22 = zext i1 %21 to i32
  %23 = add nuw nsw i32 %17, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  %24 = load double, ptr %1, align 8, !tbaa !5
  %25 = call noundef double @_ZN3glm10next_floatIdEET_S1_i(double noundef %24, i32 noundef 100)
  store double %25, ptr %2, align 8, !tbaa !5
  %26 = call noundef zeroext i1 @_ZN3glm8notEqualIdEEbRKT_S3_i(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 8 dereferenceable(8) %2, i32 noundef 0)
  %not..1 = xor i1 %26, true
  %27 = zext i1 %not..1 to i32
  %28 = add nuw nsw i32 %23, %27
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  %29 = load double, ptr %2, align 8, !tbaa !5
  %30 = call noundef double @_ZN3glm10prev_floatIdEET_S1_i(double noundef %29, i32 noundef 100)
  store double %30, ptr %3, align 8, !tbaa !5
  %31 = call noundef zeroext i1 @_ZN3glm5equalIdEEbRKT_S3_i(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 8 dereferenceable(8) %3, i32 noundef 0)
  %not.13.1 = xor i1 %31, true
  %32 = zext i1 %not.13.1 to i32
  %33 = add nuw nsw i32 %28, %32
  %34 = load double, ptr %1, align 8, !tbaa !5
  %35 = load double, ptr %2, align 8, !tbaa !5
  %36 = call noundef i64 @_ZN3glm14float_distanceEdd(double noundef %34, double noundef %35)
  %37 = icmp ne i64 %36, 100
  %38 = zext i1 %37 to i32
  %39 = add nuw nsw i32 %33, %38
  %40 = load double, ptr %1, align 8, !tbaa !5
  %41 = load double, ptr %3, align 8, !tbaa !5
  %42 = call noundef i64 @_ZN3glm14float_distanceEdd(double noundef %40, double noundef %41)
  %43 = icmp ne i64 %42, 0
  %44 = zext i1 %43 to i32
  %45 = add nuw nsw i32 %39, %44
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #4
  ret i32 %45
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZN3glm10next_floatIdEET_S1_i(double noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZN3glm10prev_floatIdEET_S1_i(double noundef, i32 noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint mustprogress 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 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 = { inlinehint mustprogress 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 #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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


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