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

; 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.player_s = type { ptr, i32, %struct.ticcmd_t, i32, i32, i32, i32, i32, i32, i32, [6 x i32], [6 x i32], i32, [4 x i32], i32, i32, [9 x i32], [4 x i32], [4 x i32], i32, i32, i32, i32, i32, i32, i32, ptr, i32, i32, ptr, i32, i32, i32, [2 x %struct.pspdef_t], i32 }
%struct.ticcmd_t = type { i8, i8, i16, i16, i8, i8 }
%struct.pspdef_t = type { ptr, i32, i32, i32 }
%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 }

@plyr = external hidden global ptr, align 8
@ST_updateFaceWidget.lastattackdown = external hidden global i32, align 4
@ST_updateFaceWidget.priority = external hidden global i32, align 4
@st_faceindex = external hidden global i32, align 4
@st_facecount = external hidden global i32, align 4
@oldweaponsowned = external hidden global [9 x i32], align 16
@st_oldhealth = external hidden global i32, align 4
@st_randomnumber = external hidden global i32, align 4

; 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
declare dso_local i32 @ST_calcPainOffset() #1

; Function Attrs: nounwind uwtable
define dso_local void @ST_updateFaceWidget() #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  %5 = load i32, ptr @ST_updateFaceWidget.priority, align 4, !tbaa !5
  %6 = icmp slt i32 %5, 10
  br i1 %6, label %7, label %14

7:                                                ; preds = %0
  %8 = load ptr, ptr @plyr, align 8, !tbaa !9
  %9 = getelementptr inbounds %struct.player_s, ptr %8, i32 0, i32 7
  %10 = load i32, ptr %9, align 4, !tbaa !11
  %11 = icmp ne i32 %10, 0
  br i1 %11, label %13, label %12

12:                                               ; preds = %7
  store i32 9, ptr @ST_updateFaceWidget.priority, align 4, !tbaa !5
  store i32 41, ptr @st_faceindex, align 4, !tbaa !5
  store i32 1, ptr @st_facecount, align 4, !tbaa !5
  br label %13

13:                                               ; preds = %12, %7
  br label %14

14:                                               ; preds = %13, %0
  %15 = load i32, ptr @ST_updateFaceWidget.priority, align 4, !tbaa !5
  %16 = icmp slt i32 %15, 9
  br i1 %16, label %17, label %60

17:                                               ; preds = %14
  %18 = load ptr, ptr @plyr, align 8, !tbaa !9
  %19 = getelementptr inbounds %struct.player_s, ptr %18, i32 0, i32 28
  %20 = load i32, ptr %19, align 4, !tbaa !15
  %21 = icmp ne i32 %20, 0
  br i1 %21, label %22, label %59

22:                                               ; preds = %17
  store i32 0, ptr %4, align 4, !tbaa !5
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %23

23:                                               ; preds = %49, %22
  %24 = load i32, ptr %1, align 4, !tbaa !5
  %25 = icmp slt i32 %24, 9
  br i1 %25, label %26, label %52

26:                                               ; preds = %23
  %27 = load i32, ptr %1, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [9 x i32], ptr @oldweaponsowned, i64 0, i64 %28
  %30 = load i32, ptr %29, align 4, !tbaa !5
  %31 = load ptr, ptr @plyr, align 8, !tbaa !9
  %32 = getelementptr inbounds %struct.player_s, ptr %31, i32 0, i32 16
  %33 = load i32, ptr %1, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [9 x i32], ptr %32, i64 0, i64 %34
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %37 = icmp ne i32 %30, %36
  br i1 %37, label %38, label %48

38:                                               ; preds = %26
  store i32 1, ptr %4, align 4, !tbaa !5
  %39 = load ptr, ptr @plyr, align 8, !tbaa !9
  %40 = getelementptr inbounds %struct.player_s, ptr %39, i32 0, i32 16
  %41 = load i32, ptr %1, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [9 x i32], ptr %40, i64 0, i64 %42
  %44 = load i32, ptr %43, align 4, !tbaa !5
  %45 = load i32, ptr %1, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [9 x i32], ptr @oldweaponsowned, i64 0, i64 %46
  store i32 %44, ptr %47, align 4, !tbaa !5
  br label %48

48:                                               ; preds = %38, %26
  br label %49

49:                                               ; preds = %48
  %50 = load i32, ptr %1, align 4, !tbaa !5
  %51 = add nsw i32 %50, 1
  store i32 %51, ptr %1, align 4, !tbaa !5
  br label %23, !llvm.loop !16

52:                                               ; preds = %23
  %53 = load i32, ptr %4, align 4, !tbaa !5
  %54 = icmp ne i32 %53, 0
  br i1 %54, label %55, label %58

55:                                               ; preds = %52
  store i32 8, ptr @ST_updateFaceWidget.priority, align 4, !tbaa !5
  store i32 70, ptr @st_facecount, align 4, !tbaa !5
  %56 = call i32 @ST_calcPainOffset()
  %57 = add nsw i32 %56, 6
  store i32 %57, ptr @st_faceindex, align 4, !tbaa !5
  br label %58

58:                                               ; preds = %55, %52
  br label %59

59:                                               ; preds = %58, %17
  br label %60

60:                                               ; preds = %59, %14
  %61 = load i32, ptr @ST_updateFaceWidget.priority, align 4, !tbaa !5
  %62 = icmp slt i32 %61, 8
  br i1 %62, label %63, label %162

63:                                               ; preds = %60
  %64 = load ptr, ptr @plyr, align 8, !tbaa !9
  %65 = getelementptr inbounds %struct.player_s, ptr %64, i32 0, i32 27
  %66 = load i32, ptr %65, align 8, !tbaa !18
  %67 = icmp ne i32 %66, 0
  br i1 %67, label %68, label %161

68:                                               ; preds = %63
  %69 = load ptr, ptr @plyr, align 8, !tbaa !9
  %70 = getelementptr inbounds %struct.player_s, ptr %69, i32 0, i32 29
  %71 = load ptr, ptr %70, align 8, !tbaa !19
  %72 = icmp ne ptr %71, null
  br i1 %72, label %73, label %161

73:                                               ; preds = %68
  %74 = load ptr, ptr @plyr, align 8, !tbaa !9
  %75 = getelementptr inbounds %struct.player_s, ptr %74, i32 0, i32 29
  %76 = load ptr, ptr %75, align 8, !tbaa !19
  %77 = load ptr, ptr @plyr, align 8, !tbaa !9
  %78 = getelementptr inbounds %struct.player_s, ptr %77, i32 0, i32 0
  %79 = load ptr, ptr %78, align 8, !tbaa !20
  %80 = icmp ne ptr %76, %79
  br i1 %80, label %81, label %161

81:                                               ; preds = %73
  store i32 7, ptr @ST_updateFaceWidget.priority, align 4, !tbaa !5
  %82 = load ptr, ptr @plyr, align 8, !tbaa !9
  %83 = getelementptr inbounds %struct.player_s, ptr %82, i32 0, i32 7
  %84 = load i32, ptr %83, align 4, !tbaa !11
  %85 = load i32, ptr @st_oldhealth, align 4, !tbaa !5
  %86 = sub nsw i32 %84, %85
  %87 = icmp sgt i32 %86, 20
  br i1 %87, label %88, label %91

88:                                               ; preds = %81
  store i32 35, ptr @st_facecount, align 4, !tbaa !5
  %89 = call i32 @ST_calcPainOffset()
  %90 = add nsw i32 %89, 5
  store i32 %90, ptr @st_faceindex, align 4, !tbaa !5
  br label %160

91:                                               ; preds = %81
  %92 = load ptr, ptr @plyr, align 8, !tbaa !9
  %93 = getelementptr inbounds %struct.player_s, ptr %92, i32 0, i32 0
  %94 = load ptr, ptr %93, align 8, !tbaa !20
  %95 = getelementptr inbounds %struct.mobj_s, ptr %94, i32 0, i32 1
  %96 = load i32, ptr %95, align 8, !tbaa !21
  %97 = load ptr, ptr @plyr, align 8, !tbaa !9
  %98 = getelementptr inbounds %struct.player_s, ptr %97, i32 0, i32 0
  %99 = load ptr, ptr %98, align 8, !tbaa !20
  %100 = getelementptr inbounds %struct.mobj_s, ptr %99, i32 0, i32 2
  %101 = load i32, ptr %100, align 4, !tbaa !25
  %102 = load ptr, ptr @plyr, align 8, !tbaa !9
  %103 = getelementptr inbounds %struct.player_s, ptr %102, i32 0, i32 29
  %104 = load ptr, ptr %103, align 8, !tbaa !19
  %105 = getelementptr inbounds %struct.mobj_s, ptr %104, i32 0, i32 1
  %106 = load i32, ptr %105, align 8, !tbaa !21
  %107 = load ptr, ptr @plyr, align 8, !tbaa !9
  %108 = getelementptr inbounds %struct.player_s, ptr %107, i32 0, i32 29
  %109 = load ptr, ptr %108, align 8, !tbaa !19
  %110 = getelementptr inbounds %struct.mobj_s, ptr %109, i32 0, i32 2
  %111 = load i32, ptr %110, align 4, !tbaa !25
  %112 = call i32 @R_PointToAngle2(i32 noundef %96, i32 noundef %101, i32 noundef %106, i32 noundef %111)
  store i32 %112, ptr %2, align 4, !tbaa !5
  %113 = load i32, ptr %2, align 4, !tbaa !5
  %114 = load ptr, ptr @plyr, align 8, !tbaa !9
  %115 = getelementptr inbounds %struct.player_s, ptr %114, i32 0, i32 0
  %116 = load ptr, ptr %115, align 8, !tbaa !20
  %117 = getelementptr inbounds %struct.mobj_s, ptr %116, i32 0, i32 6
  %118 = load i32, ptr %117, align 8, !tbaa !26
  %119 = icmp ugt i32 %113, %118
  br i1 %119, label %120, label %131

120:                                              ; preds = %91
  %121 = load i32, ptr %2, align 4, !tbaa !5
  %122 = load ptr, ptr @plyr, align 8, !tbaa !9
  %123 = getelementptr inbounds %struct.player_s, ptr %122, i32 0, i32 0
  %124 = load ptr, ptr %123, align 8, !tbaa !20
  %125 = getelementptr inbounds %struct.mobj_s, ptr %124, i32 0, i32 6
  %126 = load i32, ptr %125, align 8, !tbaa !26
  %127 = sub i32 %121, %126
  store i32 %127, ptr %3, align 4, !tbaa !5
  %128 = load i32, ptr %3, align 4, !tbaa !5
  %129 = icmp ugt i32 %128, -2147483648
  %130 = zext i1 %129 to i32
  store i32 %130, ptr %1, align 4, !tbaa !5
  br label %142

131:                                              ; preds = %91
  %132 = load ptr, ptr @plyr, align 8, !tbaa !9
  %133 = getelementptr inbounds %struct.player_s, ptr %132, i32 0, i32 0
  %134 = load ptr, ptr %133, align 8, !tbaa !20
  %135 = getelementptr inbounds %struct.mobj_s, ptr %134, i32 0, i32 6
  %136 = load i32, ptr %135, align 8, !tbaa !26
  %137 = load i32, ptr %2, align 4, !tbaa !5
  %138 = sub i32 %136, %137
  store i32 %138, ptr %3, align 4, !tbaa !5
  %139 = load i32, ptr %3, align 4, !tbaa !5
  %140 = icmp ule i32 %139, -2147483648
  %141 = zext i1 %140 to i32
  store i32 %141, ptr %1, align 4, !tbaa !5
  br label %142

142:                                              ; preds = %131, %120
  store i32 35, ptr @st_facecount, align 4, !tbaa !5
  %143 = call i32 @ST_calcPainOffset()
  store i32 %143, ptr @st_faceindex, align 4, !tbaa !5
  %144 = load i32, ptr %3, align 4, !tbaa !5
  %145 = icmp ult i32 %144, 536870912
  br i1 %145, label %146, label %149

146:                                              ; preds = %142
  %147 = load i32, ptr @st_faceindex, align 4, !tbaa !5
  %148 = add nsw i32 %147, 7
  store i32 %148, ptr @st_faceindex, align 4, !tbaa !5
  br label %159

149:                                              ; preds = %142
  %150 = load i32, ptr %1, align 4, !tbaa !5
  %151 = icmp ne i32 %150, 0
  br i1 %151, label %152, label %155

152:                                              ; preds = %149
  %153 = load i32, ptr @st_faceindex, align 4, !tbaa !5
  %154 = add nsw i32 %153, 3
  store i32 %154, ptr @st_faceindex, align 4, !tbaa !5
  br label %158

155:                                              ; preds = %149
  %156 = load i32, ptr @st_faceindex, align 4, !tbaa !5
  %157 = add nsw i32 %156, 4
  store i32 %157, ptr @st_faceindex, align 4, !tbaa !5
  br label %158

158:                                              ; preds = %155, %152
  br label %159

159:                                              ; preds = %158, %146
  br label %160

160:                                              ; preds = %159, %88
  br label %161

161:                                              ; preds = %160, %73, %68, %63
  br label %162

162:                                              ; preds = %161, %60
  %163 = load i32, ptr @ST_updateFaceWidget.priority, align 4, !tbaa !5
  %164 = icmp slt i32 %163, 7
  br i1 %164, label %165, label %185

165:                                              ; preds = %162
  %166 = load ptr, ptr @plyr, align 8, !tbaa !9
  %167 = getelementptr inbounds %struct.player_s, ptr %166, i32 0, i32 27
  %168 = load i32, ptr %167, align 8, !tbaa !18
  %169 = icmp ne i32 %168, 0
  br i1 %169, label %170, label %184

170:                                              ; preds = %165
  %171 = load ptr, ptr @plyr, align 8, !tbaa !9
  %172 = getelementptr inbounds %struct.player_s, ptr %171, i32 0, i32 7
  %173 = load i32, ptr %172, align 4, !tbaa !11
  %174 = load i32, ptr @st_oldhealth, align 4, !tbaa !5
  %175 = sub nsw i32 %173, %174
  %176 = icmp sgt i32 %175, 20
  br i1 %176, label %177, label %180

177:                                              ; preds = %170
  store i32 7, ptr @ST_updateFaceWidget.priority, align 4, !tbaa !5
  store i32 35, ptr @st_facecount, align 4, !tbaa !5
  %178 = call i32 @ST_calcPainOffset()
  %179 = add nsw i32 %178, 5
  store i32 %179, ptr @st_faceindex, align 4, !tbaa !5
  br label %183

180:                                              ; preds = %170
  store i32 6, ptr @ST_updateFaceWidget.priority, align 4, !tbaa !5
  store i32 35, ptr @st_facecount, align 4, !tbaa !5
  %181 = call i32 @ST_calcPainOffset()
  %182 = add nsw i32 %181, 7
  store i32 %182, ptr @st_faceindex, align 4, !tbaa !5
  br label %183

183:                                              ; preds = %180, %177
  br label %184

184:                                              ; preds = %183, %165
  br label %185

185:                                              ; preds = %184, %162
  %186 = load i32, ptr @ST_updateFaceWidget.priority, align 4, !tbaa !5
  %187 = icmp slt i32 %186, 6
  br i1 %187, label %188, label %208

188:                                              ; preds = %185
  %189 = load ptr, ptr @plyr, align 8, !tbaa !9
  %190 = getelementptr inbounds %struct.player_s, ptr %189, i32 0, i32 19
  %191 = load i32, ptr %190, align 8, !tbaa !27
  %192 = icmp ne i32 %191, 0
  br i1 %192, label %193, label %206

193:                                              ; preds = %188
  %194 = load i32, ptr @ST_updateFaceWidget.lastattackdown, align 4, !tbaa !5
  %195 = icmp eq i32 %194, -1
  br i1 %195, label %196, label %197

196:                                              ; preds = %193
  store i32 70, ptr @ST_updateFaceWidget.lastattackdown, align 4, !tbaa !5
  br label %205

197:                                              ; preds = %193
  %198 = load i32, ptr @ST_updateFaceWidget.lastattackdown, align 4, !tbaa !5
  %199 = add nsw i32 %198, -1
  store i32 %199, ptr @ST_updateFaceWidget.lastattackdown, align 4, !tbaa !5
  %200 = icmp ne i32 %199, 0
  br i1 %200, label %204, label %201

201:                                              ; preds = %197
  store i32 5, ptr @ST_updateFaceWidget.priority, align 4, !tbaa !5
  %202 = call i32 @ST_calcPainOffset()
  %203 = add nsw i32 %202, 7
  store i32 %203, ptr @st_faceindex, align 4, !tbaa !5
  store i32 1, ptr @st_facecount, align 4, !tbaa !5
  store i32 1, ptr @ST_updateFaceWidget.lastattackdown, align 4, !tbaa !5
  br label %204

204:                                              ; preds = %201, %197
  br label %205

205:                                              ; preds = %204, %196
  br label %207

206:                                              ; preds = %188
  store i32 -1, ptr @ST_updateFaceWidget.lastattackdown, align 4, !tbaa !5
  br label %207

207:                                              ; preds = %206, %205
  br label %208

208:                                              ; preds = %207, %185
  %209 = load i32, ptr @ST_updateFaceWidget.priority, align 4, !tbaa !5
  %210 = icmp slt i32 %209, 5
  br i1 %210, label %211, label %225

211:                                              ; preds = %208
  %212 = load ptr, ptr @plyr, align 8, !tbaa !9
  %213 = getelementptr inbounds %struct.player_s, ptr %212, i32 0, i32 21
  %214 = load i32, ptr %213, align 8, !tbaa !28
  %215 = and i32 %214, 2
  %216 = icmp ne i32 %215, 0
  br i1 %216, label %223, label %217

217:                                              ; preds = %211
  %218 = load ptr, ptr @plyr, align 8, !tbaa !9
  %219 = getelementptr inbounds %struct.player_s, ptr %218, i32 0, i32 10
  %220 = getelementptr inbounds [6 x i32], ptr %219, i64 0, i64 0
  %221 = load i32, ptr %220, align 8, !tbaa !5
  %222 = icmp ne i32 %221, 0
  br i1 %222, label %223, label %224

223:                                              ; preds = %217, %211
  store i32 4, ptr @ST_updateFaceWidget.priority, align 4, !tbaa !5
  store i32 40, ptr @st_faceindex, align 4, !tbaa !5
  store i32 1, ptr @st_facecount, align 4, !tbaa !5
  br label %224

224:                                              ; preds = %223, %217
  br label %225

225:                                              ; preds = %224, %208
  %226 = load i32, ptr @st_facecount, align 4, !tbaa !5
  %227 = icmp ne i32 %226, 0
  br i1 %227, label %233, label %228

228:                                              ; preds = %225
  %229 = call i32 @ST_calcPainOffset()
  %230 = load i32, ptr @st_randomnumber, align 4, !tbaa !5
  %231 = srem i32 %230, 3
  %232 = add nsw i32 %229, %231
  store i32 %232, ptr @st_faceindex, align 4, !tbaa !5
  store i32 17, ptr @st_facecount, align 4, !tbaa !5
  store i32 0, ptr @ST_updateFaceWidget.priority, align 4, !tbaa !5
  br label %233

233:                                              ; preds = %228, %225
  %234 = load i32, ptr @st_facecount, align 4, !tbaa !5
  %235 = add nsw i32 %234, -1
  store i32 %235, ptr @st_facecount, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  ret void
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 36}
!12 = !{!"player_s", !10, i64 0, !6, i64 8, !13, i64 12, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36, !6, i64 40, !6, i64 44, !7, i64 48, !7, i64 72, !6, i64 96, !7, i64 100, !6, i64 116, !6, i64 120, !7, i64 124, !7, i64 160, !7, i64 176, !6, i64 192, !6, i64 196, !6, i64 200, !6, i64 204, !6, i64 208, !6, i64 212, !6, i64 216, !10, i64 224, !6, i64 232, !6, i64 236, !10, i64 240, !6, i64 248, !6, i64 252, !6, i64 256, !7, i64 264, !6, i64 312}
!13 = !{!"", !7, i64 0, !7, i64 1, !14, i64 2, !14, i64 4, !7, i64 6, !7, i64 7}
!14 = !{!"short", !7, i64 0}
!15 = !{!12, !6, i64 236}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!12, !6, i64 232}
!19 = !{!12, !10, i64 240}
!20 = !{!12, !10, i64 0}
!21 = !{!22, !6, i64 24}
!22 = !{!"mobj_s", !23, i64 0, !6, i64 24, !6, i64 28, !6, i64 32, !10, i64 40, !10, i64 48, !6, i64 56, !6, i64 60, !6, i64 64, !10, i64 72, !10, i64 80, !10, 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, !10, i64 136, !6, i64 144, !10, i64 152, !6, i64 160, !6, i64 164, !6, i64 168, !6, i64 172, !10, i64 176, !6, i64 184, !6, i64 188, !10, i64 192, !6, i64 200, !24, i64 204, !10, i64 216}
!23 = !{!"thinker_s", !10, i64 0, !10, i64 8, !7, i64 16}
!24 = !{!"", !14, i64 0, !14, i64 2, !14, i64 4, !14, i64 6, !14, i64 8}
!25 = !{!22, !6, i64 28}
!26 = !{!22, !6, i64 56}
!27 = !{!12, !6, i64 192}
!28 = !{!12, !6, i64 200}


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

@plyr = external hidden local_unnamed_addr global ptr, align 8
@ST_updateFaceWidget.lastattackdown = external hidden local_unnamed_addr global i32, align 4
@ST_updateFaceWidget.priority = external hidden local_unnamed_addr global i32, align 4
@st_faceindex = external hidden local_unnamed_addr global i32, align 4
@st_facecount = external hidden local_unnamed_addr global i32, align 4
@oldweaponsowned = external hidden local_unnamed_addr global [9 x i32], align 16
@st_oldhealth = external hidden local_unnamed_addr global i32, align 4
@st_randomnumber = external hidden local_unnamed_addr global i32, align 4

; Function Attrs: nounwind uwtable
declare dso_local i32 @ST_calcPainOffset() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @ST_updateFaceWidget() local_unnamed_addr #0 {
  %1 = load i32, ptr @ST_updateFaceWidget.priority, align 4, !tbaa !5
  %2 = icmp slt i32 %1, 10
  br i1 %2, label %3, label %.thread49

3:                                                ; preds = %0
  %4 = load ptr, ptr @plyr, align 8, !tbaa !9
  %5 = getelementptr inbounds i8, ptr %4, i64 36
  %6 = load i32, ptr %5, align 4, !tbaa !11
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %.thread49.thread, label %7

.thread49.thread:                                 ; preds = %3
  store i32 9, ptr @ST_updateFaceWidget.priority, align 4, !tbaa !5
  store i32 41, ptr @st_faceindex, align 4, !tbaa !5
  br label %148

7:                                                ; preds = %3
  %.not67 = icmp eq i32 %1, 9
  br i1 %.not67, label %.thread49, label %8

8:                                                ; preds = %7
  %9 = getelementptr inbounds i8, ptr %4, i64 236
  %10 = load i32, ptr %9, align 4, !tbaa !15
  %.not24 = icmp eq i32 %10, 0
  br i1 %.not24, label %.thread, label %.preheader

.preheader:                                       ; preds = %8
  %11 = getelementptr inbounds i8, ptr %4, i64 124
  %12 = load i32, ptr @oldweaponsowned, align 16, !tbaa !5
  %13 = load i32, ptr %11, align 4, !tbaa !5
  %.not35 = icmp eq i32 %12, %13
  br i1 %.not35, label %15, label %14

14:                                               ; preds = %.preheader
  store i32 %13, ptr @oldweaponsowned, align 16, !tbaa !5
  br label %15

15:                                               ; preds = %.preheader, %14
  %.1 = phi i32 [ 1, %14 ], [ 0, %.preheader ]
  %16 = load i32, ptr getelementptr inbounds (i8, ptr @oldweaponsowned, i64 4), align 4, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %4, i64 128
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %.not35.1 = icmp eq i32 %16, %18
  br i1 %.not35.1, label %20, label %19

19:                                               ; preds = %15
  store i32 %18, ptr getelementptr inbounds (i8, ptr @oldweaponsowned, i64 4), align 4, !tbaa !5
  br label %20

20:                                               ; preds = %19, %15
  %.1.1 = phi i32 [ 1, %19 ], [ %.1, %15 ]
  %21 = load i32, ptr getelementptr inbounds (i8, ptr @oldweaponsowned, i64 8), align 8, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %4, i64 132
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %.not35.2 = icmp eq i32 %21, %23
  br i1 %.not35.2, label %25, label %24

24:                                               ; preds = %20
  store i32 %23, ptr getelementptr inbounds (i8, ptr @oldweaponsowned, i64 8), align 8, !tbaa !5
  br label %25

25:                                               ; preds = %24, %20
  %.1.2 = phi i32 [ 1, %24 ], [ %.1.1, %20 ]
  %26 = load i32, ptr getelementptr inbounds (i8, ptr @oldweaponsowned, i64 12), align 4, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %4, i64 136
  %28 = load i32, ptr %27, align 4, !tbaa !5
  %.not35.3 = icmp eq i32 %26, %28
  br i1 %.not35.3, label %30, label %29

29:                                               ; preds = %25
  store i32 %28, ptr getelementptr inbounds (i8, ptr @oldweaponsowned, i64 12), align 4, !tbaa !5
  br label %30

30:                                               ; preds = %29, %25
  %.1.3 = phi i32 [ 1, %29 ], [ %.1.2, %25 ]
  %31 = load i32, ptr getelementptr inbounds (i8, ptr @oldweaponsowned, i64 16), align 16, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %4, i64 140
  %33 = load i32, ptr %32, align 4, !tbaa !5
  %.not35.4 = icmp eq i32 %31, %33
  br i1 %.not35.4, label %35, label %34

34:                                               ; preds = %30
  store i32 %33, ptr getelementptr inbounds (i8, ptr @oldweaponsowned, i64 16), align 16, !tbaa !5
  br label %35

35:                                               ; preds = %34, %30
  %.1.4 = phi i32 [ 1, %34 ], [ %.1.3, %30 ]
  %36 = load i32, ptr getelementptr inbounds (i8, ptr @oldweaponsowned, i64 20), align 4, !tbaa !5
  %37 = getelementptr inbounds i8, ptr %4, i64 144
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %.not35.5 = icmp eq i32 %36, %38
  br i1 %.not35.5, label %40, label %39

39:                                               ; preds = %35
  store i32 %38, ptr getelementptr inbounds (i8, ptr @oldweaponsowned, i64 20), align 4, !tbaa !5
  br label %40

40:                                               ; preds = %39, %35
  %.1.5 = phi i32 [ 1, %39 ], [ %.1.4, %35 ]
  %41 = load i32, ptr getelementptr inbounds (i8, ptr @oldweaponsowned, i64 24), align 8, !tbaa !5
  %42 = getelementptr inbounds i8, ptr %4, i64 148
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %.not35.6 = icmp eq i32 %41, %43
  br i1 %.not35.6, label %45, label %44

44:                                               ; preds = %40
  store i32 %43, ptr getelementptr inbounds (i8, ptr @oldweaponsowned, i64 24), align 8, !tbaa !5
  br label %45

45:                                               ; preds = %44, %40
  %.1.6 = phi i32 [ 1, %44 ], [ %.1.5, %40 ]
  %46 = load i32, ptr getelementptr inbounds (i8, ptr @oldweaponsowned, i64 28), align 4, !tbaa !5
  %47 = getelementptr inbounds i8, ptr %4, i64 152
  %48 = load i32, ptr %47, align 4, !tbaa !5
  %.not35.7 = icmp eq i32 %46, %48
  br i1 %.not35.7, label %50, label %49

49:                                               ; preds = %45
  store i32 %48, ptr getelementptr inbounds (i8, ptr @oldweaponsowned, i64 28), align 4, !tbaa !5
  br label %50

50:                                               ; preds = %49, %45
  %.1.7 = phi i32 [ 1, %49 ], [ %.1.6, %45 ]
  %51 = load i32, ptr getelementptr inbounds (i8, ptr @oldweaponsowned, i64 32), align 16, !tbaa !5
  %52 = getelementptr inbounds i8, ptr %4, i64 156
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %.not35.8 = icmp eq i32 %51, %53
  br i1 %.not35.8, label %54, label %.thread68

.thread68:                                        ; preds = %50
  store i32 %53, ptr getelementptr inbounds (i8, ptr @oldweaponsowned, i64 32), align 16, !tbaa !5
  br label %55

54:                                               ; preds = %50
  %.not25 = icmp eq i32 %.1.7, 0
  br i1 %.not25, label %.thread, label %55

55:                                               ; preds = %.thread68, %54
  store i32 8, ptr @ST_updateFaceWidget.priority, align 4, !tbaa !5
  store i32 70, ptr @st_facecount, align 4, !tbaa !5
  %56 = tail call i32 @ST_calcPainOffset()
  %57 = add nsw i32 %56, 6
  store i32 %57, ptr @st_faceindex, align 4, !tbaa !5
  %.pr37.pr.pre = load i32, ptr @ST_updateFaceWidget.priority, align 4, !tbaa !5
  br label %.thread

.thread:                                          ; preds = %8, %55, %54
  %.pr37.pr = phi i32 [ %1, %8 ], [ %.pr37.pr.pre, %55 ], [ %1, %54 ]
  %58 = icmp slt i32 %.pr37.pr, 8
  br i1 %58, label %59, label %.thread49

59:                                               ; preds = %.thread
  %60 = load ptr, ptr @plyr, align 8, !tbaa !9
  %61 = getelementptr inbounds i8, ptr %60, i64 232
  %62 = load i32, ptr %61, align 8, !tbaa !16
  %.not26 = icmp eq i32 %62, 0
  br i1 %.not26, label %105, label %63

63:                                               ; preds = %59
  %64 = getelementptr inbounds i8, ptr %60, i64 240
  %65 = load ptr, ptr %64, align 8, !tbaa !17
  %.not27 = icmp eq ptr %65, null
  br i1 %.not27, label %105, label %66

66:                                               ; preds = %63
  %67 = load ptr, ptr %60, align 8, !tbaa !18
  %.not28 = icmp eq ptr %65, %67
  br i1 %.not28, label %105, label %68

68:                                               ; preds = %66
  store i32 7, ptr @ST_updateFaceWidget.priority, align 4, !tbaa !5
  %69 = getelementptr inbounds i8, ptr %60, i64 36
  %70 = load i32, ptr %69, align 4, !tbaa !11
  %71 = load i32, ptr @st_oldhealth, align 4, !tbaa !5
  %72 = sub nsw i32 %70, %71
  %73 = icmp sgt i32 %72, 20
  br i1 %73, label %74, label %77

74:                                               ; preds = %68
  store i32 35, ptr @st_facecount, align 4, !tbaa !5
  %75 = tail call i32 @ST_calcPainOffset()
  %76 = add nsw i32 %75, 5
  br label %.sink.split

77:                                               ; preds = %68
  %78 = getelementptr inbounds i8, ptr %67, i64 24
  %79 = load i32, ptr %78, align 8, !tbaa !19
  %80 = getelementptr inbounds i8, ptr %67, i64 28
  %81 = load i32, ptr %80, align 4, !tbaa !23
  %82 = getelementptr inbounds i8, ptr %65, i64 24
  %83 = load i32, ptr %82, align 8, !tbaa !19
  %84 = getelementptr inbounds i8, ptr %65, i64 28
  %85 = load i32, ptr %84, align 4, !tbaa !23
  %86 = tail call i32 @R_PointToAngle2(i32 noundef %79, i32 noundef %81, i32 noundef %83, i32 noundef %85) #2
  %87 = load ptr, ptr @plyr, align 8, !tbaa !9
  %88 = load ptr, ptr %87, align 8, !tbaa !18
  %89 = getelementptr inbounds i8, ptr %88, i64 56
  %90 = load i32, ptr %89, align 8, !tbaa !24
  %91 = icmp ugt i32 %86, %90
  %92 = sub i32 %86, %90
  %93 = sub i32 %90, %86
  %.014 = select i1 %91, i32 %92, i32 %93
  store i32 35, ptr @st_facecount, align 4, !tbaa !5
  %94 = tail call i32 @ST_calcPainOffset()
  %95 = icmp ult i32 %.014, 536870912
  br i1 %95, label %96, label %98

96:                                               ; preds = %77
  %97 = add nsw i32 %94, 7
  br label %.sink.split

98:                                               ; preds = %77
  %99 = icmp ugt i32 %92, -2147483648
  %100 = icmp ult i32 %93, -2147483647
  %.116.in = select i1 %91, i1 %99, i1 %100
  br i1 %.116.in, label %101, label %103

101:                                              ; preds = %98
  %102 = add nsw i32 %94, 3
  br label %.sink.split

103:                                              ; preds = %98
  %104 = add nsw i32 %94, 4
  br label %.sink.split

.sink.split:                                      ; preds = %74, %101, %103, %96
  %.sink = phi i32 [ %97, %96 ], [ %104, %103 ], [ %102, %101 ], [ %76, %74 ]
  store i32 %.sink, ptr @st_faceindex, align 4, !tbaa !5
  br label %105

105:                                              ; preds = %.sink.split, %59, %63, %66
  %.pr40 = load i32, ptr @ST_updateFaceWidget.priority, align 4, !tbaa !5
  %106 = icmp slt i32 %.pr40, 7
  br i1 %106, label %107, label %.thread49

107:                                              ; preds = %105
  %108 = load ptr, ptr @plyr, align 8, !tbaa !9
  %109 = getelementptr inbounds i8, ptr %108, i64 232
  %110 = load i32, ptr %109, align 8, !tbaa !16
  %.not29 = icmp eq i32 %110, 0
  br i1 %.not29, label %.thread42, label %.thread42.sink.split

.thread42.sink.split:                             ; preds = %107
  %111 = getelementptr inbounds i8, ptr %108, i64 36
  %112 = load i32, ptr %111, align 4, !tbaa !11
  %113 = load i32, ptr @st_oldhealth, align 4, !tbaa !5
  %114 = sub nsw i32 %112, %113
  %115 = icmp sgt i32 %114, 20
  %. = select i1 %115, i32 7, i32 6
  %.75 = select i1 %115, i32 5, i32 7
  store i32 %., ptr @ST_updateFaceWidget.priority, align 4, !tbaa !5
  store i32 35, ptr @st_facecount, align 4, !tbaa !5
  %116 = tail call i32 @ST_calcPainOffset()
  %117 = add nsw i32 %116, %.75
  store i32 %117, ptr @st_faceindex, align 4, !tbaa !5
  br label %.thread42

.thread42:                                        ; preds = %.thread42.sink.split, %107
  %.pr44.pr.pr = load i32, ptr @ST_updateFaceWidget.priority, align 4, !tbaa !5
  %118 = icmp slt i32 %.pr44.pr.pr, 6
  br i1 %118, label %119, label %.thread49

119:                                              ; preds = %.thread42
  %120 = load ptr, ptr @plyr, align 8, !tbaa !9
  %121 = getelementptr inbounds i8, ptr %120, i64 192
  %122 = load i32, ptr %121, align 8, !tbaa !25
  %.not30 = icmp eq i32 %122, 0
  br i1 %.not30, label %132, label %123

123:                                              ; preds = %119
  %124 = load i32, ptr @ST_updateFaceWidget.lastattackdown, align 4, !tbaa !5
  %125 = icmp eq i32 %124, -1
  br i1 %125, label %126, label %127

126:                                              ; preds = %123
  store i32 70, ptr @ST_updateFaceWidget.lastattackdown, align 4, !tbaa !5
  br label %133

127:                                              ; preds = %123
  %128 = add nsw i32 %124, -1
  store i32 %128, ptr @ST_updateFaceWidget.lastattackdown, align 4, !tbaa !5
  %.not31 = icmp eq i32 %128, 0
  br i1 %.not31, label %129, label %133

129:                                              ; preds = %127
  store i32 5, ptr @ST_updateFaceWidget.priority, align 4, !tbaa !5
  %130 = tail call i32 @ST_calcPainOffset()
  %131 = add nsw i32 %130, 7
  store i32 %131, ptr @st_faceindex, align 4, !tbaa !5
  store i32 1, ptr @st_facecount, align 4, !tbaa !5
  store i32 1, ptr @ST_updateFaceWidget.lastattackdown, align 4, !tbaa !5
  %.pr47.pre = load i32, ptr @ST_updateFaceWidget.priority, align 4, !tbaa !5
  br label %133

132:                                              ; preds = %119
  store i32 -1, ptr @ST_updateFaceWidget.lastattackdown, align 4, !tbaa !5
  br label %133

133:                                              ; preds = %132, %127, %129, %126
  %.pr47 = phi i32 [ %.pr44.pr.pr, %132 ], [ %.pr44.pr.pr, %127 ], [ %.pr47.pre, %129 ], [ %.pr44.pr.pr, %126 ]
  %134 = icmp slt i32 %.pr47, 5
  br i1 %134, label %135, label %.thread49

135:                                              ; preds = %133
  %136 = load ptr, ptr @plyr, align 8, !tbaa !9
  %137 = getelementptr inbounds i8, ptr %136, i64 200
  %138 = load i32, ptr %137, align 8, !tbaa !26
  %139 = and i32 %138, 2
  %.not32 = icmp eq i32 %139, 0
  br i1 %.not32, label %140, label %.thread52

140:                                              ; preds = %135
  %141 = getelementptr inbounds i8, ptr %136, i64 48
  %142 = load i32, ptr %141, align 8, !tbaa !5
  %.not33 = icmp eq i32 %142, 0
  br i1 %.not33, label %.thread49, label %.thread52

.thread52:                                        ; preds = %135, %140
  store i32 4, ptr @ST_updateFaceWidget.priority, align 4, !tbaa !5
  store i32 40, ptr @st_faceindex, align 4, !tbaa !5
  br label %148

.thread49:                                        ; preds = %0, %.thread, %7, %105, %.thread42, %140, %133
  %.pr51.pr = load i32, ptr @st_facecount, align 4, !tbaa !5
  %.not34 = icmp eq i32 %.pr51.pr, 0
  br i1 %.not34, label %143, label %148

143:                                              ; preds = %.thread49
  %144 = tail call i32 @ST_calcPainOffset()
  %145 = load i32, ptr @st_randomnumber, align 4, !tbaa !5
  %146 = srem i32 %145, 3
  %147 = add nsw i32 %146, %144
  store i32 %147, ptr @st_faceindex, align 4, !tbaa !5
  store i32 0, ptr @ST_updateFaceWidget.priority, align 4, !tbaa !5
  br label %148

148:                                              ; preds = %.thread49.thread, %.thread52, %143, %.thread49
  %149 = phi i32 [ 1, %.thread49.thread ], [ 1, %.thread52 ], [ 17, %143 ], [ %.pr51.pr, %.thread49 ]
  %150 = add nsw i32 %149, -1
  store i32 %150, ptr @st_facecount, align 4, !tbaa !5
  ret void
}

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

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

!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, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 36}
!12 = !{!"player_s", !10, i64 0, !6, i64 8, !13, i64 12, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36, !6, i64 40, !6, i64 44, !7, i64 48, !7, i64 72, !6, i64 96, !7, i64 100, !6, i64 116, !6, i64 120, !7, i64 124, !7, i64 160, !7, i64 176, !6, i64 192, !6, i64 196, !6, i64 200, !6, i64 204, !6, i64 208, !6, i64 212, !6, i64 216, !10, i64 224, !6, i64 232, !6, i64 236, !10, i64 240, !6, i64 248, !6, i64 252, !6, i64 256, !7, i64 264, !6, i64 312}
!13 = !{!"", !7, i64 0, !7, i64 1, !14, i64 2, !14, i64 4, !7, i64 6, !7, i64 7}
!14 = !{!"short", !7, i64 0}
!15 = !{!12, !6, i64 236}
!16 = !{!12, !6, i64 232}
!17 = !{!12, !10, i64 240}
!18 = !{!12, !10, i64 0}
!19 = !{!20, !6, i64 24}
!20 = !{!"mobj_s", !21, i64 0, !6, i64 24, !6, i64 28, !6, i64 32, !10, i64 40, !10, i64 48, !6, i64 56, !6, i64 60, !6, i64 64, !10, i64 72, !10, i64 80, !10, 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, !10, i64 136, !6, i64 144, !10, i64 152, !6, i64 160, !6, i64 164, !6, i64 168, !6, i64 172, !10, i64 176, !6, i64 184, !6, i64 188, !10, i64 192, !6, i64 200, !22, i64 204, !10, i64 216}
!21 = !{!"thinker_s", !10, i64 0, !10, i64 8, !7, i64 16}
!22 = !{!"", !14, i64 0, !14, i64 2, !14, i64 4, !14, i64 6, !14, i64 8}
!23 = !{!20, !6, i64 28}
!24 = !{!20, !6, i64 56}
!25 = !{!12, !6, i64 192}
!26 = !{!12, !6, i64 200}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass