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

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

@sectors = external global ptr, align 8

; Function Attrs: nounwind uwtable
declare dso_local void @T_VerticalDoor(ptr noundef) #0

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @EV_DoDoor(ptr noundef %0, i32 noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store i32 -1, ptr %5, align 4, !tbaa !9
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %9

9:                                                ; preds = %140, %23, %2
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = load i32, ptr %5, align 4, !tbaa !9
  %12 = call i32 @P_FindSectorFromLineTag(ptr noundef %10, i32 noundef %11)
  store i32 %12, ptr %5, align 4, !tbaa !9
  %13 = icmp sge i32 %12, 0
  br i1 %13, label %14, label %141

14:                                               ; preds = %9
  %15 = load ptr, ptr @sectors, align 8, !tbaa !5
  %16 = load i32, ptr %5, align 4, !tbaa !9
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds %struct.sector_t, ptr %15, i64 %17
  store ptr %18, ptr %7, align 8, !tbaa !5
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.sector_t, ptr %19, i32 0, i32 13
  %21 = load ptr, ptr %20, align 8, !tbaa !11
  %22 = icmp ne ptr %21, null
  br i1 %22, label %23, label %24

23:                                               ; preds = %14
  br label %9, !llvm.loop !16

24:                                               ; preds = %14
  store i32 1, ptr %6, align 4, !tbaa !9
  %25 = call ptr @Z_Malloc(i32 noundef 64, i32 noundef 51, ptr noundef null)
  store ptr %25, ptr %8, align 8, !tbaa !5
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.vldoor_t, ptr %26, i32 0, i32 0
  call void @P_AddThinker(ptr noundef %27)
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.sector_t, ptr %29, i32 0, i32 13
  store ptr %28, ptr %30, align 8, !tbaa !11
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.vldoor_t, ptr %31, i32 0, i32 0
  %33 = getelementptr inbounds %struct.thinker_s, ptr %32, i32 0, i32 2
  store ptr @T_VerticalDoor, ptr %33, align 8, !tbaa !18
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.vldoor_t, ptr %35, i32 0, i32 2
  store ptr %34, ptr %36, align 8, !tbaa !19
  %37 = load i32, ptr %4, align 4, !tbaa !9
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.vldoor_t, ptr %38, i32 0, i32 1
  store i32 %37, ptr %39, align 8, !tbaa !21
  %40 = load ptr, ptr %8, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.vldoor_t, ptr %40, i32 0, i32 6
  store i32 150, ptr %41, align 4, !tbaa !22
  %42 = load ptr, ptr %8, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.vldoor_t, ptr %42, i32 0, i32 4
  store i32 131072, ptr %43, align 4, !tbaa !23
  %44 = load i32, ptr %4, align 4, !tbaa !9
  switch i32 %44, label %139 [
    i32 7, label %45
    i32 2, label %62
    i32 1, label %77
    i32 5, label %89
    i32 6, label %89
    i32 0, label %115
    i32 3, label %115
  ]

45:                                               ; preds = %24
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = call i32 @P_FindLowestCeilingSurrounding(ptr noundef %46)
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.vldoor_t, ptr %48, i32 0, i32 3
  store i32 %47, ptr %49, align 8, !tbaa !24
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.vldoor_t, ptr %50, i32 0, i32 3
  %52 = load i32, ptr %51, align 8, !tbaa !24
  %53 = sub nsw i32 %52, 262144
  store i32 %53, ptr %51, align 8, !tbaa !24
  %54 = load ptr, ptr %8, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.vldoor_t, ptr %54, i32 0, i32 5
  store i32 -1, ptr %55, align 8, !tbaa !25
  %56 = load ptr, ptr %8, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.vldoor_t, ptr %56, i32 0, i32 4
  store i32 524288, ptr %57, align 4, !tbaa !23
  %58 = load ptr, ptr %8, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.vldoor_t, ptr %58, i32 0, i32 2
  %60 = load ptr, ptr %59, align 8, !tbaa !19
  %61 = getelementptr inbounds %struct.sector_t, ptr %60, i32 0, i32 10
  call void @S_StartSound(ptr noundef %61, i32 noundef 89)
  br label %140

62:                                               ; preds = %24
  %63 = load ptr, ptr %7, align 8, !tbaa !5
  %64 = call i32 @P_FindLowestCeilingSurrounding(ptr noundef %63)
  %65 = load ptr, ptr %8, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.vldoor_t, ptr %65, i32 0, i32 3
  store i32 %64, ptr %66, align 8, !tbaa !24
  %67 = load ptr, ptr %8, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.vldoor_t, ptr %67, i32 0, i32 3
  %69 = load i32, ptr %68, align 8, !tbaa !24
  %70 = sub nsw i32 %69, 262144
  store i32 %70, ptr %68, align 8, !tbaa !24
  %71 = load ptr, ptr %8, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.vldoor_t, ptr %71, i32 0, i32 5
  store i32 -1, ptr %72, align 8, !tbaa !25
  %73 = load ptr, ptr %8, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.vldoor_t, ptr %73, i32 0, i32 2
  %75 = load ptr, ptr %74, align 8, !tbaa !19
  %76 = getelementptr inbounds %struct.sector_t, ptr %75, i32 0, i32 10
  call void @S_StartSound(ptr noundef %76, i32 noundef 21)
  br label %140

77:                                               ; preds = %24
  %78 = load ptr, ptr %7, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.sector_t, ptr %78, i32 0, i32 1
  %80 = load i32, ptr %79, align 4, !tbaa !26
  %81 = load ptr, ptr %8, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.vldoor_t, ptr %81, i32 0, i32 3
  store i32 %80, ptr %82, align 8, !tbaa !24
  %83 = load ptr, ptr %8, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.vldoor_t, ptr %83, i32 0, i32 5
  store i32 -1, ptr %84, align 8, !tbaa !25
  %85 = load ptr, ptr %8, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.vldoor_t, ptr %85, i32 0, i32 2
  %87 = load ptr, ptr %86, align 8, !tbaa !19
  %88 = getelementptr inbounds %struct.sector_t, ptr %87, i32 0, i32 10
  call void @S_StartSound(ptr noundef %88, i32 noundef 21)
  br label %140

89:                                               ; preds = %24, %24
  %90 = load ptr, ptr %8, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.vldoor_t, ptr %90, i32 0, i32 5
  store i32 1, ptr %91, align 8, !tbaa !25
  %92 = load ptr, ptr %7, align 8, !tbaa !5
  %93 = call i32 @P_FindLowestCeilingSurrounding(ptr noundef %92)
  %94 = load ptr, ptr %8, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.vldoor_t, ptr %94, i32 0, i32 3
  store i32 %93, ptr %95, align 8, !tbaa !24
  %96 = load ptr, ptr %8, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.vldoor_t, ptr %96, i32 0, i32 3
  %98 = load i32, ptr %97, align 8, !tbaa !24
  %99 = sub nsw i32 %98, 262144
  store i32 %99, ptr %97, align 8, !tbaa !24
  %100 = load ptr, ptr %8, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.vldoor_t, ptr %100, i32 0, i32 4
  store i32 524288, ptr %101, align 4, !tbaa !23
  %102 = load ptr, ptr %8, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.vldoor_t, ptr %102, i32 0, i32 3
  %104 = load i32, ptr %103, align 8, !tbaa !24
  %105 = load ptr, ptr %7, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.sector_t, ptr %105, i32 0, i32 1
  %107 = load i32, ptr %106, align 4, !tbaa !26
  %108 = icmp ne i32 %104, %107
  br i1 %108, label %109, label %114

109:                                              ; preds = %89
  %110 = load ptr, ptr %8, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.vldoor_t, ptr %110, i32 0, i32 2
  %112 = load ptr, ptr %111, align 8, !tbaa !19
  %113 = getelementptr inbounds %struct.sector_t, ptr %112, i32 0, i32 10
  call void @S_StartSound(ptr noundef %113, i32 noundef 88)
  br label %114

114:                                              ; preds = %109, %89
  br label %140

115:                                              ; preds = %24, %24
  %116 = load ptr, ptr %8, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.vldoor_t, ptr %116, i32 0, i32 5
  store i32 1, ptr %117, align 8, !tbaa !25
  %118 = load ptr, ptr %7, align 8, !tbaa !5
  %119 = call i32 @P_FindLowestCeilingSurrounding(ptr noundef %118)
  %120 = load ptr, ptr %8, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct.vldoor_t, ptr %120, i32 0, i32 3
  store i32 %119, ptr %121, align 8, !tbaa !24
  %122 = load ptr, ptr %8, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct.vldoor_t, ptr %122, i32 0, i32 3
  %124 = load i32, ptr %123, align 8, !tbaa !24
  %125 = sub nsw i32 %124, 262144
  store i32 %125, ptr %123, align 8, !tbaa !24
  %126 = load ptr, ptr %8, align 8, !tbaa !5
  %127 = getelementptr inbounds %struct.vldoor_t, ptr %126, i32 0, i32 3
  %128 = load i32, ptr %127, align 8, !tbaa !24
  %129 = load ptr, ptr %7, align 8, !tbaa !5
  %130 = getelementptr inbounds %struct.sector_t, ptr %129, i32 0, i32 1
  %131 = load i32, ptr %130, align 4, !tbaa !26
  %132 = icmp ne i32 %128, %131
  br i1 %132, label %133, label %138

133:                                              ; preds = %115
  %134 = load ptr, ptr %8, align 8, !tbaa !5
  %135 = getelementptr inbounds %struct.vldoor_t, ptr %134, i32 0, i32 2
  %136 = load ptr, ptr %135, align 8, !tbaa !19
  %137 = getelementptr inbounds %struct.sector_t, ptr %136, i32 0, i32 10
  call void @S_StartSound(ptr noundef %137, i32 noundef 20)
  br label %138

138:                                              ; preds = %133, %115
  br label %140

139:                                              ; preds = %24
  br label %140

140:                                              ; preds = %139, %138, %114, %77, %62, %45
  br label %9, !llvm.loop !16

141:                                              ; preds = %9
  %142 = load i32, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret i32 %142
}

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

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

declare void @P_AddThinker(ptr noundef) #2

declare i32 @P_FindLowestCeilingSurrounding(ptr noundef) #2

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, !6, i64 104}
!12 = !{!"", !10, i64 0, !10, i64 4, !13, i64 8, !13, i64 10, !13, i64 12, !13, i64 14, !13, i64 16, !10, i64 20, !6, i64 24, !7, i64 32, !14, i64 48, !10, i64 88, !6, i64 96, !6, i64 104, !10, i64 112, !6, i64 120}
!13 = !{!"short", !7, i64 0}
!14 = !{!"", !15, i64 0, !10, i64 24, !10, i64 28, !10, i64 32}
!15 = !{!"thinker_s", !6, i64 0, !6, i64 8, !7, i64 16}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!7, !7, i64 0}
!19 = !{!20, !6, i64 32}
!20 = !{!"", !15, i64 0, !10, i64 24, !6, i64 32, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56}
!21 = !{!20, !10, i64 24}
!22 = !{!20, !10, i64 52}
!23 = !{!20, !10, i64 44}
!24 = !{!20, !10, i64 40}
!25 = !{!20, !10, i64 48}
!26 = !{!12, !10, i64 4}


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

@sectors = external local_unnamed_addr global ptr, align 8

; Function Attrs: nounwind uwtable
declare dso_local void @T_VerticalDoor(ptr noundef) #0

