; LLVM IR from cleongh/advancedprogramming :: bots/bot.ll (ZN3bot9kills_botERKS_)

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

%class.bot = type <{ ptr, i16, i16, i16, i16, i16, [2 x i8], i32, %"struct.std::pair", i32, [4 x i8] }>
%"struct.std::pair" = type { i32, i32 }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3bot9kills_botERKS_(ptr noundef nonnull align 8 dereferenceable(36) %0, ptr noundef nonnull align 8 dereferenceable(36) %1) #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %3, align 8
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  %7 = call noundef zeroext i16 @_ZNK3bot14get_experienceEv(ptr noundef nonnull align 8 dereferenceable(36) %6)
  %8 = zext i16 %7 to i32
  %9 = getelementptr inbounds %class.bot, ptr %5, i32 0, i32 4
  %10 = load i16, ptr %9, align 2, !tbaa !9
  %11 = zext i16 %10 to i32
  %12 = add nsw i32 %11, %8
  %13 = trunc i32 %12 to i16
  store i16 %13, ptr %9, align 2, !tbaa !9
  %14 = getelementptr inbounds %class.bot, ptr %5, i32 0, i32 3
  %15 = load i16, ptr %14, align 4, !tbaa !15
  %16 = add i16 %15, 1
  store i16 %16, ptr %14, align 4, !tbaa !15
  %17 = getelementptr inbounds %class.bot, ptr %5, i32 0, i32 3
  %18 = load i16, ptr %17, align 4, !tbaa !15
  %19 = zext i16 %18 to i32
  %20 = srem i32 %19, 3
  %21 = icmp eq i32 %20, 0
  br i1 %21, label %22, label %24

22:                                               ; preds = %2
  %23 = getelementptr inbounds %class.bot, ptr %5, i32 0, i32 5
  store i16 10, ptr %23, align 8, !tbaa !16
  br label %24

24:                                               ; preds = %22, %2
  %25 = getelementptr inbounds %class.bot, ptr %5, i32 0, i32 4
  %26 = load i16, ptr %25, align 2, !tbaa !9
  %27 = zext i16 %26 to i32
  %28 = mul nsw i32 3, %27
  %29 = trunc i32 %28 to i16
  %30 = getelementptr inbounds %class.bot, ptr %5, i32 0, i32 1
  store i16 %29, ptr %30, align 8, !tbaa !17
  %31 = getelementptr inbounds %class.bot, ptr %5, i32 0, i32 4
  %32 = load i16, ptr %31, align 2, !tbaa !9
  %33 = zext i16 %32 to i32
  %34 = mul nsw i32 2, %33
  %35 = trunc i32 %34 to i16
  %36 = getelementptr inbounds %class.bot, ptr %5, i32 0, i32 2
  store i16 %35, ptr %36, align 2, !tbaa !18
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i16 @_ZNK3bot14get_experienceEv(ptr noundef nonnull align 8 dereferenceable(36)) #1 align 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 = { 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" }

!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++ TBAA"}
!9 = !{!10, !11, i64 14}
!10 = !{!"_ZTS3bot", !11, i64 8, !11, i64 10, !11, i64 12, !11, i64 14, !11, i64 16, !12, i64 20, !13, i64 24, !14, i64 32}
!11 = !{!"short", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"_ZTSSt4pairIjjE", !12, i64 0, !12, i64 4}
!14 = !{!"_ZTSN3bot9directionE", !7, i64 0}
!15 = !{!10, !11, i64 12}
!16 = !{!10, !11, i64 16}
!17 = !{!10, !11, i64 8}
!18 = !{!10, !11, i64 10}


; 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: mustprogress nounwind uwtable
define dso_local void @_ZN3bot9kills_botERKS_(ptr nocapture noundef nonnull align 8 dereferenceable(36) %0, ptr noundef nonnull align 8 dereferenceable(36) %1) local_unnamed_addr #0 align 2 {
  %3 = tail call noundef zeroext i16 @_ZNK3bot14get_experienceEv(ptr noundef nonnull align 8 dereferenceable(36) %1)
  %4 = getelementptr inbounds i8, ptr %0, i64 14
  %5 = load i16, ptr %4, align 2, !tbaa !5
  %6 = add i16 %5, %3
  store i16 %6, ptr %4, align 2, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 12
  %8 = load i16, ptr %7, align 4, !tbaa !13
  %9 = add i16 %8, 1
  store i16 %9, ptr %7, align 4, !tbaa !13
  %10 = urem i16 %9, 3
  %11 = icmp eq i16 %10, 0
  br i1 %11, label %12, label %14

12:                                               ; preds = %2
  %13 = getelementptr inbounds i8, ptr %0, i64 16
  store i16 10, ptr %13, align 8, !tbaa !14
  br label %14

14:                                               ; preds = %12, %2
  %15 = mul i16 %6, 3
  %16 = getelementptr inbounds i8, ptr %0, i64 8
  store i16 %15, ptr %16, align 8, !tbaa !15
  %17 = shl i16 %6, 1
  %18 = getelementptr inbounds i8, ptr %0, i64 10
  store i16 %17, ptr %18, align 2, !tbaa !16
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i16 @_ZNK3bot14get_experienceEv(ptr noundef nonnull align 8 dereferenceable(36)) local_unnamed_addr #1 align 2

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 = { 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" }

!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, !7, i64 14}
!6 = !{!"_ZTS3bot", !7, i64 8, !7, i64 10, !7, i64 12, !7, i64 14, !7, i64 16, !10, i64 20, !11, i64 24, !12, i64 32}
!7 = !{!"short", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"_ZTSSt4pairIjjE", !10, i64 0, !10, i64 4}
!12 = !{!"_ZTSN3bot9directionE", !8, i64 0}
!13 = !{!6, !7, i64 12}
!14 = !{!6, !7, i64 16}
!15 = !{!6, !7, i64 8}
!16 = !{!6, !7, i64 10}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,TailCallElimPass