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

; 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.state_t = type { i32, i64, i64, %union.actionf_t, i32, i64, i64 }
%union.actionf_t = type { ptr }
%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 }
%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 }
%struct.mapthing_t = type { i16, i16, i16, i16, i16 }
%struct.subsector_s = type { ptr, i16, i16 }
%struct.sector_t = type { i32, i32, i16, i16, i16, i16, i16, i32, ptr, [4 x i32], %struct.degenmobj_t, i32, ptr, ptr, i32, ptr }
%struct.degenmobj_t = type { %struct.thinker_s, i32, i32, i32 }

@states = external global [967 x %struct.state_t], align 16
@mobjinfo = external global [137 x %struct.mobjinfo_t], align 16
@gameskill = external 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

declare i32 @P_Random() #1

; Function Attrs: nounwind uwtable
define dso_local ptr @P_SpawnMobj(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) #2 {
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  store i32 %0, ptr %5, align 4, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !5
  store i32 %3, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %12 = call ptr @Z_Malloc(i32 noundef 224, i32 noundef 50, ptr noundef null)
  store ptr %12, ptr %9, align 8, !tbaa !9
  %13 = load ptr, ptr %9, align 8, !tbaa !9
  call void @llvm.memset.p0.i64(ptr align 8 %13, i8 0, i64 224, i1 false)
  %14 = load i32, ptr %8, align 4, !tbaa !5
  %15 = zext i32 %14 to i64
  %16 = getelementptr inbounds [137 x %struct.mobjinfo_t], ptr @mobjinfo, i64 0, i64 %15
  store ptr %16, ptr %11, align 8, !tbaa !9
  %17 = load i32, ptr %8, align 4, !tbaa !5
  %18 = load ptr, ptr %9, align 8, !tbaa !9
  %19 = getelementptr inbounds %struct.mobj_s, ptr %18, i32 0, i32 20
  store i32 %17, ptr %19, align 8, !tbaa !11
  %20 = load ptr, ptr %11, align 8, !tbaa !9
  %21 = load ptr, ptr %9, align 8, !tbaa !9
  %22 = getelementptr inbounds %struct.mobj_s, ptr %21, i32 0, i32 21
  store ptr %20, ptr %22, align 8, !tbaa !16
  %23 = load i32, ptr %5, align 4, !tbaa !5
  %24 = load ptr, ptr %9, align 8, !tbaa !9
  %25 = getelementptr inbounds %struct.mobj_s, ptr %24, i32 0, i32 1
  store i32 %23, ptr %25, align 8, !tbaa !17
  %26 = load i32, ptr %6, align 4, !tbaa !5
  %27 = load ptr, ptr %9, align 8, !tbaa !9
  %28 = getelementptr inbounds %struct.mobj_s, ptr %27, i32 0, i32 2
  store i32 %26, ptr %28, align 4, !tbaa !18
  %29 = load ptr, ptr %11, align 8, !tbaa !9
  %30 = getelementptr inbounds %struct.mobjinfo_t, ptr %29, i32 0, i32 16
  %31 = load i32, ptr %30, align 4, !tbaa !19
  %32 = load ptr, ptr %9, align 8, !tbaa !9
  %33 = getelementptr inbounds %struct.mobj_s, ptr %32, i32 0, i32 14
  store i32 %31, ptr %33, align 8, !tbaa !21
  %34 = load ptr, ptr %11, align 8, !tbaa !9
  %35 = getelementptr inbounds %struct.mobjinfo_t, ptr %34, i32 0, i32 17
  %36 = load i32, ptr %35, align 4, !tbaa !22
  %37 = load ptr, ptr %9, align 8, !tbaa !9
  %38 = getelementptr inbounds %struct.mobj_s, ptr %37, i32 0, i32 15
  store i32 %36, ptr %38, align 4, !tbaa !23
  %39 = load ptr, ptr %11, align 8, !tbaa !9
  %40 = getelementptr inbounds %struct.mobjinfo_t, ptr %39, i32 0, i32 21
  %41 = load i32, ptr %40, align 4, !tbaa !24
  %42 = load ptr, ptr %9, align 8, !tbaa !9
  %43 = getelementptr inbounds %struct.mobj_s, ptr %42, i32 0, i32 24
  store i32 %41, ptr %43, align 8, !tbaa !25
  %44 = load ptr, ptr %11, align 8, !tbaa !9
  %45 = getelementptr inbounds %struct.mobjinfo_t, ptr %44, i32 0, i32 2
  %46 = load i32, ptr %45, align 4, !tbaa !26
  %47 = load ptr, ptr %9, align 8, !tbaa !9
  %48 = getelementptr inbounds %struct.mobj_s, ptr %47, i32 0, i32 25
  store i32 %46, ptr %48, align 4, !tbaa !27
  %49 = load i32, ptr @gameskill, align 4, !tbaa !5
  %50 = icmp ne i32 %49, 4
  br i1 %50, label %51, label %57

51:                                               ; preds = %4
  %52 = load ptr, ptr %11, align 8, !tbaa !9
  %53 = getelementptr inbounds %struct.mobjinfo_t, ptr %52, i32 0, i32 5
  %54 = load i32, ptr %53, align 4, !tbaa !28
  %55 = load ptr, ptr %9, align 8, !tbaa !9
  %56 = getelementptr inbounds %struct.mobj_s, ptr %55, i32 0, i32 29
  store i32 %54, ptr %56, align 8, !tbaa !29
  br label %57

57:                                               ; preds = %51, %4
  %58 = call i32 @P_Random()
  %59 = srem i32 %58, 4
  %60 = load ptr, ptr %9, align 8, !tbaa !9
  %61 = getelementptr inbounds %struct.mobj_s, ptr %60, i32 0, i32 32
  store i32 %59, ptr %61, align 8, !tbaa !30
  %62 = load ptr, ptr %11, align 8, !tbaa !9
  %63 = getelementptr inbounds %struct.mobjinfo_t, ptr %62, i32 0, i32 1
  %64 = load i32, ptr %63, align 4, !tbaa !31
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [967 x %struct.state_t], ptr @states, i64 0, i64 %65
  store ptr %66, ptr %10, align 8, !tbaa !9
  %67 = load ptr, ptr %10, align 8, !tbaa !9
  %68 = load ptr, ptr %9, align 8, !tbaa !9
  %69 = getelementptr inbounds %struct.mobj_s, ptr %68, i32 0, i32 23
  store ptr %67, ptr %69, align 8, !tbaa !32
  %70 = load ptr, ptr %10, align 8, !tbaa !9
  %71 = getelementptr inbounds %struct.state_t, ptr %70, i32 0, i32 2
  %72 = load i64, ptr %71, align 8, !tbaa !33
  %73 = trunc i64 %72 to i32
  %74 = load ptr, ptr %9, align 8, !tbaa !9
  %75 = getelementptr inbounds %struct.mobj_s, ptr %74, i32 0, i32 22
  store i32 %73, ptr %75, align 8, !tbaa !36
  %76 = load ptr, ptr %10, align 8, !tbaa !9
  %77 = getelementptr inbounds %struct.state_t, ptr %76, i32 0, i32 0
  %78 = load i32, ptr %77, align 8, !tbaa !37
  %79 = load ptr, ptr %9, align 8, !tbaa !9
  %80 = getelementptr inbounds %struct.mobj_s, ptr %79, i32 0, i32 7
  store i32 %78, ptr %80, align 4, !tbaa !38
  %81 = load ptr, ptr %10, align 8, !tbaa !9
  %82 = getelementptr inbounds %struct.state_t, ptr %81, i32 0, i32 1
  %83 = load i64, ptr %82, align 8, !tbaa !39
  %84 = trunc i64 %83 to i32
  %85 = load ptr, ptr %9, align 8, !tbaa !9
  %86 = getelementptr inbounds %struct.mobj_s, ptr %85, i32 0, i32 8
  store i32 %84, ptr %86, align 8, !tbaa !40
  %87 = load ptr, ptr %9, align 8, !tbaa !9
  call void @P_SetThingPosition(ptr noundef %87)
  %88 = load ptr, ptr %9, align 8, !tbaa !9
  %89 = getelementptr inbounds %struct.mobj_s, ptr %88, i32 0, i32 11
  %90 = load ptr, ptr %89, align 8, !tbaa !41
  %91 = getelementptr inbounds %struct.subsector_s, ptr %90, i32 0, i32 0
  %92 = load ptr, ptr %91, align 8, !tbaa !42
  %93 = getelementptr inbounds %struct.sector_t, ptr %92, i32 0, i32 0
  %94 = load i32, ptr %93, align 8, !tbaa !44
  %95 = load ptr, ptr %9, align 8, !tbaa !9
  %96 = getelementptr inbounds %struct.mobj_s, ptr %95, i32 0, i32 12
  store i32 %94, ptr %96, align 8, !tbaa !47
  %97 = load ptr, ptr %9, align 8, !tbaa !9
  %98 = getelementptr inbounds %struct.mobj_s, ptr %97, i32 0, i32 11
  %99 = load ptr, ptr %98, align 8, !tbaa !41
  %100 = getelementptr inbounds %struct.subsector_s, ptr %99, i32 0, i32 0
  %101 = load ptr, ptr %100, align 8, !tbaa !42
  %102 = getelementptr inbounds %struct.sector_t, ptr %101, i32 0, i32 1
  %103 = load i32, ptr %102, align 4, !tbaa !48
  %104 = load ptr, ptr %9, align 8, !tbaa !9
  %105 = getelementptr inbounds %struct.mobj_s, ptr %104, i32 0, i32 13
  store i32 %103, ptr %105, align 4, !tbaa !49
  %106 = load i32, ptr %7, align 4, !tbaa !5
  %107 = icmp eq i32 %106, -2147483648
  br i1 %107, label %108, label %114

108:                                              ; preds = %57
  %109 = load ptr, ptr %9, align 8, !tbaa !9
  %110 = getelementptr inbounds %struct.mobj_s, ptr %109, i32 0, i32 12
  %111 = load i32, ptr %110, align 8, !tbaa !47
  %112 = load ptr, ptr %9, align 8, !tbaa !9
  %113 = getelementptr inbounds %struct.mobj_s, ptr %112, i32 0, i32 3
  store i32 %111, ptr %113, align 8, !tbaa !50
  br label %134

114:                                              ; preds = %57
  %115 = load i32, ptr %7, align 4, !tbaa !5
  %116 = icmp eq i32 %115, 2147483647
  br i1 %116, label %117, label %129

117:                                              ; preds = %114
  %118 = load ptr, ptr %9, align 8, !tbaa !9
  %119 = getelementptr inbounds %struct.mobj_s, ptr %118, i32 0, i32 13
  %120 = load i32, ptr %119, align 4, !tbaa !49
  %121 = load ptr, ptr %9, align 8, !tbaa !9
  %122 = getelementptr inbounds %struct.mobj_s, ptr %121, i32 0, i32 21
  %123 = load ptr, ptr %122, align 8, !tbaa !16
  %124 = getelementptr inbounds %struct.mobjinfo_t, ptr %123, i32 0, i32 17
  %125 = load i32, ptr %124, align 4, !tbaa !22
  %126 = sub nsw i32 %120, %125
  %127 = load ptr, ptr %9, align 8, !tbaa !9
  %128 = getelementptr inbounds %struct.mobj_s, ptr %127, i32 0, i32 3
  store i32 %126, ptr %128, align 8, !tbaa !50
  br label %133

129:                                              ; preds = %114
  %130 = load i32, ptr %7, align 4, !tbaa !5
  %131 = load ptr, ptr %9, align 8, !tbaa !9
  %132 = getelementptr inbounds %struct.mobj_s, ptr %131, i32 0, i32 3
  store i32 %130, ptr %132, align 8, !tbaa !50
  br label %133

133:                                              ; preds = %129, %117
  br label %134

134:                                              ; preds = %133, %108
  %135 = load ptr, ptr %9, align 8, !tbaa !9
  %136 = getelementptr inbounds %struct.mobj_s, ptr %135, i32 0, i32 0
  %137 = getelementptr inbounds %struct.thinker_s, ptr %136, i32 0, i32 2
  store ptr @P_MobjThinker, ptr %137, align 8, !tbaa !51
  %138 = load ptr, ptr %9, align 8, !tbaa !9
  %139 = getelementptr inbounds %struct.mobj_s, ptr %138, i32 0, i32 0
  call void @P_AddThinker(ptr noundef %139)
  %140 = load ptr, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  ret ptr %140
}

; Function Attrs: nounwind uwtable
declare dso_local void @P_MobjThinker(ptr noundef) #2

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

declare void @P_SetThingPosition(ptr noundef) #1

declare void @P_AddThinker(ptr noundef) #1

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 128}
!12 = !{!"mobj_s", !13, 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, !14, i64 204, !10, i64 216}
!13 = !{!"thinker_s", !10, i64 0, !10, 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 136}
!17 = !{!12, !6, i64 24}
!18 = !{!12, !6, i64 28}
!19 = !{!20, !6, i64 64}
!20 = !{!"", !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}
!21 = !{!12, !6, i64 104}
!22 = !{!20, !6, i64 68}
!23 = !{!12, !6, i64 108}
!24 = !{!20, !6, i64 84}
!25 = !{!12, !6, i64 160}
!26 = !{!20, !6, i64 8}
!27 = !{!12, !6, i64 164}
!28 = !{!20, !6, i64 20}
!29 = !{!12, !6, i64 184}
!30 = !{!12, !6, i64 200}
!31 = !{!20, !6, i64 4}
!32 = !{!12, !10, i64 152}
!33 = !{!34, !35, i64 16}
!34 = !{!"", !6, i64 0, !35, i64 8, !35, i64 16, !7, i64 24, !6, i64 32, !35, i64 40, !35, i64 48}
!35 = !{!"long", !7, i64 0}
!36 = !{!12, !6, i64 144}
!37 = !{!34, !6, i64 0}
!38 = !{!12, !6, i64 60}
!39 = !{!34, !35, i64 8}
!40 = !{!12, !6, i64 64}
!41 = !{!12, !10, i64 88}
!42 = !{!43, !10, i64 0}
!43 = !{!"subsector_s", !10, i64 0, !15, i64 8, !15, i64 10}
!44 = !{!45, !6, i64 0}
!45 = !{!"", !6, i64 0, !6, i64 4, !15, i64 8, !15, i64 10, !15, i64 12, !15, i64 14, !15, i64 16, !6, i64 20, !10, i64 24, !7, i64 32, !46, i64 48, !6, i64 88, !10, i64 96, !10, i64 104, !6, i64 112, !10, i64 120}
!46 = !{!"", !13, i64 0, !6, i64 24, !6, i64 28, !6, i64 32}
!47 = !{!12, !6, i64 96}
!48 = !{!45, !6, i64 4}
!49 = !{!12, !6, i64 100}
!50 = !{!12, !6, i64 32}
!51 = !{!7, !7, i64 0}


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

%struct.state_t = type { i32, i64, i64, %union.actionf_t, i32, i64, i64 }
%union.actionf_t = type { ptr }
%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 }

@states = external global [967 x %struct.state_t], align 16
@mobjinfo = external global [137 x %struct.mobjinfo_t], align 16
@gameskill = external local_unnamed_addr global i32, align 4

declare i32 @P_Random() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @P_SpawnMobj(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #1 {
  %5 = tail call ptr @Z_Malloc(i32 noundef 224, i32 noundef 50, ptr noundef null) #3
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(224) %5, i8 0, i64 224, i1 false)
  %6 = zext i32 %3 to i64
  %7 = getelementptr inbounds [137 x %struct.mobjinfo_t], ptr @mobjinfo, i64 0, i64 %6
  %8 = getelementptr inbounds i8, ptr %5, i64 128
  store i32 %3, ptr %8, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %5, i64 136
  store ptr %7, ptr %9, align 8, !tbaa !14
  %10 = getelementptr inbounds i8, ptr %5, i64 24
  store i32 %0, ptr %10, align 8, !tbaa !15
  %11 = getelementptr inbounds i8, ptr %5, i64 28
  store i32 %1, ptr %11, align 4, !tbaa !16
  %12 = getelementptr inbounds i8, ptr %7, i64 64
  %13 = getelementptr inbounds i8, ptr %5, i64 104
  %14 = load <2 x i32>, ptr %12, align 4, !tbaa !17
  store <2 x i32> %14, ptr %13, align 8, !tbaa !17
  %15 = getelementptr inbounds i8, ptr %7, i64 84
  %16 = load i32, ptr %15, align 4, !tbaa !18
  %17 = getelementptr inbounds i8, ptr %5, i64 160
  store i32 %16, ptr %17, align 8, !tbaa !20
  %18 = getelementptr inbounds i8, ptr %7, i64 8
  %19 = load i32, ptr %18, align 4, !tbaa !21
  %20 = getelementptr inbounds i8, ptr %5, i64 164
  store i32 %19, ptr %20, align 4, !tbaa !22
  %21 = load i32, ptr @gameskill, align 4, !tbaa !17
  %.not = icmp eq i32 %21, 4
  br i1 %.not, label %26, label %22

22:                                               ; preds = %4
  %23 = getelementptr inbounds i8, ptr %7, i64 20
  %24 = load i32, ptr %23, align 4, !tbaa !23
  %25 = getelementptr inbounds i8, ptr %5, i64 184
  store i32 %24, ptr %25, align 8, !tbaa !24
  br label %26

26:                                               ; preds = %22, %4
  %27 = tail call i32 @P_Random() #3
  %28 = srem i32 %27, 4
  %29 = getelementptr inbounds i8, ptr %5, i64 200
  store i32 %28, ptr %29, align 8, !tbaa !25
  %30 = getelementptr inbounds i8, ptr %7, i64 4
  %31 = load i32, ptr %30, align 4, !tbaa !26
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [967 x %struct.state_t], ptr @states, i64 0, i64 %32
  %34 = getelementptr inbounds i8, ptr %5, i64 152
  store ptr %33, ptr %34, align 8, !tbaa !27
  %35 = getelementptr inbounds i8, ptr %33, i64 16
  %36 = load i64, ptr %35, align 8, !tbaa !28
  %37 = trunc i64 %36 to i32
  %38 = getelementptr inbounds i8, ptr %5, i64 144
  store i32 %37, ptr %38, align 8, !tbaa !31
  %39 = load i32, ptr %33, align 8, !tbaa !32
  %40 = getelementptr inbounds i8, ptr %5, i64 60
  store i32 %39, ptr %40, align 4, !tbaa !33
  %41 = getelementptr inbounds i8, ptr %33, i64 8
  %42 = load i64, ptr %41, align 8, !tbaa !34
  %43 = trunc i64 %42 to i32
  %44 = getelementptr inbounds i8, ptr %5, i64 64
  store i32 %43, ptr %44, align 8, !tbaa !35
  tail call void @P_SetThingPosition(ptr noundef nonnull %5) #3
  %45 = getelementptr inbounds i8, ptr %5, i64 88
  %46 = load ptr, ptr %45, align 8, !tbaa !36
  %47 = load ptr, ptr %46, align 8, !tbaa !37
  %48 = load i32, ptr %47, align 8, !tbaa !39
  %49 = getelementptr inbounds i8, ptr %5, i64 96
  store i32 %48, ptr %49, align 8, !tbaa !42
  %50 = getelementptr inbounds i8, ptr %47, i64 4
  %51 = load i32, ptr %50, align 4, !tbaa !43
  %52 = getelementptr inbounds i8, ptr %5, i64 100
  store i32 %51, ptr %52, align 4, !tbaa !44
  switch i32 %2, label %58 [
    i32 -2147483648, label %59
    i32 2147483647, label %53
  ]

53:                                               ; preds = %26
  %54 = load ptr, ptr %9, align 8, !tbaa !14
  %55 = getelementptr inbounds i8, ptr %54, i64 68
  %56 = load i32, ptr %55, align 4, !tbaa !45
  %57 = sub nsw i32 %51, %56
  br label %59

58:                                               ; preds = %26
  br label %59

59:                                               ; preds = %26, %53, %58
  %.sink = phi i32 [ %57, %53 ], [ %2, %58 ], [ %48, %26 ]
  %60 = getelementptr inbounds i8, ptr %5, i64 32
  store i32 %.sink, ptr %60, align 8, !tbaa !46
  %61 = getelementptr inbounds i8, ptr %5, i64 16
  store ptr @P_MobjThinker, ptr %61, align 8, !tbaa !47
  tail call void @P_AddThinker(ptr noundef nonnull %5) #3
  ret ptr %5
}

; Function Attrs: nounwind uwtable
declare dso_local void @P_MobjThinker(ptr noundef) #1

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

declare void @P_SetThingPosition(ptr noundef) local_unnamed_addr #0

declare void @P_AddThinker(ptr noundef) local_unnamed_addr #0

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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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, !11, i64 128}
!6 = !{!"mobj_s", !7, i64 0, !11, i64 24, !11, i64 28, !11, i64 32, !8, i64 40, !8, i64 48, !11, i64 56, !11, i64 60, !11, i64 64, !8, i64 72, !8, i64 80, !8, i64 88, !11, i64 96, !11, i64 100, !11, i64 104, !11, i64 108, !11, i64 112, !11, i64 116, !11, i64 120, !11, i64 124, !11, i64 128, !8, i64 136, !11, i64 144, !8, i64 152, !11, i64 160, !11, i64 164, !11, i64 168, !11, i64 172, !8, i64 176, !11, i64 184, !11, i64 188, !8, i64 192, !11, i64 200, !12, i64 204, !8, i64 216}
!7 = !{!"thinker_s", !8, i64 0, !8, i64 8, !9, i64 16}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!"", !13, i64 0, !13, i64 2, !13, i64 4, !13, i64 6, !13, i64 8}
!13 = !{!"short", !9, i64 0}
!14 = !{!6, !8, i64 136}
!15 = !{!6, !11, i64 24}
!16 = !{!6, !11, i64 28}
!17 = !{!11, !11, i64 0}
!18 = !{!19, !11, i64 84}
!19 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !11, i64 48, !11, i64 52, !11, i64 56, !11, i64 60, !11, i64 64, !11, i64 68, !11, i64 72, !11, i64 76, !11, i64 80, !11, i64 84, !11, i64 88}
!20 = !{!6, !11, i64 160}
!21 = !{!19, !11, i64 8}
!22 = !{!6, !11, i64 164}
!23 = !{!19, !11, i64 20}
!24 = !{!6, !11, i64 184}
!25 = !{!6, !11, i64 200}
!26 = !{!19, !11, i64 4}
!27 = !{!6, !8, i64 152}
!28 = !{!29, !30, i64 16}
!29 = !{!"", !11, i64 0, !30, i64 8, !30, i64 16, !9, i64 24, !11, i64 32, !30, i64 40, !30, i64 48}
!30 = !{!"long", !9, i64 0}
!31 = !{!6, !11, i64 144}
!32 = !{!29, !11, i64 0}
!33 = !{!6, !11, i64 60}
!34 = !{!29, !30, i64 8}
!35 = !{!6, !11, i64 64}
!36 = !{!6, !8, i64 88}
!37 = !{!38, !8, i64 0}
!38 = !{!"subsector_s", !8, i64 0, !13, i64 8, !13, i64 10}
!39 = !{!40, !11, i64 0}
!40 = !{!"", !11, i64 0, !11, i64 4, !13, i64 8, !13, i64 10, !13, i64 12, !13, i64 14, !13, i64 16, !11, i64 20, !8, i64 24, !9, i64 32, !41, i64 48, !11, i64 88, !8, i64 96, !8, i64 104, !11, i64 112, !8, i64 120}
!41 = !{!"", !7, i64 0, !11, i64 24, !11, i64 28, !11, i64 32}
!42 = !{!6, !11, i64 96}
!43 = !{!40, !11, i64 4}
!44 = !{!6, !11, i64 100}
!45 = !{!19, !11, i64 68}
!46 = !{!6, !11, i64 32}
!47 = !{!9, !9, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass