; LLVM IR from kazunetakahashi/atcoder :: 201510_201609/0208/ARC008_D.ll (Z7koushinidd)

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

%struct.oishikunaru = type { double, double }

@conv = external dso_local global [330 x [330 x %struct.oishikunaru]], align 16
@skip = external dso_local global [330 x %struct.oishikunaru], align 16

; Function Attrs: mustprogress uwtable
declare dso_local { double, double } @_ZmlRK11oishikunaruS1_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN11oishikunaruC2Edd(ptr noundef nonnull align 8 dereferenceable(16), double noundef, double noundef) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_Z7koushinidd(i32 noundef %0, double noundef %1, double noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca %struct.oishikunaru, align 8
  %8 = alloca %struct.oishikunaru, align 8
  %9 = alloca i32, align 4
  %10 = alloca %struct.oishikunaru, align 8
  %11 = alloca i32, align 4
  %12 = alloca %struct.oishikunaru, align 8
  store i32 %0, ptr %4, align 4, !tbaa !5
  store double %1, ptr %5, align 8, !tbaa !9
  store double %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #4
  %13 = load double, ptr %5, align 8, !tbaa !9
  %14 = load double, ptr %6, align 8, !tbaa !9
  call void @_ZN11oishikunaruC2Edd(ptr noundef nonnull align 8 dereferenceable(16) %7, double noundef %13, double noundef %14)
  %15 = load i32, ptr %4, align 4, !tbaa !5
  %16 = sdiv i32 %15, 330
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [330 x [330 x %struct.oishikunaru]], ptr @conv, i64 0, i64 %17
  %19 = load i32, ptr %4, align 4, !tbaa !5
  %20 = srem i32 %19, 330
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [330 x %struct.oishikunaru], ptr %18, i64 0, i64 %21
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %22, ptr align 8 %7, i64 16, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #4
  call void @_ZN11oishikunaruC2Edd(ptr noundef nonnull align 8 dereferenceable(16) %8, double noundef 1.000000e+00, double noundef 0.000000e+00)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %23

23:                                               ; preds = %40, %3
  %24 = load i32, ptr %9, align 4, !tbaa !5
  %25 = icmp slt i32 %24, 330
  br i1 %25, label %27, label %26

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

27:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #4
  %28 = load i32, ptr %4, align 4, !tbaa !5
  %29 = sdiv i32 %28, 330
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [330 x [330 x %struct.oishikunaru]], ptr @conv, i64 0, i64 %30
  %32 = load i32, ptr %9, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [330 x %struct.oishikunaru], ptr %31, i64 0, i64 %33
  %35 = call { double, double } @_ZmlRK11oishikunaruS1_(ptr noundef nonnull align 8 dereferenceable(16) %8, ptr noundef nonnull align 8 dereferenceable(16) %34)
  %36 = getelementptr inbounds { double, double }, ptr %10, i32 0, i32 0
  %37 = extractvalue { double, double } %35, 0
  store double %37, ptr %36, align 8
  %38 = getelementptr inbounds { double, double }, ptr %10, i32 0, i32 1
  %39 = extractvalue { double, double } %35, 1
  store double %39, ptr %38, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %8, ptr align 8 %10, i64 16, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #4
  br label %40

40:                                               ; preds = %27
  %41 = load i32, ptr %9, align 4, !tbaa !5
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %9, align 4, !tbaa !5
  br label %23, !llvm.loop !12

43:                                               ; preds = %26
  %44 = load i32, ptr %4, align 4, !tbaa !5
  %45 = sdiv i32 %44, 330
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [330 x %struct.oishikunaru], ptr @skip, i64 0, i64 %46
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %47, ptr align 8 %8, i64 16, i1 false), !tbaa.struct !11
  %48 = getelementptr inbounds %struct.oishikunaru, ptr %8, i32 0, i32 0
  store double 1.000000e+00, ptr %48, align 8, !tbaa !14
  %49 = getelementptr inbounds %struct.oishikunaru, ptr %8, i32 0, i32 1
  store double 0.000000e+00, ptr %49, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %50

50:                                               ; preds = %63, %43
  %51 = load i32, ptr %11, align 4, !tbaa !5
  %52 = icmp slt i32 %51, 330
  br i1 %52, label %54, label %53

53:                                               ; preds = %50
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %66

54:                                               ; preds = %50
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #4
  %55 = load i32, ptr %11, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [330 x %struct.oishikunaru], ptr @skip, i64 0, i64 %56
  %58 = call { double, double } @_ZmlRK11oishikunaruS1_(ptr noundef nonnull align 8 dereferenceable(16) %8, ptr noundef nonnull align 8 dereferenceable(16) %57)
  %59 = getelementptr inbounds { double, double }, ptr %12, i32 0, i32 0
  %60 = extractvalue { double, double } %58, 0
  store double %60, ptr %59, align 8
  %61 = getelementptr inbounds { double, double }, ptr %12, i32 0, i32 1
  %62 = extractvalue { double, double } %58, 1
  store double %62, ptr %61, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %8, ptr align 8 %12, i64 16, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #4
  br label %63

63:                                               ; preds = %54
  %64 = load i32, ptr %11, align 4, !tbaa !5
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %11, align 4, !tbaa !5
  br label %50, !llvm.loop !17

66:                                               ; preds = %53
  %67 = getelementptr inbounds %struct.oishikunaru, ptr %8, i32 0, i32 0
  %68 = load double, ptr %67, align 8, !tbaa !14
  %69 = getelementptr inbounds %struct.oishikunaru, ptr %8, i32 0, i32 1
  %70 = load double, ptr %69, align 8, !tbaa !16
  %71 = fadd double %68, %70
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #4
  ret double %71
}

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

; 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) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{i64 0, i64 8, !9, i64 8, i64 8, !9}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!15, !10, i64 0}
!15 = !{!"_ZTS11oishikunaru", !10, i64 0, !10, i64 8}
!16 = !{!15, !10, i64 8}
!17 = distinct !{!17, !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"

%struct.oishikunaru = type { double, double }

@conv = external dso_local global [330 x [330 x %struct.oishikunaru]], align 16
@skip = external dso_local global [330 x %struct.oishikunaru], align 16

; Function Attrs: mustprogress uwtable
declare dso_local { double, double } @_ZmlRK11oishikunaruS1_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN11oishikunaruC2Edd(ptr noundef nonnull align 8 dereferenceable(16), double noundef, double noundef) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_Z7koushinidd(i32 noundef %0, double noundef %1, double noundef %2) local_unnamed_addr #0 {
  %4 = alloca %struct.oishikunaru, align 8
  %5 = alloca %struct.oishikunaru, align 16
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #4
  call void @_ZN11oishikunaruC2Edd(ptr noundef nonnull align 8 dereferenceable(16) %4, double noundef %1, double noundef %2)
  %6 = sdiv i32 %0, 330
  %7 = sext i32 %6 to i64
  %8 = srem i32 %0, 330
  %9 = sext i32 %8 to i64
  %10 = getelementptr inbounds [330 x [330 x %struct.oishikunaru]], ptr @conv, i64 0, i64 %7, i64 %9
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %10, ptr noundef nonnull align 8 dereferenceable(16) %4, i64 16, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #4
  call void @_ZN11oishikunaruC2Edd(ptr noundef nonnull align 8 dereferenceable(16) %5, double noundef 1.000000e+00, double noundef 0.000000e+00)
  %.sroa.44.0..sroa_idx = getelementptr inbounds i8, ptr %5, i64 8
  br label %13

11:                                               ; preds = %13
  %12 = getelementptr inbounds [330 x %struct.oishikunaru], ptr @skip, i64 0, i64 %7
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %12, ptr noundef nonnull align 16 dereferenceable(16) %5, i64 16, i1 false), !tbaa.struct !5
  store <2 x double> <double 1.000000e+00, double 0.000000e+00>, ptr %5, align 16, !tbaa !6
  br label %20

13:                                               ; preds = %3, %13
  %indvars.iv = phi i64 [ 0, %3 ], [ %indvars.iv.next, %13 ]
  %14 = getelementptr inbounds [330 x [330 x %struct.oishikunaru]], ptr @conv, i64 0, i64 %7, i64 %indvars.iv
  %15 = call { double, double } @_ZmlRK11oishikunaruS1_(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef nonnull align 8 dereferenceable(16) %14)
  %16 = extractvalue { double, double } %15, 0
  %17 = extractvalue { double, double } %15, 1
  store double %16, ptr %5, align 16, !tbaa !6
  store double %17, ptr %.sroa.44.0..sroa_idx, align 8, !tbaa !6
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 330
  br i1 %exitcond.not, label %11, label %13, !llvm.loop !10

18:                                               ; preds = %20
  %19 = fadd double %23, %24
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #4
  ret double %19

20:                                               ; preds = %11, %20
  %indvars.iv17 = phi i64 [ 0, %11 ], [ %indvars.iv.next18, %20 ]
  %21 = getelementptr inbounds [330 x %struct.oishikunaru], ptr @skip, i64 0, i64 %indvars.iv17
  %22 = call { double, double } @_ZmlRK11oishikunaruS1_(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef nonnull align 8 dereferenceable(16) %21)
  %23 = extractvalue { double, double } %22, 0
  %24 = extractvalue { double, double } %22, 1
  store double %23, ptr %5, align 16, !tbaa !6
  store double %24, ptr %.sroa.44.0..sroa_idx, align 8, !tbaa !6
  %indvars.iv.next18 = add nuw nsw i64 %indvars.iv17, 1
  %exitcond20.not = icmp eq i64 %indvars.iv.next18, 330
  br i1 %exitcond20.not, label %18, label %20, !llvm.loop !12
}

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

; 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) #3

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{i64 0, i64 8, !6, i64 8, i64 8, !6}
!6 = !{!7, !7, i64 0}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!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,LoopUnrollPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass