; LLVM IR from openai/procgen :: procgen/src/entity.ll (ZN6Entity4stepEv)

; 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.Entity = type { float, float, float, float, float, float, i32, i32, i32, i32, i8, i8, float, float, float, i8, i32, i32, i32, i32, i8, float, i8, i8, i8, float, float, float, float, float, float }

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN6Entity4stepEv(ptr noundef nonnull align 4 dereferenceable(112) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  %4 = getelementptr inbounds %class.Entity, ptr %3, i32 0, i32 22
  %5 = load i8, ptr %4, align 4, !tbaa !9, !range !14, !noundef !15
  %6 = trunc i8 %5 to i1
  br i1 %6, label %18, label %7

7:                                                ; preds = %1
  %8 = getelementptr inbounds %class.Entity, ptr %3, i32 0, i32 2
  %9 = load float, ptr %8, align 4, !tbaa !16
  %10 = getelementptr inbounds %class.Entity, ptr %3, i32 0, i32 0
  %11 = load float, ptr %10, align 4, !tbaa !17
  %12 = fadd float %11, %9
  store float %12, ptr %10, align 4, !tbaa !17
  %13 = getelementptr inbounds %class.Entity, ptr %3, i32 0, i32 3
  %14 = load float, ptr %13, align 4, !tbaa !18
  %15 = getelementptr inbounds %class.Entity, ptr %3, i32 0, i32 1
  %16 = load float, ptr %15, align 4, !tbaa !19
  %17 = fadd float %16, %14
  store float %17, ptr %15, align 4, !tbaa !19
  br label %18

18:                                               ; preds = %7, %1
  %19 = getelementptr inbounds %class.Entity, ptr %3, i32 0, i32 14
  %20 = load float, ptr %19, align 4, !tbaa !20
  %21 = getelementptr inbounds %class.Entity, ptr %3, i32 0, i32 13
  %22 = load float, ptr %21, align 4, !tbaa !21
  %23 = fadd float %22, %20
  store float %23, ptr %21, align 4, !tbaa !21
  %24 = getelementptr inbounds %class.Entity, ptr %3, i32 0, i32 21
  %25 = load float, ptr %24, align 4, !tbaa !22
  %26 = getelementptr inbounds %class.Entity, ptr %3, i32 0, i32 2
  %27 = load float, ptr %26, align 4, !tbaa !16
  %28 = fmul float %27, %25
  store float %28, ptr %26, align 4, !tbaa !16
  %29 = getelementptr inbounds %class.Entity, ptr %3, i32 0, i32 21
  %30 = load float, ptr %29, align 4, !tbaa !22
  %31 = getelementptr inbounds %class.Entity, ptr %3, i32 0, i32 3
  %32 = load float, ptr %31, align 4, !tbaa !18
  %33 = fmul float %32, %30
  store float %33, ptr %31, align 4, !tbaa !18
  %34 = getelementptr inbounds %class.Entity, ptr %3, i32 0, i32 18
  %35 = load i32, ptr %34, align 4, !tbaa !23
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr %34, align 4, !tbaa !23
  %37 = getelementptr inbounds %class.Entity, ptr %3, i32 0, i32 19
  %38 = load i32, ptr %37, align 4, !tbaa !24
  %39 = icmp sgt i32 %38, 0
  br i1 %39, label %40, label %48

40:                                               ; preds = %18
  %41 = getelementptr inbounds %class.Entity, ptr %3, i32 0, i32 18
  %42 = load i32, ptr %41, align 4, !tbaa !23
  %43 = getelementptr inbounds %class.Entity, ptr %3, i32 0, i32 19
  %44 = load i32, ptr %43, align 4, !tbaa !24
  %45 = icmp sgt i32 %42, %44
  br i1 %45, label %46, label %48

46:                                               ; preds = %40
  %47 = getelementptr inbounds %class.Entity, ptr %3, i32 0, i32 10
  store i8 1, ptr %47, align 4, !tbaa !25
  br label %48

48:                                               ; preds = %46, %40, %18
  %49 = getelementptr inbounds %class.Entity, ptr %3, i32 0, i32 6
  %50 = load i32, ptr %49, align 4, !tbaa !26
  %51 = icmp eq i32 %50, 54
  br i1 %51, label %52, label %61

52:                                               ; preds = %48
  %53 = getelementptr inbounds %class.Entity, ptr %3, i32 0, i32 7
  %54 = load i32, ptr %53, align 4, !tbaa !27
  %55 = icmp slt i32 %54, 58
  br i1 %55, label %56, label %60

56:                                               ; preds = %52
  %57 = getelementptr inbounds %class.Entity, ptr %3, i32 0, i32 7
  %58 = load i32, ptr %57, align 4, !tbaa !27
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %57, align 4, !tbaa !27
  br label %60

60:                                               ; preds = %56, %52
  br label %61

61:                                               ; preds = %60, %48
  %62 = getelementptr inbounds %class.Entity, ptr %3, i32 0, i32 28
  %63 = load float, ptr %62, align 4, !tbaa !28
  %64 = getelementptr inbounds %class.Entity, ptr %3, i32 0, i32 4
  %65 = load float, ptr %64, align 4, !tbaa !29
  %66 = fmul float %65, %63
  store float %66, ptr %64, align 4, !tbaa !29
  %67 = getelementptr inbounds %class.Entity, ptr %3, i32 0, i32 28
  %68 = load float, ptr %67, align 4, !tbaa !28
  %69 = getelementptr inbounds %class.Entity, ptr %3, i32 0, i32 5
  %70 = load float, ptr %69, align 4, !tbaa !30
  %71 = fmul float %70, %68
  store float %71, ptr %69, align 4, !tbaa !30
  %72 = getelementptr inbounds %class.Entity, ptr %3, i32 0, i32 29
  %73 = load float, ptr %72, align 4, !tbaa !31
  %74 = getelementptr inbounds %class.Entity, ptr %3, i32 0, i32 25
  %75 = load float, ptr %74, align 4, !tbaa !32
  %76 = fmul float %73, %75
  %77 = getelementptr inbounds %class.Entity, ptr %3, i32 0, i32 25
  store float %76, ptr %77, align 4, !tbaa !32
  ret void
}

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

!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, !13, i64 84}
!10 = !{!"_ZTS6Entity", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !13, i64 40, !13, i64 41, !11, i64 44, !11, i64 48, !11, i64 52, !13, i64 56, !12, i64 60, !12, i64 64, !12, i64 68, !12, i64 72, !13, i64 76, !11, i64 80, !13, i64 84, !13, i64 85, !13, i64 86, !11, i64 88, !11, i64 92, !11, i64 96, !11, i64 100, !11, i64 104, !11, i64 108}
!11 = !{!"float", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"bool", !7, i64 0}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = !{!10, !11, i64 8}
!17 = !{!10, !11, i64 0}
!18 = !{!10, !11, i64 12}
!19 = !{!10, !11, i64 4}
!20 = !{!10, !11, i64 52}
!21 = !{!10, !11, i64 48}
!22 = !{!10, !11, i64 80}
!23 = !{!10, !12, i64 68}
!24 = !{!10, !12, i64 72}
!25 = !{!10, !13, i64 40}
!26 = !{!10, !12, i64 24}
!27 = !{!10, !12, i64 28}
!28 = !{!10, !11, i64 100}
!29 = !{!10, !11, i64 16}
!30 = !{!10, !11, i64 20}
!31 = !{!10, !11, i64 104}
!32 = !{!10, !11, i64 88}


; 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 nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @_ZN6Entity4stepEv(ptr nocapture noundef nonnull align 4 dereferenceable(112) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 84
  %3 = load i8, ptr %2, align 4, !tbaa !5, !range !12, !noundef !13
  %4 = trunc nuw i8 %3 to i1
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 8
  %.pre = load float, ptr %.phi.trans.insert, align 4, !tbaa !14
  br i1 %4, label %._crit_edge, label %5

._crit_edge:                                      ; preds = %1
  %.phi.trans.insert2 = getelementptr inbounds i8, ptr %0, i64 12
  %.pre3 = load float, ptr %.phi.trans.insert2, align 4, !tbaa !15
  br label %12

5:                                                ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 12
  %7 = load float, ptr %6, align 4, !tbaa !15
  %8 = load <2 x float>, ptr %0, align 4, !tbaa !16
  %9 = insertelement <2 x float> poison, float %.pre, i64 0
  %10 = insertelement <2 x float> %9, float %7, i64 1
  %11 = fadd <2 x float> %10, %8
  store <2 x float> %11, ptr %0, align 4, !tbaa !16
  br label %12

12:                                               ; preds = %._crit_edge, %5
  %13 = phi float [ %.pre3, %._crit_edge ], [ %7, %5 ]
  %14 = getelementptr inbounds i8, ptr %0, i64 52
  %15 = load float, ptr %14, align 4, !tbaa !17
  %16 = getelementptr inbounds i8, ptr %0, i64 48
  %17 = load float, ptr %16, align 4, !tbaa !18
  %18 = fadd float %15, %17
  store float %18, ptr %16, align 4, !tbaa !18
  %19 = getelementptr inbounds i8, ptr %0, i64 80
  %20 = load <4 x float>, ptr %19, align 4
  %21 = getelementptr inbounds i8, ptr %0, i64 8
  %22 = shufflevector <4 x float> %20, <4 x float> poison, <2 x i32> zeroinitializer
  %23 = insertelement <2 x float> poison, float %.pre, i64 0
  %24 = insertelement <2 x float> %23, float %13, i64 1
  %25 = fmul <2 x float> %22, %24
  store <2 x float> %25, ptr %21, align 4, !tbaa !16
  %26 = getelementptr inbounds i8, ptr %0, i64 68
  %27 = load i32, ptr %26, align 4, !tbaa !19
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr %26, align 4, !tbaa !19
  %29 = getelementptr inbounds i8, ptr %0, i64 72
  %30 = load i32, ptr %29, align 4, !tbaa !20
  %31 = icmp slt i32 %30, 1
  %.not = icmp slt i32 %27, %30
  %or.cond = select i1 %31, i1 true, i1 %.not
  br i1 %or.cond, label %34, label %32

32:                                               ; preds = %12
  %33 = getelementptr inbounds i8, ptr %0, i64 40
  store i8 1, ptr %33, align 4, !tbaa !21
  br label %34

34:                                               ; preds = %32, %12
  %35 = getelementptr inbounds i8, ptr %0, i64 24
  %36 = load i32, ptr %35, align 4, !tbaa !22
  %37 = icmp eq i32 %36, 54
  br i1 %37, label %38, label %44

38:                                               ; preds = %34
  %39 = getelementptr inbounds i8, ptr %0, i64 28
  %40 = load i32, ptr %39, align 4, !tbaa !23
  %41 = icmp slt i32 %40, 58
  br i1 %41, label %42, label %44

42:                                               ; preds = %38
  %43 = add nsw i32 %40, 1
  store i32 %43, ptr %39, align 4, !tbaa !23
  br label %44

44:                                               ; preds = %38, %42, %34
  %45 = getelementptr inbounds i8, ptr %0, i64 100
  %46 = load float, ptr %45, align 4, !tbaa !24
  %47 = getelementptr inbounds i8, ptr %0, i64 16
  %48 = load <2 x float>, ptr %47, align 4, !tbaa !16
  %49 = insertelement <2 x float> poison, float %46, i64 0
  %50 = shufflevector <2 x float> %49, <2 x float> poison, <2 x i32> zeroinitializer
  %51 = fmul <2 x float> %50, %48
  store <2 x float> %51, ptr %47, align 4, !tbaa !16
  %52 = getelementptr inbounds i8, ptr %0, i64 104
  %53 = load float, ptr %52, align 4, !tbaa !25
  %54 = getelementptr inbounds i8, ptr %0, i64 88
  %55 = load float, ptr %54, align 4, !tbaa !26
  %56 = fmul float %53, %55
  store float %56, ptr %54, align 4, !tbaa !26
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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, !11, i64 84}
!6 = !{!"_ZTS6Entity", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !11, i64 40, !11, i64 41, !7, i64 44, !7, i64 48, !7, i64 52, !11, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !10, i64 72, !11, i64 76, !7, i64 80, !11, i64 84, !11, i64 85, !11, i64 86, !7, i64 88, !7, i64 92, !7, i64 96, !7, i64 100, !7, i64 104, !7, i64 108}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"bool", !8, i64 0}
!12 = !{i8 0, i8 2}
!13 = !{}
!14 = !{!6, !7, i64 8}
!15 = !{!6, !7, i64 12}
!16 = !{!7, !7, i64 0}
!17 = !{!6, !7, i64 52}
!18 = !{!6, !7, i64 48}
!19 = !{!6, !10, i64 68}
!20 = !{!6, !10, i64 72}
!21 = !{!6, !11, i64 40}
!22 = !{!6, !10, i64 24}
!23 = !{!6, !10, i64 28}
!24 = !{!6, !7, i64 100}
!25 = !{!6, !7, i64 104}
!26 = !{!6, !7, i64 88}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,VectorCombinePass