declare void @S_StartSound(ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @EV_DoDoor(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  br label %.outer

.outer:                                           ; preds = %.outer.backedge, %2
  %.045.ph = phi i32 [ 0, %2 ], [ 1, %.outer.backedge ]
  %.0.ph = phi i32 [ -1, %2 ], [ %4, %.outer.backedge ]
  br label %3

3:                                                ; preds = %.outer, %6
  %.0 = phi i32 [ %4, %6 ], [ %.0.ph, %.outer ]
  %4 = tail call i32 @P_FindSectorFromLineTag(ptr noundef %0, i32 noundef %.0) #2
  %5 = icmp sgt i32 %4, -1
  br i1 %5, label %6, label %56

6:                                                ; preds = %3
  %7 = load ptr, ptr @sectors, align 8, !tbaa !5
  %8 = zext nneg i32 %4 to i64
  %9 = getelementptr inbounds %struct.sector_t, ptr %7, i64 %8
  %10 = getelementptr inbounds i8, ptr %9, i64 104
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  %.not = icmp eq ptr %11, null
  br i1 %.not, label %12, label %3, !llvm.loop !15

12:                                               ; preds = %6
  %13 = getelementptr inbounds i8, ptr %9, i64 104
  %14 = tail call ptr @Z_Malloc(i32 noundef 64, i32 noundef 51, ptr noundef null) #2
  tail call void @P_AddThinker(ptr noundef %14) #2
  store ptr %14, ptr %13, align 8, !tbaa !9
  %15 = getelementptr inbounds i8, ptr %14, i64 16
  store ptr @T_VerticalDoor, ptr %15, align 8, !tbaa !17
  %16 = getelementptr inbounds i8, ptr %14, i64 32
  store ptr %9, ptr %16, align 8, !tbaa !18
  %17 = getelementptr inbounds i8, ptr %14, i64 24
  store i32 %1, ptr %17, align 8, !tbaa !20
  %18 = getelementptr inbounds i8, ptr %14, i64 52
  store i32 150, ptr %18, align 4, !tbaa !21
  %19 = getelementptr inbounds i8, ptr %14, i64 44
  store i32 131072, ptr %19, align 4, !tbaa !22
  switch i32 %1, label %.outer.backedge [
    i32 7, label %20
    i32 2, label %26
    i32 1, label %32
    i32 5, label %37
    i32 6, label %37
    i32 0, label %46
    i32 3, label %46
  ]

20:                                               ; preds = %12
  %21 = tail call i32 @P_FindLowestCeilingSurrounding(ptr noundef nonnull %9) #2
  %22 = getelementptr inbounds i8, ptr %14, i64 40
  %23 = add nsw i32 %21, -262144
  store i32 %23, ptr %22, align 8, !tbaa !23
  %24 = getelementptr inbounds i8, ptr %14, i64 48
  store i32 -1, ptr %24, align 8, !tbaa !24
  store i32 524288, ptr %19, align 4, !tbaa !22
  %25 = load ptr, ptr %16, align 8, !tbaa !18
  br label %.sink.split

26:                                               ; preds = %12
  %27 = tail call i32 @P_FindLowestCeilingSurrounding(ptr noundef nonnull %9) #2
  %28 = getelementptr inbounds i8, ptr %14, i64 40
  %29 = add nsw i32 %27, -262144
  store i32 %29, ptr %28, align 8, !tbaa !23
  %30 = getelementptr inbounds i8, ptr %14, i64 48
  store i32 -1, ptr %30, align 8, !tbaa !24
  %31 = load ptr, ptr %16, align 8, !tbaa !18
  br label %.sink.split

32:                                               ; preds = %12
  %33 = getelementptr inbounds i8, ptr %9, i64 4
  %34 = load i32, ptr %33, align 4, !tbaa !25
  %35 = getelementptr inbounds i8, ptr %14, i64 40
  store i32 %34, ptr %35, align 8, !tbaa !23
  %36 = getelementptr inbounds i8, ptr %14, i64 48
  store i32 -1, ptr %36, align 8, !tbaa !24
  br label %.sink.split

37:                                               ; preds = %12, %12
  %38 = getelementptr inbounds i8, ptr %14, i64 48
  store i32 1, ptr %38, align 8, !tbaa !24
  %39 = tail call i32 @P_FindLowestCeilingSurrounding(ptr noundef nonnull %9) #2
  %40 = getelementptr inbounds i8, ptr %14, i64 40
  %41 = add nsw i32 %39, -262144
  store i32 %41, ptr %40, align 8, !tbaa !23
  store i32 524288, ptr %19, align 4, !tbaa !22
  %42 = getelementptr inbounds i8, ptr %9, i64 4
  %43 = load i32, ptr %42, align 4, !tbaa !25
  %.not48 = icmp eq i32 %41, %43
  br i1 %.not48, label %.outer.backedge, label %44

44:                                               ; preds = %37
  %45 = load ptr, ptr %16, align 8, !tbaa !18
  br label %.sink.split

46:                                               ; preds = %12, %12
  %47 = getelementptr inbounds i8, ptr %14, i64 48
  store i32 1, ptr %47, align 8, !tbaa !24
  %48 = tail call i32 @P_FindLowestCeilingSurrounding(ptr noundef nonnull %9) #2
  %49 = getelementptr inbounds i8, ptr %14, i64 40
  %50 = add nsw i32 %48, -262144
  store i32 %50, ptr %49, align 8, !tbaa !23
  %51 = getelementptr inbounds i8, ptr %9, i64 4
  %52 = load i32, ptr %51, align 4, !tbaa !25
  %.not47 = icmp eq i32 %50, %52
  br i1 %.not47, label %.outer.backedge, label %53

53:                                               ; preds = %46
  %54 = load ptr, ptr %16, align 8, !tbaa !18
  br label %.sink.split

.sink.split:                                      ; preds = %20, %26, %32, %44, %53
  %.sink58 = phi ptr [ %54, %53 ], [ %45, %44 ], [ %9, %32 ], [ %31, %26 ], [ %25, %20 ]
  %.sink57 = phi i32 [ 20, %53 ], [ 88, %44 ], [ 21, %32 ], [ 21, %26 ], [ 89, %20 ]
  %55 = getelementptr inbounds i8, ptr %.sink58, i64 48
  tail call void @S_StartSound(ptr noundef nonnull %55, i32 noundef %.sink57) #2
  br label %.outer.backedge

.outer.backedge:                                  ; preds = %.sink.split, %12, %46, %37
  br label %.outer, !llvm.loop !15

56:                                               ; preds = %3
  ret i32 %.045.ph
}

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

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

declare void @P_AddThinker(ptr noundef) local_unnamed_addr #1

declare i32 @P_FindLowestCeilingSurrounding(ptr 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 104}
!10 = !{!"", !11, i64 0, !11, i64 4, !12, i64 8, !12, i64 10, !12, i64 12, !12, i64 14, !12, i64 16, !11, i64 20, !6, i64 24, !7, i64 32, !13, i64 48, !11, i64 88, !6, i64 96, !6, i64 104, !11, i64 112, !6, i64 120}
!11 = !{!"int", !7, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = !{!"", !14, i64 0, !11, i64 24, !11, i64 28, !11, i64 32}
!14 = !{!"thinker_s", !6, i64 0, !6, i64 8, !7, i64 16}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!7, !7, i64 0}
!18 = !{!19, !6, i64 32}
!19 = !{!"", !14, i64 0, !11, i64 24, !6, i64 32, !11, i64 40, !11, i64 44, !11, i64 48, !11, i64 52, !11, i64 56}
!20 = !{!19, !11, i64 24}
!21 = !{!19, !11, i64 52}
!22 = !{!19, !11, i64 44}
!23 = !{!19, !11, i64 40}
!24 = !{!19, !11, i64 48}
!25 = !{!10, !11, i64 4}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass