; LLVM IR from greensoftwarelab/Energy-Languages :: C/mandelbrot/mandelbrot.gcc-6 (mand64)

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

; 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: nounwind uwtable
define dso_local i64 @mand64(ptr noundef %0, <2 x double> noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca <2 x double>, align 16
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store <2 x double> %1, ptr %4, align 16, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  store i64 0, ptr %5, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store i64 0, ptr %6, align 8, !tbaa !10
  br label %8

8:                                                ; preds = %23, %2
  %9 = load i64, ptr %6, align 8, !tbaa !10
  %10 = icmp slt i64 %9, 8
  br i1 %10, label %12, label %11

11:                                               ; preds = %8
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %26

12:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = load <2 x double>, ptr %4, align 16, !tbaa !9
  %15 = call i64 @mand8(ptr noundef %13, <2 x double> noundef %14)
  store i64 %15, ptr %7, align 8, !tbaa !10
  %16 = load i64, ptr %5, align 8, !tbaa !10
  %17 = lshr i64 %16, 8
  %18 = load i64, ptr %7, align 8, !tbaa !10
  %19 = shl i64 %18, 56
  %20 = or i64 %17, %19
  store i64 %20, ptr %5, align 8, !tbaa !10
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds <2 x double>, ptr %21, i64 4
  store ptr %22, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  br label %23

23:                                               ; preds = %12
  %24 = load i64, ptr %6, align 8, !tbaa !10
  %25 = add nsw i64 %24, 1
  store i64 %25, ptr %6, align 8, !tbaa !10
  br label %8, !llvm.loop !12

26:                                               ; preds = %11
  %27 = load i64, ptr %5, align 8, !tbaa !10
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret i64 %27
}

; Function Attrs: inlinehint nounwind uwtable
declare i64 @mand8(ptr noundef, <2 x double> noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="128" "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 = { inlinehint nounwind uwtable "min-legal-vector-width"="128" "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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"long", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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

; Function Attrs: nounwind uwtable
define dso_local i64 @mand64(ptr noundef %0, <2 x double> noundef %1) local_unnamed_addr #0 {
  %3 = tail call i64 @mand8(ptr noundef %0, <2 x double> noundef %1)
  %4 = shl i64 %3, 56
  %5 = getelementptr inbounds i8, ptr %0, i64 64
  %6 = tail call i64 @mand8(ptr noundef nonnull %5, <2 x double> noundef %1)
  %7 = tail call i64 @llvm.fshl.i64(i64 %6, i64 %4, i64 56)
  %8 = getelementptr inbounds i8, ptr %0, i64 128
  %9 = tail call i64 @mand8(ptr noundef nonnull %8, <2 x double> noundef %1)
  %10 = tail call i64 @llvm.fshl.i64(i64 %9, i64 %7, i64 56)
  %11 = getelementptr inbounds i8, ptr %0, i64 192
  %12 = tail call i64 @mand8(ptr noundef nonnull %11, <2 x double> noundef %1)
  %13 = tail call i64 @llvm.fshl.i64(i64 %12, i64 %10, i64 56)
  %14 = getelementptr inbounds i8, ptr %0, i64 256
  %15 = tail call i64 @mand8(ptr noundef nonnull %14, <2 x double> noundef %1)
  %16 = tail call i64 @llvm.fshl.i64(i64 %15, i64 %13, i64 56)
  %17 = getelementptr inbounds i8, ptr %0, i64 320
  %18 = tail call i64 @mand8(ptr noundef nonnull %17, <2 x double> noundef %1)
  %19 = tail call i64 @llvm.fshl.i64(i64 %18, i64 %16, i64 56)
  %20 = getelementptr inbounds i8, ptr %0, i64 384
  %21 = tail call i64 @mand8(ptr noundef nonnull %20, <2 x double> noundef %1)
  %22 = tail call i64 @llvm.fshl.i64(i64 %21, i64 %19, i64 56)
  %23 = getelementptr inbounds i8, ptr %0, i64 448
  %24 = tail call i64 @mand8(ptr noundef nonnull %23, <2 x double> noundef %1)
  %25 = tail call i64 @llvm.fshl.i64(i64 %24, i64 %22, i64 56)
  ret i64 %25
}

; Function Attrs: inlinehint nounwind uwtable
declare i64 @mand8(ptr noundef, <2 x double> noundef) local_unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.fshl.i64(i64, i64, i64) #2

attributes #0 = { nounwind uwtable "min-legal-vector-width"="128" "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 = { inlinehint nounwind uwtable "min-legal-vector-width"="128" "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 speculatable willreturn memory(none) }

!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)"}


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