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

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

@size = external dso_local global [3 x i32], align 4
@dmax = external dso_local global [3 x i64], align 16
@dmin = external dso_local global [3 x i64], align 16
@dcnt = external dso_local global [3 x i64], align 16
@.str = external hidden unnamed_addr constant [11 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 void @_Z5solvei(i32 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z5checkv() #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 i64, align 8
  %4 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %5

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

8:                                                ; preds = %5
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  br label %14

9:                                                ; preds = %5
  %10 = load i32, ptr %2, align 4, !tbaa !5
  call void @_Z5solvei(i32 noundef %10)
  br label %11

11:                                               ; preds = %9
  %12 = load i32, ptr %2, align 4, !tbaa !5
  %13 = add nsw i32 %12, 1
  store i32 %13, ptr %2, align 4, !tbaa !5
  br label %5, !llvm.loop !9

14:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %15 = load i64, ptr @dcnt, align 16, !tbaa !11
  store i64 %15, ptr %3, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %16 = load i64, ptr @dcnt, align 16, !tbaa !11
  store i64 %16, ptr %4, align 8, !tbaa !11
  %17 = load i64, ptr %3, align 8, !tbaa !11
  %18 = load i64, ptr %4, align 8, !tbaa !11
  %19 = call i32 (ptr, ...) @printf(ptr noundef @.str, i64 noundef %17, i64 noundef %18)
  %20 = load i64, ptr getelementptr inbounds ([3 x i64], ptr @dcnt, i64 0, i64 1), align 8, !tbaa !11
  %21 = load i32, ptr @size, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = load i64, ptr @dmin, align 16, !tbaa !11
  %24 = add nsw i64 %22, %23
  %25 = load i32, ptr getelementptr inbounds ([3 x i32], ptr @size, i64 0, i64 1), align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = mul nsw i64 %24, %26
  %28 = add nsw i64 %20, %27
  %29 = load i64, ptr %3, align 8, !tbaa !11
  %30 = add nsw i64 %29, %28
  store i64 %30, ptr %3, align 8, !tbaa !11
  %31 = load i64, ptr getelementptr inbounds ([3 x i64], ptr @dcnt, i64 0, i64 1), align 8, !tbaa !11
  %32 = load i32, ptr @size, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = load i64, ptr @dmax, align 16, !tbaa !11
  %35 = add nsw i64 %33, %34
  %36 = load i32, ptr getelementptr inbounds ([3 x i32], ptr @size, i64 0, i64 1), align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = mul nsw i64 %35, %37
  %39 = add nsw i64 %31, %38
  %40 = load i64, ptr %4, align 8, !tbaa !11
  %41 = add nsw i64 %40, %39
  store i64 %41, ptr %4, align 8, !tbaa !11
  %42 = load i64, ptr %3, align 8, !tbaa !11
  %43 = load i32, ptr @size, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = load i64, ptr getelementptr inbounds ([3 x i64], ptr @dmin, i64 0, i64 1), align 8, !tbaa !11
  %46 = mul nsw i64 %44, %45
  %47 = add nsw i64 %42, %46
  %48 = load i64, ptr %4, align 8, !tbaa !11
  %49 = load i32, ptr @size, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = load i64, ptr getelementptr inbounds ([3 x i64], ptr @dmax, i64 0, i64 1), align 8, !tbaa !11
  %52 = mul nsw i64 %50, %51
  %53 = add nsw i64 %48, %52
  %54 = call i32 (ptr, ...) @printf(ptr noundef @.str, i64 noundef %47, i64 noundef %53)
  %55 = load i64, ptr getelementptr inbounds ([3 x i64], ptr @dcnt, i64 0, i64 2), align 16, !tbaa !11
  %56 = load i32, ptr @size, align 4, !tbaa !5
  %57 = mul nsw i32 2, %56
  %58 = load i32, ptr getelementptr inbounds ([3 x i32], ptr @size, i64 0, i64 1), align 4, !tbaa !5
  %59 = add nsw i32 %57, %58
  %60 = sext i32 %59 to i64
  %61 = load i64, ptr @dmin, align 16, !tbaa !11
  %62 = add nsw i64 %60, %61
  %63 = load i32, ptr getelementptr inbounds ([3 x i32], ptr @size, i64 0, i64 2), align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = mul nsw i64 %62, %64
  %66 = add nsw i64 %55, %65
  %67 = load i32, ptr @size, align 4, !tbaa !5
  %68 = load i32, ptr getelementptr inbounds ([3 x i32], ptr @size, i64 0, i64 1), align 4, !tbaa !5
  %69 = add nsw i32 %67, %68
  %70 = sext i32 %69 to i64
  %71 = load i64, ptr getelementptr inbounds ([3 x i64], ptr @dmin, i64 0, i64 2), align 16, !tbaa !11
  %72 = mul nsw i64 %70, %71
  %73 = add nsw i64 %66, %72
  %74 = load i64, ptr %3, align 8, !tbaa !11
  %75 = add nsw i64 %74, %73
  store i64 %75, ptr %3, align 8, !tbaa !11
  %76 = load i64, ptr getelementptr inbounds ([3 x i64], ptr @dcnt, i64 0, i64 2), align 16, !tbaa !11
  %77 = load i32, ptr @size, align 4, !tbaa !5
  %78 = mul nsw i32 2, %77
  %79 = load i32, ptr getelementptr inbounds ([3 x i32], ptr @size, i64 0, i64 1), align 4, !tbaa !5
  %80 = add nsw i32 %78, %79
  %81 = sext i32 %80 to i64
  %82 = load i64, ptr @dmax, align 16, !tbaa !11
  %83 = add nsw i64 %81, %82
  %84 = load i32, ptr getelementptr inbounds ([3 x i32], ptr @size, i64 0, i64 2), align 4, !tbaa !5
  %85 = sext i32 %84 to i64
  %86 = mul nsw i64 %83, %85
  %87 = add nsw i64 %76, %86
  %88 = load i32, ptr @size, align 4, !tbaa !5
  %89 = load i32, ptr getelementptr inbounds ([3 x i32], ptr @size, i64 0, i64 1), align 4, !tbaa !5
  %90 = add nsw i32 %88, %89
  %91 = sext i32 %90 to i64
  %92 = load i64, ptr getelementptr inbounds ([3 x i64], ptr @dmax, i64 0, i64 2), align 16, !tbaa !11
  %93 = mul nsw i64 %91, %92
  %94 = add nsw i64 %87, %93
  %95 = load i64, ptr %4, align 8, !tbaa !11
  %96 = add nsw i64 %95, %94
  store i64 %96, ptr %4, align 8, !tbaa !11
  %97 = load i64, ptr %3, align 8, !tbaa !11
  %98 = load i32, ptr @size, align 4, !tbaa !5
  %99 = load i32, ptr getelementptr inbounds ([3 x i32], ptr @size, i64 0, i64 2), align 4, !tbaa !5
  %100 = add nsw i32 %98, %99
  %101 = sext i32 %100 to i64
  %102 = load i64, ptr getelementptr inbounds ([3 x i64], ptr @dmin, i64 0, i64 1), align 8, !tbaa !11
  %103 = mul nsw i64 %101, %102
  %104 = add nsw i64 %97, %103
  %105 = load i64, ptr %4, align 8, !tbaa !11
  %106 = call noundef i64 @_Z5checkv()
  %107 = add nsw i64 %105, %106
  %108 = call i32 (ptr, ...) @printf(ptr noundef @.str, i64 noundef %104, i64 noundef %107)
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  ret i32 0
}

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 = !{!12, !12, i64 0}
!12 = !{!"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"

@size = external dso_local local_unnamed_addr global [3 x i32], align 4
@dmax = external dso_local local_unnamed_addr global [3 x i64], align 16
@dmin = external dso_local local_unnamed_addr global [3 x i64], align 16
@dcnt = external dso_local local_unnamed_addr global [3 x i64], align 16
@.str = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5solvei(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z5checkv() local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  tail call void @_Z5solvei(i32 noundef 0)
  tail call void @_Z5solvei(i32 noundef 1)
  tail call void @_Z5solvei(i32 noundef 2)
  %1 = load i64, ptr @dcnt, align 16, !tbaa !5
  %2 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i64 noundef %1, i64 noundef %1)
  %3 = load i64, ptr getelementptr inbounds (i8, ptr @dcnt, i64 8), align 8, !tbaa !5
  %4 = load i32, ptr @size, align 4, !tbaa !9
  %5 = sext i32 %4 to i64
  %6 = load i64, ptr @dmin, align 16, !tbaa !5
  %7 = add nsw i64 %6, %5
  %8 = load i32, ptr getelementptr inbounds (i8, ptr @size, i64 4), align 4, !tbaa !9
  %9 = sext i32 %8 to i64
  %10 = mul nsw i64 %7, %9
  %11 = add i64 %3, %1
  %12 = add i64 %11, %10
  %13 = load i64, ptr @dmax, align 16, !tbaa !5
  %14 = add nsw i64 %13, %5
  %15 = mul nsw i64 %14, %9
  %16 = add i64 %11, %15
  %17 = load i64, ptr getelementptr inbounds (i8, ptr @dmin, i64 8), align 8, !tbaa !5
  %18 = mul nsw i64 %17, %5
  %19 = add nsw i64 %12, %18
  %20 = load i64, ptr getelementptr inbounds (i8, ptr @dmax, i64 8), align 8, !tbaa !5
  %21 = mul nsw i64 %20, %5
  %22 = add nsw i64 %16, %21
  %23 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i64 noundef %19, i64 noundef %22)
  %24 = load i64, ptr getelementptr inbounds (i8, ptr @dcnt, i64 16), align 16, !tbaa !5
  %25 = load i32, ptr @size, align 4, !tbaa !9
  %26 = shl nsw i32 %25, 1
  %27 = load i32, ptr getelementptr inbounds (i8, ptr @size, i64 4), align 4, !tbaa !9
  %28 = add nsw i32 %26, %27
  %29 = sext i32 %28 to i64
  %30 = load i64, ptr @dmin, align 16, !tbaa !5
  %31 = add nsw i64 %30, %29
  %32 = load i32, ptr getelementptr inbounds (i8, ptr @size, i64 8), align 4, !tbaa !9
  %33 = sext i32 %32 to i64
  %34 = mul nsw i64 %31, %33
  %35 = add nsw i32 %27, %25
  %36 = sext i32 %35 to i64
  %37 = load i64, ptr getelementptr inbounds (i8, ptr @dmin, i64 16), align 16, !tbaa !5
  %38 = mul nsw i64 %37, %36
  %39 = load i64, ptr @dmax, align 16, !tbaa !5
  %40 = add nsw i64 %39, %29
  %41 = mul nsw i64 %40, %33
  %42 = load i64, ptr getelementptr inbounds (i8, ptr @dmax, i64 16), align 16, !tbaa !5
  %43 = mul nsw i64 %42, %36
  %44 = add nsw i32 %32, %25
  %45 = sext i32 %44 to i64
  %46 = load i64, ptr getelementptr inbounds (i8, ptr @dmin, i64 8), align 8, !tbaa !5
  %47 = mul nsw i64 %46, %45
  %48 = add i64 %24, %12
  %49 = add i64 %48, %34
  %50 = add i64 %49, %38
  %51 = add nsw i64 %50, %47
  %52 = tail call noundef i64 @_Z5checkv()
  %53 = add i64 %16, %24
  %54 = add i64 %53, %41
  %55 = add i64 %54, %43
  %56 = add nsw i64 %55, %52
  %57 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i64 noundef %51, i64 noundef %56)
  ret i32 0
}

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

!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 long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}


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