; LLVM IR from DionysiosB/CodeForces :: 0300-0399 (371B-FoxDividingCheese)

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

@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z3gcdll(i64 noundef, i64 noundef) #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #1 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  store i64 0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  store i64 0, ptr %3, align 8, !tbaa !5
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2, ptr noundef %3)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %9 = load i64, ptr %2, align 8, !tbaa !5
  %10 = load i64, ptr %3, align 8, !tbaa !5
  %11 = call noundef i64 @_Z3gcdll(i64 noundef %9, i64 noundef %10)
  store i64 %11, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %12 = load i64, ptr %2, align 8, !tbaa !5
  %13 = load i64, ptr %4, align 8, !tbaa !5
  %14 = sdiv i64 %12, %13
  store i64 %14, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %15 = load i64, ptr %3, align 8, !tbaa !5
  %16 = load i64, ptr %4, align 8, !tbaa !5
  %17 = sdiv i64 %15, %16
  store i64 %17, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  store i64 0, ptr %7, align 8, !tbaa !5
  br label %18

18:                                               ; preds = %22, %0
  %19 = load i64, ptr %5, align 8, !tbaa !5
  %20 = srem i64 %19, 2
  %21 = icmp eq i64 %20, 0
  br i1 %21, label %22, label %27

22:                                               ; preds = %18
  %23 = load i64, ptr %5, align 8, !tbaa !5
  %24 = sdiv i64 %23, 2
  store i64 %24, ptr %5, align 8, !tbaa !5
  %25 = load i64, ptr %7, align 8, !tbaa !5
  %26 = add nsw i64 %25, 1
  store i64 %26, ptr %7, align 8, !tbaa !5
  br label %18, !llvm.loop !9

27:                                               ; preds = %18
  br label %28

28:                                               ; preds = %32, %27
  %29 = load i64, ptr %5, align 8, !tbaa !5
  %30 = srem i64 %29, 3
  %31 = icmp eq i64 %30, 0
  br i1 %31, label %32, label %37

32:                                               ; preds = %28
  %33 = load i64, ptr %5, align 8, !tbaa !5
  %34 = sdiv i64 %33, 3
  store i64 %34, ptr %5, align 8, !tbaa !5
  %35 = load i64, ptr %7, align 8, !tbaa !5
  %36 = add nsw i64 %35, 1
  store i64 %36, ptr %7, align 8, !tbaa !5
  br label %28, !llvm.loop !11

37:                                               ; preds = %28
  br label %38

38:                                               ; preds = %42, %37
  %39 = load i64, ptr %5, align 8, !tbaa !5
  %40 = srem i64 %39, 5
  %41 = icmp eq i64 %40, 0
  br i1 %41, label %42, label %47

42:                                               ; preds = %38
  %43 = load i64, ptr %5, align 8, !tbaa !5
  %44 = sdiv i64 %43, 5
  store i64 %44, ptr %5, align 8, !tbaa !5
  %45 = load i64, ptr %7, align 8, !tbaa !5
  %46 = add nsw i64 %45, 1
  store i64 %46, ptr %7, align 8, !tbaa !5
  br label %38, !llvm.loop !12

47:                                               ; preds = %38
  br label %48

48:                                               ; preds = %52, %47
  %49 = load i64, ptr %6, align 8, !tbaa !5
  %50 = srem i64 %49, 2
  %51 = icmp eq i64 %50, 0
  br i1 %51, label %52, label %57

52:                                               ; preds = %48
  %53 = load i64, ptr %6, align 8, !tbaa !5
  %54 = sdiv i64 %53, 2
  store i64 %54, ptr %6, align 8, !tbaa !5
  %55 = load i64, ptr %7, align 8, !tbaa !5
  %56 = add nsw i64 %55, 1
  store i64 %56, ptr %7, align 8, !tbaa !5
  br label %48, !llvm.loop !13

57:                                               ; preds = %48
  br label %58

58:                                               ; preds = %62, %57
  %59 = load i64, ptr %6, align 8, !tbaa !5
  %60 = srem i64 %59, 3
  %61 = icmp eq i64 %60, 0
  br i1 %61, label %62, label %67

62:                                               ; preds = %58
  %63 = load i64, ptr %6, align 8, !tbaa !5
  %64 = sdiv i64 %63, 3
  store i64 %64, ptr %6, align 8, !tbaa !5
  %65 = load i64, ptr %7, align 8, !tbaa !5
  %66 = add nsw i64 %65, 1
  store i64 %66, ptr %7, align 8, !tbaa !5
  br label %58, !llvm.loop !14

67:                                               ; preds = %58
  br label %68

68:                                               ; preds = %72, %67
  %69 = load i64, ptr %6, align 8, !tbaa !5
  %70 = srem i64 %69, 5
  %71 = icmp eq i64 %70, 0
  br i1 %71, label %72, label %77

72:                                               ; preds = %68
  %73 = load i64, ptr %6, align 8, !tbaa !5
  %74 = sdiv i64 %73, 5
  store i64 %74, ptr %6, align 8, !tbaa !5
  %75 = load i64, ptr %7, align 8, !tbaa !5
  %76 = add nsw i64 %75, 1
  store i64 %76, ptr %7, align 8, !tbaa !5
  br label %68, !llvm.loop !15

77:                                               ; preds = %68
  %78 = load i64, ptr %5, align 8, !tbaa !5
  %79 = icmp sgt i64 %78, 1
  br i1 %79, label %83, label %80

80:                                               ; preds = %77
  %81 = load i64, ptr %6, align 8, !tbaa !5
  %82 = icmp sgt i64 %81, 1
  br i1 %82, label %83, label %85

83:                                               ; preds = %80, %77
  %84 = call i32 @puts(ptr noundef @.str.1)
  br label %88

85:                                               ; preds = %80
  %86 = load i64, ptr %7, align 8, !tbaa !5
  %87 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i64 noundef %86)
  br label %88

88:                                               ; preds = %85, %83
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  ret i32 0
}

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

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

declare i32 @puts(ptr noundef) #3

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

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

attributes #0 = { mustprogress 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 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 = !{!"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}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !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"

@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z3gcdll(i64 noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = alloca i64, align 8
  %2 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #4
  store i64 0, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  store i64 0, ptr %2, align 8, !tbaa !5
  %3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %4 = load i64, ptr %1, align 8, !tbaa !5
  %5 = load i64, ptr %2, align 8, !tbaa !5
  %6 = call noundef i64 @_Z3gcdll(i64 noundef %4, i64 noundef %5)
  %7 = load i64, ptr %1, align 8, !tbaa !5
  %8 = sdiv i64 %7, %6
  %9 = load i64, ptr %2, align 8, !tbaa !5
  %10 = sdiv i64 %9, %6
  %11 = and i64 %8, 1
  %12 = icmp eq i64 %11, 0
  br i1 %12, label %.lr.ph, label %.preheader33

.preheader33:                                     ; preds = %.lr.ph, %0
  %.027.lcssa = phi i64 [ %8, %0 ], [ %15, %.lr.ph ]
  %.0.lcssa = phi i64 [ 0, %0 ], [ %16, %.lr.ph ]
  %13 = srem i64 %.027.lcssa, 3
  %14 = icmp eq i64 %13, 0
  br i1 %14, label %.lr.ph39, label %.preheader32

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.035 = phi i64 [ %16, %.lr.ph ], [ 0, %0 ]
  %.02734 = phi i64 [ %15, %.lr.ph ], [ %8, %0 ]
  %15 = ashr exact i64 %.02734, 1
  %16 = add nuw nsw i64 %.035, 1
  %17 = and i64 %.02734, 2
  %18 = icmp eq i64 %17, 0
  br i1 %18, label %.lr.ph, label %.preheader33, !llvm.loop !9

.preheader32:                                     ; preds = %.lr.ph39, %.preheader33
  %.128.lcssa = phi i64 [ %.027.lcssa, %.preheader33 ], [ %21, %.lr.ph39 ]
  %.1.lcssa = phi i64 [ %.0.lcssa, %.preheader33 ], [ %22, %.lr.ph39 ]
  %19 = srem i64 %.128.lcssa, 5
  %20 = icmp eq i64 %19, 0
  br i1 %20, label %.lr.ph44, label %.preheader31

.lr.ph39:                                         ; preds = %.preheader33, %.lr.ph39
  %.138 = phi i64 [ %22, %.lr.ph39 ], [ %.0.lcssa, %.preheader33 ]
  %.12837 = phi i64 [ %21, %.lr.ph39 ], [ %.027.lcssa, %.preheader33 ]
  %21 = sdiv i64 %.12837, 3
  %22 = add nuw nsw i64 %.138, 1
  %23 = srem i64 %21, 3
  %24 = icmp eq i64 %23, 0
  br i1 %24, label %.lr.ph39, label %.preheader32, !llvm.loop !11

.preheader31:                                     ; preds = %.lr.ph44, %.preheader32
  %.229.lcssa = phi i64 [ %.128.lcssa, %.preheader32 ], [ %27, %.lr.ph44 ]
  %.2.lcssa = phi i64 [ %.1.lcssa, %.preheader32 ], [ %28, %.lr.ph44 ]
  %25 = and i64 %10, 1
  %26 = icmp eq i64 %25, 0
  br i1 %26, label %.lr.ph49, label %.preheader30

.lr.ph44:                                         ; preds = %.preheader32, %.lr.ph44
  %.243 = phi i64 [ %28, %.lr.ph44 ], [ %.1.lcssa, %.preheader32 ]
  %.22942 = phi i64 [ %27, %.lr.ph44 ], [ %.128.lcssa, %.preheader32 ]
  %27 = sdiv i64 %.22942, 5
  %28 = add nuw nsw i64 %.243, 1
  %29 = srem i64 %27, 5
  %30 = icmp eq i64 %29, 0
  br i1 %30, label %.lr.ph44, label %.preheader31, !llvm.loop !12

.preheader30:                                     ; preds = %.lr.ph49, %.preheader31
  %.024.lcssa = phi i64 [ %10, %.preheader31 ], [ %33, %.lr.ph49 ]
  %.3.lcssa = phi i64 [ %.2.lcssa, %.preheader31 ], [ %34, %.lr.ph49 ]
  %31 = srem i64 %.024.lcssa, 3
  %32 = icmp eq i64 %31, 0
  br i1 %32, label %.lr.ph54, label %.preheader

.lr.ph49:                                         ; preds = %.preheader31, %.lr.ph49
  %.348 = phi i64 [ %34, %.lr.ph49 ], [ %.2.lcssa, %.preheader31 ]
  %.02447 = phi i64 [ %33, %.lr.ph49 ], [ %10, %.preheader31 ]
  %33 = ashr exact i64 %.02447, 1
  %34 = add nuw nsw i64 %.348, 1
  %35 = and i64 %.02447, 2
  %36 = icmp eq i64 %35, 0
  br i1 %36, label %.lr.ph49, label %.preheader30, !llvm.loop !13

.preheader:                                       ; preds = %.lr.ph54, %.preheader30
  %.125.lcssa = phi i64 [ %.024.lcssa, %.preheader30 ], [ %39, %.lr.ph54 ]
  %.4.lcssa = phi i64 [ %.3.lcssa, %.preheader30 ], [ %40, %.lr.ph54 ]
  %37 = srem i64 %.125.lcssa, 5
  %38 = icmp eq i64 %37, 0
  br i1 %38, label %.lr.ph59, label %._crit_edge

.lr.ph54:                                         ; preds = %.preheader30, %.lr.ph54
  %.453 = phi i64 [ %40, %.lr.ph54 ], [ %.3.lcssa, %.preheader30 ]
  %.12552 = phi i64 [ %39, %.lr.ph54 ], [ %.024.lcssa, %.preheader30 ]
  %39 = sdiv i64 %.12552, 3
  %40 = add nuw nsw i64 %.453, 1
  %41 = srem i64 %39, 3
  %42 = icmp eq i64 %41, 0
  br i1 %42, label %.lr.ph54, label %.preheader, !llvm.loop !14

.lr.ph59:                                         ; preds = %.preheader, %.lr.ph59
  %.558 = phi i64 [ %44, %.lr.ph59 ], [ %.4.lcssa, %.preheader ]
  %.22657 = phi i64 [ %43, %.lr.ph59 ], [ %.125.lcssa, %.preheader ]
  %43 = sdiv i64 %.22657, 5
  %44 = add nuw nsw i64 %.558, 1
  %45 = srem i64 %43, 5
  %46 = icmp eq i64 %45, 0
  br i1 %46, label %.lr.ph59, label %._crit_edge, !llvm.loop !15

._crit_edge:                                      ; preds = %.lr.ph59, %.preheader
  %.226.lcssa = phi i64 [ %.125.lcssa, %.preheader ], [ %43, %.lr.ph59 ]
  %.5.lcssa = phi i64 [ %.4.lcssa, %.preheader ], [ %44, %.lr.ph59 ]
  %47 = icmp sgt i64 %.229.lcssa, 1
  %48 = icmp sgt i64 %.226.lcssa, 1
  %or.cond = or i1 %47, %48
  br i1 %or.cond, label %49, label %51

49:                                               ; preds = %._crit_edge
  %50 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.1)
  br label %53

51:                                               ; preds = %._crit_edge
  %52 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %.5.lcssa)
  br label %53

53:                                               ; preds = %51, %49
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #4
  ret i32 0
}

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #3

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

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

attributes #0 = { mustprogress 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 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #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 = !{!"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}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}


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