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

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

@cnt = external dso_local global [100000 x i32], align 16
@s1 = external dso_local global [10 x i32], align 16
@s2 = external dso_local global [10 x i32], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z5solveii(i32 noundef, i32 noundef) #1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %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
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 1, ptr %4, align 4, !tbaa !5
  br label %6

6:                                                ; preds = %30, %0
  %7 = load i32, ptr %4, align 4, !tbaa !5
  %8 = icmp slt i32 %7, 100000
  br i1 %8, label %10, label %9

9:                                                ; preds = %6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %33

10:                                               ; preds = %6
  %11 = load i32, ptr %4, align 4, !tbaa !5
  %12 = sdiv i32 %11, 10
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [100000 x i32], ptr @cnt, i64 0, i64 %13
  %15 = load i32, ptr %14, align 4, !tbaa !5
  %16 = load i32, ptr %4, align 4, !tbaa !5
  %17 = srem i32 %16, 10
  %18 = icmp eq i32 %17, 4
  br i1 %18, label %23, label %19

19:                                               ; preds = %10
  %20 = load i32, ptr %4, align 4, !tbaa !5
  %21 = srem i32 %20, 10
  %22 = icmp eq i32 %21, 7
  br label %23

23:                                               ; preds = %19, %10
  %24 = phi i1 [ true, %10 ], [ %22, %19 ]
  %25 = zext i1 %24 to i32
  %26 = add nsw i32 %15, %25
  %27 = load i32, ptr %4, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [100000 x i32], ptr @cnt, i64 0, i64 %28
  store i32 %26, ptr %29, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %23
  %31 = load i32, ptr %4, align 4, !tbaa !5
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %4, align 4, !tbaa !5
  br label %6, !llvm.loop !9

33:                                               ; preds = %9
  store i32 1, ptr @s2, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 1, ptr %5, align 4, !tbaa !5
  br label %34

34:                                               ; preds = %58, %33
  %35 = load i32, ptr %5, align 4, !tbaa !5
  %36 = icmp slt i32 %35, 10
  br i1 %36, label %38, label %37

37:                                               ; preds = %34
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %61

38:                                               ; preds = %34
  %39 = load i32, ptr %5, align 4, !tbaa !5
  %40 = sub nsw i32 %39, 1
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [10 x i32], ptr @s1, i64 0, i64 %41
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %44 = mul nsw i32 %43, 10
  %45 = add nsw i32 %44, 1
  %46 = load i32, ptr %5, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [10 x i32], ptr @s1, i64 0, i64 %47
  store i32 %45, ptr %48, align 4, !tbaa !5
  %49 = load i32, ptr %5, align 4, !tbaa !5
  %50 = sub nsw i32 %49, 1
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [10 x i32], ptr @s2, i64 0, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %54 = mul nsw i32 %53, 10
  %55 = load i32, ptr %5, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [10 x i32], ptr @s2, i64 0, i64 %56
  store i32 %54, ptr %57, align 4, !tbaa !5
  br label %58

58:                                               ; preds = %38
  %59 = load i32, ptr %5, align 4, !tbaa !5
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr %5, align 4, !tbaa !5
  br label %34, !llvm.loop !11

61:                                               ; preds = %37
  %62 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2, ptr noundef %3)
  %63 = load i32, ptr %2, align 4, !tbaa !5
  %64 = load i32, ptr %3, align 4, !tbaa !5
  %65 = call noundef i32 @_Z5solveii(i32 noundef %63, i32 noundef %64)
  %66 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %65)
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  ret i32 0
}

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #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 = !{!"int", !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}


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

@cnt = external dso_local local_unnamed_addr global [100000 x i32], align 16
@s1 = external dso_local local_unnamed_addr global [10 x i32], align 16
@s2 = external dso_local local_unnamed_addr global [10 x i32], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z5solveii(i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca i32, align 4
  %2 = 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
  br label %28

3:                                                ; preds = %28
  %4 = load i32, ptr @s1, align 16, !tbaa !5
  %5 = mul nsw i32 %4, 10
  %6 = or disjoint i32 %5, 1
  store i32 %6, ptr getelementptr inbounds (i8, ptr @s1, i64 4), align 4, !tbaa !5
  %7 = mul nsw i32 %6, 10
  %8 = or disjoint i32 %7, 1
  store i32 %8, ptr getelementptr inbounds (i8, ptr @s1, i64 8), align 8, !tbaa !5
  %9 = mul nsw i32 %8, 10
  %10 = or disjoint i32 %9, 1
  store i32 %10, ptr getelementptr inbounds (i8, ptr @s1, i64 12), align 4, !tbaa !5
  store <4 x i32> <i32 1, i32 10, i32 100, i32 1000>, ptr @s2, align 16, !tbaa !5
  %11 = mul nsw i32 %10, 10
  %12 = or disjoint i32 %11, 1
  store i32 %12, ptr getelementptr inbounds (i8, ptr @s1, i64 16), align 16, !tbaa !5
  %13 = mul nsw i32 %12, 10
  %14 = or disjoint i32 %13, 1
  store i32 %14, ptr getelementptr inbounds (i8, ptr @s1, i64 20), align 4, !tbaa !5
  %15 = mul nsw i32 %14, 10
  %16 = or disjoint i32 %15, 1
  store i32 %16, ptr getelementptr inbounds (i8, ptr @s1, i64 24), align 8, !tbaa !5
  %17 = mul nsw i32 %16, 10
  %18 = or disjoint i32 %17, 1
  store i32 %18, ptr getelementptr inbounds (i8, ptr @s1, i64 28), align 4, !tbaa !5
  store <4 x i32> <i32 10000, i32 100000, i32 1000000, i32 10000000>, ptr getelementptr inbounds (i8, ptr @s2, i64 16), align 16, !tbaa !5
  %19 = mul nsw i32 %18, 10
  %20 = or disjoint i32 %19, 1
  store i32 %20, ptr getelementptr inbounds (i8, ptr @s1, i64 32), align 16, !tbaa !5
  store i32 100000000, ptr getelementptr inbounds (i8, ptr @s2, i64 32), align 16, !tbaa !5
  %21 = mul nsw i32 %20, 10
  %22 = or disjoint i32 %21, 1
  store i32 %22, ptr getelementptr inbounds (i8, ptr @s1, i64 36), align 4, !tbaa !5
  store i32 1000000000, ptr getelementptr inbounds (i8, ptr @s2, i64 36), align 4, !tbaa !5
  %23 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %24 = load i32, ptr %1, align 4, !tbaa !5
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = call noundef i32 @_Z5solveii(i32 noundef %24, i32 noundef %25)
  %27 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %26)
  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

28:                                               ; preds = %0, %28
  %indvars.iv = phi i64 [ 1, %0 ], [ %indvars.iv.next, %28 ]
  %29 = trunc nuw nsw i64 %indvars.iv to i32
  %30 = udiv i32 %29, 10
  %31 = zext nneg i32 %30 to i64
  %32 = getelementptr inbounds [100000 x i32], ptr @cnt, i64 0, i64 %31
  %33 = load i32, ptr %32, align 4, !tbaa !5
  %34 = urem i32 %29, 10
  %35 = icmp eq i32 %34, 4
  %36 = icmp eq i32 %34, 7
  %spec.select = or i1 %35, %36
  %37 = zext i1 %spec.select to i32
  %38 = add nsw i32 %33, %37
  %39 = getelementptr inbounds [100000 x i32], ptr @cnt, i64 0, i64 %indvars.iv
  store i32 %38, ptr %39, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 100000
  br i1 %exitcond.not, label %3, label %28, !llvm.loop !9
}

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

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

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass