; LLVM IR from tangjz/acm-icpc :: buaa/oj3rd (1183)

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

@x = external dso_local global i64, align 8
@y = external dso_local global i64, align 8
@.str = external hidden unnamed_addr constant [9 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 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
  br label %2

2:                                                ; preds = %43, %0
  %3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @x, ptr noundef @y)
  %4 = icmp eq i32 %3, 2
  br i1 %4, label %5, label %46

5:                                                ; preds = %2
  br label %6

6:                                                ; preds = %16, %5
  %7 = load i64, ptr @x, align 8, !tbaa !5
  %8 = sitofp i64 %7 to double
  %9 = call double @log2(double noundef %8) #3
  %10 = fptosi double %9 to i32
  %11 = load i64, ptr @y, align 8, !tbaa !5
  %12 = sitofp i64 %11 to double
  %13 = call double @log2(double noundef %12) #3
  %14 = fptosi double %13 to i32
  %15 = icmp sgt i32 %10, %14
  br i1 %15, label %16, label %19

16:                                               ; preds = %6
  %17 = load i64, ptr @x, align 8, !tbaa !5
  %18 = ashr i64 %17, 1
  store i64 %18, ptr @x, align 8, !tbaa !5
  br label %6, !llvm.loop !9

19:                                               ; preds = %6
  br label %20

20:                                               ; preds = %30, %19
  %21 = load i64, ptr @x, align 8, !tbaa !5
  %22 = sitofp i64 %21 to double
  %23 = call double @log2(double noundef %22) #3
  %24 = fptosi double %23 to i32
  %25 = load i64, ptr @y, align 8, !tbaa !5
  %26 = sitofp i64 %25 to double
  %27 = call double @log2(double noundef %26) #3
  %28 = fptosi double %27 to i32
  %29 = icmp slt i32 %24, %28
  br i1 %29, label %30, label %33

30:                                               ; preds = %20
  %31 = load i64, ptr @y, align 8, !tbaa !5
  %32 = ashr i64 %31, 1
  store i64 %32, ptr @y, align 8, !tbaa !5
  br label %20, !llvm.loop !11

33:                                               ; preds = %20
  br label %34

34:                                               ; preds = %38, %33
  %35 = load i64, ptr @x, align 8, !tbaa !5
  %36 = load i64, ptr @y, align 8, !tbaa !5
  %37 = icmp ne i64 %35, %36
  br i1 %37, label %38, label %43

38:                                               ; preds = %34
  %39 = load i64, ptr @x, align 8, !tbaa !5
  %40 = ashr i64 %39, 1
  store i64 %40, ptr @x, align 8, !tbaa !5
  %41 = load i64, ptr @y, align 8, !tbaa !5
  %42 = ashr i64 %41, 1
  store i64 %42, ptr @y, align 8, !tbaa !5
  br label %34, !llvm.loop !12

43:                                               ; preds = %34
  %44 = load i64, ptr @x, align 8, !tbaa !5
  %45 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i64 noundef %44)
  br label %2, !llvm.loop !13

46:                                               ; preds = %2
  ret i32 0
}

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

; Function Attrs: nounwind
declare double @log2(double noundef) #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 = { 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 #3 = { 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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !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"

@x = external dso_local global i64, align 8
@y = external dso_local global i64, align 8
@.str = external hidden unnamed_addr constant [9 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 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 @x, ptr noundef nonnull @y)
  %2 = icmp eq i32 %1, 2
  br i1 %2, label %.preheader2, label %._crit_edge8

.preheader2:                                      ; preds = %0, %46
  %3 = load i64, ptr @x, align 8, !tbaa !5
  %4 = sitofp i64 %3 to double
  %5 = tail call double @log2(double noundef %4) #3
  %6 = fptosi double %5 to i32
  %7 = load i64, ptr @y, align 8, !tbaa !5
  %8 = sitofp i64 %7 to double
  %9 = tail call double @log2(double noundef %8) #3
  %10 = fptosi double %9 to i32
  %11 = icmp sgt i32 %6, %10
  br i1 %11, label %.lr.ph, label %.preheader1

