; LLVM IR from DionysiosB/CodeForces :: 0300-0399 (322B-CielAndFlowers)

; 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 [12 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %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
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  store i64 0, ptr %4, align 8, !tbaa !5
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2, ptr noundef %3, ptr noundef %4)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %9 = load i64, ptr %2, align 8, !tbaa !5
  %10 = sdiv i64 %9, 3
  %11 = load i64, ptr %3, align 8, !tbaa !5
  %12 = sdiv i64 %11, 3
  %13 = add nsw i64 %10, %12
  %14 = load i64, ptr %4, align 8, !tbaa !5
  %15 = sdiv i64 %14, 3
  %16 = add nsw i64 %13, %15
  store i64 %16, ptr %5, align 8, !tbaa !5
  %17 = load i64, ptr %2, align 8, !tbaa !5
  %18 = icmp sge i64 %17, 1
  br i1 %18, label %19, label %40

19:                                               ; preds = %0
  %20 = load i64, ptr %3, align 8, !tbaa !5
  %21 = icmp sge i64 %20, 1
  br i1 %21, label %22, label %40

22:                                               ; preds = %19
  %23 = load i64, ptr %4, align 8, !tbaa !5
  %24 = icmp sge i64 %23, 1
  br i1 %24, label %25, label %40

25:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %26 = load i64, ptr %2, align 8, !tbaa !5
  %27 = sub nsw i64 %26, 1
  %28 = sdiv i64 %27, 3
  %29 = add nsw i64 1, %28
  %30 = load i64, ptr %3, align 8, !tbaa !5
  %31 = sub nsw i64 %30, 1
  %32 = sdiv i64 %31, 3
  %33 = add nsw i64 %29, %32
  %34 = load i64, ptr %4, align 8, !tbaa !5
  %35 = sub nsw i64 %34, 1
  %36 = sdiv i64 %35, 3
  %37 = add nsw i64 %33, %36
  store i64 %37, ptr %6, align 8, !tbaa !5
  %38 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIlERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %6)
  %39 = load i64, ptr %38, align 8, !tbaa !5
  store i64 %39, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  br label %40

40:                                               ; preds = %25, %22, %19, %0
  %41 = load i64, ptr %2, align 8, !tbaa !5
  %42 = icmp sge i64 %41, 2
  br i1 %42, label %43, label %64

43:                                               ; preds = %40
  %44 = load i64, ptr %3, align 8, !tbaa !5
  %45 = icmp sge i64 %44, 2
  br i1 %45, label %46, label %64

46:                                               ; preds = %43
  %47 = load i64, ptr %4, align 8, !tbaa !5
  %48 = icmp sge i64 %47, 2
  br i1 %48, label %49, label %64

49:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %50 = load i64, ptr %2, align 8, !tbaa !5
  %51 = sub nsw i64 %50, 2
  %52 = sdiv i64 %51, 3
  %53 = add nsw i64 2, %52
  %54 = load i64, ptr %3, align 8, !tbaa !5
  %55 = sub nsw i64 %54, 2
  %56 = sdiv i64 %55, 3
  %57 = add nsw i64 %53, %56
  %58 = load i64, ptr %4, align 8, !tbaa !5
  %59 = sub nsw i64 %58, 2
  %60 = sdiv i64 %59, 3
  %61 = add nsw i64 %57, %60
  store i64 %61, ptr %7, align 8, !tbaa !5
  %62 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIlERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %7)
  %63 = load i64, ptr %62, align 8, !tbaa !5
  store i64 %63, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  br label %64

64:                                               ; preds = %49, %46, %43, %40
  %65 = load i64, ptr %5, align 8, !tbaa !5
  %66 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i64 noundef %65)
  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) #1

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIlERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #3

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

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; 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 [12 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: mustprogress norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i64, align 8
  %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
  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
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  store i64 0, ptr %3, align 8, !tbaa !5
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef nonnull %3)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  %8 = load i64, ptr %1, align 8, !tbaa !5
  %9 = sdiv i64 %8, 3
  %10 = load i64, ptr %2, align 8
  %11 = sdiv i64 %10, 3
  %12 = add nsw i64 %11, %9
  %13 = load i64, ptr %3, align 8
  %14 = sdiv i64 %13, 3
  %15 = add nsw i64 %12, %14
  store i64 %15, ptr %4, align 8, !tbaa !5
  %16 = icmp sgt i64 %8, 0
  %17 = icmp sgt i64 %10, 0
  %or.cond = select i1 %16, i1 %17, i1 false
  %18 = icmp sgt i64 %13, 0
  %or.cond3 = select i1 %or.cond, i1 %18, i1 false
  br i1 %or.cond3, label %19, label %31

19:                                               ; preds = %0
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  %20 = add nsw i64 %8, -1
  %21 = udiv i64 %20, 3
  %22 = add nuw nsw i64 %21, 1
  %23 = add nsw i64 %10, -1
  %24 = udiv i64 %23, 3
  %25 = add nuw nsw i64 %22, %24
  %26 = add nsw i64 %13, -1
  %27 = udiv i64 %26, 3
  %28 = add nuw nsw i64 %25, %27
  store i64 %28, ptr %5, align 8, !tbaa !5
  %29 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIlERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %5)
  %30 = load i64, ptr %29, align 8, !tbaa !5
  store i64 %30, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  %.pre = load i64, ptr %1, align 8, !tbaa !5
  %.pre8 = load i64, ptr %2, align 8
  %.pre9 = load i64, ptr %3, align 8
  br label %31

31:                                               ; preds = %19, %0
  %32 = phi i64 [ %30, %19 ], [ %15, %0 ]
  %33 = phi i64 [ %.pre9, %19 ], [ %13, %0 ]
  %34 = phi i64 [ %.pre8, %19 ], [ %10, %0 ]
  %35 = phi i64 [ %.pre, %19 ], [ %8, %0 ]
  %36 = icmp sgt i64 %35, 1
  %37 = icmp sgt i64 %34, 1
  %or.cond5 = select i1 %36, i1 %37, i1 false
  %38 = icmp sgt i64 %33, 1
  %or.cond7 = select i1 %or.cond5, i1 %38, i1 false
  br i1 %or.cond7, label %39, label %51

39:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #4
  %40 = add nsw i64 %35, -2
  %41 = udiv i64 %40, 3
  %42 = add nuw nsw i64 %41, 2
  %43 = add nsw i64 %34, -2
  %44 = udiv i64 %43, 3
  %45 = add nuw nsw i64 %42, %44
  %46 = add nsw i64 %33, -2
  %47 = udiv i64 %46, 3
  %48 = add nuw nsw i64 %45, %47
  store i64 %48, ptr %6, align 8, !tbaa !5
  %49 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIlERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %6)
  %50 = load i64, ptr %49, align 8, !tbaa !5
  store i64 %50, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #4
  br label %51

51:                                               ; preds = %39, %31
  %52 = phi i64 [ %50, %39 ], [ %32, %31 ]
  %53 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %52)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  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) #1

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIlERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) 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) #1

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

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass