; LLVM IR from tangjz/acm-icpc :: codeforces/complete/341D.ll (Z5solvev)

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

%class.anon = type { ptr }
%class.anon.0 = type { i8 }

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvev() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca %class.anon, align 8
  %4 = alloca %class.anon.0, align 1
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  %11 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %1, ptr noundef %2)
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %12 = getelementptr inbounds %class.anon, ptr %3, i32 0, i32 0
  store ptr %1, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %4) #4
  br label %13

13:                                               ; preds = %60, %0
  %14 = load i32, ptr %2, align 4, !tbaa !9
  %15 = add nsw i32 %14, -1
  store i32 %15, ptr %2, align 4, !tbaa !9
  %16 = icmp ne i32 %14, 0
  br i1 %16, label %17, label %61

17:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %18 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %5, ptr noundef %6, ptr noundef %7, ptr noundef %8, ptr noundef %9)
  %19 = load i32, ptr %5, align 4, !tbaa !9
  %20 = icmp eq i32 %19, 1
  br i1 %20, label %21, label %42

21:                                               ; preds = %17
  %22 = load i32, ptr %8, align 4, !tbaa !9
  %23 = load i32, ptr %9, align 4, !tbaa !9
  %24 = call noundef i64 @"_ZZ5solvevENK3$_1clEii"(ptr noundef nonnull align 1 dereferenceable(1) %4, i32 noundef %22, i32 noundef %23)
  %25 = load i32, ptr %6, align 4, !tbaa !9
  %26 = sub nsw i32 %25, 1
  %27 = load i32, ptr %9, align 4, !tbaa !9
  %28 = call noundef i64 @"_ZZ5solvevENK3$_1clEii"(ptr noundef nonnull align 1 dereferenceable(1) %4, i32 noundef %26, i32 noundef %27)
  %29 = xor i64 %24, %28
  %30 = load i32, ptr %8, align 4, !tbaa !9
  %31 = load i32, ptr %7, align 4, !tbaa !9
  %32 = sub nsw i32 %31, 1
  %33 = call noundef i64 @"_ZZ5solvevENK3$_1clEii"(ptr noundef nonnull align 1 dereferenceable(1) %4, i32 noundef %30, i32 noundef %32)
  %34 = xor i64 %29, %33
  %35 = load i32, ptr %6, align 4, !tbaa !9
  %36 = sub nsw i32 %35, 1
  %37 = load i32, ptr %7, align 4, !tbaa !9
  %38 = sub nsw i32 %37, 1
  %39 = call noundef i64 @"_ZZ5solvevENK3$_1clEii"(ptr noundef nonnull align 1 dereferenceable(1) %4, i32 noundef %36, i32 noundef %38)
  %40 = xor i64 %34, %39
  %41 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i64 noundef %40)
  br label %60

42:                                               ; preds = %17
  %43 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.4, ptr noundef %10)
  %44 = load i32, ptr %6, align 4, !tbaa !9
  %45 = load i32, ptr %7, align 4, !tbaa !9
  %46 = load i64, ptr %10, align 8, !tbaa !11
  call void @"_ZZ5solvevENK3$_0clEiix"(ptr noundef nonnull align 8 dereferenceable(8) %3, i32 noundef %44, i32 noundef %45, i64 noundef %46)
  %47 = load i32, ptr %6, align 4, !tbaa !9
  %48 = load i32, ptr %9, align 4, !tbaa !9
  %49 = add nsw i32 %48, 1
  %50 = load i64, ptr %10, align 8, !tbaa !11
  call void @"_ZZ5solvevENK3$_0clEiix"(ptr noundef nonnull align 8 dereferenceable(8) %3, i32 noundef %47, i32 noundef %49, i64 noundef %50)
  %51 = load i32, ptr %8, align 4, !tbaa !9
  %52 = add nsw i32 %51, 1
  %53 = load i32, ptr %7, align 4, !tbaa !9
  %54 = load i64, ptr %10, align 8, !tbaa !11
  call void @"_ZZ5solvevENK3$_0clEiix"(ptr noundef nonnull align 8 dereferenceable(8) %3, i32 noundef %52, i32 noundef %53, i64 noundef %54)
  %55 = load i32, ptr %8, align 4, !tbaa !9
  %56 = add nsw i32 %55, 1
  %57 = load i32, ptr %9, align 4, !tbaa !9
  %58 = add nsw i32 %57, 1
  %59 = load i64, ptr %10, align 8, !tbaa !11
  call void @"_ZZ5solvevENK3$_0clEiix"(ptr noundef nonnull align 8 dereferenceable(8) %3, i32 noundef %56, i32 noundef %58, i64 noundef %59)
  br label %60

60:                                               ; preds = %42, %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %13, !llvm.loop !13

61:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #4
  ret void
}

; 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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef i64 @"_ZZ5solvevENK3$_1clEii"(ptr noundef nonnull align 1 dereferenceable(1), i32 noundef, i32 noundef) #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden void @"_ZZ5solvevENK3$_0clEiix"(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef, i32 noundef, i64 noundef) #3 align 2

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

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 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

%class.anon = type { ptr }
%class.anon.0 = type { i8 }

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z5solvev() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca %class.anon, align 8
  %4 = alloca %class.anon.0, align 1
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  %11 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1, ptr noundef nonnull %2)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  store ptr %1, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %4) #4
  %12 = load i32, ptr %2, align 4, !tbaa !9
  %13 = add nsw i32 %12, -1
  store i32 %13, ptr %2, align 4, !tbaa !9
  %.not1 = icmp eq i32 %12, 0
  br i1 %.not1, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %0, %56
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %10) #4
  %14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %5, ptr noundef nonnull %6, ptr noundef nonnull %7, ptr noundef nonnull %8, ptr noundef nonnull %9)
  %15 = load i32, ptr %5, align 4, !tbaa !9
  %16 = icmp eq i32 %15, 1
  br i1 %16, label %17, label %38

17:                                               ; preds = %.lr.ph
  %18 = load i32, ptr %8, align 4, !tbaa !9
  %19 = load i32, ptr %9, align 4, !tbaa !9
  %20 = call noundef i64 @"_ZZ5solvevENK3$_1clEii"(ptr noundef nonnull align 1 dereferenceable(1) %4, i32 noundef %18, i32 noundef %19)
  %21 = load i32, ptr %6, align 4, !tbaa !9
  %22 = add nsw i32 %21, -1
  %23 = load i32, ptr %9, align 4, !tbaa !9
  %24 = call noundef i64 @"_ZZ5solvevENK3$_1clEii"(ptr noundef nonnull align 1 dereferenceable(1) %4, i32 noundef %22, i32 noundef %23)
  %25 = xor i64 %24, %20
  %26 = load i32, ptr %8, align 4, !tbaa !9
  %27 = load i32, ptr %7, align 4, !tbaa !9
  %28 = add nsw i32 %27, -1
  %29 = call noundef i64 @"_ZZ5solvevENK3$_1clEii"(ptr noundef nonnull align 1 dereferenceable(1) %4, i32 noundef %26, i32 noundef %28)
  %30 = xor i64 %25, %29
  %31 = load i32, ptr %6, align 4, !tbaa !9
  %32 = add nsw i32 %31, -1
  %33 = load i32, ptr %7, align 4, !tbaa !9
  %34 = add nsw i32 %33, -1
  %35 = call noundef i64 @"_ZZ5solvevENK3$_1clEii"(ptr noundef nonnull align 1 dereferenceable(1) %4, i32 noundef %32, i32 noundef %34)
  %36 = xor i64 %30, %35
  %37 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i64 noundef %36)
  br label %56

38:                                               ; preds = %.lr.ph
  %39 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.4, ptr noundef nonnull %10)
  %40 = load i32, ptr %6, align 4, !tbaa !9
  %41 = load i32, ptr %7, align 4, !tbaa !9
  %42 = load i64, ptr %10, align 8, !tbaa !11
  call void @"_ZZ5solvevENK3$_0clEiix"(ptr noundef nonnull align 8 dereferenceable(8) %3, i32 noundef %40, i32 noundef %41, i64 noundef %42)
  %43 = load i32, ptr %6, align 4, !tbaa !9
  %44 = load i32, ptr %9, align 4, !tbaa !9
  %45 = add nsw i32 %44, 1
  %46 = load i64, ptr %10, align 8, !tbaa !11
  call void @"_ZZ5solvevENK3$_0clEiix"(ptr noundef nonnull align 8 dereferenceable(8) %3, i32 noundef %43, i32 noundef %45, i64 noundef %46)
  %47 = load i32, ptr %8, align 4, !tbaa !9
  %48 = add nsw i32 %47, 1
  %49 = load i32, ptr %7, align 4, !tbaa !9
  %50 = load i64, ptr %10, align 8, !tbaa !11
  call void @"_ZZ5solvevENK3$_0clEiix"(ptr noundef nonnull align 8 dereferenceable(8) %3, i32 noundef %48, i32 noundef %49, i64 noundef %50)
  %51 = load i32, ptr %8, align 4, !tbaa !9
  %52 = add nsw i32 %51, 1
  %53 = load i32, ptr %9, align 4, !tbaa !9
  %54 = add nsw i32 %53, 1
  %55 = load i64, ptr %10, align 8, !tbaa !11
  call void @"_ZZ5solvevENK3$_0clEiix"(ptr noundef nonnull align 8 dereferenceable(8) %3, i32 noundef %52, i32 noundef %54, i64 noundef %55)
  br label %56

56:                                               ; preds = %38, %17
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #4
  %57 = load i32, ptr %2, align 4, !tbaa !9
  %58 = add nsw i32 %57, -1
  store i32 %58, ptr %2, align 4, !tbaa !9
  %.not = icmp eq i32 %57, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !13

._crit_edge:                                      ; preds = %56, %0
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  ret void
}

; 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: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef i64 @"_ZZ5solvevENK3$_1clEii"(ptr noundef nonnull align 1 dereferenceable(1), i32 noundef, i32 noundef) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden void @"_ZZ5solvevENK3$_0clEiix"(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef, i32 noundef, i64 noundef) local_unnamed_addr #3 align 2

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

attributes #0 = { 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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