; LLVM IR from tangjz/acm-icpc :: self_training/2014-12-07 (H)

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

@n = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@f = external dso_local global [1000000 x i32], align 16
@g = external dso_local global [1000000 x i32], align 16
@maxl = external dso_local global i32, align 4
@sg = external dso_local global [1000000 x i64], align 16
@ans = external dso_local global i64, align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 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 @_Z2dpv() #1

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #4 {
  %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
  br label %6

6:                                                ; preds = %94, %0
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @q)
  %8 = icmp eq i32 %7, 2
  br i1 %8, label %9, label %104

9:                                                ; preds = %6
  store i64 0, ptr @ans, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 16 @sg, i8 0, i64 8000000, i1 false)
  %10 = call noundef i32 @_Z2dpv()
  store i32 %10, ptr @maxl, align 4, !tbaa !9
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) @n, ptr noundef nonnull align 4 dereferenceable(4) @q) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 @g, ptr align 16 @f, i64 4000000, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  %11 = call noundef i32 @_Z2dpv()
  store i32 %11, ptr %2, align 4, !tbaa !9
  %12 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @maxl, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %13 = load i32, ptr %12, align 4, !tbaa !9
  store i32 %13, ptr @maxl, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  %14 = load i32, ptr @q, align 4, !tbaa !9
  store i32 %14, ptr %3, align 4, !tbaa !9
  br label %15

15:                                               ; preds = %34, %9
  %16 = load i32, ptr %3, align 4, !tbaa !9
  %17 = icmp ne i32 %16, 0
  br i1 %17, label %19, label %18

18:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  br label %37

19:                                               ; preds = %15
  %20 = load i32, ptr %3, align 4, !tbaa !9
  %21 = add nsw i32 %20, 1
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [1000000 x i64], ptr @sg, i64 0, i64 %22
  %24 = load i64, ptr %23, align 8, !tbaa !5
  %25 = load i32, ptr %3, align 4, !tbaa !9
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [1000000 x i32], ptr @g, i64 0, i64 %26
  %28 = load i32, ptr %27, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = add nsw i64 %24, %29
  %31 = load i32, ptr %3, align 4, !tbaa !9
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [1000000 x i64], ptr @sg, i64 0, i64 %32
  store i64 %30, ptr %33, align 8, !tbaa !5
  br label %34

34:                                               ; preds = %19
  %35 = load i32, ptr %3, align 4, !tbaa !9
  %36 = add nsw i32 %35, -1
  store i32 %36, ptr %3, align 4, !tbaa !9
  br label %15, !llvm.loop !11

37:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  store i32 1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  %38 = load i32, ptr @q, align 4, !tbaa !9
  store i32 %38, ptr %5, align 4, !tbaa !9
  br label %39

39:                                               ; preds = %91, %37
  %40 = load i32, ptr %4, align 4, !tbaa !9
  %41 = load i32, ptr @n, align 4, !tbaa !9
  %42 = icmp sle i32 %40, %41
  br i1 %42, label %44, label %43

43:                                               ; preds = %39
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  br label %94

44:                                               ; preds = %39
  br label %45

45:                                               ; preds = %63, %44
  %46 = load i32, ptr %5, align 4, !tbaa !9
  %47 = icmp ne i32 %46, 0
  br i1 %47, label %48, label %61

48:                                               ; preds = %45
  %49 = load i32, ptr %4, align 4, !tbaa !9
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [1000000 x i32], ptr @f, i64 0, i64 %50
  %52 = load i32, ptr %51, align 4, !tbaa !9
  %53 = load i32, ptr %5, align 4, !tbaa !9
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [1000000 x i32], ptr @g, i64 0, i64 %54
  %56 = load i32, ptr %55, align 4, !tbaa !9
  %57 = add nsw i32 %52, %56
  %58 = add nsw i32 %57, 1
  %59 = load i32, ptr @maxl, align 4, !tbaa !9
  %60 = icmp sge i32 %58, %59
  br label %61

61:                                               ; preds = %48, %45
  %62 = phi i1 [ false, %45 ], [ %60, %48 ]
  br i1 %62, label %63, label %66

63:                                               ; preds = %61
  %64 = load i32, ptr %5, align 4, !tbaa !9
  %65 = add nsw i32 %64, -1
  store i32 %65, ptr %5, align 4, !tbaa !9
  br label %45, !llvm.loop !13

66:                                               ; preds = %61
  %67 = load i32, ptr %4, align 4, !tbaa !9
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [1000000 x i32], ptr @f, i64 0, i64 %68
  %70 = load i32, ptr %69, align 4, !tbaa !9
  %71 = add nsw i32 %70, 1
  %72 = load i32, ptr @q, align 4, !tbaa !9
  %73 = load i32, ptr %5, align 4, !tbaa !9
  %74 = sub nsw i32 %72, %73
  %75 = mul nsw i32 %71, %74
  %76 = sext i32 %75 to i64
  %77 = load i32, ptr %5, align 4, !tbaa !9
  %78 = add nsw i32 %77, 1
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [1000000 x i64], ptr @sg, i64 0, i64 %79
  %81 = load i64, ptr %80, align 8, !tbaa !5
  %82 = add nsw i64 %76, %81
  %83 = load i64, ptr @ans, align 8, !tbaa !5
  %84 = add nsw i64 %83, %82
  store i64 %84, ptr @ans, align 8, !tbaa !5
  %85 = load i32, ptr @maxl, align 4, !tbaa !9
  %86 = load i32, ptr %5, align 4, !tbaa !9
  %87 = mul nsw i32 %85, %86
  %88 = sext i32 %87 to i64
  %89 = load i64, ptr @ans, align 8, !tbaa !5
  %90 = add nsw i64 %89, %88
  store i64 %90, ptr @ans, align 8, !tbaa !5
  br label %91

91:                                               ; preds = %66
  %92 = load i32, ptr %4, align 4, !tbaa !9
  %93 = add nsw i32 %92, 1
  store i32 %93, ptr %4, align 4, !tbaa !9
  br label %39, !llvm.loop !14

94:                                               ; preds = %43
  %95 = load i64, ptr @ans, align 8, !tbaa !5
  %96 = sitofp i64 %95 to double
  %97 = load i32, ptr @n, align 4, !tbaa !9
  %98 = load i32, ptr @q, align 4, !tbaa !9
  %99 = mul nsw i32 %97, %98
  %100 = sitofp i32 %99 to double
  %101 = fdiv double %96, %100
  %102 = fadd double %101, 1.000000e-05
  %103 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, double noundef %102)
  br label %6, !llvm.loop !15

104:                                              ; preds = %6
  ret i32 0
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #5

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #6

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #5

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

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 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 #5 = { 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 #6 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #7 = { 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 = !{!"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}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}


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

@n = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@f = external dso_local local_unnamed_addr global [1000000 x i32], align 16
@g = external dso_local local_unnamed_addr global [1000000 x i32], align 16
@maxl = external dso_local global i32, align 4
@sg = external dso_local local_unnamed_addr global [1000000 x i64], align 16
@ans = external dso_local local_unnamed_addr global i64, align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 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 @_Z2dpv() local_unnamed_addr #1

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #4 {
  %1 = alloca i32, align 4
  %2 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @q)
  %3 = icmp eq i32 %2, 2
  br i1 %3, label %.lr.ph35, label %._crit_edge36

.lr.ph35:                                         ; preds = %0, %41
  store i64 0, ptr @ans, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(8000000) @sg, i8 0, i64 8000000, i1 false)
  %4 = call noundef i32 @_Z2dpv()
  store i32 %4, ptr @maxl, align 4, !tbaa !9
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) @n, ptr noundef nonnull align 4 dereferenceable(4) @q) #7
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(4000000) @g, ptr noundef nonnull align 16 dereferenceable(4000000) @f, i64 4000000, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  %5 = call noundef i32 @_Z2dpv()
  store i32 %5, ptr %1, align 4, !tbaa !9
  %6 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @maxl, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %7 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %7, ptr @maxl, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  %8 = load i32, ptr @q, align 4, !tbaa !9
  %.not22 = icmp eq i32 %8, 0
  br i1 %.not22, label %.preheader21, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %.lr.ph35
  %9 = sext i32 %8 to i64
  %10 = shl nsw i64 %9, 3
  %scevgep = getelementptr i8, ptr getelementptr inbounds (i8, ptr @sg, i64 8), i64 %10
  %load_initial = load i64, ptr %scevgep, align 8
  %xtraiter = and i64 %9, 3
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol

.lr.ph.prol:                                      ; preds = %.lr.ph.preheader, %.lr.ph.prol
  %store_forwarded.prol = phi i64 [ %14, %.lr.ph.prol ], [ %load_initial, %.lr.ph.preheader ]
  %indvars.iv.prol = phi i64 [ %indvars.iv.next.prol, %.lr.ph.prol ], [ %9, %.lr.ph.preheader ]
  %prol.iter = phi i64 [ %prol.iter.next, %.lr.ph.prol ], [ 0, %.lr.ph.preheader ]
  %11 = getelementptr inbounds [1000000 x i32], ptr @g, i64 0, i64 %indvars.iv.prol
  %12 = load i32, ptr %11, align 4, !tbaa !9
  %13 = sext i32 %12 to i64
  %14 = add nsw i64 %store_forwarded.prol, %13
  %15 = getelementptr inbounds [1000000 x i64], ptr @sg, i64 0, i64 %indvars.iv.prol
  store i64 %14, ptr %15, align 8, !tbaa !5
  %indvars.iv.next.prol = add nsw i64 %indvars.iv.prol, -1
  %prol.iter.next = add i64 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i64 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol, !llvm.loop !11

.lr.ph.prol.loopexit:                             ; preds = %.lr.ph.prol, %.lr.ph.preheader
  %store_forwarded.unr = phi i64 [ %load_initial, %.lr.ph.preheader ], [ %14, %.lr.ph.prol ]
  %indvars.iv.unr = phi i64 [ %9, %.lr.ph.preheader ], [ %indvars.iv.next.prol, %.lr.ph.prol ]
  %16 = icmp ult i32 %8, 4
  br i1 %16, label %.preheader21, label %.lr.ph

.preheader21:                                     ; preds = %.lr.ph.prol.loopexit, %.lr.ph, %.lr.ph35
  %17 = load i32, ptr @n, align 4, !tbaa !9
  %ans.promoted = load i64, ptr @ans, align 8, !tbaa !5
  %.not1829 = icmp slt i32 %17, 1
  br i1 %.not1829, label %41, label %.preheader.preheader

.preheader.preheader:                             ; preds = %.preheader21
  %18 = add nuw i32 %17, 1
  %wide.trip.count = zext i32 %18 to i64
  br label %.preheader

.lr.ph:                                           ; preds = %.lr.ph.prol.loopexit, %.lr.ph
  %store_forwarded = phi i64 [ %37, %.lr.ph ], [ %store_forwarded.unr, %.lr.ph.prol.loopexit ]
  %indvars.iv = phi i64 [ %indvars.iv.next.3, %.lr.ph ], [ %indvars.iv.unr, %.lr.ph.prol.loopexit ]
  %19 = getelementptr inbounds [1000000 x i32], ptr @g, i64 0, i64 %indvars.iv
  %20 = load i32, ptr %19, align 4, !tbaa !9
  %21 = sext i32 %20 to i64
  %22 = add nsw i64 %store_forwarded, %21
  %23 = getelementptr inbounds [1000000 x i64], ptr @sg, i64 0, i64 %indvars.iv
  store i64 %22, ptr %23, align 8, !tbaa !5
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %24 = getelementptr inbounds [1000000 x i32], ptr @g, i64 0, i64 %indvars.iv.next
  %25 = load i32, ptr %24, align 4, !tbaa !9
  %26 = sext i32 %25 to i64
  %27 = add nsw i64 %22, %26
  %28 = getelementptr inbounds [1000000 x i64], ptr @sg, i64 0, i64 %indvars.iv.next
  store i64 %27, ptr %28, align 8, !tbaa !5
  %indvars.iv.next.1 = add nsw i64 %indvars.iv, -2
  %29 = getelementptr inbounds [1000000 x i32], ptr @g, i64 0, i64 %indvars.iv.next.1
  %30 = load i32, ptr %29, align 4, !tbaa !9
  %31 = sext i32 %30 to i64
  %32 = add nsw i64 %27, %31
  %33 = getelementptr inbounds [1000000 x i64], ptr @sg, i64 0, i64 %indvars.iv.next.1
  store i64 %32, ptr %33, align 8, !tbaa !5
  %indvars.iv.next.2 = add nsw i64 %indvars.iv, -3
  %34 = getelementptr inbounds [1000000 x i32], ptr @g, i64 0, i64 %indvars.iv.next.2
  %35 = load i32, ptr %34, align 4, !tbaa !9
  %36 = sext i32 %35 to i64
  %37 = add nsw i64 %32, %36
  %38 = getelementptr inbounds [1000000 x i64], ptr @sg, i64 0, i64 %indvars.iv.next.2
  store i64 %37, ptr %38, align 8, !tbaa !5
  %indvars.iv.next.3 = add nsw i64 %indvars.iv, -4
  %.not.3 = icmp eq i64 %indvars.iv.next.3, 0
  br i1 %.not.3, label %.preheader21, label %.lr.ph, !llvm.loop !13

.preheader:                                       ; preds = %.preheader.preheader, %.critedge
  %indvars.iv41 = phi i64 [ 1, %.preheader.preheader ], [ %indvars.iv.next42, %.critedge ]
  %.031 = phi i32 [ %8, %.preheader.preheader ], [ %.1.lcssa, %.critedge ]
  %39 = phi i64 [ %ans.promoted, %.preheader.preheader ], [ %68, %.critedge ]
  %.not1924 = icmp eq i32 %.031, 0
  %.phi.trans.insert = getelementptr inbounds [1000000 x i32], ptr @f, i64 0, i64 %indvars.iv41
  %.pre = load i32, ptr %.phi.trans.insert, align 4, !tbaa !9
  %.pre44 = add i32 %.pre, 1
  br i1 %.not1924, label %.critedge, label %.lr.ph26

.lr.ph26:                                         ; preds = %.preheader
  %40 = sext i32 %.031 to i64
  br label %51

._crit_edge:                                      ; preds = %.critedge
  store i64 %68, ptr @ans, align 8, !tbaa !5
  br label %41

41:                                               ; preds = %._crit_edge, %.preheader21
  %42 = phi i64 [ %68, %._crit_edge ], [ %ans.promoted, %.preheader21 ]
  %43 = sitofp i64 %42 to double
  %44 = mul nsw i32 %17, %8
  %45 = sitofp i32 %44 to double
  %46 = fdiv double %43, %45
  %47 = fadd double %46, 1.000000e-05
  %48 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, double noundef %47)
  %49 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @q)
  %50 = icmp eq i32 %49, 2
  br i1 %50, label %.lr.ph35, label %._crit_edge36, !llvm.loop !15

51:                                               ; preds = %.lr.ph26, %55
  %indvars.iv38 = phi i64 [ %40, %.lr.ph26 ], [ %indvars.iv.next39, %55 ]
  %52 = getelementptr inbounds [1000000 x i32], ptr @g, i64 0, i64 %indvars.iv38
  %53 = load i32, ptr %52, align 4, !tbaa !9
  %54 = add i32 %.pre44, %53
  %.not20 = icmp slt i32 %54, %7
  br i1 %.not20, label %.critedge.loopexit.split.loop.exit45, label %55

55:                                               ; preds = %51
  %indvars.iv.next39 = add nsw i64 %indvars.iv38, -1
  %.not19 = icmp eq i64 %indvars.iv.next39, 0
  br i1 %.not19, label %.critedge, label %51, !llvm.loop !16

.critedge.loopexit.split.loop.exit45:             ; preds = %51
  %56 = trunc nsw i64 %indvars.iv38 to i32
  br label %.critedge

.critedge:                                        ; preds = %55, %.critedge.loopexit.split.loop.exit45, %.preheader
  %.1.lcssa = phi i32 [ 0, %.preheader ], [ %56, %.critedge.loopexit.split.loop.exit45 ], [ 0, %55 ]
  %57 = sub nsw i32 %8, %.1.lcssa
  %58 = mul nsw i32 %.pre44, %57
  %59 = sext i32 %58 to i64
  %60 = add nsw i32 %.1.lcssa, 1
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [1000000 x i64], ptr @sg, i64 0, i64 %61
  %63 = load i64, ptr %62, align 8, !tbaa !5
  %64 = mul nsw i32 %.1.lcssa, %7
  %65 = sext i32 %64 to i64
  %66 = add i64 %63, %65
  %67 = add i64 %66, %39
  %68 = add i64 %67, %59
  %indvars.iv.next42 = add nuw nsw i64 %indvars.iv41, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next42, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.preheader, !llvm.loop !17

._crit_edge36:                                    ; preds = %41, %0
  ret i32 0
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #5

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #6

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #5

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

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 = { 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 nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 #5 = { 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 #6 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #7 = { 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 = !{!"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}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.unroll.disable"}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !14}


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