; LLVM IR from tangjz/acm-icpc :: hdu/5401.ll (Z3Ansi)

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

@a = external dso_local global [61 x i32], align 16
@b = external dso_local global [61 x i32], align 16
@l = external dso_local global [61 x i32], align 16
@ans = external dso_local global [61 x i32], align 16
@c = external dso_local global [61 x i64], align 16
@d = external dso_local global [61 x i64], align 16
@sz = external dso_local global [61 x i64], align 16

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z3incRii(ptr noundef nonnull align 4 dereferenceable(4), 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z3Ansi(i32 noundef %0) #2 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  %5 = load i32, ptr %3, align 4, !tbaa !5
  %6 = sext i32 %5 to i64
  %7 = getelementptr inbounds [61 x i32], ptr @ans, i64 0, i64 %6
  %8 = load i32, ptr %7, align 4, !tbaa !5
  %9 = icmp ne i32 %8, -1
  br i1 %9, label %10, label %15

10:                                               ; preds = %1
  %11 = load i32, ptr %3, align 4, !tbaa !5
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds [61 x i32], ptr @ans, i64 0, i64 %12
  %14 = load i32, ptr %13, align 4, !tbaa !5
  store i32 %14, ptr %2, align 4
  br label %98

15:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %4, align 4, !tbaa !5
  %16 = load i32, ptr %3, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [61 x i32], ptr @a, i64 0, i64 %17
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %20 = call noundef i32 @_Z3Ansi(i32 noundef %19)
  call void @_Z3incRii(ptr noundef nonnull align 4 dereferenceable(4) %4, i32 noundef %20)
  %21 = load i32, ptr %3, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [61 x i32], ptr @b, i64 0, i64 %22
  %24 = load i32, ptr %23, align 4, !tbaa !5
  %25 = call noundef i32 @_Z3Ansi(i32 noundef %24)
  call void @_Z3incRii(ptr noundef nonnull align 4 dereferenceable(4) %4, i32 noundef %25)
  %26 = load i32, ptr %3, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [61 x i32], ptr @a, i64 0, i64 %27
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [61 x i64], ptr @sz, i64 0, i64 %30
  %32 = load i64, ptr %31, align 8, !tbaa !9
  %33 = srem i64 %32, 1000000007
  %34 = load i32, ptr %3, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [61 x i32], ptr @b, i64 0, i64 %35
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [61 x i64], ptr @sz, i64 0, i64 %38
  %40 = load i64, ptr %39, align 8, !tbaa !9
  %41 = srem i64 %40, 1000000007
  %42 = mul nsw i64 %33, %41
  %43 = srem i64 %42, 1000000007
  %44 = load i32, ptr %3, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [61 x i32], ptr @l, i64 0, i64 %45
  %47 = load i32, ptr %46, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = mul nsw i64 %43, %48
  %50 = srem i64 %49, 1000000007
  %51 = trunc i64 %50 to i32
  call void @_Z3incRii(ptr noundef nonnull align 4 dereferenceable(4) %4, i32 noundef %51)
  %52 = load i32, ptr %3, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [61 x i32], ptr @b, i64 0, i64 %53
  %55 = load i32, ptr %54, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [61 x i64], ptr @sz, i64 0, i64 %56
  %58 = load i64, ptr %57, align 8, !tbaa !9
  %59 = srem i64 %58, 1000000007
  %60 = load i32, ptr %3, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [61 x i32], ptr @a, i64 0, i64 %61
  %63 = load i32, ptr %62, align 4, !tbaa !5
  %64 = load i32, ptr %3, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [61 x i64], ptr @c, i64 0, i64 %65
  %67 = load i64, ptr %66, align 8, !tbaa !9
  %68 = call noundef i32 @_Z3Sumix(i32 noundef %63, i64 noundef %67)
  %69 = sext i32 %68 to i64
  %70 = mul nsw i64 %59, %69
  %71 = srem i64 %70, 1000000007
  %72 = trunc i64 %71 to i32
  call void @_Z3incRii(ptr noundef nonnull align 4 dereferenceable(4) %4, i32 noundef %72)
  %73 = load i32, ptr %3, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [61 x i32], ptr @a, i64 0, i64 %74
  %76 = load i32, ptr %75, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [61 x i64], ptr @sz, i64 0, i64 %77
  %79 = load i64, ptr %78, align 8, !tbaa !9
  %80 = srem i64 %79, 1000000007
  %81 = load i32, ptr %3, align 4, !tbaa !5
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [61 x i32], ptr @b, i64 0, i64 %82
  %84 = load i32, ptr %83, align 4, !tbaa !5
  %85 = load i32, ptr %3, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [61 x i64], ptr @d, i64 0, i64 %86
  %88 = load i64, ptr %87, align 8, !tbaa !9
  %89 = call noundef i32 @_Z3Sumix(i32 noundef %84, i64 noundef %88)
  %90 = sext i32 %89 to i64
  %91 = mul nsw i64 %80, %90
  %92 = srem i64 %91, 1000000007
  %93 = trunc i64 %92 to i32
  call void @_Z3incRii(ptr noundef nonnull align 4 dereferenceable(4) %4, i32 noundef %93)
  %94 = load i32, ptr %4, align 4, !tbaa !5
  %95 = load i32, ptr %3, align 4, !tbaa !5
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [61 x i32], ptr @ans, i64 0, i64 %96
  store i32 %94, ptr %97, align 4, !tbaa !5
  store i32 %94, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %98

98:                                               ; preds = %15, %10
  %99 = load i32, ptr %2, align 4
  ret i32 %99
}

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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}


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

@a = external dso_local local_unnamed_addr global [61 x i32], align 16
@b = external dso_local local_unnamed_addr global [61 x i32], align 16
@l = external dso_local local_unnamed_addr global [61 x i32], align 16
@ans = external dso_local local_unnamed_addr global [61 x i32], align 16
@c = external dso_local local_unnamed_addr global [61 x i64], align 16
@d = external dso_local local_unnamed_addr global [61 x i64], align 16
@sz = external dso_local local_unnamed_addr global [61 x i64], align 16

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z3incRii(ptr noundef nonnull align 4 dereferenceable(4), 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z3Sumix(i32 noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z3Ansi(i32 noundef %0) local_unnamed_addr #2 {
  %2 = alloca i32, align 4
  %3 = sext i32 %0 to i64
  %4 = getelementptr inbounds [61 x i32], ptr @ans, i64 0, i64 %3
  %5 = load i32, ptr %4, align 4, !tbaa !5
  %.not = icmp eq i32 %5, -1
  br i1 %.not, label %6, label %58

6:                                                ; preds = %1
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #3
  store i32 0, ptr %2, align 4, !tbaa !5
  %7 = getelementptr inbounds [61 x i32], ptr @a, i64 0, i64 %3
  %8 = load i32, ptr %7, align 4, !tbaa !5
  %9 = tail call noundef i32 @_Z3Ansi(i32 noundef %8)
  call void @_Z3incRii(ptr noundef nonnull align 4 dereferenceable(4) %2, i32 noundef %9)
  %10 = getelementptr inbounds [61 x i32], ptr @b, i64 0, i64 %3
  %11 = load i32, ptr %10, align 4, !tbaa !5
  %12 = call noundef i32 @_Z3Ansi(i32 noundef %11)
  call void @_Z3incRii(ptr noundef nonnull align 4 dereferenceable(4) %2, i32 noundef %12)
  %13 = load i32, ptr %7, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [61 x i64], ptr @sz, i64 0, i64 %14
  %16 = load i64, ptr %15, align 8, !tbaa !9
  %17 = srem i64 %16, 1000000007
  %18 = load i32, ptr %10, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [61 x i64], ptr @sz, i64 0, i64 %19
  %21 = load i64, ptr %20, align 8, !tbaa !9
  %22 = srem i64 %21, 1000000007
  %23 = mul nsw i64 %22, %17
  %24 = srem i64 %23, 1000000007
  %25 = getelementptr inbounds [61 x i32], ptr @l, i64 0, i64 %3
  %26 = load i32, ptr %25, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = mul nsw i64 %24, %27
  %29 = srem i64 %28, 1000000007
  %30 = trunc nsw i64 %29 to i32
  call void @_Z3incRii(ptr noundef nonnull align 4 dereferenceable(4) %2, i32 noundef %30)
  %31 = load i32, ptr %10, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [61 x i64], ptr @sz, i64 0, i64 %32
  %34 = load i64, ptr %33, align 8, !tbaa !9
  %35 = srem i64 %34, 1000000007
  %36 = load i32, ptr %7, align 4, !tbaa !5
  %37 = getelementptr inbounds [61 x i64], ptr @c, i64 0, i64 %3
  %38 = load i64, ptr %37, align 8, !tbaa !9
  %39 = call noundef i32 @_Z3Sumix(i32 noundef %36, i64 noundef %38)
  %40 = sext i32 %39 to i64
  %41 = mul nsw i64 %35, %40
  %42 = srem i64 %41, 1000000007
  %43 = trunc nsw i64 %42 to i32
  call void @_Z3incRii(ptr noundef nonnull align 4 dereferenceable(4) %2, i32 noundef %43)
  %44 = load i32, ptr %7, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [61 x i64], ptr @sz, i64 0, i64 %45
  %47 = load i64, ptr %46, align 8, !tbaa !9
  %48 = srem i64 %47, 1000000007
  %49 = load i32, ptr %10, align 4, !tbaa !5
  %50 = getelementptr inbounds [61 x i64], ptr @d, i64 0, i64 %3
  %51 = load i64, ptr %50, align 8, !tbaa !9
  %52 = call noundef i32 @_Z3Sumix(i32 noundef %49, i64 noundef %51)
  %53 = sext i32 %52 to i64
  %54 = mul nsw i64 %48, %53
  %55 = srem i64 %54, 1000000007
  %56 = trunc nsw i64 %55 to i32
  call void @_Z3incRii(ptr noundef nonnull align 4 dereferenceable(4) %2, i32 noundef %56)
  %57 = load i32, ptr %2, align 4, !tbaa !5
  store i32 %57, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #3
  br label %58

58:                                               ; preds = %1, %6
  %.0 = phi i32 [ %57, %6 ], [ %5, %1 ]
  ret i32 %.0
}

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 = { 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 #3 = { 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}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass