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

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

@numsectors = external global i32, align 4
@sectors = external global ptr, align 8
@thinkercap = external global %struct.thinker_s, align 8
@finecosine = external global ptr, align 8
@finesine = external global [10240 x i32], align 16

; Function Attrs: nounwind uwtable
define dso_local i32 @EV_Teleport(ptr noundef %0, i32 noundef %1, ptr noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.mobj_s, ptr %19, i32 0, i32 24
  %21 = load i32, ptr %20, align 8, !tbaa !11
  %22 = and i32 %21, 65536
  %23 = icmp ne i32 %22, 0
  br i1 %23, label %24, label %25

24:                                               ; preds = %3
  store i32 0, ptr %4, align 4
  store i32 1, ptr %18, align 4
  br label %190

25:                                               ; preds = %3
  %26 = load i32, ptr %6, align 4, !tbaa !9
  %27 = icmp eq i32 %26, 1
  br i1 %27, label %28, label %29

28:                                               ; preds = %25
  store i32 0, ptr %4, align 4
  store i32 1, ptr %18, align 4
  br label %190

29:                                               ; preds = %25
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.line_s, ptr %30, i32 0, i32 6
  %32 = load i16, ptr %31, align 4, !tbaa !16
  %33 = sext i16 %32 to i32
  store i32 %33, ptr %9, align 4, !tbaa !9
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %34

34:                                               ; preds = %186, %29
  %35 = load i32, ptr %8, align 4, !tbaa !9
  %36 = load i32, ptr @numsectors, align 4, !tbaa !9
  %37 = icmp slt i32 %35, %36
  br i1 %37, label %38, label %189

38:                                               ; preds = %34
  %39 = load ptr, ptr @sectors, align 8, !tbaa !5
  %40 = load i32, ptr %8, align 4, !tbaa !9
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds %struct.sector_t, ptr %39, i64 %41
  %43 = getelementptr inbounds %struct.sector_t, ptr %42, i32 0, i32 6
  %44 = load i16, ptr %43, align 8, !tbaa !18
  %45 = sext i16 %44 to i32
  %46 = load i32, ptr %9, align 4, !tbaa !9
  %47 = icmp eq i32 %45, %46
  br i1 %47, label %48, label %185

48:                                               ; preds = %38
  %49 = load ptr, ptr getelementptr inbounds (%struct.thinker_s, ptr @thinkercap, i32 0, i32 1), align 8, !tbaa !21
  store ptr %49, ptr %13, align 8, !tbaa !5
  %50 = load ptr, ptr getelementptr inbounds (%struct.thinker_s, ptr @thinkercap, i32 0, i32 1), align 8, !tbaa !21
  store ptr %50, ptr %13, align 8, !tbaa !5
  br label %51

51:                                               ; preds = %180, %48
  %52 = load ptr, ptr %13, align 8, !tbaa !5
  %53 = icmp ne ptr %52, @thinkercap
  br i1 %53, label %54, label %184

54:                                               ; preds = %51
  %55 = load ptr, ptr %13, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.thinker_s, ptr %55, i32 0, i32 2
  %57 = load ptr, ptr %56, align 8, !tbaa !22
  %58 = icmp ne ptr %57, @P_MobjThinker
  br i1 %58, label %59, label %60

59:                                               ; preds = %54
  br label %180

60:                                               ; preds = %54
  %61 = load ptr, ptr %13, align 8, !tbaa !5
  store ptr %61, ptr %10, align 8, !tbaa !5
  %62 = load ptr, ptr %10, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.mobj_s, ptr %62, i32 0, i32 20
  %64 = load i32, ptr %63, align 8, !tbaa !23
  %65 = icmp ne i32 %64, 41
  br i1 %65, label %66, label %67

66:                                               ; preds = %60
  br label %180

67:                                               ; preds = %60
  %68 = load ptr, ptr %10, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.mobj_s, ptr %68, i32 0, i32 11
  %70 = load ptr, ptr %69, align 8, !tbaa !24
  %71 = getelementptr inbounds %struct.subsector_s, ptr %70, i32 0, i32 0
  %72 = load ptr, ptr %71, align 8, !tbaa !25
  store ptr %72, ptr %14, align 8, !tbaa !5
  %73 = load ptr, ptr %14, align 8, !tbaa !5
  %74 = load ptr, ptr @sectors, align 8, !tbaa !5
  %75 = ptrtoint ptr %73 to i64
  %76 = ptrtoint ptr %74 to i64
  %77 = sub i64 %75, %76
  %78 = sdiv exact i64 %77, 128
  %79 = load i32, ptr %8, align 4, !tbaa !9
  %80 = sext i32 %79 to i64
  %81 = icmp ne i64 %78, %80
  br i1 %81, label %82, label %83

82:                                               ; preds = %67
  br label %180

83:                                               ; preds = %67
  %84 = load ptr, ptr %7, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.mobj_s, ptr %84, i32 0, i32 1
  %86 = load i32, ptr %85, align 8, !tbaa !27
  store i32 %86, ptr %15, align 4, !tbaa !9
  %87 = load ptr, ptr %7, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.mobj_s, ptr %87, i32 0, i32 2
  %89 = load i32, ptr %88, align 4, !tbaa !28
  store i32 %89, ptr %16, align 4, !tbaa !9
  %90 = load ptr, ptr %7, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.mobj_s, ptr %90, i32 0, i32 3
  %92 = load i32, ptr %91, align 8, !tbaa !29
  store i32 %92, ptr %17, align 4, !tbaa !9
  %93 = load ptr, ptr %7, align 8, !tbaa !5
  %94 = load ptr, ptr %10, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.mobj_s, ptr %94, i32 0, i32 1
  %96 = load i32, ptr %95, align 8, !tbaa !27
  %97 = load ptr, ptr %10, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.mobj_s, ptr %97, i32 0, i32 2
  %99 = load i32, ptr %98, align 4, !tbaa !28
  %100 = call i32 @P_TeleportMove(ptr noundef %93, i32 noundef %96, i32 noundef %99)
  %101 = icmp ne i32 %100, 0
  br i1 %101, label %103, label %102

102:                                              ; preds = %83
  store i32 0, ptr %4, align 4
  store i32 1, ptr %18, align 4
  br label %190

103:                                              ; preds = %83
  %104 = load ptr, ptr %7, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.mobj_s, ptr %104, i32 0, i32 12
  %106 = load i32, ptr %105, align 8, !tbaa !30
  %107 = load ptr, ptr %7, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.mobj_s, ptr %107, i32 0, i32 3
  store i32 %106, ptr %108, align 8, !tbaa !29
  %109 = load ptr, ptr %7, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct.mobj_s, ptr %109, i32 0, i32 31
  %111 = load ptr, ptr %110, align 8, !tbaa !31
  %112 = icmp ne ptr %111, null
  br i1 %112, label %113, label %127

113:                                              ; preds = %103
  %114 = load ptr, ptr %7, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.mobj_s, ptr %114, i32 0, i32 3
  %116 = load i32, ptr %115, align 8, !tbaa !29
  %117 = load ptr, ptr %7, align 8, !tbaa !5
  %118 = getelementptr inbounds %struct.mobj_s, ptr %117, i32 0, i32 31
  %119 = load ptr, ptr %118, align 8, !tbaa !31
  %120 = getelementptr inbounds %struct.player_s, ptr %119, i32 0, i32 4
  %121 = load i32, ptr %120, align 8, !tbaa !32
  %122 = add nsw i32 %116, %121
  %123 = load ptr, ptr %7, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.mobj_s, ptr %123, i32 0, i32 31
  %125 = load ptr, ptr %124, align 8, !tbaa !31
  %126 = getelementptr inbounds %struct.player_s, ptr %125, i32 0, i32 3
  store i32 %122, ptr %126, align 4, !tbaa !35
  br label %127

127:                                              ; preds = %113, %103
  %128 = load i32, ptr %15, align 4, !tbaa !9
  %129 = load i32, ptr %16, align 4, !tbaa !9
  %130 = load i32, ptr %17, align 4, !tbaa !9
  %131 = call ptr @P_SpawnMobj(i32 noundef %128, i32 noundef %129, i32 noundef %130, i32 noundef 39)
  store ptr %131, ptr %11, align 8, !tbaa !5
  %132 = load ptr, ptr %11, align 8, !tbaa !5
  call void @S_StartSound(ptr noundef %132, i32 noundef 35)
  %133 = load ptr, ptr %10, align 8, !tbaa !5
  %134 = getelementptr inbounds %struct.mobj_s, ptr %133, i32 0, i32 6
  %135 = load i32, ptr %134, align 8, !tbaa !36
  %136 = lshr i32 %135, 19
  store i32 %136, ptr %12, align 4, !tbaa !9
  %137 = load ptr, ptr %10, align 8, !tbaa !5
  %138 = getelementptr inbounds %struct.mobj_s, ptr %137, i32 0, i32 1
  %139 = load i32, ptr %138, align 8, !tbaa !27
  %140 = load ptr, ptr @finecosine, align 8, !tbaa !5
  %141 = load i32, ptr %12, align 4, !tbaa !9
  %142 = zext i32 %141 to i64
  %143 = getelementptr inbounds i32, ptr %140, i64 %142
  %144 = load i32, ptr %143, align 4, !tbaa !9
  %145 = mul nsw i32 20, %144
  %146 = add nsw i32 %139, %145
  %147 = load ptr, ptr %10, align 8, !tbaa !5
  %148 = getelementptr inbounds %struct.mobj_s, ptr %147, i32 0, i32 2
  %149 = load i32, ptr %148, align 4, !tbaa !28
  %150 = load i32, ptr %12, align 4, !tbaa !9
  %151 = zext i32 %150 to i64
  %152 = getelementptr inbounds [10240 x i32], ptr @finesine, i64 0, i64 %151
  %153 = load i32, ptr %152, align 4, !tbaa !9
  %154 = mul nsw i32 20, %153
  %155 = add nsw i32 %149, %154
  %156 = load ptr, ptr %7, align 8, !tbaa !5
  %157 = getelementptr inbounds %struct.mobj_s, ptr %156, i32 0, i32 3
  %158 = load i32, ptr %157, align 8, !tbaa !29
  %159 = call ptr @P_SpawnMobj(i32 noundef %146, i32 noundef %155, i32 noundef %158, i32 noundef 39)
  store ptr %159, ptr %11, align 8, !tbaa !5
  %160 = load ptr, ptr %11, align 8, !tbaa !5
  call void @S_StartSound(ptr noundef %160, i32 noundef 35)
  %161 = load ptr, ptr %7, align 8, !tbaa !5
  %162 = getelementptr inbounds %struct.mobj_s, ptr %161, i32 0, i32 31
  %163 = load ptr, ptr %162, align 8, !tbaa !31
  %164 = icmp ne ptr %163, null
  br i1 %164, label %165, label %168

165:                                              ; preds = %127
  %166 = load ptr, ptr %7, align 8, !tbaa !5
  %167 = getelementptr inbounds %struct.mobj_s, ptr %166, i32 0, i32 29
  store i32 18, ptr %167, align 8, !tbaa !37
  br label %168

168:                                              ; preds = %165, %127
  %169 = load ptr, ptr %10, align 8, !tbaa !5
  %170 = getelementptr inbounds %struct.mobj_s, ptr %169, i32 0, i32 6
  %171 = load i32, ptr %170, align 8, !tbaa !36
  %172 = load ptr, ptr %7, align 8, !tbaa !5
  %173 = getelementptr inbounds %struct.mobj_s, ptr %172, i32 0, i32 6
  store i32 %171, ptr %173, align 8, !tbaa !36
  %174 = load ptr, ptr %7, align 8, !tbaa !5
  %175 = getelementptr inbounds %struct.mobj_s, ptr %174, i32 0, i32 18
  store i32 0, ptr %175, align 8, !tbaa !38
  %176 = load ptr, ptr %7, align 8, !tbaa !5
  %177 = getelementptr inbounds %struct.mobj_s, ptr %176, i32 0, i32 17
  store i32 0, ptr %177, align 4, !tbaa !39
  %178 = load ptr, ptr %7, align 8, !tbaa !5
  %179 = getelementptr inbounds %struct.mobj_s, ptr %178, i32 0, i32 16
  store i32 0, ptr %179, align 8, !tbaa !40
  store i32 1, ptr %4, align 4
  store i32 1, ptr %18, align 4
  br label %190

180:                                              ; preds = %82, %66, %59
  %181 = load ptr, ptr %13, align 8, !tbaa !5
  %182 = getelementptr inbounds %struct.thinker_s, ptr %181, i32 0, i32 1
  %183 = load ptr, ptr %182, align 8, !tbaa !21
  store ptr %183, ptr %13, align 8, !tbaa !5
  br label %51, !llvm.loop !41

184:                                              ; preds = %51
  br label %185

185:                                              ; preds = %184, %38
  br label %186

186:                                              ; preds = %185
  %187 = load i32, ptr %8, align 4, !tbaa !9
  %188 = add nsw i32 %187, 1
  store i32 %188, ptr %8, align 4, !tbaa !9
  br label %34, !llvm.loop !43

189:                                              ; preds = %34
  store i32 0, ptr %4, align 4
  store i32 1, ptr %18, align 4
  br label %190

190:                                              ; preds = %189, %168, %102, %28, %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %191 = load i32, ptr %4, align 4
  ret i32 %191
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

declare void @P_MobjThinker(ptr noundef) #2

declare i32 @P_TeleportMove(ptr noundef, i32 noundef, i32 noundef) #2

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

declare void @S_StartSound(ptr noundef, i32 noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"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 160}
!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 = !{!17, !15, i64 28}
!17 = !{!"line_s", !6, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !15, i64 24, !15, i64 26, !15, i64 28, !7, i64 30, !7, i64 36, !10, i64 52, !6, i64 56, !6, i64 64, !10, i64 72, !6, i64 80}
!18 = !{!19, !15, i64 16}
!19 = !{!"", !10, i64 0, !10, i64 4, !15, i64 8, !15, i64 10, !15, i64 12, !15, i64 14, !15, i64 16, !10, i64 20, !6, i64 24, !7, i64 32, !20, i64 48, !10, i64 88, !6, i64 96, !6, i64 104, !10, i64 112, !6, i64 120}
!20 = !{!"", !13, i64 0, !10, i64 24, !10, i64 28, !10, i64 32}
!21 = !{!13, !6, i64 8}
!22 = !{!7, !7, i64 0}
!23 = !{!12, !10, i64 128}
!24 = !{!12, !6, i64 88}
!25 = !{!26, !6, i64 0}
!26 = !{!"subsector_s", !6, i64 0, !15, i64 8, !15, i64 10}
!27 = !{!12, !10, i64 24}
!28 = !{!12, !10, i64 28}
!29 = !{!12, !10, i64 32}
!30 = !{!12, !10, i64 96}
!31 = !{!12, !6, i64 192}
!32 = !{!33, !10, i64 24}
!33 = !{!"player_s", !6, i64 0, !10, i64 8, !34, i64 12, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !7, i64 48, !7, i64 72, !10, i64 96, !7, i64 100, !10, i64 116, !10, i64 120, !7, i64 124, !7, i64 160, !7, i64 176, !10, i64 192, !10, i64 196, !10, i64 200, !10, i64 204, !10, i64 208, !10, i64 212, !10, i64 216, !6, i64 224, !10, i64 232, !10, i64 236, !6, i64 240, !10, i64 248, !10, i64 252, !10, i64 256, !7, i64 264, !10, i64 312}
!34 = !{!"", !7, i64 0, !7, i64 1, !15, i64 2, !15, i64 4, !7, i64 6, !7, i64 7}
!35 = !{!33, !10, i64 20}
!36 = !{!12, !10, i64 56}
!37 = !{!12, !10, i64 184}
!38 = !{!12, !10, i64 120}
!39 = !{!12, !10, i64 116}
!40 = !{!12, !10, i64 112}
!41 = distinct !{!41, !42}
!42 = !{!"llvm.loop.mustprogress"}
!43 = distinct !{!43, !42}


; 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.thinker_s = type { ptr, ptr, %union.actionf_t }
%union.actionf_t = type { ptr }
%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 }

@numsectors = external local_unnamed_addr global i32, align 4
@sectors = external local_unnamed_addr global ptr, align 8
@thinkercap = external global %struct.thinker_s, align 8
@finecosine = external local_unnamed_addr global ptr, align 8
@finesine = external local_unnamed_addr global [10240 x i32], align 16

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @EV_Teleport(ptr nocapture noundef readonly %0, i32 noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %2, i64 160
  %5 = load i32, ptr %4, align 8, !tbaa !5
  %6 = and i32 %5, 65536
  %.not = icmp ne i32 %6, 0
  %7 = icmp eq i32 %1, 1
  %or.cond = or i1 %7, %.not
  br i1 %or.cond, label %.loopexit55, label %8

8:                                                ; preds = %3
  %9 = getelementptr inbounds i8, ptr %0, i64 28
  %10 = load i16, ptr %9, align 4, !tbaa !14
  %11 = load i32, ptr @numsectors, align 4, !tbaa !16
  %12 = icmp sgt i32 %11, 0
  br i1 %12, label %.lr.ph61, label %.loopexit55

.lr.ph61:                                         ; preds = %8
  %13 = load ptr, ptr @sectors, align 8, !tbaa !17
  %.04657 = load ptr, ptr getelementptr inbounds (i8, ptr @thinkercap, i64 8), align 8
  %.04657.fr = freeze ptr %.04657
  %.not4858 = icmp eq ptr %.04657.fr, @thinkercap
  %14 = ptrtoint ptr %13 to i64
  br i1 %.not4858, label %.loopexit55, label %.lr.ph61.split.preheader

.lr.ph61.split.preheader:                         ; preds = %.lr.ph61
  %wide.trip.count = zext nneg i32 %11 to i64
  br label %.lr.ph61.split

.lr.ph61.split:                                   ; preds = %.lr.ph61.split.preheader, %..loopexit_crit_edge
  %indvars.iv = phi i64 [ 0, %.lr.ph61.split.preheader ], [ %indvars.iv.next, %..loopexit_crit_edge ]
  %15 = getelementptr inbounds %struct.sector_t, ptr %13, i64 %indvars.iv, i32 6
  %16 = load i16, ptr %15, align 8, !tbaa !18
  %17 = icmp eq i16 %16, %10
  br i1 %17, label %.preheader, label %..loopexit_crit_edge

.preheader:                                       ; preds = %.lr.ph61.split, %80
  %.04659 = phi ptr [ %.046, %80 ], [ %.04657.fr, %.lr.ph61.split ]
  %18 = getelementptr inbounds i8, ptr %.04659, i64 16
  %19 = load ptr, ptr %18, align 8, !tbaa !21
  %.not49 = icmp eq ptr %19, @P_MobjThinker
  br i1 %.not49, label %20, label %80

20:                                               ; preds = %.preheader
  %21 = getelementptr inbounds i8, ptr %.04659, i64 128
  %22 = load i32, ptr %21, align 8, !tbaa !22
  %.not50 = icmp eq i32 %22, 41
  br i1 %.not50, label %23, label %80

23:                                               ; preds = %20
  %24 = getelementptr inbounds i8, ptr %.04659, i64 88
  %25 = load ptr, ptr %24, align 8, !tbaa !23
  %26 = load ptr, ptr %25, align 8, !tbaa !24
  %27 = ptrtoint ptr %26 to i64
  %28 = sub i64 %27, %14
  %29 = ashr exact i64 %28, 7
  %.not51 = icmp eq i64 %29, %indvars.iv
  br i1 %.not51, label %30, label %80

30:                                               ; preds = %23
  %31 = getelementptr inbounds i8, ptr %2, i64 24
  %32 = load i32, ptr %31, align 8, !tbaa !26
  %33 = getelementptr inbounds i8, ptr %2, i64 28
  %34 = load i32, ptr %33, align 4, !tbaa !27
  %35 = getelementptr inbounds i8, ptr %2, i64 32
  %36 = load i32, ptr %35, align 8, !tbaa !28
  %37 = getelementptr inbounds i8, ptr %.04659, i64 24
  %38 = load i32, ptr %37, align 8, !tbaa !26
  %39 = getelementptr inbounds i8, ptr %.04659, i64 28
  %40 = load i32, ptr %39, align 4, !tbaa !27
  %41 = tail call i32 @P_TeleportMove(ptr noundef %2, i32 noundef %38, i32 noundef %40) #2
  %.not52 = icmp eq i32 %41, 0
  br i1 %.not52, label %.loopexit55, label %42

42:                                               ; preds = %30
  %43 = getelementptr inbounds i8, ptr %2, i64 96
  %44 = load i32, ptr %43, align 8, !tbaa !29
  store i32 %44, ptr %35, align 8, !tbaa !28
  %45 = getelementptr inbounds i8, ptr %2, i64 192
  %46 = load ptr, ptr %45, align 8, !tbaa !30
  %.not53 = icmp eq ptr %46, null
  br i1 %.not53, label %52, label %47

47:                                               ; preds = %42
  %48 = getelementptr inbounds i8, ptr %46, i64 24
  %49 = load i32, ptr %48, align 8, !tbaa !31
  %50 = add nsw i32 %49, %44
  %51 = getelementptr inbounds i8, ptr %46, i64 20
  store i32 %50, ptr %51, align 4, !tbaa !34
  br label %52

52:                                               ; preds = %47, %42
  %53 = tail call ptr @P_SpawnMobj(i32 noundef %32, i32 noundef %34, i32 noundef %36, i32 noundef 39) #2
  tail call void @S_StartSound(ptr noundef %53, i32 noundef 35) #2
  %54 = getelementptr inbounds i8, ptr %.04659, i64 56
  %55 = load i32, ptr %54, align 8, !tbaa !35
  %56 = lshr i32 %55, 19
  %57 = load i32, ptr %37, align 8, !tbaa !26
  %58 = load ptr, ptr @finecosine, align 8, !tbaa !17
  %59 = zext nneg i32 %56 to i64
  %60 = getelementptr inbounds i32, ptr %58, i64 %59
  %61 = load i32, ptr %60, align 4, !tbaa !16
  %62 = mul nsw i32 %61, 20
  %63 = add nsw i32 %62, %57
  %64 = load i32, ptr %39, align 4, !tbaa !27
  %65 = getelementptr inbounds [10240 x i32], ptr @finesine, i64 0, i64 %59
  %66 = load i32, ptr %65, align 4, !tbaa !16
  %67 = mul nsw i32 %66, 20
  %68 = add nsw i32 %67, %64
  %69 = load i32, ptr %35, align 8, !tbaa !28
  %70 = tail call ptr @P_SpawnMobj(i32 noundef %63, i32 noundef %68, i32 noundef %69, i32 noundef 39) #2
  tail call void @S_StartSound(ptr noundef %70, i32 noundef 35) #2
  %71 = load ptr, ptr %45, align 8, !tbaa !30
  %.not54 = icmp eq ptr %71, null
  br i1 %.not54, label %74, label %72

72:                                               ; preds = %52
  %73 = getelementptr inbounds i8, ptr %2, i64 184
  store i32 18, ptr %73, align 8, !tbaa !36
  br label %74

74:                                               ; preds = %72, %52
  %75 = load i32, ptr %54, align 8, !tbaa !35
  %76 = getelementptr inbounds i8, ptr %2, i64 56
  store i32 %75, ptr %76, align 8, !tbaa !35
  %77 = getelementptr inbounds i8, ptr %2, i64 120
  store i32 0, ptr %77, align 8, !tbaa !37
  %78 = getelementptr inbounds i8, ptr %2, i64 116
  store i32 0, ptr %78, align 4, !tbaa !38
  %79 = getelementptr inbounds i8, ptr %2, i64 112
  store i32 0, ptr %79, align 8, !tbaa !39
  br label %.loopexit55

80:                                               ; preds = %23, %20, %.preheader
  %81 = getelementptr inbounds i8, ptr %.04659, i64 8
  %.046 = load ptr, ptr %81, align 8, !tbaa !40
  %.not48 = icmp eq ptr %.046, @thinkercap
  br i1 %.not48, label %..loopexit_crit_edge, label %.preheader, !llvm.loop !41

..loopexit_crit_edge:                             ; preds = %80, %.lr.ph61.split
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.loopexit55, label %.lr.ph61.split, !llvm.loop !43

.loopexit55:                                      ; preds = %..loopexit_crit_edge, %.lr.ph61, %8, %30, %3, %74
  %.0 = phi i32 [ 1, %74 ], [ 0, %3 ], [ 0, %30 ], [ 0, %8 ], [ 0, %.lr.ph61 ], [ 0, %..loopexit_crit_edge ]
  ret i32 %.0
}

declare void @P_MobjThinker(ptr noundef) #1

declare i32 @P_TeleportMove(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

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

declare void @S_StartSound(ptr 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, !11, i64 160}
!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 = !{!15, !13, i64 28}
!15 = !{!"line_s", !8, i64 0, !8, i64 8, !11, i64 16, !11, i64 20, !13, i64 24, !13, i64 26, !13, i64 28, !9, i64 30, !9, i64 36, !11, i64 52, !8, i64 56, !8, i64 64, !11, i64 72, !8, i64 80}
!16 = !{!11, !11, i64 0}
!17 = !{!8, !8, i64 0}
!18 = !{!19, !13, i64 16}
!19 = !{!"", !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, !20, i64 48, !11, i64 88, !8, i64 96, !8, i64 104, !11, i64 112, !8, i64 120}
!20 = !{!"", !7, i64 0, !11, i64 24, !11, i64 28, !11, i64 32}
!21 = !{!9, !9, i64 0}
!22 = !{!6, !11, i64 128}
!23 = !{!6, !8, i64 88}
!24 = !{!25, !8, i64 0}
!25 = !{!"subsector_s", !8, i64 0, !13, i64 8, !13, i64 10}
!26 = !{!6, !11, i64 24}
!27 = !{!6, !11, i64 28}
!28 = !{!6, !11, i64 32}
!29 = !{!6, !11, i64 96}
!30 = !{!6, !8, i64 192}
!31 = !{!32, !11, i64 24}
!32 = !{!"player_s", !8, i64 0, !11, i64 8, !33, i64 12, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !9, i64 48, !9, i64 72, !11, i64 96, !9, i64 100, !11, i64 116, !11, i64 120, !9, i64 124, !9, i64 160, !9, i64 176, !11, i64 192, !11, i64 196, !11, i64 200, !11, i64 204, !11, i64 208, !11, i64 212, !11, i64 216, !8, i64 224, !11, i64 232, !11, i64 236, !8, i64 240, !11, i64 248, !11, i64 252, !11, i64 256, !9, i64 264, !11, i64 312}
!33 = !{!"", !9, i64 0, !9, i64 1, !13, i64 2, !13, i64 4, !9, i64 6, !9, i64 7}
!34 = !{!32, !11, i64 20}
!35 = !{!6, !11, i64 56}
!36 = !{!6, !11, i64 184}
!37 = !{!6, !11, i64 120}
!38 = !{!6, !11, i64 116}
!39 = !{!6, !11, i64 112}
!40 = !{!7, !8, i64 8}
!41 = distinct !{!41, !42}
!42 = !{!"llvm.loop.mustprogress"}
!43 = distinct !{!43, !42}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass