; LLVM IR from HandmadeMath/HandmadeMath :: test/hmm_test.ll (Z25_hmt_test_UnaryMinus_Vec2P21hmt_testresult_struct)

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

%union.HMM_Vec2 = type { %struct.anon }
%struct.anon = type { float, float }
%struct.hmt_testresult_struct = type { i32, i32 }

@.str.15 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [34 x i8], align 1
@__const._Z25_hmt_test_UnaryMinus_Vec2P21hmt_testresult_struct.VectorOne = external hidden unnamed_addr constant %union.HMM_Vec2, align 4

; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z25_hmt_test_UnaryMinus_Vec2P21hmt_testresult_struct(ptr noundef %0) #3 {
  %2 = alloca ptr, align 8
  %3 = alloca %union.HMM_Vec2, align 4
  %4 = alloca %union.HMM_Vec2, align 4
  %5 = alloca %union.HMM_Vec2, align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %3, ptr align 4 @__const._Z25_hmt_test_UnaryMinus_Vec2P21hmt_testresult_struct.VectorOne, i64 8, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %5, ptr align 4 %3, i64 8, i1 false), !tbaa.struct !9
  %10 = getelementptr inbounds %union.HMM_Vec2, ptr %5, i32 0, i32 0
  %11 = load <2 x float>, ptr %10, align 4
  %12 = call <2 x float> @_Zng8HMM_Vec2(<2 x float> %11)
  %13 = getelementptr inbounds %union.HMM_Vec2, ptr %4, i32 0, i32 0
  store <2 x float> %12, ptr %13, align 4
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.hmt_testresult_struct, ptr %14, i32 0, i32 0
  %16 = load i32, ptr %15, align 4, !tbaa !11
  %17 = add nsw i32 %16, 1
  store i32 %17, ptr %15, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %18 = getelementptr inbounds %struct.anon, ptr %4, i32 0, i32 0
  %19 = load float, ptr %18, align 4, !tbaa !10
  store float %19, ptr %6, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %20 = load float, ptr %6, align 4, !tbaa !14
  %21 = fsub float %20, -1.000000e+00
  store float %21, ptr %7, align 4, !tbaa !14
  %22 = load float, ptr %7, align 4, !tbaa !14
  %23 = fcmp olt float %22, 0xBE80000000000000
  br i1 %23, label %27, label %24

24:                                               ; preds = %1
  %25 = load float, ptr %7, align 4, !tbaa !14
  %26 = fcmp olt float 0x3E80000000000000, %25
  br i1 %26, label %27, label %38

27:                                               ; preds = %24, %1
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.hmt_testresult_struct, ptr %28, i32 0, i32 1
  %30 = load i32, ptr %29, align 4, !tbaa !16
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr %29, align 4, !tbaa !16
  %32 = call i32 (ptr, ...) @printf(ptr noundef @.str.15, i32 noundef 335)
  %33 = load float, ptr %6, align 4, !tbaa !14
  %34 = fpext float %33 to double
  %35 = load float, ptr %7, align 4, !tbaa !14
  %36 = fpext float %35 to double
  %37 = call i32 (ptr, ...) @printf(ptr noundef @.str.18, double noundef -1.000000e+00, double noundef %34, double noundef %36)
  br label %38

38:                                               ; preds = %27, %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  %39 = load ptr, ptr %2, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.hmt_testresult_struct, ptr %39, i32 0, i32 0
  %41 = load i32, ptr %40, align 4, !tbaa !11
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %40, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %43 = getelementptr inbounds %struct.anon, ptr %4, i32 0, i32 1
  %44 = load float, ptr %43, align 4, !tbaa !10
  store float %44, ptr %8, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %45 = load float, ptr %8, align 4, !tbaa !14
  %46 = fsub float %45, -2.000000e+00
  store float %46, ptr %9, align 4, !tbaa !14
  %47 = load float, ptr %9, align 4, !tbaa !14
  %48 = fcmp olt float %47, 0xBE80000000000000
  br i1 %48, label %52, label %49

49:                                               ; preds = %38
  %50 = load float, ptr %9, align 4, !tbaa !14
  %51 = fcmp olt float 0x3E80000000000000, %50
  br i1 %51, label %52, label %63