.preheader1:                                      ; preds = %.lr.ph, %.preheader2
  %12 = load i64, ptr @x, align 8, !tbaa !5
  %13 = sitofp i64 %12 to double
  %14 = tail call double @log2(double noundef %13) #3
  %15 = fptosi double %14 to i32
  %16 = load i64, ptr @y, align 8, !tbaa !5
  %17 = sitofp i64 %16 to double
  %18 = tail call double @log2(double noundef %17) #3
  %19 = fptosi double %18 to i32
  %20 = icmp slt i32 %15, %19
  br i1 %20, label %.lr.ph3, label %.preheader

.lr.ph:                                           ; preds = %.preheader2, %.lr.ph
  %21 = load i64, ptr @x, align 8, !tbaa !5
  %22 = ashr i64 %21, 1
  store i64 %22, ptr @x, align 8, !tbaa !5
  %23 = sitofp i64 %22 to double
  %24 = tail call double @log2(double noundef %23) #3
  %25 = fptosi double %24 to i32
  %26 = load i64, ptr @y, align 8, !tbaa !5
  %27 = sitofp i64 %26 to double
  %28 = tail call double @log2(double noundef %27) #3
  %29 = fptosi double %28 to i32
  %30 = icmp sgt i32 %25, %29
  br i1 %30, label %.lr.ph, label %.preheader1, !llvm.loop !9

.preheader:                                       ; preds = %.lr.ph3, %.preheader1
  %x.promoted = load i64, ptr @x, align 8, !tbaa !5
  %y.promoted = load i64, ptr @y, align 8, !tbaa !5
  %.not4 = icmp eq i64 %x.promoted, %y.promoted
  br i1 %.not4, label %46, label %.lr.ph5

.lr.ph3:                                          ; preds = %.preheader1, %.lr.ph3
  %31 = load i64, ptr @y, align 8, !tbaa !5
  %32 = ashr i64 %31, 1
  store i64 %32, ptr @y, align 8, !tbaa !5
  %33 = load i64, ptr @x, align 8, !tbaa !5
  %34 = sitofp i64 %33 to double
  %35 = tail call double @log2(double noundef %34) #3
  %36 = fptosi double %35 to i32
  %37 = load i64, ptr @y, align 8, !tbaa !5
  %38 = sitofp i64 %37 to double
  %39 = tail call double @log2(double noundef %38) #3
  %40 = fptosi double %39 to i32
  %41 = icmp slt i32 %36, %40
  br i1 %41, label %.lr.ph3, label %.preheader, !llvm.loop !11

.lr.ph5:                                          ; preds = %.preheader, %.lr.ph5
  %42 = phi i64 [ %44, %.lr.ph5 ], [ %x.promoted, %.preheader ]
  %43 = phi i64 [ %45, %.lr.ph5 ], [ %y.promoted, %.preheader ]
  %44 = ashr i64 %42, 1
  %45 = ashr i64 %43, 1
  %.not = icmp eq i64 %44, %45
  br i1 %.not, label %._crit_edge, label %.lr.ph5, !llvm.loop !12

._crit_edge:                                      ; preds = %.lr.ph5
  store i64 %44, ptr @x, align 8, !tbaa !5
  store i64 %44, ptr @y, align 8, !tbaa !5
  br label %46

46:                                               ; preds = %._crit_edge, %.preheader
  %.lcssa = phi i64 [ %44, %._crit_edge ], [ %x.promoted, %.preheader ]
  %47 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %.lcssa)
  %48 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @x, ptr noundef nonnull @y)
  %49 = icmp eq i32 %48, 2
  br i1 %49, label %.preheader2, label %._crit_edge8, !llvm.loop !13

._crit_edge8:                                     ; preds = %46, %0
  ret i32 0
}

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @log2(double noundef) local_unnamed_addr #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 nofree nounwind willreturn memory(write) "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 = { 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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}


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