; LLVM IR from tangjz/acm-icpc :: 51nod (1093)

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

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@ans = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca x86_fp80, align 16
  %3 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @m)
  call void @llvm.lifetime.start.p0(i64 16, ptr %2) #4
  %5 = load i32, ptr @n, align 4, !tbaa !5
  %6 = sitofp i32 %5 to x86_fp80
  store x86_fp80 %6, ptr %2, align 16, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %7

7:                                                ; preds = %36, %0
  %8 = load x86_fp80, ptr %2, align 16, !tbaa !9
  %9 = load i32, ptr %3, align 4, !tbaa !5
  %10 = sitofp i32 %9 to x86_fp80
  %11 = fmul x86_fp80 %8, %10
  %12 = load i32, ptr @m, align 4, !tbaa !5
  %13 = sitofp i32 %12 to x86_fp80
  %14 = fcmp oge x86_fp80 %11, %13
  br i1 %14, label %15, label %26

15:                                               ; preds = %7
  %16 = load i32, ptr @m, align 4, !tbaa !5
  %17 = sitofp i32 %16 to x86_fp80
  %18 = load i32, ptr %3, align 4, !tbaa !5
  %19 = sitofp i32 %18 to x86_fp80
  %20 = fdiv x86_fp80 %17, %19
  %21 = load x86_fp80, ptr %2, align 16, !tbaa !9
  %22 = fsub x86_fp80 %21, %20
  store x86_fp80 %22, ptr %2, align 16, !tbaa !9
  %23 = load i32, ptr @m, align 4, !tbaa !5
  %24 = load i32, ptr @ans, align 4, !tbaa !5
  %25 = add nsw i32 %24, %23
  store i32 %25, ptr @ans, align 4, !tbaa !5
  br label %35

26:                                               ; preds = %7
  %27 = load x86_fp80, ptr %2, align 16, !tbaa !9
  %28 = load i32, ptr %3, align 4, !tbaa !5
  %29 = sitofp i32 %28 to x86_fp80
  %30 = fmul x86_fp80 %27, %29
  %31 = call noundef x86_fp80 @_ZSt4ceile(x86_fp80 noundef %30)
  %32 = fptosi x86_fp80 %31 to i32
  %33 = load i32, ptr @ans, align 4, !tbaa !5
  %34 = add nsw i32 %33, %32
  store i32 %34, ptr @ans, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  br label %39

35:                                               ; preds = %15
  br label %36

36:                                               ; preds = %35
  %37 = load i32, ptr %3, align 4, !tbaa !5
  %38 = add nsw i32 %37, 2
  store i32 %38, ptr %3, align 4, !tbaa !5
  br label %7, !llvm.loop !11

39:                                               ; preds = %26
  %40 = load i32, ptr @ans, align 4, !tbaa !5
  %41 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %40)
  call void @llvm.lifetime.end.p0(i64 16, ptr %2) #4
  ret i32 0
}

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef x86_fp80 @_ZSt4ceile(x86_fp80 noundef) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 willreturn memory(argmem: readwrite) }
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 = !{!"long 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"

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@ans = external dso_local local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress 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 @n, ptr noundef nonnull @m)
  %2 = load i32, ptr @n, align 4, !tbaa !5
  %3 = sitofp i32 %2 to x86_fp80
  %4 = load i32, ptr @m, align 4, !tbaa !5
  %5 = sitofp i32 %4 to x86_fp80
  %6 = fcmp ult x86_fp80 %3, %5
  br i1 %6, label %16, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %0
  %ans.promoted = load i32, ptr @ans, align 4, !tbaa !5
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %7 = phi x86_fp80 [ %13, %.lr.ph ], [ 0xK3FFF8000000000000000, %.lr.ph.preheader ]
  %.010 = phi i32 [ %12, %.lr.ph ], [ 1, %.lr.ph.preheader ]
  %.069 = phi x86_fp80 [ %10, %.lr.ph ], [ %3, %.lr.ph.preheader ]
  %8 = phi i32 [ %11, %.lr.ph ], [ %ans.promoted, %.lr.ph.preheader ]
  %9 = fdiv x86_fp80 %5, %7
  %10 = fsub x86_fp80 %.069, %9
  %11 = add nsw i32 %8, %4
  %12 = add nuw nsw i32 %.010, 2
  %13 = uitofp nneg i32 %12 to x86_fp80
  %14 = fmul x86_fp80 %10, %13
  %15 = fcmp ult x86_fp80 %14, %5
  br i1 %15, label %._crit_edge, label %.lr.ph, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph
  store i32 %11, ptr @ans, align 4, !tbaa !5
  br label %16

16:                                               ; preds = %._crit_edge, %0
  %.lcssa = phi x86_fp80 [ %14, %._crit_edge ], [ %3, %0 ]
  %17 = tail call noundef x86_fp80 @_ZSt4ceile(x86_fp80 noundef %.lcssa)
  %18 = fptosi x86_fp80 %17 to i32
  %19 = load i32, ptr @ans, align 4, !tbaa !5
  %20 = add nsw i32 %19, %18
  store i32 %20, ptr @ans, align 4, !tbaa !5
  %21 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %20)
  ret i32 0
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef x86_fp80 @_ZSt4ceile(x86_fp80 noundef) local_unnamed_addr #2

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

attributes #0 = { mustprogress 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 = { 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" }

!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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass