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

; 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 [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [15 x i8], align 1
@_ZZ4mainE3buf = external hidden global [21 x i8], align 16
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1

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

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

; Function Attrs: nounwind
declare i32 @sprintf(ptr noundef, ptr noundef, ...) #2

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6, ptr noundef %7, ptr noundef %8)
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %13 = load i32, ptr %7, align 4, !tbaa !5
  %14 = load i32, ptr %8, align 4, !tbaa !5
  %15 = load i32, ptr %3, align 4, !tbaa !5
  %16 = load i32, ptr %4, align 4, !tbaa !5
  %17 = call noundef i64 @_Z5solveiiii(i32 noundef %13, i32 noundef %14, i32 noundef %15, i32 noundef %16)
  %18 = load i32, ptr %5, align 4, !tbaa !5
  %19 = load i32, ptr %6, align 4, !tbaa !5
  %20 = load i32, ptr %3, align 4, !tbaa !5
  %21 = load i32, ptr %4, align 4, !tbaa !5
  %22 = call noundef i64 @_Z5solveiiii(i32 noundef %18, i32 noundef %19, i32 noundef %20, i32 noundef %21)
  %23 = sub nsw i64 %17, %22
  store i64 %23, ptr %9, align 8, !tbaa !9
  %24 = load i32, ptr %7, align 4, !tbaa !5
  %25 = load i32, ptr %5, align 4, !tbaa !5
  %26 = icmp slt i32 %24, %25
  br i1 %26, label %35, label %27

27:                                               ; preds = %0
  %28 = load i32, ptr %7, align 4, !tbaa !5
  %29 = load i32, ptr %5, align 4, !tbaa !5
  %30 = icmp eq i32 %28, %29
  br i1 %30, label %31, label %98

31:                                               ; preds = %27
  %32 = load i32, ptr %8, align 4, !tbaa !5
  %33 = load i32, ptr %6, align 4, !tbaa !5
  %34 = icmp slt i32 %32, %33
  br i1 %34, label %35, label %98

35:                                               ; preds = %31, %0
  %36 = load i32, ptr %2, align 4, !tbaa !5
  %37 = sub nsw i32 %36, 1
  %38 = load i32, ptr %3, align 4, !tbaa !5
  %39 = sub nsw i32 %38, 1
  %40 = load i32, ptr %3, align 4, !tbaa !5
  %41 = load i32, ptr %4, align 4, !tbaa !5
  %42 = call noundef i64 @_Z5solveiiii(i32 noundef %37, i32 noundef %39, i32 noundef %40, i32 noundef %41)
  %43 = load i64, ptr %9, align 8, !tbaa !9
  %44 = add nsw i64 %43, %42
  store i64 %44, ptr %9, align 8, !tbaa !9
  %45 = load i32, ptr %2, align 4, !tbaa !5
  %46 = sub nsw i32 %45, 1
  %47 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef @_ZZ4mainE3buf, ptr noundef @.str, i32 noundef %46) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %48

48:                                               ; preds = %65, %35
  %49 = load i32, ptr %10, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [21 x i8], ptr @_ZZ4mainE3buf, i64 0, i64 %50
  %52 = load i8, ptr %51, align 1, !tbaa !11
  %53 = icmp ne i8 %52, 0
  br i1 %53, label %55, label %54

54:                                               ; preds = %48
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %68

55:                                               ; preds = %48
  %56 = load i32, ptr %10, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [21 x i8], ptr @_ZZ4mainE3buf, i64 0, i64 %57
  %59 = load i8, ptr %58, align 1, !tbaa !11
  %60 = sext i8 %59 to i32
  %61 = icmp ne i32 %60, 48
  %62 = zext i1 %61 to i32
  %63 = load i32, ptr %4, align 4, !tbaa !5
  %64 = sub nsw i32 %63, %62
  store i32 %64, ptr %4, align 4, !tbaa !5
  br label %65

65:                                               ; preds = %55
  %66 = load i32, ptr %10, align 4, !tbaa !5
  %67 = add nsw i32 %66, 1
  store i32 %67, ptr %10, align 4, !tbaa !5
  br label %48, !llvm.loop !12

68:                                               ; preds = %54
  %69 = load i32, ptr %3, align 4, !tbaa !5
  %70 = sub nsw i32 %69, 1
  %71 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef @_ZZ4mainE3buf, ptr noundef @.str, i32 noundef %70) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %72

72:                                               ; preds = %89, %68
  %73 = load i32, ptr %11, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [21 x i8], ptr @_ZZ4mainE3buf, i64 0, i64 %74
  %76 = load i8, ptr %75, align 1, !tbaa !11
  %77 = icmp ne i8 %76, 0
  br i1 %77, label %79, label %78

78:                                               ; preds = %72
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  br label %92

79:                                               ; preds = %72
  %80 = load i32, ptr %11, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [21 x i8], ptr @_ZZ4mainE3buf, i64 0, i64 %81
  %83 = load i8, ptr %82, align 1, !tbaa !11
  %84 = sext i8 %83 to i32
  %85 = icmp ne i32 %84, 48
  %86 = zext i1 %85 to i32
  %87 = load i32, ptr %4, align 4, !tbaa !5
  %88 = sub nsw i32 %87, %86
  store i32 %88, ptr %4, align 4, !tbaa !5
  br label %89

89:                                               ; preds = %79
  %90 = load i32, ptr %11, align 4, !tbaa !5
  %91 = add nsw i32 %90, 1
  store i32 %91, ptr %11, align 4, !tbaa !5
  br label %72, !llvm.loop !14

92:                                               ; preds = %78
  %93 = load i32, ptr %4, align 4, !tbaa !5
  %94 = icmp sle i32 %93, 0
  %95 = zext i1 %94 to i64
  %96 = load i64, ptr %9, align 8, !tbaa !9
  %97 = add nsw i64 %96, %95
  store i64 %97, ptr %9, align 8, !tbaa !9
  br label %98

98:                                               ; preds = %92, %31, %27
  %99 = load i64, ptr %9, align 8, !tbaa !9
  %100 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i64 noundef %99)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  ret i32 0
}

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

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

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 = { 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 = { 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 #4 = { "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 #5 = { 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 long", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


; 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 [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [15 x i8], align 1
@_ZZ4mainE3buf = external hidden global [21 x i8], align 16
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z5solveiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #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 @sprintf(ptr noalias nocapture noundef writeonly, ptr nocapture noundef readonly, ...) local_unnamed_addr #2

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #4
  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
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef nonnull %3, ptr noundef nonnull %4, ptr noundef nonnull %5, ptr noundef nonnull %6, ptr noundef nonnull %7)
  %9 = load i32, ptr %6, align 4, !tbaa !5
  %10 = load i32, ptr %7, align 4, !tbaa !5
  %11 = load i32, ptr %2, align 4, !tbaa !5
  %12 = load i32, ptr %3, align 4, !tbaa !5
  %13 = call noundef i64 @_Z5solveiiii(i32 noundef %9, i32 noundef %10, i32 noundef %11, i32 noundef %12)
  %14 = load i32, ptr %4, align 4, !tbaa !5
  %15 = load i32, ptr %5, align 4, !tbaa !5
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = load i32, ptr %3, align 4, !tbaa !5
  %18 = call noundef i64 @_Z5solveiiii(i32 noundef %14, i32 noundef %15, i32 noundef %16, i32 noundef %17)
  %19 = sub nsw i64 %13, %18
  %20 = load i32, ptr %6, align 4, !tbaa !5
  %21 = load i32, ptr %4, align 4, !tbaa !5
  %22 = icmp slt i32 %20, %21
  br i1 %22, label %29, label %23

23:                                               ; preds = %0
  %24 = icmp eq i32 %20, %21
  br i1 %24, label %25, label %63

25:                                               ; preds = %23
  %26 = load i32, ptr %7, align 4, !tbaa !5
  %27 = load i32, ptr %5, align 4, !tbaa !5
  %28 = icmp slt i32 %26, %27
  br i1 %28, label %29, label %63

29:                                               ; preds = %25, %0
  %30 = load i32, ptr %1, align 4, !tbaa !5
  %31 = add nsw i32 %30, -1
  %32 = load i32, ptr %2, align 4, !tbaa !5
  %33 = add nsw i32 %32, -1
  %34 = load i32, ptr %3, align 4, !tbaa !5
  %35 = call noundef i64 @_Z5solveiiii(i32 noundef %31, i32 noundef %33, i32 noundef %32, i32 noundef %34)
  %36 = add nsw i64 %35, %19
  %37 = load i32, ptr %1, align 4, !tbaa !5
  %38 = add nsw i32 %37, -1
  %39 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) @_ZZ4mainE3buf, ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %38) #4
  %40 = load i8, ptr @_ZZ4mainE3buf, align 16, !tbaa !9
  %.not17 = icmp eq i8 %40, 0
  br i1 %.not17, label %41, label %.lr.ph.preheader

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

