; LLVM IR from libtcod/libtcod :: src/libtcod (fov_permissive2)

; 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.ViewBumpContainer = type { i32, ptr }
%struct.ActiveViewArray = type { i64, ptr }
%struct.TCOD_Map = type { i32, i32, i32, ptr }
%struct.TCOD_MapCell = type { i8, i8, i8 }

@.str = external hidden unnamed_addr constant [73 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [93 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [15 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @TCOD_map_compute_fov_permissive2(ptr noalias noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i1 noundef zeroext %4, i32 noundef %5) #0 {
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i8, align 1
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca ptr, align 8
  %18 = alloca %struct.ViewBumpContainer, align 8
  %19 = alloca %struct.ActiveViewArray, align 8
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i32 %1, ptr %9, align 4, !tbaa !9
  store i32 %2, ptr %10, align 4, !tbaa !9
  store i32 %3, ptr %11, align 4, !tbaa !9
  %24 = zext i1 %4 to i8
  store i8 %24, ptr %12, align 1, !tbaa !11
  store i32 %5, ptr %13, align 4, !tbaa !9
  %25 = load i32, ptr %13, align 4, !tbaa !9
  %26 = icmp sle i32 0, %25
  br i1 %26, label %27, label %30

27:                                               ; preds = %6
  %28 = load i32, ptr %13, align 4, !tbaa !9
  %29 = icmp sle i32 %28, 8
  br i1 %29, label %33, label %30

30:                                               ; preds = %27, %6
  %31 = load i32, ptr %13, align 4, !tbaa !9
  %32 = call i32 (ptr, ...) @TCOD_set_errorf(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 285, i32 noundef %31)
  store i32 -2, ptr %7, align 4
  br label %213

33:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  %34 = load i32, ptr %13, align 4, !tbaa !9
  %35 = sub nsw i32 8, %34
  store i32 %35, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  %36 = load i32, ptr %13, align 4, !tbaa !9
  %37 = add nsw i32 8, %36
  store i32 %37, ptr %15, align 4, !tbaa !9
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  %39 = load i32, ptr %9, align 4, !tbaa !9
  %40 = load i32, ptr %10, align 4, !tbaa !9
  %41 = call zeroext i1 @TCOD_map_in_bounds(ptr noundef %38, i32 noundef %39, i32 noundef %40)
  br i1 %41, label %46, label %42

42:                                               ; preds = %33
  %43 = load i32, ptr %9, align 4, !tbaa !9
  %44 = load i32, ptr %10, align 4, !tbaa !9
  %45 = call i32 (ptr, ...) @TCOD_set_errorf(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 294, i32 noundef %43, i32 noundef %44)
  store i32 -2, ptr %7, align 4
  store i32 1, ptr %16, align 4
  br label %212

46:                                               ; preds = %33
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.TCOD_Map, ptr %47, i32 0, i32 3
  %49 = load ptr, ptr %48, align 8, !tbaa !13
  %50 = load i32, ptr %9, align 4, !tbaa !9
  %51 = load i32, ptr %10, align 4, !tbaa !9
  %52 = load ptr, ptr %8, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.TCOD_Map, ptr %52, i32 0, i32 0
  %54 = load i32, ptr %53, align 8, !tbaa !15
  %55 = mul nsw i32 %51, %54
  %56 = add nsw i32 %50, %55
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds %struct.TCOD_MapCell, ptr %49, i64 %57
  %59 = getelementptr inbounds %struct.TCOD_MapCell, ptr %58, i32 0, i32 2
  store i8 1, ptr %59, align 1, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #6
  %60 = load ptr, ptr %8, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.TCOD_Map, ptr %60, i32 0, i32 0
  %62 = load i32, ptr %61, align 8, !tbaa !15
  %63 = load ptr, ptr %8, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.TCOD_Map, ptr %63, i32 0, i32 1
  %65 = load i32, ptr %64, align 4, !tbaa !18
  %66 = mul nsw i32 %62, %65
  %67 = sext i32 %66 to i64
  %68 = mul i64 %67, 48
  %69 = call noalias ptr @malloc(i64 noundef %68) #7
  store ptr %69, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %18) #6
  %70 = getelementptr inbounds %struct.ViewBumpContainer, ptr %18, i32 0, i32 0
  store i32 0, ptr %70, align 8, !tbaa !19
  %71 = getelementptr inbounds %struct.ViewBumpContainer, ptr %18, i32 0, i32 1
  %72 = load ptr, ptr %8, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.TCOD_Map, ptr %72, i32 0, i32 0
  %74 = load i32, ptr %73, align 8, !tbaa !15
  %75 = load ptr, ptr %8, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.TCOD_Map, ptr %75, i32 0, i32 1
  %77 = load i32, ptr %76, align 4, !tbaa !18
  %78 = mul nsw i32 %74, %77
  %79 = sext i32 %78 to i64
  %80 = mul i64 %79, 16
  %81 = call noalias ptr @malloc(i64 noundef %80) #7
  store ptr %81, ptr %71, align 8, !tbaa !21
  call void @llvm.lifetime.start.p0(i64 16, ptr %19) #6
  %82 = getelementptr inbounds %struct.ActiveViewArray, ptr %19, i32 0, i32 0
  store i64 0, ptr %82, align 8, !tbaa !22
  %83 = getelementptr inbounds %struct.ActiveViewArray, ptr %19, i32 0, i32 1
  %84 = load ptr, ptr %8, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.TCOD_Map, ptr %84, i32 0, i32 0
  %86 = load i32, ptr %85, align 8, !tbaa !15
  %87 = load ptr, ptr %8, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.TCOD_Map, ptr %87, i32 0, i32 1
  %89 = load i32, ptr %88, align 4, !tbaa !18
  %90 = mul nsw i32 %86, %89
  %91 = sext i32 %90 to i64
  %92 = mul i64 %91, 8
  %93 = call noalias ptr @malloc(i64 noundef %92) #7
  store ptr %93, ptr %83, align 8, !tbaa !25
  %94 = load ptr, ptr %17, align 8, !tbaa !5
  %95 = icmp ne ptr %94, null
  br i1 %95, label %96, label %104

96:                                               ; preds = %46
  %97 = getelementptr inbounds %struct.ViewBumpContainer, ptr %18, i32 0, i32 1
  %98 = load ptr, ptr %97, align 8, !tbaa !21
  %99 = icmp ne ptr %98, null
  br i1 %99, label %100, label %104

100:                                              ; preds = %96
  %101 = getelementptr inbounds %struct.ActiveViewArray, ptr %19, i32 0, i32 1
  %102 = load ptr, ptr %101, align 8, !tbaa !25
  %103 = icmp ne ptr %102, null
  br i1 %103, label %111, label %104

104:                                              ; preds = %100, %96, %46
  %105 = getelementptr inbounds %struct.ViewBumpContainer, ptr %18, i32 0, i32 1
  %106 = load ptr, ptr %105, align 8, !tbaa !21
  call void @free(ptr noundef %106) #6
  %107 = load ptr, ptr %17, align 8, !tbaa !5
  call void @free(ptr noundef %107) #6
  %108 = getelementptr inbounds %struct.ActiveViewArray, ptr %19, i32 0, i32 1
  %109 = load ptr, ptr %108, align 8, !tbaa !25
  call void @free(ptr noundef %109) #6
  %110 = call i32 (ptr, ...) @TCOD_set_errorf(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 307, ptr noundef @.str.4)
  store i32 -3, ptr %7, align 4
  store i32 1, ptr %16, align 4
  br label %211

111:                                              ; preds = %100
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #6
  %112 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %112, ptr %20, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #6
  %113 = load ptr, ptr %8, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.TCOD_Map, ptr %113, i32 0, i32 0
  %115 = load i32, ptr %114, align 8, !tbaa !15
  %116 = load i32, ptr %9, align 4, !tbaa !9
  %117 = sub nsw i32 %115, %116
  %118 = sub nsw i32 %117, 1
  store i32 %118, ptr %21, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #6
  %119 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %119, ptr %22, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #6
  %120 = load ptr, ptr %8, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct.TCOD_Map, ptr %120, i32 0, i32 1
  %122 = load i32, ptr %121, align 4, !tbaa !18
  %123 = load i32, ptr %10, align 4, !tbaa !9
  %124 = sub nsw i32 %122, %123
  %125 = sub nsw i32 %124, 1
  store i32 %125, ptr %23, align 4, !tbaa !9
  %126 = load i32, ptr %11, align 4, !tbaa !9
  %127 = icmp sgt i32 %126, 0
  br i1 %127, label %128, label %165

128:                                              ; preds = %111
  %129 = load i32, ptr %20, align 4, !tbaa !9
  %130 = load i32, ptr %11, align 4, !tbaa !9
  %131 = icmp slt i32 %129, %130
  br i1 %131, label %132, label %134

132:                                              ; preds = %128
  %133 = load i32, ptr %20, align 4, !tbaa !9
  br label %136

134:                                              ; preds = %128
  %135 = load i32, ptr %11, align 4, !tbaa !9
  br label %136

136:                                              ; preds = %134, %132
  %137 = phi i32 [ %133, %132 ], [ %135, %134 ]
  store i32 %137, ptr %20, align 4, !tbaa !9
  %138 = load i32, ptr %21, align 4, !tbaa !9
  %139 = load i32, ptr %11, align 4, !tbaa !9
  %140 = icmp slt i32 %138, %139
  br i1 %140, label %141, label %143

141:                                              ; preds = %136
  %142 = load i32, ptr %21, align 4, !tbaa !9
  br label %145

143:                                              ; preds = %136
  %144 = load i32, ptr %11, align 4, !tbaa !9
  br label %145

145:                                              ; preds = %143, %141
  %146 = phi i32 [ %142, %141 ], [ %144, %143 ]
  store i32 %146, ptr %21, align 4, !tbaa !9
  %147 = load i32, ptr %22, align 4, !tbaa !9
  %148 = load i32, ptr %11, align 4, !tbaa !9
  %149 = icmp slt i32 %147, %148
  br i1 %149, label %150, label %152

150:                                              ; preds = %145
  %151 = load i32, ptr %22, align 4, !tbaa !9
  br label %154

152:                                              ; preds = %145
  %153 = load i32, ptr %11, align 4, !tbaa !9
  br label %154

154:                                              ; preds = %152, %150
  %155 = phi i32 [ %151, %150 ], [ %153, %152 ]
  store i32 %155, ptr %22, align 4, !tbaa !9
  %156 = load i32, ptr %23, align 4, !tbaa !9
  %157 = load i32, ptr %11, align 4, !tbaa !9
  %158 = icmp slt i32 %156, %157
  br i1 %158, label %159, label %161

159:                                              ; preds = %154
  %160 = load i32, ptr %23, align 4, !tbaa !9
  br label %163

161:                                              ; preds = %154
  %162 = load i32, ptr %11, align 4, !tbaa !9
  br label %163

163:                                              ; preds = %161, %159
  %164 = phi i32 [ %160, %159 ], [ %162, %161 ]
  store i32 %164, ptr %23, align 4, !tbaa !9
  br label %165

165:                                              ; preds = %163, %111
  %166 = load ptr, ptr %8, align 8, !tbaa !5
  %167 = load i32, ptr %9, align 4, !tbaa !9
  %168 = load i32, ptr %10, align 4, !tbaa !9
  %169 = load i32, ptr %21, align 4, !tbaa !9
  %170 = load i32, ptr %23, align 4, !tbaa !9
  %171 = load i8, ptr %12, align 1, !tbaa !11, !range !26, !noundef !27
  %172 = trunc i8 %171 to i1
  %173 = load i32, ptr %14, align 4, !tbaa !9
  %174 = load i32, ptr %15, align 4, !tbaa !9
  %175 = load ptr, ptr %17, align 8, !tbaa !5
  call void @check_quadrant(ptr noundef %166, i32 noundef %167, i32 noundef %168, i32 noundef 1, i32 noundef 1, i32 noundef %169, i32 noundef %170, i1 noundef zeroext %172, i32 noundef %173, i32 noundef %174, ptr noundef %175, ptr noundef %18, ptr noundef %19)
  %176 = load ptr, ptr %8, align 8, !tbaa !5
  %177 = load i32, ptr %9, align 4, !tbaa !9
  %178 = load i32, ptr %10, align 4, !tbaa !9
  %179 = load i32, ptr %21, align 4, !tbaa !9
  %180 = load i32, ptr %22, align 4, !tbaa !9
  %181 = load i8, ptr %12, align 1, !tbaa !11, !range !26, !noundef !27
  %182 = trunc i8 %181 to i1
  %183 = load i32, ptr %14, align 4, !tbaa !9
  %184 = load i32, ptr %15, align 4, !tbaa !9
  %185 = load ptr, ptr %17, align 8, !tbaa !5
  call void @check_quadrant(ptr noundef %176, i32 noundef %177, i32 noundef %178, i32 noundef 1, i32 noundef -1, i32 noundef %179, i32 noundef %180, i1 noundef zeroext %182, i32 noundef %183, i32 noundef %184, ptr noundef %185, ptr noundef %18, ptr noundef %19)
  %186 = load ptr, ptr %8, align 8, !tbaa !5
  %187 = load i32, ptr %9, align 4, !tbaa !9
  %188 = load i32, ptr %10, align 4, !tbaa !9
  %189 = load i32, ptr %20, align 4, !tbaa !9
  %190 = load i32, ptr %22, align 4, !tbaa !9
  %191 = load i8, ptr %12, align 1, !tbaa !11, !range !26, !noundef !27
  %192 = trunc i8 %191 to i1
  %193 = load i32, ptr %14, align 4, !tbaa !9
  %194 = load i32, ptr %15, align 4, !tbaa !9
  %195 = load ptr, ptr %17, align 8, !tbaa !5
  call void @check_quadrant(ptr noundef %186, i32 noundef %187, i32 noundef %188, i32 noundef -1, i32 noundef -1, i32 noundef %189, i32 noundef %190, i1 noundef zeroext %192, i32 noundef %193, i32 noundef %194, ptr noundef %195, ptr noundef %18, ptr noundef %19)
  %196 = load ptr, ptr %8, align 8, !tbaa !5
  %197 = load i32, ptr %9, align 4, !tbaa !9
  %198 = load i32, ptr %10, align 4, !tbaa !9
  %199 = load i32, ptr %20, align 4, !tbaa !9
  %200 = load i32, ptr %23, align 4, !tbaa !9
  %201 = load i8, ptr %12, align 1, !tbaa !11, !range !26, !noundef !27
  %202 = trunc i8 %201 to i1
  %203 = load i32, ptr %14, align 4, !tbaa !9
  %204 = load i32, ptr %15, align 4, !tbaa !9
  %205 = load ptr, ptr %17, align 8, !tbaa !5
  call void @check_quadrant(ptr noundef %196, i32 noundef %197, i32 noundef %198, i32 noundef -1, i32 noundef 1, i32 noundef %199, i32 noundef %200, i1 noundef zeroext %202, i32 noundef %203, i32 noundef %204, ptr noundef %205, ptr noundef %18, ptr noundef %19)
  %206 = getelementptr inbounds %struct.ViewBumpContainer, ptr %18, i32 0, i32 1
  %207 = load ptr, ptr %206, align 8, !tbaa !21
  call void @free(ptr noundef %207) #6
  %208 = load ptr, ptr %17, align 8, !tbaa !5
  call void @free(ptr noundef %208) #6
  %209 = getelementptr inbounds %struct.ActiveViewArray, ptr %19, i32 0, i32 1
  %210 = load ptr, ptr %209, align 8, !tbaa !25
  call void @free(ptr noundef %210) #6
  store i32 0, ptr %7, align 4
  store i32 1, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #6
  br label %211

211:                                              ; preds = %165, %104
  call void @llvm.lifetime.end.p0(i64 16, ptr %19) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #6
  br label %212

212:                                              ; preds = %211, %42
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  br label %213

213:                                              ; preds = %212, %30
  %214 = load i32, ptr %7, align 4
  ret i32 %214
}

declare i32 @TCOD_set_errorf(ptr noundef, ...) #1

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @TCOD_map_in_bounds(ptr noundef, i32 noundef, i32 noundef) #3

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #4

; Function Attrs: nounwind
declare void @free(ptr noundef) #5

; Function Attrs: nounwind uwtable
declare hidden void @check_quadrant(ptr noalias noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i1 noundef zeroext, i32 noundef, i32 noundef, ptr noalias noundef, ptr noalias noundef, ptr noalias noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { inlinehint 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 #4 = { nounwind allocsize(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 #5 = { nounwind "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 #6 = { nounwind }
attributes #7 = { nounwind allocsize(0) }

!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, !12, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!14, !6, i64 16}
!14 = !{!"TCOD_Map", !10, i64 0, !10, i64 4, !10, i64 8, !6, i64 16}
!15 = !{!14, !10, i64 0}
!16 = !{!17, !12, i64 2}
!17 = !{!"TCOD_MapCell", !12, i64 0, !12, i64 1, !12, i64 2}
!18 = !{!14, !10, i64 4}
!19 = !{!20, !10, i64 0}
!20 = !{!"ViewBumpContainer", !10, i64 0, !6, i64 8}
!21 = !{!20, !6, i64 8}
!22 = !{!23, !24, i64 0}
!23 = !{!"ActiveViewArray", !24, i64 0, !6, i64 8}
!24 = !{!"long", !7, i64 0}
!25 = !{!23, !6, i64 8}
!26 = !{i8 0, i8 2}
!27 = !{}


; 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.ViewBumpContainer = type { i32, ptr }
%struct.ActiveViewArray = type { i64, ptr }
%struct.TCOD_MapCell = type { i8, i8, i8 }

@.str = external hidden unnamed_addr constant [73 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [93 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [15 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 -3, 1) i32 @TCOD_map_compute_fov_permissive2(ptr noalias noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i1 noundef zeroext %4, i32 noundef %5) local_unnamed_addr #0 {
  %7 = alloca %struct.ViewBumpContainer, align 8
  %8 = alloca %struct.ActiveViewArray, align 8
  %or.cond = icmp ult i32 %5, 9
  br i1 %or.cond, label %11, label %9

9:                                                ; preds = %6
  %10 = tail call i32 (ptr, ...) @TCOD_set_errorf(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 285, i32 noundef %5) #7
  br label %57

11:                                               ; preds = %6
  %12 = sub nuw nsw i32 8, %5
  %13 = add nuw nsw i32 %5, 8
  %14 = tail call zeroext i1 @TCOD_map_in_bounds(ptr noundef %0, i32 noundef %1, i32 noundef %2)
  br i1 %14, label %17, label %15

15:                                               ; preds = %11
  %16 = tail call i32 (ptr, ...) @TCOD_set_errorf(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 294, i32 noundef %1, i32 noundef %2) #7
  br label %57

17:                                               ; preds = %11
  %18 = getelementptr inbounds i8, ptr %0, i64 16
  %19 = load ptr, ptr %18, align 8, !tbaa !5
  %20 = load i32, ptr %0, align 8, !tbaa !11
  %21 = mul nsw i32 %20, %2
  %22 = add nsw i32 %21, %1
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds %struct.TCOD_MapCell, ptr %19, i64 %23, i32 2
  store i8 1, ptr %24, align 1, !tbaa !12
  %25 = getelementptr inbounds i8, ptr %0, i64 4
  %26 = load i32, ptr %25, align 4, !tbaa !15
  %27 = mul nsw i32 %26, %20
  %28 = sext i32 %27 to i64
  %29 = mul nsw i64 %28, 48
  %30 = tail call noalias ptr @malloc(i64 noundef %29) #8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %7) #7
  store i32 0, ptr %7, align 8, !tbaa !16
  %31 = getelementptr inbounds i8, ptr %7, i64 8
  %32 = shl nsw i64 %28, 4
  %33 = tail call noalias ptr @malloc(i64 noundef %32) #8
  store ptr %33, ptr %31, align 8, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %8) #7
  store i64 0, ptr %8, align 8, !tbaa !19
  %34 = getelementptr inbounds i8, ptr %8, i64 8
  %35 = shl nsw i64 %28, 3
  %36 = tail call noalias ptr @malloc(i64 noundef %35) #8
  store ptr %36, ptr %34, align 8, !tbaa !22
  %37 = icmp ne ptr %30, null
  %38 = icmp ne ptr %33, null
  %or.cond4 = and i1 %37, %38
  %39 = icmp ne ptr %36, null
  %or.cond7 = and i1 %or.cond4, %39
  br i1 %or.cond7, label %42, label %40

40:                                               ; preds = %17
  tail call void @free(ptr noundef %33) #7
  tail call void @free(ptr noundef %30) #7
  tail call void @free(ptr noundef %36) #7
  %41 = tail call i32 (ptr, ...) @TCOD_set_errorf(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 307, ptr noundef nonnull @.str.4) #7
  br label %56

42:                                               ; preds = %17
  %43 = xor i32 %1, -1
  %44 = add i32 %20, %43
  %45 = xor i32 %2, -1
  %46 = add i32 %26, %45
  %47 = icmp sgt i32 %3, 0
  br i1 %47, label %48, label %53

48:                                               ; preds = %42
  %49 = tail call i32 @llvm.smin.i32(i32 %1, i32 %3)
  %50 = tail call i32 @llvm.smin.i32(i32 %44, i32 %3)
  %51 = tail call i32 @llvm.smin.i32(i32 %2, i32 %3)
  %52 = tail call i32 @llvm.smin.i32(i32 %46, i32 %3)
  br label %53

53:                                               ; preds = %48, %42
  %.091 = phi i32 [ %49, %48 ], [ %1, %42 ]
  %.090 = phi i32 [ %50, %48 ], [ %44, %42 ]
  %.089 = phi i32 [ %51, %48 ], [ %2, %42 ]
  %.0 = phi i32 [ %52, %48 ], [ %46, %42 ]
  call void @check_quadrant(ptr noundef nonnull %0, i32 noundef %1, i32 noundef %2, i32 noundef 1, i32 noundef 1, i32 noundef %.090, i32 noundef %.0, i1 noundef zeroext %4, i32 noundef %12, i32 noundef %13, ptr noundef nonnull %30, ptr noundef nonnull %7, ptr noundef nonnull %8)
  call void @check_quadrant(ptr noundef nonnull %0, i32 noundef %1, i32 noundef %2, i32 noundef 1, i32 noundef -1, i32 noundef %.090, i32 noundef %.089, i1 noundef zeroext %4, i32 noundef %12, i32 noundef %13, ptr noundef nonnull %30, ptr noundef nonnull %7, ptr noundef nonnull %8)
  call void @check_quadrant(ptr noundef nonnull %0, i32 noundef %1, i32 noundef %2, i32 noundef -1, i32 noundef -1, i32 noundef %.091, i32 noundef %.089, i1 noundef zeroext %4, i32 noundef %12, i32 noundef %13, ptr noundef nonnull %30, ptr noundef nonnull %7, ptr noundef nonnull %8)
  call void @check_quadrant(ptr noundef nonnull %0, i32 noundef %1, i32 noundef %2, i32 noundef -1, i32 noundef 1, i32 noundef %.091, i32 noundef %.0, i1 noundef zeroext %4, i32 noundef %12, i32 noundef %13, ptr noundef nonnull %30, ptr noundef nonnull %7, ptr noundef nonnull %8)
  %54 = load ptr, ptr %31, align 8, !tbaa !18
  call void @free(ptr noundef %54) #7
  call void @free(ptr noundef nonnull %30) #7
  %55 = load ptr, ptr %34, align 8, !tbaa !22
  call void @free(ptr noundef %55) #7
  br label %56

56:                                               ; preds = %53, %40
  %.092 = phi i32 [ 0, %53 ], [ -3, %40 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %8) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #7
  br label %57

57:                                               ; preds = %15, %56, %9
  %.2 = phi i32 [ -2, %9 ], [ %.092, %56 ], [ -2, %15 ]
  ret i32 %.2
}

declare i32 @TCOD_set_errorf(ptr noundef, ...) local_unnamed_addr #1

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @TCOD_map_in_bounds(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #5

; Function Attrs: nounwind uwtable
declare hidden void @check_quadrant(ptr noalias noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i1 noundef zeroext, i32 noundef, i32 noundef, ptr noalias noundef, ptr noalias noundef, ptr noalias noundef) local_unnamed_addr #0

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

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

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { inlinehint 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 #4 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #5 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #6 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #7 = { nounwind }
attributes #8 = { nounwind allocsize(0) }

!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, !10, i64 16}
!6 = !{!"TCOD_Map", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!13, !14, i64 2}
!13 = !{!"TCOD_MapCell", !14, i64 0, !14, i64 1, !14, i64 2}
!14 = !{!"_Bool", !8, i64 0}
!15 = !{!6, !7, i64 4}
!16 = !{!17, !7, i64 0}
!17 = !{!"ViewBumpContainer", !7, i64 0, !10, i64 8}
!18 = !{!17, !10, i64 8}
!19 = !{!20, !21, i64 0}
!20 = !{!"ActiveViewArray", !21, i64 0, !10, i64 8}
!21 = !{!"long", !8, i64 0}
!22 = !{!20, !10, i64 8}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass