; LLVM IR from wgtdkp/wgtcc :: example (heart)

; 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() #0 {
  %1 = alloca i32, align 4
  %2 = alloca float, align 4
  %3 = alloca i32, align 4
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store float 1.500000e+00, ptr %2, align 4, !tbaa !5
  br label %6

6:                                                ; preds = %47, %0
  %7 = load float, ptr %2, align 4, !tbaa !5
  %8 = fcmp ogt float %7, -1.500000e+00
  br i1 %8, label %10, label %9

9:                                                ; preds = %6
  store i32 2, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  br label %50

10:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store float -1.500000e+00, ptr %4, align 4, !tbaa !5
  br label %11

11:                                               ; preds = %42, %10
  %12 = load float, ptr %4, align 4, !tbaa !5
  %13 = fcmp olt float %12, 1.500000e+00
  br i1 %13, label %15, label %14

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

15:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %16 = load float, ptr %4, align 4, !tbaa !5
  %17 = load float, ptr %4, align 4, !tbaa !5
  %18 = load float, ptr %2, align 4, !tbaa !5
  %19 = load float, ptr %2, align 4, !tbaa !5
  %20 = fmul float %18, %19
  %21 = call float @llvm.fmuladd.f32(float %16, float %17, float %20)
  %22 = fsub float %21, 1.000000e+00
  store float %22, ptr %5, align 4, !tbaa !5
  %23 = load float, ptr %5, align 4, !tbaa !5
  %24 = load float, ptr %5, align 4, !tbaa !5
  %25 = fmul float %23, %24
  %26 = load float, ptr %5, align 4, !tbaa !5
  %27 = load float, ptr %4, align 4, !tbaa !5
  %28 = load float, ptr %4, align 4, !tbaa !5
  %29 = fmul float %27, %28
  %30 = load float, ptr %2, align 4, !tbaa !5
  %31 = fmul float %29, %30
  %32 = load float, ptr %2, align 4, !tbaa !5
  %33 = fmul float %31, %32
  %34 = load float, ptr %2, align 4, !tbaa !5
  %35 = fmul float %33, %34
  %36 = fneg float %35
  %37 = call float @llvm.fmuladd.f32(float %25, float %26, float %36)
  %38 = fcmp ole float %37, 0.000000e+00
  %39 = zext i1 %38 to i64
  %40 = select i1 %38, i32 42, i32 32
  %41 = call i32 @putchar(i32 noundef %40)
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %42

42:                                               ; preds = %15
  %43 = load float, ptr %4, align 4, !tbaa !5
  %44 = fadd float %43, 0x3FA99999A0000000
  store float %44, ptr %4, align 4, !tbaa !5
  br label %11, !llvm.loop !9

45:                                               ; preds = %14
  %46 = call i32 @putchar(i32 noundef 10)
  br label %47

47:                                               ; preds = %45
  %48 = load float, ptr %2, align 4, !tbaa !5
  %49 = fsub float %48, 0x3FB99999A0000000
  store float %49, ptr %2, align 4, !tbaa !5
  br label %6, !llvm.loop !11

50:                                               ; preds = %9
  %51 = load i32, ptr %1, align 4
  ret i32 %51
}

; 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 speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #2

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

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

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 nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #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 = !{!"float", !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"

; Function Attrs: nofree nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  br label %.preheader

.preheader:                                       ; preds = %0, %3
  %.018 = phi float [ 1.500000e+00, %0 ], [ %5, %3 ]
  %1 = fmul float %.018, %.018
  br label %7

2:                                                ; preds = %3
  ret i32 0

3:                                                ; preds = %7
  %4 = tail call i32 @putchar(i32 noundef 10)
  %5 = fadd float %.018, 0xBFB99999A0000000
  %6 = fcmp ogt float %5, -1.500000e+00
  br i1 %6, label %.preheader, label %2, !llvm.loop !5

7:                                                ; preds = %.preheader, %7
  %.01617 = phi float [ -1.500000e+00, %.preheader ], [ %20, %7 ]
  %8 = tail call float @llvm.fmuladd.f32(float %.01617, float %.01617, float %1)
  %9 = fadd float %8, -1.000000e+00
  %10 = fmul float %9, %9
  %11 = fneg float %.01617
  %12 = fmul float %.01617, %11
  %13 = fmul float %.018, %12
  %14 = fmul float %.018, %13
  %15 = fmul float %.018, %14
  %16 = tail call float @llvm.fmuladd.f32(float %10, float %9, float %15)
  %17 = fcmp ole float %16, 0.000000e+00
  %18 = select i1 %17, i32 42, i32 32
  %19 = tail call i32 @putchar(i32 noundef %18)
  %20 = fadd float %.01617, 0x3FA99999A0000000
  %21 = fcmp olt float %20, 1.500000e+00
  br i1 %21, label %7, label %3, !llvm.loop !7
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = distinct !{!7, !6}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass