; LLVM IR from BrunoLevy/learn-fpga :: LiteX/software/Doom/mc1-doom/src (p_enemy)

; 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.mobj_s = type { %struct.thinker_s, i32, i32, i32, ptr, ptr, i32, i32, i32, ptr, ptr, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, i32, ptr, i32, i32, i32, i32, ptr, i32, i32, ptr, i32, %struct.mapthing_t, ptr }
%struct.thinker_s = type { ptr, ptr, %union.actionf_t }
%union.actionf_t = type { ptr }
%struct.mapthing_t = type { i16, i16, i16, i16, i16 }
%struct.mobjinfo_t = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }

@TRACEANGLE = external dso_local global i32, align 4
@gametic = external global i32, align 4
@finecosine = external global ptr, align 8
@finesine = external global [10240 x i32], align 16

; 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

declare i32 @P_AproxDistance(i32 noundef, i32 noundef) #1

declare i32 @P_Random() #1

declare i32 @R_PointToAngle2(i32 noundef, i32 noundef, i32 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @A_Tracer(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %9 = load i32, ptr @gametic, align 4, !tbaa !9
  %10 = and i32 %9, 3
  %11 = icmp ne i32 %10, 0
  br i1 %11, label %12, label %13

12:                                               ; preds = %1
  store i32 1, ptr %8, align 4
  br label %211

13:                                               ; preds = %1
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.mobj_s, ptr %14, i32 0, i32 1
  %16 = load i32, ptr %15, align 8, !tbaa !11
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.mobj_s, ptr %17, i32 0, i32 2
  %19 = load i32, ptr %18, align 4, !tbaa !16
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.mobj_s, ptr %20, i32 0, i32 3
  %22 = load i32, ptr %21, align 8, !tbaa !17
  call void @P_SpawnPuff(i32 noundef %16, i32 noundef %19, i32 noundef %22)
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.mobj_s, ptr %23, i32 0, i32 1
  %25 = load i32, ptr %24, align 8, !tbaa !11
  %26 = load ptr, ptr %2, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.mobj_s, ptr %26, i32 0, i32 16
  %28 = load i32, ptr %27, align 8, !tbaa !18
  %29 = sub nsw i32 %25, %28
  %30 = load ptr, ptr %2, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.mobj_s, ptr %30, i32 0, i32 2
  %32 = load i32, ptr %31, align 4, !tbaa !16
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.mobj_s, ptr %33, i32 0, i32 17
  %35 = load i32, ptr %34, align 4, !tbaa !19
  %36 = sub nsw i32 %32, %35
  %37 = load ptr, ptr %2, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.mobj_s, ptr %37, i32 0, i32 3
  %39 = load i32, ptr %38, align 8, !tbaa !17
  %40 = call ptr @P_SpawnMobj(i32 noundef %29, i32 noundef %36, i32 noundef %39, i32 noundef 7)
  store ptr %40, ptr %7, align 8, !tbaa !5
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.mobj_s, ptr %41, i32 0, i32 18
  store i32 65536, ptr %42, align 8, !tbaa !20
  %43 = call i32 @P_Random()
  %44 = and i32 %43, 3
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.mobj_s, ptr %45, i32 0, i32 22
  %47 = load i32, ptr %46, align 8, !tbaa !21
  %48 = sub nsw i32 %47, %44
  store i32 %48, ptr %46, align 8, !tbaa !21
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.mobj_s, ptr %49, i32 0, i32 22
  %51 = load i32, ptr %50, align 8, !tbaa !21
  %52 = icmp slt i32 %51, 1
  br i1 %52, label %53, label %56

53:                                               ; preds = %13
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.mobj_s, ptr %54, i32 0, i32 22
  store i32 1, ptr %55, align 8, !tbaa !21
  br label %56

56:                                               ; preds = %53, %13
  %57 = load ptr, ptr %2, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.mobj_s, ptr %57, i32 0, i32 34
  %59 = load ptr, ptr %58, align 8, !tbaa !22
  store ptr %59, ptr %6, align 8, !tbaa !5
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  %61 = icmp ne ptr %60, null
  br i1 %61, label %62, label %67

62:                                               ; preds = %56
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.mobj_s, ptr %63, i32 0, i32 25
  %65 = load i32, ptr %64, align 4, !tbaa !23
  %66 = icmp sle i32 %65, 0
  br i1 %66, label %67, label %68

67:                                               ; preds = %62, %56
  store i32 1, ptr %8, align 4
  br label %211

68:                                               ; preds = %62
  %69 = load ptr, ptr %2, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.mobj_s, ptr %69, i32 0, i32 1
  %71 = load i32, ptr %70, align 8, !tbaa !11
  %72 = load ptr, ptr %2, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.mobj_s, ptr %72, i32 0, i32 2
  %74 = load i32, ptr %73, align 4, !tbaa !16
  %75 = load ptr, ptr %6, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.mobj_s, ptr %75, i32 0, i32 1
  %77 = load i32, ptr %76, align 8, !tbaa !11
  %78 = load ptr, ptr %6, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.mobj_s, ptr %78, i32 0, i32 2
  %80 = load i32, ptr %79, align 4, !tbaa !16
  %81 = call i32 @R_PointToAngle2(i32 noundef %71, i32 noundef %74, i32 noundef %77, i32 noundef %80)
  store i32 %81, ptr %3, align 4, !tbaa !9
  %82 = load i32, ptr %3, align 4, !tbaa !9
  %83 = load ptr, ptr %2, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.mobj_s, ptr %83, i32 0, i32 6
  %85 = load i32, ptr %84, align 8, !tbaa !24
  %86 = icmp ne i32 %82, %85
  br i1 %86, label %87, label %129

87:                                               ; preds = %68
  %88 = load i32, ptr %3, align 4, !tbaa !9
  %89 = load ptr, ptr %2, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.mobj_s, ptr %89, i32 0, i32 6
  %91 = load i32, ptr %90, align 8, !tbaa !24
  %92 = sub i32 %88, %91
  %93 = icmp ugt i32 %92, -2147483648
  br i1 %93, label %94, label %111

94:                                               ; preds = %87
  %95 = load i32, ptr @TRACEANGLE, align 4, !tbaa !9
  %96 = load ptr, ptr %2, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.mobj_s, ptr %96, i32 0, i32 6
  %98 = load i32, ptr %97, align 8, !tbaa !24
  %99 = sub i32 %98, %95
  store i32 %99, ptr %97, align 8, !tbaa !24
  %100 = load i32, ptr %3, align 4, !tbaa !9
  %101 = load ptr, ptr %2, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.mobj_s, ptr %101, i32 0, i32 6
  %103 = load i32, ptr %102, align 8, !tbaa !24
  %104 = sub i32 %100, %103
  %105 = icmp ult i32 %104, -2147483648
  br i1 %105, label %106, label %110

106:                                              ; preds = %94
  %107 = load i32, ptr %3, align 4, !tbaa !9
  %108 = load ptr, ptr %2, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.mobj_s, ptr %108, i32 0, i32 6
  store i32 %107, ptr %109, align 8, !tbaa !24
  br label %110

110:                                              ; preds = %106, %94
  br label %128

111:                                              ; preds = %87
  %112 = load i32, ptr @TRACEANGLE, align 4, !tbaa !9
  %113 = load ptr, ptr %2, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.mobj_s, ptr %113, i32 0, i32 6
  %115 = load i32, ptr %114, align 8, !tbaa !24
  %116 = add i32 %115, %112
  store i32 %116, ptr %114, align 8, !tbaa !24
  %117 = load i32, ptr %3, align 4, !tbaa !9
  %118 = load ptr, ptr %2, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.mobj_s, ptr %118, i32 0, i32 6
  %120 = load i32, ptr %119, align 8, !tbaa !24
  %121 = sub i32 %117, %120
  %122 = icmp ugt i32 %121, -2147483648
  br i1 %122, label %123, label %127

123:                                              ; preds = %111
  %124 = load i32, ptr %3, align 4, !tbaa !9
  %125 = load ptr, ptr %2, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct.mobj_s, ptr %125, i32 0, i32 6
  store i32 %124, ptr %126, align 8, !tbaa !24
  br label %127

127:                                              ; preds = %123, %111
  br label %128

128:                                              ; preds = %127, %110
  br label %129

129:                                              ; preds = %128, %68
  %130 = load ptr, ptr %2, align 8, !tbaa !5
  %131 = getelementptr inbounds %struct.mobj_s, ptr %130, i32 0, i32 6
  %132 = load i32, ptr %131, align 8, !tbaa !24
  %133 = lshr i32 %132, 19
  store i32 %133, ptr %3, align 4, !tbaa !9
  %134 = load ptr, ptr %2, align 8, !tbaa !5
  %135 = getelementptr inbounds %struct.mobj_s, ptr %134, i32 0, i32 21
  %136 = load ptr, ptr %135, align 8, !tbaa !25
  %137 = getelementptr inbounds %struct.mobjinfo_t, ptr %136, i32 0, i32 15
  %138 = load i32, ptr %137, align 4, !tbaa !26
  %139 = load ptr, ptr @finecosine, align 8, !tbaa !5
  %140 = load i32, ptr %3, align 4, !tbaa !9
  %141 = zext i32 %140 to i64
  %142 = getelementptr inbounds i32, ptr %139, i64 %141
  %143 = load i32, ptr %142, align 4, !tbaa !9
  %144 = call i32 @FixedMul(i32 noundef %138, i32 noundef %143)
  %145 = load ptr, ptr %2, align 8, !tbaa !5
  %146 = getelementptr inbounds %struct.mobj_s, ptr %145, i32 0, i32 16
  store i32 %144, ptr %146, align 8, !tbaa !18
  %147 = load ptr, ptr %2, align 8, !tbaa !5
  %148 = getelementptr inbounds %struct.mobj_s, ptr %147, i32 0, i32 21
  %149 = load ptr, ptr %148, align 8, !tbaa !25
  %150 = getelementptr inbounds %struct.mobjinfo_t, ptr %149, i32 0, i32 15
  %151 = load i32, ptr %150, align 4, !tbaa !26
  %152 = load i32, ptr %3, align 4, !tbaa !9
  %153 = zext i32 %152 to i64
  %154 = getelementptr inbounds [10240 x i32], ptr @finesine, i64 0, i64 %153
  %155 = load i32, ptr %154, align 4, !tbaa !9
  %156 = call i32 @FixedMul(i32 noundef %151, i32 noundef %155)
  %157 = load ptr, ptr %2, align 8, !tbaa !5
  %158 = getelementptr inbounds %struct.mobj_s, ptr %157, i32 0, i32 17
  store i32 %156, ptr %158, align 4, !tbaa !19
  %159 = load ptr, ptr %6, align 8, !tbaa !5
  %160 = getelementptr inbounds %struct.mobj_s, ptr %159, i32 0, i32 1
  %161 = load i32, ptr %160, align 8, !tbaa !11
  %162 = load ptr, ptr %2, align 8, !tbaa !5
  %163 = getelementptr inbounds %struct.mobj_s, ptr %162, i32 0, i32 1
  %164 = load i32, ptr %163, align 8, !tbaa !11
  %165 = sub nsw i32 %161, %164
  %166 = load ptr, ptr %6, align 8, !tbaa !5
  %167 = getelementptr inbounds %struct.mobj_s, ptr %166, i32 0, i32 2
  %168 = load i32, ptr %167, align 4, !tbaa !16
  %169 = load ptr, ptr %2, align 8, !tbaa !5
  %170 = getelementptr inbounds %struct.mobj_s, ptr %169, i32 0, i32 2
  %171 = load i32, ptr %170, align 4, !tbaa !16
  %172 = sub nsw i32 %168, %171
  %173 = call i32 @P_AproxDistance(i32 noundef %165, i32 noundef %172)
  store i32 %173, ptr %4, align 4, !tbaa !9
  %174 = load i32, ptr %4, align 4, !tbaa !9
  %175 = load ptr, ptr %2, align 8, !tbaa !5
  %176 = getelementptr inbounds %struct.mobj_s, ptr %175, i32 0, i32 21
  %177 = load ptr, ptr %176, align 8, !tbaa !25
  %178 = getelementptr inbounds %struct.mobjinfo_t, ptr %177, i32 0, i32 15
  %179 = load i32, ptr %178, align 4, !tbaa !26
  %180 = sdiv i32 %174, %179
  store i32 %180, ptr %4, align 4, !tbaa !9
  %181 = load i32, ptr %4, align 4, !tbaa !9
  %182 = icmp slt i32 %181, 1
  br i1 %182, label %183, label %184

183:                                              ; preds = %129
  store i32 1, ptr %4, align 4, !tbaa !9
  br label %184

184:                                              ; preds = %183, %129
  %185 = load ptr, ptr %6, align 8, !tbaa !5
  %186 = getelementptr inbounds %struct.mobj_s, ptr %185, i32 0, i32 3
  %187 = load i32, ptr %186, align 8, !tbaa !17
  %188 = add nsw i32 %187, 2621440
  %189 = load ptr, ptr %2, align 8, !tbaa !5
  %190 = getelementptr inbounds %struct.mobj_s, ptr %189, i32 0, i32 3
  %191 = load i32, ptr %190, align 8, !tbaa !17
  %192 = sub nsw i32 %188, %191
  %193 = load i32, ptr %4, align 4, !tbaa !9
  %194 = sdiv i32 %192, %193
  store i32 %194, ptr %5, align 4, !tbaa !9
  %195 = load i32, ptr %5, align 4, !tbaa !9
  %196 = load ptr, ptr %2, align 8, !tbaa !5
  %197 = getelementptr inbounds %struct.mobj_s, ptr %196, i32 0, i32 18
  %198 = load i32, ptr %197, align 8, !tbaa !20
  %199 = icmp slt i32 %195, %198
  br i1 %199, label %200, label %205

200:                                              ; preds = %184
  %201 = load ptr, ptr %2, align 8, !tbaa !5
  %202 = getelementptr inbounds %struct.mobj_s, ptr %201, i32 0, i32 18
  %203 = load i32, ptr %202, align 8, !tbaa !20
  %204 = sub nsw i32 %203, 8192
  store i32 %204, ptr %202, align 8, !tbaa !20
  br label %210

205:                                              ; preds = %184
  %206 = load ptr, ptr %2, align 8, !tbaa !5
  %207 = getelementptr inbounds %struct.mobj_s, ptr %206, i32 0, i32 18
  %208 = load i32, ptr %207, align 8, !tbaa !20
  %209 = add nsw i32 %208, 8192
  store i32 %209, ptr %207, align 8, !tbaa !20
  br label %210

210:                                              ; preds = %205, %200
  store i32 0, ptr %8, align 4
  br label %211

211:                                              ; preds = %210, %67, %12
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  %212 = load i32, ptr %8, align 4
  switch i32 %212, label %214 [
    i32 0, label %213
    i32 1, label %213
  ]

213:                                              ; preds = %211, %211
  ret void

214:                                              ; preds = %211
  unreachable
}

declare void @P_SpawnPuff(i32 noundef, i32 noundef, i32 noundef) #1

declare ptr @P_SpawnMobj(i32 noundef, i32 noundef, i32 noundef, i32 noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @FixedMul(i32 noundef, i32 noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { 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 #3 = { inlinehint 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 24}
!12 = !{!"mobj_s", !13, i64 0, !10, i64 24, !10, i64 28, !10, i64 32, !6, i64 40, !6, i64 48, !10, i64 56, !10, i64 60, !10, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !10, i64 96, !10, i64 100, !10, i64 104, !10, i64 108, !10, i64 112, !10, i64 116, !10, i64 120, !10, i64 124, !10, i64 128, !6, i64 136, !10, i64 144, !6, i64 152, !10, i64 160, !10, i64 164, !10, i64 168, !10, i64 172, !6, i64 176, !10, i64 184, !10, i64 188, !6, i64 192, !10, i64 200, !14, i64 204, !6, i64 216}
!13 = !{!"thinker_s", !6, i64 0, !6, i64 8, !7, i64 16}
!14 = !{!"", !15, i64 0, !15, i64 2, !15, i64 4, !15, i64 6, !15, i64 8}
!15 = !{!"short", !7, i64 0}
!16 = !{!12, !10, i64 28}
!17 = !{!12, !10, i64 32}
!18 = !{!12, !10, i64 112}
!19 = !{!12, !10, i64 116}
!20 = !{!12, !10, i64 120}
!21 = !{!12, !10, i64 144}
!22 = !{!12, !6, i64 216}
!23 = !{!12, !10, i64 164}
!24 = !{!12, !10, i64 56}
!25 = !{!12, !6, i64 136}
!26 = !{!27, !10, i64 60}
!27 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !10, i64 72, !10, i64 76, !10, i64 80, !10, i64 84, !10, 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"

@TRACEANGLE = external dso_local local_unnamed_addr global i32, align 4
@gametic = external local_unnamed_addr global i32, align 4
@finecosine = external local_unnamed_addr global ptr, align 8
@finesine = external local_unnamed_addr global [10240 x i32], align 16

declare i32 @P_AproxDistance(i32 noundef, i32 noundef) local_unnamed_addr #0

declare i32 @P_Random() local_unnamed_addr #0

declare i32 @R_PointToAngle2(i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @A_Tracer(ptr nocapture noundef %0) local_unnamed_addr #1 {
  %2 = load i32, ptr @gametic, align 4, !tbaa !5
  %3 = and i32 %2, 3
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %4, label %93

4:                                                ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  %6 = load i32, ptr %5, align 8, !tbaa !9
  %7 = getelementptr inbounds i8, ptr %0, i64 28
  %8 = load i32, ptr %7, align 4, !tbaa !15
  %9 = getelementptr inbounds i8, ptr %0, i64 32
  %10 = load i32, ptr %9, align 8, !tbaa !16
  tail call void @P_SpawnPuff(i32 noundef %6, i32 noundef %8, i32 noundef %10) #4
  %11 = load i32, ptr %5, align 8, !tbaa !9
  %12 = getelementptr inbounds i8, ptr %0, i64 112
  %13 = load i32, ptr %12, align 8, !tbaa !17
  %14 = sub nsw i32 %11, %13
  %15 = load i32, ptr %7, align 4, !tbaa !15
  %16 = getelementptr inbounds i8, ptr %0, i64 116
  %17 = load i32, ptr %16, align 4, !tbaa !18
  %18 = sub nsw i32 %15, %17
  %19 = load i32, ptr %9, align 8, !tbaa !16
  %20 = tail call ptr @P_SpawnMobj(i32 noundef %14, i32 noundef %18, i32 noundef %19, i32 noundef 7) #4
  %21 = getelementptr inbounds i8, ptr %20, i64 120
  store i32 65536, ptr %21, align 8, !tbaa !19
  %22 = tail call i32 @P_Random() #4
  %23 = and i32 %22, 3
  %24 = getelementptr inbounds i8, ptr %20, i64 144
  %25 = load i32, ptr %24, align 8, !tbaa !20
  %26 = sub nsw i32 %25, %23
  %spec.select = tail call i32 @llvm.smax.i32(i32 %26, i32 1)
  store i32 %spec.select, ptr %24, align 8, !tbaa !20
  %27 = getelementptr inbounds i8, ptr %0, i64 216
  %28 = load ptr, ptr %27, align 8, !tbaa !21
  %.not56 = icmp eq ptr %28, null
  br i1 %.not56, label %93, label %29

29:                                               ; preds = %4
  %30 = getelementptr inbounds i8, ptr %28, i64 164
  %31 = load i32, ptr %30, align 4, !tbaa !22
  %32 = icmp slt i32 %31, 1
  br i1 %32, label %93, label %33

33:                                               ; preds = %29
  %34 = load i32, ptr %5, align 8, !tbaa !9
  %35 = load i32, ptr %7, align 4, !tbaa !15
  %36 = getelementptr inbounds i8, ptr %28, i64 24
  %37 = load i32, ptr %36, align 8, !tbaa !9
  %38 = getelementptr inbounds i8, ptr %28, i64 28
  %39 = load i32, ptr %38, align 4, !tbaa !15
  %40 = tail call i32 @R_PointToAngle2(i32 noundef %34, i32 noundef %35, i32 noundef %37, i32 noundef %39) #4
  %41 = getelementptr inbounds i8, ptr %0, i64 56
  %42 = load i32, ptr %41, align 8, !tbaa !23
  %.not57 = icmp eq i32 %40, %42
  br i1 %.not57, label %55, label %43

43:                                               ; preds = %33
  %44 = sub i32 %40, %42
  %45 = icmp ugt i32 %44, -2147483648
  %46 = load i32, ptr @TRACEANGLE, align 4, !tbaa !5
  br i1 %45, label %47, label %51

47:                                               ; preds = %43
  %48 = sub i32 %42, %46
  %49 = sub i32 %40, %48
  %50 = icmp slt i32 %49, 0
  %spec.store.select59 = select i1 %50, i32 %48, i32 %40
  br label %.sink.split

51:                                               ; preds = %43
  %52 = add i32 %46, %42
  %53 = sub i32 %40, %52
  %54 = icmp ugt i32 %53, -2147483648
  %spec.store.select60 = select i1 %54, i32 %40, i32 %52
  br label %.sink.split

.sink.split:                                      ; preds = %47, %51
  %spec.store.select60.sink = phi i32 [ %spec.store.select60, %51 ], [ %spec.store.select59, %47 ]
  store i32 %spec.store.select60.sink, ptr %41, align 8
  br label %55

55:                                               ; preds = %.sink.split, %33
  %56 = phi i32 [ %40, %33 ], [ %spec.store.select60.sink, %.sink.split ]
  %57 = lshr i32 %56, 19
  %58 = getelementptr inbounds i8, ptr %0, i64 136
  %59 = load ptr, ptr %58, align 8, !tbaa !24
  %60 = getelementptr inbounds i8, ptr %59, i64 60
  %61 = load i32, ptr %60, align 4, !tbaa !25
  %62 = load ptr, ptr @finecosine, align 8, !tbaa !27
  %63 = zext nneg i32 %57 to i64
  %64 = getelementptr inbounds i32, ptr %62, i64 %63
  %65 = load i32, ptr %64, align 4, !tbaa !5
  %66 = tail call i32 @FixedMul(i32 noundef %61, i32 noundef %65)
  store i32 %66, ptr %12, align 8, !tbaa !17
  %67 = load ptr, ptr %58, align 8, !tbaa !24
  %68 = getelementptr inbounds i8, ptr %67, i64 60
  %69 = load i32, ptr %68, align 4, !tbaa !25
  %70 = getelementptr inbounds [10240 x i32], ptr @finesine, i64 0, i64 %63
  %71 = load i32, ptr %70, align 4, !tbaa !5
  %72 = tail call i32 @FixedMul(i32 noundef %69, i32 noundef %71)
  store i32 %72, ptr %16, align 4, !tbaa !18
  %73 = load i32, ptr %36, align 8, !tbaa !9
  %74 = load i32, ptr %5, align 8, !tbaa !9
  %75 = sub nsw i32 %73, %74
  %76 = load i32, ptr %38, align 4, !tbaa !15
  %77 = load i32, ptr %7, align 4, !tbaa !15
  %78 = sub nsw i32 %76, %77
  %79 = tail call i32 @P_AproxDistance(i32 noundef %75, i32 noundef %78) #4
  %80 = load ptr, ptr %58, align 8, !tbaa !24
  %81 = getelementptr inbounds i8, ptr %80, i64 60
  %82 = load i32, ptr %81, align 4, !tbaa !25
  %83 = sdiv i32 %79, %82
  %spec.store.select = tail call i32 @llvm.smax.i32(i32 %83, i32 1)
  %84 = getelementptr inbounds i8, ptr %28, i64 32
  %85 = load i32, ptr %84, align 8, !tbaa !16
  %86 = add nsw i32 %85, 2621440
  %87 = load i32, ptr %9, align 8, !tbaa !16
  %88 = sub i32 %86, %87
  %89 = sdiv i32 %88, %spec.store.select
  %90 = getelementptr inbounds i8, ptr %0, i64 120
  %91 = load i32, ptr %90, align 8, !tbaa !19
  %92 = icmp slt i32 %89, %91
  %storemerge58.v = select i1 %92, i32 -8192, i32 8192
  %storemerge58 = add nsw i32 %storemerge58.v, %91
  store i32 %storemerge58, ptr %90, align 8, !tbaa !19
  br label %93

93:                                               ; preds = %4, %29, %1, %55
  ret void
}

declare void @P_SpawnPuff(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

declare ptr @P_SpawnMobj(i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @FixedMul(i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #3

attributes #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 = { 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 = { inlinehint 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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/C++ TBAA"}
!9 = !{!10, !6, i64 24}
!10 = !{!"mobj_s", !11, i64 0, !6, i64 24, !6, i64 28, !6, i64 32, !12, i64 40, !12, i64 48, !6, i64 56, !6, i64 60, !6, i64 64, !12, i64 72, !12, i64 80, !12, i64 88, !6, i64 96, !6, i64 100, !6, i64 104, !6, i64 108, !6, i64 112, !6, i64 116, !6, i64 120, !6, i64 124, !6, i64 128, !12, i64 136, !6, i64 144, !12, i64 152, !6, i64 160, !6, i64 164, !6, i64 168, !6, i64 172, !12, i64 176, !6, i64 184, !6, i64 188, !12, i64 192, !6, i64 200, !13, i64 204, !12, i64 216}
!11 = !{!"thinker_s", !12, i64 0, !12, i64 8, !7, i64 16}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!"", !14, i64 0, !14, i64 2, !14, i64 4, !14, i64 6, !14, i64 8}
!14 = !{!"short", !7, i64 0}
!15 = !{!10, !6, i64 28}
!16 = !{!10, !6, i64 32}
!17 = !{!10, !6, i64 112}
!18 = !{!10, !6, i64 116}
!19 = !{!10, !6, i64 120}
!20 = !{!10, !6, i64 144}
!21 = !{!10, !12, i64 216}
!22 = !{!10, !6, i64 164}
!23 = !{!10, !6, i64 56}
!24 = !{!10, !12, i64 136}
!25 = !{!26, !6, i64 60}
!26 = !{!"", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36, !6, i64 40, !6, i64 44, !6, i64 48, !6, i64 52, !6, i64 56, !6, i64 60, !6, i64 64, !6, i64 68, !6, i64 72, !6, i64 76, !6, i64 80, !6, i64 84, !6, i64 88}
!27 = !{!12, !12, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass