; LLVM IR from tangjz/acm-icpc :: TDL_training/2015-11-01 (H - Hunters - lzy)

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

@T = external dso_local global i32, align 4
@x = external dso_local global i32, align 4
@y = external dso_local global i32, align 4
@p = external dso_local global double, align 8
@q = external dso_local global double, align 8
@a = external dso_local global double, align 8
@b = external dso_local global double, align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [12 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @T)
  br label %3

3:                                                ; preds = %44, %0
  %4 = load i32, ptr @T, align 4, !tbaa !5
  %5 = add nsw i32 %4, -1
  store i32 %5, ptr @T, align 4, !tbaa !5
  %6 = icmp ne i32 %4, 0
  br i1 %6, label %7, label %45

7:                                                ; preds = %3
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @x, ptr noundef @y, ptr noundef @p, ptr noundef @q)
  %9 = load double, ptr @q, align 8, !tbaa !9
  %10 = load double, ptr @p, align 8, !tbaa !9
  %11 = load i32, ptr @x, align 4, !tbaa !5
  %12 = load i32, ptr @y, align 4, !tbaa !5
  %13 = add nsw i32 %11, %12
  %14 = sitofp i32 %13 to double
  %15 = fmul double %10, %14
  %16 = load double, ptr @q, align 8, !tbaa !9
  %17 = fsub double 1.000000e+00, %16
  %18 = load i32, ptr @x, align 4, !tbaa !5
  %19 = sitofp i32 %18 to double
  %20 = fmul double %17, %19
  %21 = call double @llvm.fmuladd.f64(double %9, double %15, double %20)
  store double %21, ptr @a, align 8, !tbaa !9
  %22 = load double, ptr @q, align 8, !tbaa !9
  %23 = load i32, ptr @y, align 4, !tbaa !5
  %24 = sitofp i32 %23 to double
  %25 = load double, ptr @q, align 8, !tbaa !9
  %26 = fsub double 1.000000e+00, %25
  %27 = load double, ptr @p, align 8, !tbaa !9
  %28 = load i32, ptr @x, align 4, !tbaa !5
  %29 = load i32, ptr @y, align 4, !tbaa !5
  %30 = add nsw i32 %28, %29
  %31 = sitofp i32 %30 to double
  %32 = fmul double %27, %31
  %33 = fmul double %26, %32
  %34 = call double @llvm.fmuladd.f64(double %22, double %24, double %33)
  store double %34, ptr @b, align 8, !tbaa !9
  %35 = load double, ptr @a, align 8, !tbaa !9
  %36 = load double, ptr @b, align 8, !tbaa !9
  %37 = fcmp olt double %35, %36
  br i1 %37, label %38, label %41

38:                                               ; preds = %7
  %39 = load double, ptr @b, align 8, !tbaa !9
  %40 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, double noundef %39)
  br label %44

41:                                               ; preds = %7
  %42 = load double, ptr @a, align 8, !tbaa !9
  %43 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, double noundef %42)
  br label %44

44:                                               ; preds = %41, %38
  br label %3, !llvm.loop !11

45:                                               ; preds = %3
  ret i32 0
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #1

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

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

attributes #0 = { mustprogress norecurse 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 = { "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 = { 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, !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 = distinct !{!11, !12}
!12 = !{!"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"

@T = external dso_local global i32, align 4
@x = external dso_local global i32, align 4
@y = external dso_local global i32, align 4
@p = external dso_local global double, align 8
@q = external dso_local global double, align 8
@a = external dso_local local_unnamed_addr global double, align 8
@b = external dso_local local_unnamed_addr global double, align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [12 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @T)
  %2 = load i32, ptr @T, align 4, !tbaa !5
  %3 = add nsw i32 %2, -1
  store i32 %3, ptr @T, align 4, !tbaa !5
  %.not2 = icmp eq i32 %2, 0
  br i1 %.not2, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %0, %24
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @x, ptr noundef nonnull @y, ptr noundef nonnull @p, ptr noundef nonnull @q)
  %5 = load double, ptr @q, align 8, !tbaa !9
  %6 = load double, ptr @p, align 8, !tbaa !9
  %7 = load i32, ptr @x, align 4, !tbaa !5
  %8 = load i32, ptr @y, align 4, !tbaa !5
  %9 = add nsw i32 %8, %7
  %10 = sitofp i32 %9 to double
  %11 = fmul double %6, %10
  %12 = fsub double 1.000000e+00, %5
  %13 = sitofp i32 %7 to double
  %14 = fmul double %12, %13
  %15 = tail call double @llvm.fmuladd.f64(double %5, double %11, double %14)
  store double %15, ptr @a, align 8, !tbaa !9
  %16 = sitofp i32 %8 to double
  %17 = fmul double %12, %11
  %18 = tail call double @llvm.fmuladd.f64(double %5, double %16, double %17)
  store double %18, ptr @b, align 8, !tbaa !9
  %19 = fcmp olt double %15, %18
  br i1 %19, label %20, label %22

20:                                               ; preds = %.lr.ph
  %21 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, double noundef %18)
  br label %24

22:                                               ; preds = %.lr.ph
  %23 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, double noundef %15)
  br label %24

24:                                               ; preds = %22, %20
  %25 = load i32, ptr @T, align 4, !tbaa !5
  %26 = add nsw i32 %25, -1
  store i32 %26, ptr @T, align 4, !tbaa !5
  %.not = icmp eq i32 %25, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !11

._crit_edge:                                      ; preds = %24, %0
  ret i32 0
}

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

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

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

attributes #0 = { mustprogress nofree norecurse 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" }
attributes #2 = { mustprogress 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, !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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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