52:                                               ; preds = %49, %38
  %53 = load ptr, ptr %2, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.hmt_testresult_struct, ptr %53, i32 0, i32 1
  %55 = load i32, ptr %54, align 4, !tbaa !16
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %54, align 4, !tbaa !16
  %57 = call i32 (ptr, ...) @printf(ptr noundef @.str.15, i32 noundef 336)
  %58 = load float, ptr %8, align 4, !tbaa !14
  %59 = fpext float %58 to double
  %60 = load float, ptr %9, align 4, !tbaa !14
  %61 = fpext float %60 to double
  %62 = call i32 (ptr, ...) @printf(ptr noundef @.str.18, double noundef -2.000000e+00, double noundef %59, double noundef %61)
  br label %63

63:                                               ; preds = %52, %49
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare hidden <2 x float> @_Zng8HMM_Vec2(<2 x float>) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree 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 = { mustprogress uwtable "min-legal-vector-width"="64" "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 mustprogress uwtable "min-legal-vector-width"="64" "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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{i64 0, i64 8, !10}
!10 = !{!7, !7, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"_ZTS21hmt_testresult_struct", !13, i64 0, !13, i64 4}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"float", !7, i64 0}
!16 = !{!12, !13, i64 4}


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

%union.HMM_Vec2 = type { %struct.anon }
%struct.anon = type { float, float }

@.str.15 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [34 x i8], align 1
@__const._Z25_hmt_test_UnaryMinus_Vec2P21hmt_testresult_struct.VectorOne = external hidden unnamed_addr constant %union.HMM_Vec2, align 4

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z25_hmt_test_UnaryMinus_Vec2P21hmt_testresult_struct(ptr nocapture noundef %0) local_unnamed_addr #1 {
  %.sroa.014.0.copyload = load <2 x float>, ptr @__const._Z25_hmt_test_UnaryMinus_Vec2P21hmt_testresult_struct.VectorOne, align 4
  %2 = tail call <2 x float> @_Zng8HMM_Vec2(<2 x float> %.sroa.014.0.copyload)
  %3 = load i32, ptr %0, align 4, !tbaa !5
  %4 = add nsw i32 %3, 1
  store i32 %4, ptr %0, align 4, !tbaa !5
  %.sroa.013.0.vec.extract = extractelement <2 x float> %2, i64 0
  %5 = fadd float %.sroa.013.0.vec.extract, 1.000000e+00
  %6 = tail call float @llvm.fabs.f32(float %5)
  %or.cond = fcmp ogt float %6, 0x3E80000000000000
  br i1 %or.cond, label %7, label %15

7:                                                ; preds = %1
  %8 = getelementptr inbounds i8, ptr %0, i64 4
  %9 = load i32, ptr %8, align 4, !tbaa !10
  %10 = add nsw i32 %9, 1
  store i32 %10, ptr %8, align 4, !tbaa !10
  %11 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.15, i32 noundef 335)
  %12 = fpext float %.sroa.013.0.vec.extract to double
  %13 = fpext float %5 to double
  %14 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.18, double noundef -1.000000e+00, double noundef %12, double noundef %13)
  %.pre = load i32, ptr %0, align 4, !tbaa !5
  br label %15

15:                                               ; preds = %1, %7
  %16 = phi i32 [ %4, %1 ], [ %.pre, %7 ]
  %17 = add nsw i32 %16, 1
  store i32 %17, ptr %0, align 4, !tbaa !5
  %.sroa.013.4.vec.extract = extractelement <2 x float> %2, i64 1
  %18 = fadd float %.sroa.013.4.vec.extract, 2.000000e+00
  %19 = tail call float @llvm.fabs.f32(float %18)
  %or.cond3 = fcmp ogt float %19, 0x3E80000000000000
  br i1 %or.cond3, label %20, label %28

20:                                               ; preds = %15
  %21 = getelementptr inbounds i8, ptr %0, i64 4
  %22 = load i32, ptr %21, align 4, !tbaa !10
  %23 = add nsw i32 %22, 1
  store i32 %23, ptr %21, align 4, !tbaa !10
  %24 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.15, i32 noundef 336)
  %25 = fpext float %.sroa.013.4.vec.extract to double
  %26 = fpext float %18 to double
  %27 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.18, double noundef -2.000000e+00, double noundef %25, double noundef %26)
  br label %28

28:                                               ; preds = %15, %20
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare hidden <2 x float> @_Zng8HMM_Vec2(<2 x float>) local_unnamed_addr #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fabs.f32(float) #3

attributes #0 = { 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 #1 = { mustprogress uwtable "min-legal-vector-width"="64" "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 mustprogress uwtable "min-legal-vector-width"="64" "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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, !7, i64 0}
!6 = !{!"_ZTS21hmt_testresult_struct", !7, i64 0, !7, i64 4}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 4}


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