._crit_edge:                                      ; preds = %.lr.ph
  store i32 %49, ptr %3, align 4, !tbaa !5
  br label %41

41:                                               ; preds = %._crit_edge, %29
  %42 = load i32, ptr %2, align 4, !tbaa !5
  %43 = add nsw i32 %42, -1
  %44 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) @_ZZ4mainE3buf, ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %43) #4
  %.promoted19 = load i32, ptr %3, align 4, !tbaa !5
  %45 = load i8, ptr @_ZZ4mainE3buf, align 16, !tbaa !9
  %.not1520 = icmp eq i8 %45, 0
  br i1 %.not1520, label %52, label %.lr.ph23

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %46 = phi i8 [ %40, %.lr.ph.preheader ], [ %51, %.lr.ph ]
  %47 = phi i32 [ %.promoted, %.lr.ph.preheader ], [ %49, %.lr.ph ]
  %48 = icmp ne i8 %46, 48
  %.neg16 = sext i1 %48 to i32
  %49 = add i32 %47, %.neg16
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %50 = getelementptr inbounds [21 x i8], ptr @_ZZ4mainE3buf, i64 0, i64 %indvars.iv.next
  %51 = load i8, ptr %50, align 1, !tbaa !9
  %.not = icmp eq i8 %51, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !10

._crit_edge24:                                    ; preds = %.lr.ph23
  store i32 %60, ptr %3, align 4, !tbaa !5
  br label %52

52:                                               ; preds = %._crit_edge24, %41
  %53 = phi i32 [ %60, %._crit_edge24 ], [ %.promoted19, %41 ]
  %54 = icmp slt i32 %53, 1
  %55 = zext i1 %54 to i64
  %56 = add nsw i64 %36, %55
  br label %63

.lr.ph23:                                         ; preds = %41, %.lr.ph23
  %indvars.iv27 = phi i64 [ %indvars.iv.next28, %.lr.ph23 ], [ 0, %41 ]
  %57 = phi i8 [ %62, %.lr.ph23 ], [ %45, %41 ]
  %58 = phi i32 [ %60, %.lr.ph23 ], [ %.promoted19, %41 ]
  %59 = icmp ne i8 %57, 48
  %.neg = sext i1 %59 to i32
  %60 = add i32 %58, %.neg
  %indvars.iv.next28 = add nuw nsw i64 %indvars.iv27, 1
  %61 = getelementptr inbounds [21 x i8], ptr @_ZZ4mainE3buf, i64 0, i64 %indvars.iv.next28
  %62 = load i8, ptr %61, align 1, !tbaa !9
  %.not15 = icmp eq i8 %62, 0
  br i1 %.not15, label %._crit_edge24, label %.lr.ph23, !llvm.loop !12

63:                                               ; preds = %52, %25, %23
  %.010 = phi i64 [ %56, %52 ], [ %19, %25 ], [ %19, %23 ]
  %64 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %.010)
  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
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 4, 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 i32 0
}

; 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

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 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 = { 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 #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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}


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