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

; 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.divline_t = type { i32, i32, i32, i32 }
%struct.subsector_s = type { ptr, i16, i16 }
%struct.seg_t = type { ptr, ptr, i32, i32, ptr, ptr, ptr, ptr }
%struct.line_s = type { ptr, ptr, i32, i32, i16, i16, i16, [2 x i16], [4 x i32], i32, ptr, ptr, i32, ptr }
%struct.vertex_t = type { i32, i32 }
%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 }

@numsubsectors = external global i32, align 4
@.str = external hidden unnamed_addr constant [40 x i8], align 1
@subsectors = external global ptr, align 8
@segs = external global ptr, align 8
@validcount = external global i32, align 4
@strace = external dso_local global %struct.divline_t, align 4
@t2x = external dso_local global i32, align 4
@t2y = external dso_local global i32, align 4
@sightzstart = external dso_local global i32, align 4
@bottomslope = external dso_local global i32, align 4
@topslope = external dso_local global i32, align 4

; Function Attrs: nounwind uwtable
declare dso_local i32 @P_DivlineSide(i32 noundef, i32 noundef, ptr noundef) #0

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

; 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
declare dso_local i32 @P_InterceptVector2(ptr noundef, ptr noundef) #0

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

; Function Attrs: nounwind uwtable
define dso_local i32 @P_CrossSubsector(i32 noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %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
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca %struct.divline_t, align 4
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  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
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr %14) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  %20 = load i32, ptr %3, align 4, !tbaa !5
  %21 = load i32, ptr @numsubsectors, align 4, !tbaa !5
  %22 = icmp sge i32 %20, %21
  br i1 %22, label %23, label %26

23:                                               ; preds = %1
  %24 = load i32, ptr %3, align 4, !tbaa !5
  %25 = load i32, ptr @numsubsectors, align 4, !tbaa !5
  call void (ptr, ...) @I_Error(ptr noundef @.str, i32 noundef %24, i32 noundef %25) #5
  unreachable

26:                                               ; preds = %1
  %27 = load ptr, ptr @subsectors, align 8, !tbaa !9
  %28 = load i32, ptr %3, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds %struct.subsector_s, ptr %27, i64 %29
  store ptr %30, ptr %9, align 8, !tbaa !9
  %31 = load ptr, ptr %9, align 8, !tbaa !9
  %32 = getelementptr inbounds %struct.subsector_s, ptr %31, i32 0, i32 1
  %33 = load i16, ptr %32, align 8, !tbaa !11
  %34 = sext i16 %33 to i32
  store i32 %34, ptr %8, align 4, !tbaa !5
  %35 = load ptr, ptr @segs, align 8, !tbaa !9
  %36 = load ptr, ptr %9, align 8, !tbaa !9
  %37 = getelementptr inbounds %struct.subsector_s, ptr %36, i32 0, i32 2
  %38 = load i16, ptr %37, align 2, !tbaa !14
  %39 = sext i16 %38 to i64
  %40 = getelementptr inbounds %struct.seg_t, ptr %35, i64 %39
  store ptr %40, ptr %4, align 8, !tbaa !9
  br label %41

41:                                               ; preds = %232, %26
  %42 = load i32, ptr %8, align 4, !tbaa !5
  %43 = icmp ne i32 %42, 0
  br i1 %43, label %44, label %237

44:                                               ; preds = %41
  %45 = load ptr, ptr %4, align 8, !tbaa !9
  %46 = getelementptr inbounds %struct.seg_t, ptr %45, i32 0, i32 5
  %47 = load ptr, ptr %46, align 8, !tbaa !15
  store ptr %47, ptr %5, align 8, !tbaa !9
  %48 = load ptr, ptr %5, align 8, !tbaa !9
  %49 = getelementptr inbounds %struct.line_s, ptr %48, i32 0, i32 12
  %50 = load i32, ptr %49, align 8, !tbaa !17
  %51 = load i32, ptr @validcount, align 4, !tbaa !5
  %52 = icmp eq i32 %50, %51
  br i1 %52, label %53, label %54

53:                                               ; preds = %44
  br label %232

54:                                               ; preds = %44
  %55 = load i32, ptr @validcount, align 4, !tbaa !5
  %56 = load ptr, ptr %5, align 8, !tbaa !9
  %57 = getelementptr inbounds %struct.line_s, ptr %56, i32 0, i32 12
  store i32 %55, ptr %57, align 8, !tbaa !17
  %58 = load ptr, ptr %5, align 8, !tbaa !9
  %59 = getelementptr inbounds %struct.line_s, ptr %58, i32 0, i32 0
  %60 = load ptr, ptr %59, align 8, !tbaa !19
  store ptr %60, ptr %15, align 8, !tbaa !9
  %61 = load ptr, ptr %5, align 8, !tbaa !9
  %62 = getelementptr inbounds %struct.line_s, ptr %61, i32 0, i32 1
  %63 = load ptr, ptr %62, align 8, !tbaa !20
  store ptr %63, ptr %16, align 8, !tbaa !9
  %64 = load ptr, ptr %15, align 8, !tbaa !9
  %65 = getelementptr inbounds %struct.vertex_t, ptr %64, i32 0, i32 0
  %66 = load i32, ptr %65, align 4, !tbaa !21
  %67 = load ptr, ptr %15, align 8, !tbaa !9
  %68 = getelementptr inbounds %struct.vertex_t, ptr %67, i32 0, i32 1
  %69 = load i32, ptr %68, align 4, !tbaa !23
  %70 = call i32 @P_DivlineSide(i32 noundef %66, i32 noundef %69, ptr noundef @strace)
  store i32 %70, ptr %6, align 4, !tbaa !5
  %71 = load ptr, ptr %16, align 8, !tbaa !9
  %72 = getelementptr inbounds %struct.vertex_t, ptr %71, i32 0, i32 0
  %73 = load i32, ptr %72, align 4, !tbaa !21
  %74 = load ptr, ptr %16, align 8, !tbaa !9
  %75 = getelementptr inbounds %struct.vertex_t, ptr %74, i32 0, i32 1
  %76 = load i32, ptr %75, align 4, !tbaa !23
  %77 = call i32 @P_DivlineSide(i32 noundef %73, i32 noundef %76, ptr noundef @strace)
  store i32 %77, ptr %7, align 4, !tbaa !5
  %78 = load i32, ptr %6, align 4, !tbaa !5
  %79 = load i32, ptr %7, align 4, !tbaa !5
  %80 = icmp eq i32 %78, %79
  br i1 %80, label %81, label %82

81:                                               ; preds = %54
  br label %232

82:                                               ; preds = %54
  %83 = load ptr, ptr %15, align 8, !tbaa !9
  %84 = getelementptr inbounds %struct.vertex_t, ptr %83, i32 0, i32 0
  %85 = load i32, ptr %84, align 4, !tbaa !21
  %86 = getelementptr inbounds %struct.divline_t, ptr %14, i32 0, i32 0
  store i32 %85, ptr %86, align 4, !tbaa !24
  %87 = load ptr, ptr %15, align 8, !tbaa !9
  %88 = getelementptr inbounds %struct.vertex_t, ptr %87, i32 0, i32 1
  %89 = load i32, ptr %88, align 4, !tbaa !23
  %90 = getelementptr inbounds %struct.divline_t, ptr %14, i32 0, i32 1
  store i32 %89, ptr %90, align 4, !tbaa !26
  %91 = load ptr, ptr %16, align 8, !tbaa !9
  %92 = getelementptr inbounds %struct.vertex_t, ptr %91, i32 0, i32 0
  %93 = load i32, ptr %92, align 4, !tbaa !21
  %94 = load ptr, ptr %15, align 8, !tbaa !9
  %95 = getelementptr inbounds %struct.vertex_t, ptr %94, i32 0, i32 0
  %96 = load i32, ptr %95, align 4, !tbaa !21
  %97 = sub nsw i32 %93, %96
  %98 = getelementptr inbounds %struct.divline_t, ptr %14, i32 0, i32 2
  store i32 %97, ptr %98, align 4, !tbaa !27
  %99 = load ptr, ptr %16, align 8, !tbaa !9
  %100 = getelementptr inbounds %struct.vertex_t, ptr %99, i32 0, i32 1
  %101 = load i32, ptr %100, align 4, !tbaa !23
  %102 = load ptr, ptr %15, align 8, !tbaa !9
  %103 = getelementptr inbounds %struct.vertex_t, ptr %102, i32 0, i32 1
  %104 = load i32, ptr %103, align 4, !tbaa !23
  %105 = sub nsw i32 %101, %104
  %106 = getelementptr inbounds %struct.divline_t, ptr %14, i32 0, i32 3
  store i32 %105, ptr %106, align 4, !tbaa !28
  %107 = load i32, ptr @strace, align 4, !tbaa !24
  %108 = load i32, ptr getelementptr inbounds (%struct.divline_t, ptr @strace, i32 0, i32 1), align 4, !tbaa !26
  %109 = call i32 @P_DivlineSide(i32 noundef %107, i32 noundef %108, ptr noundef %14)
  store i32 %109, ptr %6, align 4, !tbaa !5
  %110 = load i32, ptr @t2x, align 4, !tbaa !5
  %111 = load i32, ptr @t2y, align 4, !tbaa !5
  %112 = call i32 @P_DivlineSide(i32 noundef %110, i32 noundef %111, ptr noundef %14)
  store i32 %112, ptr %7, align 4, !tbaa !5
  %113 = load i32, ptr %6, align 4, !tbaa !5
  %114 = load i32, ptr %7, align 4, !tbaa !5
  %115 = icmp eq i32 %113, %114
  br i1 %115, label %116, label %117

116:                                              ; preds = %82
  br label %232

117:                                              ; preds = %82
  %118 = load ptr, ptr %5, align 8, !tbaa !9
  %119 = getelementptr inbounds %struct.line_s, ptr %118, i32 0, i32 4
  %120 = load i16, ptr %119, align 8, !tbaa !29
  %121 = sext i16 %120 to i32
  %122 = and i32 %121, 4
  %123 = icmp ne i32 %122, 0
  br i1 %123, label %125, label %124

124:                                              ; preds = %117
  store i32 0, ptr %2, align 4
  store i32 1, ptr %19, align 4
  br label %238

125:                                              ; preds = %117
  %126 = load ptr, ptr %4, align 8, !tbaa !9
  %127 = getelementptr inbounds %struct.seg_t, ptr %126, i32 0, i32 6
  %128 = load ptr, ptr %127, align 8, !tbaa !30
  store ptr %128, ptr %10, align 8, !tbaa !9
  %129 = load ptr, ptr %4, align 8, !tbaa !9
  %130 = getelementptr inbounds %struct.seg_t, ptr %129, i32 0, i32 7
  %131 = load ptr, ptr %130, align 8, !tbaa !31
  store ptr %131, ptr %11, align 8, !tbaa !9
  %132 = load ptr, ptr %10, align 8, !tbaa !9
  %133 = getelementptr inbounds %struct.sector_t, ptr %132, i32 0, i32 0
  %134 = load i32, ptr %133, align 8, !tbaa !32
  %135 = load ptr, ptr %11, align 8, !tbaa !9
  %136 = getelementptr inbounds %struct.sector_t, ptr %135, i32 0, i32 0
  %137 = load i32, ptr %136, align 8, !tbaa !32
  %138 = icmp eq i32 %134, %137
  br i1 %138, label %139, label %148

139:                                              ; preds = %125
  %140 = load ptr, ptr %10, align 8, !tbaa !9
  %141 = getelementptr inbounds %struct.sector_t, ptr %140, i32 0, i32 1
  %142 = load i32, ptr %141, align 4, !tbaa !36
  %143 = load ptr, ptr %11, align 8, !tbaa !9
  %144 = getelementptr inbounds %struct.sector_t, ptr %143, i32 0, i32 1
  %145 = load i32, ptr %144, align 4, !tbaa !36
  %146 = icmp eq i32 %142, %145
  br i1 %146, label %147, label %148

147:                                              ; preds = %139
  br label %232

148:                                              ; preds = %139, %125
  %149 = load ptr, ptr %10, align 8, !tbaa !9
  %150 = getelementptr inbounds %struct.sector_t, ptr %149, i32 0, i32 1
  %151 = load i32, ptr %150, align 4, !tbaa !36
  %152 = load ptr, ptr %11, align 8, !tbaa !9
  %153 = getelementptr inbounds %struct.sector_t, ptr %152, i32 0, i32 1
  %154 = load i32, ptr %153, align 4, !tbaa !36
  %155 = icmp slt i32 %151, %154
  br i1 %155, label %156, label %160

156:                                              ; preds = %148
  %157 = load ptr, ptr %10, align 8, !tbaa !9
  %158 = getelementptr inbounds %struct.sector_t, ptr %157, i32 0, i32 1
  %159 = load i32, ptr %158, align 4, !tbaa !36
  store i32 %159, ptr %12, align 4, !tbaa !5
  br label %164

160:                                              ; preds = %148
  %161 = load ptr, ptr %11, align 8, !tbaa !9
  %162 = getelementptr inbounds %struct.sector_t, ptr %161, i32 0, i32 1
  %163 = load i32, ptr %162, align 4, !tbaa !36
  store i32 %163, ptr %12, align 4, !tbaa !5
  br label %164

164:                                              ; preds = %160, %156
  %165 = load ptr, ptr %10, align 8, !tbaa !9
  %166 = getelementptr inbounds %struct.sector_t, ptr %165, i32 0, i32 0
  %167 = load i32, ptr %166, align 8, !tbaa !32
  %168 = load ptr, ptr %11, align 8, !tbaa !9
  %169 = getelementptr inbounds %struct.sector_t, ptr %168, i32 0, i32 0
  %170 = load i32, ptr %169, align 8, !tbaa !32
  %171 = icmp sgt i32 %167, %170
  br i1 %171, label %172, label %176

172:                                              ; preds = %164
  %173 = load ptr, ptr %10, align 8, !tbaa !9
  %174 = getelementptr inbounds %struct.sector_t, ptr %173, i32 0, i32 0
  %175 = load i32, ptr %174, align 8, !tbaa !32
  store i32 %175, ptr %13, align 4, !tbaa !5
  br label %180

176:                                              ; preds = %164
  %177 = load ptr, ptr %11, align 8, !tbaa !9
  %178 = getelementptr inbounds %struct.sector_t, ptr %177, i32 0, i32 0
  %179 = load i32, ptr %178, align 8, !tbaa !32
  store i32 %179, ptr %13, align 4, !tbaa !5
  br label %180

180:                                              ; preds = %176, %172
  %181 = load i32, ptr %13, align 4, !tbaa !5
  %182 = load i32, ptr %12, align 4, !tbaa !5
  %183 = icmp sge i32 %181, %182
  br i1 %183, label %184, label %185

184:                                              ; preds = %180
  store i32 0, ptr %2, align 4
  store i32 1, ptr %19, align 4
  br label %238

185:                                              ; preds = %180
  %186 = call i32 @P_InterceptVector2(ptr noundef @strace, ptr noundef %14)
  store i32 %186, ptr %17, align 4, !tbaa !5
  %187 = load ptr, ptr %10, align 8, !tbaa !9
  %188 = getelementptr inbounds %struct.sector_t, ptr %187, i32 0, i32 0
  %189 = load i32, ptr %188, align 8, !tbaa !32
  %190 = load ptr, ptr %11, align 8, !tbaa !9
  %191 = getelementptr inbounds %struct.sector_t, ptr %190, i32 0, i32 0
  %192 = load i32, ptr %191, align 8, !tbaa !32
  %193 = icmp ne i32 %189, %192
  br i1 %193, label %194, label %206

194:                                              ; preds = %185
  %195 = load i32, ptr %13, align 4, !tbaa !5
  %196 = load i32, ptr @sightzstart, align 4, !tbaa !5
  %197 = sub nsw i32 %195, %196
  %198 = load i32, ptr %17, align 4, !tbaa !5
  %199 = call i32 @FixedDiv(i32 noundef %197, i32 noundef %198)
  store i32 %199, ptr %18, align 4, !tbaa !5
  %200 = load i32, ptr %18, align 4, !tbaa !5
  %201 = load i32, ptr @bottomslope, align 4, !tbaa !5
  %202 = icmp sgt i32 %200, %201
  br i1 %202, label %203, label %205

203:                                              ; preds = %194
  %204 = load i32, ptr %18, align 4, !tbaa !5
  store i32 %204, ptr @bottomslope, align 4, !tbaa !5
  br label %205

205:                                              ; preds = %203, %194
  br label %206

206:                                              ; preds = %205, %185
  %207 = load ptr, ptr %10, align 8, !tbaa !9
  %208 = getelementptr inbounds %struct.sector_t, ptr %207, i32 0, i32 1
  %209 = load i32, ptr %208, align 4, !tbaa !36
  %210 = load ptr, ptr %11, align 8, !tbaa !9
  %211 = getelementptr inbounds %struct.sector_t, ptr %210, i32 0, i32 1
  %212 = load i32, ptr %211, align 4, !tbaa !36
  %213 = icmp ne i32 %209, %212
  br i1 %213, label %214, label %226

214:                                              ; preds = %206
  %215 = load i32, ptr %12, align 4, !tbaa !5
  %216 = load i32, ptr @sightzstart, align 4, !tbaa !5
  %217 = sub nsw i32 %215, %216
  %218 = load i32, ptr %17, align 4, !tbaa !5
  %219 = call i32 @FixedDiv(i32 noundef %217, i32 noundef %218)
  store i32 %219, ptr %18, align 4, !tbaa !5
  %220 = load i32, ptr %18, align 4, !tbaa !5
  %221 = load i32, ptr @topslope, align 4, !tbaa !5
  %222 = icmp slt i32 %220, %221
  br i1 %222, label %223, label %225

223:                                              ; preds = %214
  %224 = load i32, ptr %18, align 4, !tbaa !5
  store i32 %224, ptr @topslope, align 4, !tbaa !5
  br label %225

225:                                              ; preds = %223, %214
  br label %226

226:                                              ; preds = %225, %206
  %227 = load i32, ptr @topslope, align 4, !tbaa !5
  %228 = load i32, ptr @bottomslope, align 4, !tbaa !5
  %229 = icmp sle i32 %227, %228
  br i1 %229, label %230, label %231

230:                                              ; preds = %226
  store i32 0, ptr %2, align 4
  store i32 1, ptr %19, align 4
  br label %238

231:                                              ; preds = %226
  br label %232

232:                                              ; preds = %231, %147, %116, %81, %53
  %233 = load ptr, ptr %4, align 8, !tbaa !9
  %234 = getelementptr inbounds %struct.seg_t, ptr %233, i32 1
  store ptr %234, ptr %4, align 8, !tbaa !9
  %235 = load i32, ptr %8, align 4, !tbaa !5
  %236 = add nsw i32 %235, -1
  store i32 %236, ptr %8, align 4, !tbaa !5
  br label %41, !llvm.loop !37

237:                                              ; preds = %41
  store i32 1, ptr %2, align 4
  store i32 1, ptr %19, align 4
  br label %238

238:                                              ; preds = %237, %230, %184, %124
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  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
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  %239 = load i32, ptr %2, align 4
  ret i32 %239
}

; Function Attrs: noreturn
declare void @I_Error(ptr noundef, ...) #3

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 = { noreturn "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }
attributes #5 = { noreturn }

!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, !13, i64 8}
!12 = !{!"subsector_s", !10, i64 0, !13, i64 8, !13, i64 10}
!13 = !{!"short", !7, i64 0}
!14 = !{!12, !13, i64 10}
!15 = !{!16, !10, i64 32}
!16 = !{!"", !10, i64 0, !10, i64 8, !6, i64 16, !6, i64 20, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48}
!17 = !{!18, !6, i64 72}
!18 = !{!"line_s", !10, i64 0, !10, i64 8, !6, i64 16, !6, i64 20, !13, i64 24, !13, i64 26, !13, i64 28, !7, i64 30, !7, i64 36, !6, i64 52, !10, i64 56, !10, i64 64, !6, i64 72, !10, i64 80}
!19 = !{!18, !10, i64 0}
!20 = !{!18, !10, i64 8}
!21 = !{!22, !6, i64 0}
!22 = !{!"", !6, i64 0, !6, i64 4}
!23 = !{!22, !6, i64 4}
!24 = !{!25, !6, i64 0}
!25 = !{!"", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12}
!26 = !{!25, !6, i64 4}
!27 = !{!25, !6, i64 8}
!28 = !{!25, !6, i64 12}
!29 = !{!18, !13, i64 24}
!30 = !{!16, !10, i64 40}
!31 = !{!16, !10, i64 48}
!32 = !{!33, !6, i64 0}
!33 = !{!"", !6, i64 0, !6, i64 4, !13, i64 8, !13, i64 10, !13, i64 12, !13, i64 14, !13, i64 16, !6, i64 20, !10, i64 24, !7, i64 32, !34, i64 48, !6, i64 88, !10, i64 96, !10, i64 104, !6, i64 112, !10, i64 120}
!34 = !{!"", !35, i64 0, !6, i64 24, !6, i64 28, !6, i64 32}
!35 = !{!"thinker_s", !10, i64 0, !10, i64 8, !7, i64 16}
!36 = !{!33, !6, i64 4}
!37 = distinct !{!37, !38}
!38 = !{!"llvm.loop.mustprogress"}


; 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.divline_t = type { i32, i32, i32, i32 }
%struct.subsector_s = type { ptr, i16, i16 }
%struct.seg_t = type { ptr, ptr, i32, i32, ptr, ptr, ptr, ptr }

@numsubsectors = external local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [40 x i8], align 1
@subsectors = external local_unnamed_addr global ptr, align 8
@segs = external local_unnamed_addr global ptr, align 8
@validcount = external local_unnamed_addr global i32, align 4
@strace = external dso_local global %struct.divline_t, align 4
@t2x = external dso_local local_unnamed_addr global i32, align 4
@t2y = external dso_local local_unnamed_addr global i32, align 4
@sightzstart = external dso_local local_unnamed_addr global i32, align 4
@bottomslope = external dso_local local_unnamed_addr global i32, align 4
@topslope = external dso_local local_unnamed_addr global i32, align 4

; Function Attrs: nounwind uwtable
declare dso_local i32 @P_DivlineSide(i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @P_InterceptVector2(ptr noundef, ptr noundef) local_unnamed_addr #0

declare i32 @FixedDiv(i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @P_CrossSubsector(i32 noundef %0) local_unnamed_addr #0 {
  %2 = alloca %struct.divline_t, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #5
  %3 = load i32, ptr @numsubsectors, align 4, !tbaa !5
  %.not = icmp sgt i32 %3, %0
  br i1 %.not, label %5, label %4

4:                                                ; preds = %1
  tail call void (ptr, ...) @I_Error(ptr noundef nonnull @.str, i32 noundef %0, i32 noundef %3) #6
  unreachable

5:                                                ; preds = %1
  %6 = load ptr, ptr @subsectors, align 8, !tbaa !9
  %7 = sext i32 %0 to i64
  %8 = getelementptr inbounds %struct.subsector_s, ptr %6, i64 %7
  %9 = getelementptr inbounds i8, ptr %8, i64 8
  %10 = load i16, ptr %9, align 8, !tbaa !11
  %.not6975 = icmp eq i16 %10, 0
  br i1 %.not6975, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %5
  %11 = sext i16 %10 to i32
  %12 = load ptr, ptr @segs, align 8, !tbaa !9
  %13 = getelementptr inbounds i8, ptr %8, i64 10
  %14 = load i16, ptr %13, align 2, !tbaa !14
  %15 = sext i16 %14 to i64
  %16 = getelementptr inbounds %struct.seg_t, ptr %12, i64 %15
  %17 = getelementptr inbounds i8, ptr %2, i64 8
  br label %18

18:                                               ; preds = %.lr.ph, %92
  %.05677 = phi ptr [ %16, %.lr.ph ], [ %93, %92 ]
  %.05976 = phi i32 [ %11, %.lr.ph ], [ %94, %92 ]
  %19 = getelementptr inbounds i8, ptr %.05677, i64 32
  %20 = load ptr, ptr %19, align 8, !tbaa !15
  %21 = getelementptr inbounds i8, ptr %20, i64 72
  %22 = load i32, ptr %21, align 8, !tbaa !17
  %23 = load i32, ptr @validcount, align 4, !tbaa !5
  %24 = icmp eq i32 %22, %23
  br i1 %24, label %92, label %25

25:                                               ; preds = %18
  store i32 %23, ptr %21, align 8, !tbaa !17
  %26 = load ptr, ptr %20, align 8, !tbaa !19
  %27 = getelementptr inbounds i8, ptr %20, i64 8
  %28 = load ptr, ptr %27, align 8, !tbaa !20
  %29 = load i32, ptr %26, align 4, !tbaa !21
  %30 = getelementptr inbounds i8, ptr %26, i64 4
  %31 = load i32, ptr %30, align 4, !tbaa !23
  %32 = call i32 @P_DivlineSide(i32 noundef %29, i32 noundef %31, ptr noundef nonnull @strace)
  %33 = load i32, ptr %28, align 4, !tbaa !21
  %34 = getelementptr inbounds i8, ptr %28, i64 4
  %35 = load i32, ptr %34, align 4, !tbaa !23
  %36 = call i32 @P_DivlineSide(i32 noundef %33, i32 noundef %35, ptr noundef nonnull @strace)
  %37 = icmp eq i32 %32, %36
  br i1 %37, label %92, label %38

38:                                               ; preds = %25
  %39 = load <2 x i32>, ptr %26, align 4, !tbaa !5
  store <2 x i32> %39, ptr %2, align 8, !tbaa !5
  %40 = load <2 x i32>, ptr %28, align 4, !tbaa !5
  %41 = sub nsw <2 x i32> %40, %39
  store <2 x i32> %41, ptr %17, align 8, !tbaa !5
  %42 = load i32, ptr @strace, align 4, !tbaa !24
  %43 = load i32, ptr getelementptr inbounds (i8, ptr @strace, i64 4), align 4, !tbaa !26
  %44 = call i32 @P_DivlineSide(i32 noundef %42, i32 noundef %43, ptr noundef nonnull %2)
  %45 = load i32, ptr @t2x, align 4, !tbaa !5
  %46 = load i32, ptr @t2y, align 4, !tbaa !5
  %47 = call i32 @P_DivlineSide(i32 noundef %45, i32 noundef %46, ptr noundef nonnull %2)
  %48 = icmp eq i32 %44, %47
  br i1 %48, label %92, label %49

49:                                               ; preds = %38
  %50 = getelementptr inbounds i8, ptr %20, i64 24
  %51 = load i16, ptr %50, align 8, !tbaa !27
  %52 = and i16 %51, 4
  %.not70 = icmp eq i16 %52, 0
  br i1 %.not70, label %._crit_edge, label %53

53:                                               ; preds = %49
  %54 = getelementptr inbounds i8, ptr %.05677, i64 40
  %55 = load ptr, ptr %54, align 8, !tbaa !28
  %56 = getelementptr inbounds i8, ptr %.05677, i64 48
  %57 = load ptr, ptr %56, align 8, !tbaa !29
  %58 = load i32, ptr %55, align 8, !tbaa !30
  %59 = load i32, ptr %57, align 8, !tbaa !30
  %60 = icmp eq i32 %58, %59
  %61 = getelementptr inbounds i8, ptr %55, i64 4
  %62 = load i32, ptr %61, align 4, !tbaa !34
  %63 = getelementptr inbounds i8, ptr %57, i64 4
  %64 = load i32, ptr %63, align 4, !tbaa !34
  %65 = icmp eq i32 %62, %64
  %or.cond = select i1 %60, i1 %65, i1 false
  br i1 %or.cond, label %92, label %._crit_edge84

._crit_edge84:                                    ; preds = %53
  %66 = getelementptr inbounds i8, ptr %55, i64 4
  %67 = getelementptr inbounds i8, ptr %57, i64 4
  %. = call i32 @llvm.smin.i32(i32 %62, i32 %64)
  %.057 = call i32 @llvm.smax.i32(i32 %58, i32 %59)
  %.not71 = icmp slt i32 %.057, %.
  br i1 %.not71, label %68, label %._crit_edge

68:                                               ; preds = %._crit_edge84
  %69 = call i32 @P_InterceptVector2(ptr noundef nonnull @strace, ptr noundef nonnull %2)
  %70 = load i32, ptr %55, align 8, !tbaa !30
  %71 = load i32, ptr %57, align 8, !tbaa !30
  %.not72 = icmp eq i32 %70, %71
  br i1 %.not72, label %79, label %72

72:                                               ; preds = %68
  %73 = load i32, ptr @sightzstart, align 4, !tbaa !5
  %74 = sub nsw i32 %.057, %73
  %75 = call i32 @FixedDiv(i32 noundef %74, i32 noundef %69) #5
  %76 = load i32, ptr @bottomslope, align 4, !tbaa !5
  %77 = icmp sgt i32 %75, %76
  br i1 %77, label %78, label %79

78:                                               ; preds = %72
  store i32 %75, ptr @bottomslope, align 4, !tbaa !5
  br label %79

79:                                               ; preds = %72, %78, %68
  %80 = load i32, ptr %66, align 4, !tbaa !34
  %81 = load i32, ptr %67, align 4, !tbaa !34
  %.not73 = icmp eq i32 %80, %81
  br i1 %.not73, label %._crit_edge87, label %82

._crit_edge87:                                    ; preds = %79
  %.pre88 = load i32, ptr @topslope, align 4, !tbaa !5
  br label %89

82:                                               ; preds = %79
  %83 = load i32, ptr @sightzstart, align 4, !tbaa !5
  %84 = sub nsw i32 %., %83
  %85 = call i32 @FixedDiv(i32 noundef %84, i32 noundef %69) #5
  %86 = load i32, ptr @topslope, align 4, !tbaa !5
  %87 = icmp slt i32 %85, %86
  br i1 %87, label %88, label %89

88:                                               ; preds = %82
  store i32 %85, ptr @topslope, align 4, !tbaa !5
  br label %89

89:                                               ; preds = %._crit_edge87, %82, %88
  %90 = phi i32 [ %.pre88, %._crit_edge87 ], [ %86, %82 ], [ %85, %88 ]
  %91 = load i32, ptr @bottomslope, align 4, !tbaa !5
  %.not74 = icmp sgt i32 %90, %91
  br i1 %.not74, label %92, label %._crit_edge

92:                                               ; preds = %53, %89, %38, %25, %18
  %93 = getelementptr inbounds i8, ptr %.05677, i64 56
  %94 = add nsw i32 %.05976, -1
  %.not69 = icmp eq i32 %94, 0
  br i1 %.not69, label %._crit_edge, label %18, !llvm.loop !35

._crit_edge:                                      ; preds = %49, %._crit_edge84, %89, %92, %5
  %.0 = phi i32 [ 1, %5 ], [ 1, %92 ], [ 0, %89 ], [ 0, %._crit_edge84 ], [ 0, %49 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #5
  ret i32 %.0
}

; Function Attrs: noreturn
declare void @I_Error(ptr noundef, ...) local_unnamed_addr #3

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

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

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 = { mustprogress 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 = { noreturn "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { nounwind }
attributes #6 = { noreturn 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, !13, i64 8}
!12 = !{!"subsector_s", !10, i64 0, !13, i64 8, !13, i64 10}
!13 = !{!"short", !7, i64 0}
!14 = !{!12, !13, i64 10}
!15 = !{!16, !10, i64 32}
!16 = !{!"", !10, i64 0, !10, i64 8, !6, i64 16, !6, i64 20, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48}
!17 = !{!18, !6, i64 72}
!18 = !{!"line_s", !10, i64 0, !10, i64 8, !6, i64 16, !6, i64 20, !13, i64 24, !13, i64 26, !13, i64 28, !7, i64 30, !7, i64 36, !6, i64 52, !10, i64 56, !10, i64 64, !6, i64 72, !10, i64 80}
!19 = !{!18, !10, i64 0}
!20 = !{!18, !10, i64 8}
!21 = !{!22, !6, i64 0}
!22 = !{!"", !6, i64 0, !6, i64 4}
!23 = !{!22, !6, i64 4}
!24 = !{!25, !6, i64 0}
!25 = !{!"", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12}
!26 = !{!25, !6, i64 4}
!27 = !{!18, !13, i64 24}
!28 = !{!16, !10, i64 40}
!29 = !{!16, !10, i64 48}
!30 = !{!31, !6, i64 0}
!31 = !{!"", !6, i64 0, !6, i64 4, !13, i64 8, !13, i64 10, !13, i64 12, !13, i64 14, !13, i64 16, !6, i64 20, !10, i64 24, !7, i64 32, !32, i64 48, !6, i64 88, !10, i64 96, !10, i64 104, !6, i64 112, !10, i64 120}
!32 = !{!"", !33, i64 0, !6, i64 24, !6, i64 28, !6, i64 32}
!33 = !{!"thinker_s", !10, i64 0, !10, i64 8, !7, i64 16}
!34 = !{!31, !6, i64 4}
!35 = distinct !{!35, !36}
!36 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass