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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @TCOD_map_compute_fov_diamond_raycasting(ptr noalias noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i1 noundef zeroext %4) #0 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i8, align 1
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca %struct.DiamondFov, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !9
  store i32 %2, ptr %9, align 4, !tbaa !9
  store i32 %3, ptr %10, align 4, !tbaa !9
  %18 = zext i1 %4 to i8
  store i8 %18, ptr %11, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  %19 = load i32, ptr %10, align 4, !tbaa !9
  %20 = load i32, ptr %10, align 4, !tbaa !9
  %21 = mul nsw i32 %19, %20
  store i32 %21, ptr %12, align 4, !tbaa !9
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = load i32, ptr %8, align 4, !tbaa !9
  %24 = load i32, ptr %9, align 4, !tbaa !9
  %25 = call zeroext i1 @TCOD_map_in_bounds(ptr noundef %22, i32 noundef %23, i32 noundef %24)
  br i1 %25, label %30, label %26

26:                                               ; preds = %5
  %27 = load i32, ptr %8, align 4, !tbaa !9
  %28 = load i32, ptr %9, align 4, !tbaa !9
  %29 = call i32 (ptr, ...) @TCOD_set_errorf(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 201, i32 noundef %27, i32 noundef %28)
  store i32 -2, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %158

30:                                               ; preds = %5
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.TCOD_Map, ptr %31, i32 0, i32 3
  %33 = load ptr, ptr %32, align 8, !tbaa !13
  %34 = load i32, ptr %8, align 4, !tbaa !9
  %35 = load i32, ptr %9, align 4, !tbaa !9
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.TCOD_Map, ptr %36, i32 0, i32 0
  %38 = load i32, ptr %37, align 8, !tbaa !15
  %39 = mul nsw i32 %35, %38
  %40 = add nsw i32 %34, %39
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds %struct.TCOD_MapCell, ptr %33, i64 %41
  %43 = getelementptr inbounds %struct.TCOD_MapCell, ptr %42, i32 0, i32 2
  store i8 1, ptr %43, align 1, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 32, ptr %14) #6
  %44 = getelementptr inbounds %struct.DiamondFov, ptr %14, i32 0, i32 0
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %45, ptr %44, align 8, !tbaa !18
  %46 = getelementptr inbounds %struct.DiamondFov, ptr %14, i32 0, i32 1
  %47 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %47, ptr %46, align 8, !tbaa !20
  %48 = getelementptr inbounds %struct.DiamondFov, ptr %14, i32 0, i32 2
  %49 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %49, ptr %48, align 4, !tbaa !21
  %50 = getelementptr inbounds %struct.DiamondFov, ptr %14, i32 0, i32 3
  %51 = load ptr, ptr %7, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.TCOD_Map, ptr %51, i32 0, i32 2
  %53 = load i32, ptr %52, align 8, !tbaa !22
  %54 = sext i32 %53 to i64
  %55 = call noalias ptr @calloc(i64 noundef %54, i64 noundef 56) #7
  store ptr %55, ptr %50, align 8, !tbaa !23
  %56 = getelementptr inbounds %struct.DiamondFov, ptr %14, i32 0, i32 4
  store ptr null, ptr %56, align 8, !tbaa !24
  %57 = getelementptr inbounds %struct.DiamondFov, ptr %14, i32 0, i32 3
  %58 = load ptr, ptr %57, align 8, !tbaa !23
  %59 = icmp ne ptr %58, null
  br i1 %59, label %62, label %60

60:                                               ; preds = %30
  %61 = call i32 (ptr, ...) @TCOD_set_errorf(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 214, ptr noundef @.str.3)
  store i32 -3, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %157

62:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  %63 = call ptr @get_ray(ptr noundef %14, i32 noundef 0, i32 noundef 0)
  %64 = getelementptr inbounds %struct.DiamondFov, ptr %14, i32 0, i32 4
  store ptr %63, ptr %64, align 8, !tbaa !24
  store ptr %63, ptr %15, align 8, !tbaa !5
  %65 = load ptr, ptr %15, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.RaycastTile, ptr %65, i32 0, i32 9
  store i8 1, ptr %66, align 8, !tbaa !25
  %67 = load ptr, ptr %15, align 8, !tbaa !5
  call void @expand_perimeter_from(ptr noundef %14, ptr noundef %67)
  br label %68

68:                                               ; preds = %121, %120, %106, %92, %62
  %69 = load ptr, ptr %15, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.RaycastTile, ptr %69, i32 0, i32 8
  %71 = load ptr, ptr %70, align 8, !tbaa !27
  store ptr %71, ptr %15, align 8, !tbaa !5
  %72 = icmp ne ptr %71, null
  br i1 %72, label %73, label %145

73:                                               ; preds = %68
  %74 = load i32, ptr %12, align 4, !tbaa !9
  %75 = icmp sle i32 %74, 0
  br i1 %75, label %81, label %76

76:                                               ; preds = %73
  %77 = load ptr, ptr %15, align 8, !tbaa !5
  %78 = call i32 @ray_length_sq(ptr noundef %77)
  %79 = load i32, ptr %12, align 4, !tbaa !9
  %80 = icmp sle i32 %78, %79
  br i1 %80, label %81, label %83

81:                                               ; preds = %76, %73
  %82 = load ptr, ptr %15, align 8, !tbaa !5
  call void @merge_input(ptr noundef %14, ptr noundef %82)
  br label %86

83:                                               ; preds = %76
  %84 = load ptr, ptr %15, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.RaycastTile, ptr %84, i32 0, i32 10
  store i8 1, ptr %85, align 1, !tbaa !28
  br label %86

86:                                               ; preds = %83, %81
  %87 = load ptr, ptr %15, align 8, !tbaa !5
  call void @expand_perimeter_from(ptr noundef %14, ptr noundef %87)
  %88 = load ptr, ptr %15, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.RaycastTile, ptr %88, i32 0, i32 10
  %90 = load i8, ptr %89, align 1, !tbaa !28, !range !29, !noundef !30
  %91 = trunc i8 %90 to i1
  br i1 %91, label %92, label %93

92:                                               ; preds = %86
  br label %68, !llvm.loop !31

93:                                               ; preds = %86
  %94 = load ptr, ptr %15, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.RaycastTile, ptr %94, i32 0, i32 4
  %96 = load i32, ptr %95, align 8, !tbaa !33
  %97 = icmp sgt i32 %96, 0
  br i1 %97, label %98, label %107

98:                                               ; preds = %93
  %99 = load ptr, ptr %15, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.RaycastTile, ptr %99, i32 0, i32 4
  %101 = load i32, ptr %100, align 8, !tbaa !33
  %102 = load ptr, ptr %15, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.RaycastTile, ptr %102, i32 0, i32 2
  %104 = load i32, ptr %103, align 8, !tbaa !34
  %105 = icmp sle i32 %101, %104
  br i1 %105, label %106, label %107

106:                                              ; preds = %98
  br label %68, !llvm.loop !31

107:                                              ; preds = %98, %93
  %108 = load ptr, ptr %15, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.RaycastTile, ptr %108, i32 0, i32 5
  %110 = load i32, ptr %109, align 4, !tbaa !35
  %111 = icmp sgt i32 %110, 0
  br i1 %111, label %112, label %121

112:                                              ; preds = %107
  %113 = load ptr, ptr %15, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.RaycastTile, ptr %113, i32 0, i32 5
  %115 = load i32, ptr %114, align 4, !tbaa !35
  %116 = load ptr, ptr %15, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.RaycastTile, ptr %116, i32 0, i32 3
  %118 = load i32, ptr %117, align 4, !tbaa !36
  %119 = icmp sle i32 %115, %118
  br i1 %119, label %120, label %121

120:                                              ; preds = %112
  br label %68, !llvm.loop !31

121:                                              ; preds = %112, %107
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  %122 = load i32, ptr %8, align 4, !tbaa !9
  %123 = load ptr, ptr %15, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.RaycastTile, ptr %123, i32 0, i32 0
  %125 = load i32, ptr %124, align 8, !tbaa !37
  %126 = add nsw i32 %122, %125
  store i32 %126, ptr %16, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  %127 = load i32, ptr %9, align 4, !tbaa !9
  %128 = load ptr, ptr %15, align 8, !tbaa !5
  %129 = getelementptr inbounds %struct.RaycastTile, ptr %128, i32 0, i32 1
  %130 = load i32, ptr %129, align 4, !tbaa !38
  %131 = add nsw i32 %127, %130
  store i32 %131, ptr %17, align 4, !tbaa !9
  %132 = load ptr, ptr %7, align 8, !tbaa !5
  %133 = getelementptr inbounds %struct.TCOD_Map, ptr %132, i32 0, i32 3
  %134 = load ptr, ptr %133, align 8, !tbaa !13
  %135 = load i32, ptr %16, align 4, !tbaa !9
  %136 = load i32, ptr %17, align 4, !tbaa !9
  %137 = load ptr, ptr %7, align 8, !tbaa !5
  %138 = getelementptr inbounds %struct.TCOD_Map, ptr %137, i32 0, i32 0
  %139 = load i32, ptr %138, align 8, !tbaa !15
  %140 = mul nsw i32 %136, %139
  %141 = add nsw i32 %135, %140
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds %struct.TCOD_MapCell, ptr %134, i64 %142
  %144 = getelementptr inbounds %struct.TCOD_MapCell, ptr %143, i32 0, i32 2
  store i8 1, ptr %144, align 1, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  br label %68, !llvm.loop !31

145:                                              ; preds = %68
  %146 = getelementptr inbounds %struct.DiamondFov, ptr %14, i32 0, i32 3
  %147 = load ptr, ptr %146, align 8, !tbaa !23
  call void @free(ptr noundef %147) #6
  %148 = load i8, ptr %11, align 1, !tbaa !11, !range !29, !noundef !30
  %149 = trunc i8 %148 to i1
  br i1 %149, label %150, label %156

150:                                              ; preds = %145
  %151 = load ptr, ptr %7, align 8, !tbaa !5
  %152 = load i32, ptr %8, align 4, !tbaa !9
  %153 = load i32, ptr %9, align 4, !tbaa !9
  %154 = load i32, ptr %10, align 4, !tbaa !9
  %155 = call i32 @TCOD_map_postprocess(ptr noundef %151, i32 noundef %152, i32 noundef %153, i32 noundef %154)
  br label %156

156:                                              ; preds = %150, %145
  store i32 0, ptr %6, align 4
  store i32 1, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  br label %157

157:                                              ; preds = %156, %60
  call void @llvm.lifetime.end.p0(i64 32, ptr %14) #6
  br label %158

158:                                              ; preds = %157, %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  %159 = load i32, ptr %6, align 4
  ret i32 %159
}

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

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

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

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

; Function Attrs: nounwind uwtable
declare hidden ptr @get_ray(ptr noalias noundef, i32 noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @expand_perimeter_from(ptr noalias noundef, ptr noalias noundef) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @ray_length_sq(ptr noalias noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @merge_input(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) #1

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

declare i32 @TCOD_map_postprocess(ptr noundef, i32 noundef, i32 noundef, i32 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 = { 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 #3 = { "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,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 #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,1) }

!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 = !{!19, !6, i64 0}
!19 = !{!"DiamondFov", !6, i64 0, !10, i64 8, !10, i64 12, !6, i64 16, !6, i64 24}
!20 = !{!19, !10, i64 8}
!21 = !{!19, !10, i64 12}
!22 = !{!14, !10, i64 8}
!23 = !{!19, !6, i64 16}
!24 = !{!19, !6, i64 24}
!25 = !{!26, !12, i64 48}
!26 = !{!"RaycastTile", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !6, i64 24, !6, i64 32, !6, i64 40, !12, i64 48, !12, i64 49}
!27 = !{!26, !6, i64 40}
!28 = !{!26, !12, i64 49}
!29 = !{i8 0, i8 2}
!30 = !{}
!31 = distinct !{!31, !32}
!32 = !{!"llvm.loop.mustprogress"}
!33 = !{!26, !10, i64 16}
!34 = !{!26, !10, i64 8}
!35 = !{!26, !10, i64 20}
!36 = !{!26, !10, i64 12}
!37 = !{!26, !10, i64 0}
!38 = !{!26, !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.DiamondFov = type { ptr, i32, i32, ptr, ptr }
%struct.TCOD_MapCell = type { i8, i8, i8 }

@.str = external hidden unnamed_addr constant [47 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [100 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.3 = 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_diamond_raycasting(ptr noalias noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i1 noundef zeroext %4) local_unnamed_addr #0 {
  %6 = alloca %struct.DiamondFov, align 8
  %7 = mul nsw i32 %3, %3
  %8 = tail call zeroext i1 @TCOD_map_in_bounds(ptr noundef %0, i32 noundef %1, i32 noundef %2)
  br i1 %8, label %11, label %9

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

11:                                               ; preds = %5
  %12 = getelementptr inbounds i8, ptr %0, i64 16
  %13 = load ptr, ptr %12, align 8, !tbaa !5
  %14 = load i32, ptr %0, align 8, !tbaa !11
  %15 = mul nsw i32 %14, %2
  %16 = add nsw i32 %15, %1
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds %struct.TCOD_MapCell, ptr %13, i64 %17, i32 2
  store i8 1, ptr %18, align 1, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %6) #6
  store ptr %0, ptr %6, align 8, !tbaa !15
  %19 = getelementptr inbounds i8, ptr %6, i64 8
  store i32 %1, ptr %19, align 8, !tbaa !17
  %20 = getelementptr inbounds i8, ptr %6, i64 12
  store i32 %2, ptr %20, align 4, !tbaa !18
  %21 = getelementptr inbounds i8, ptr %6, i64 16
  %22 = getelementptr inbounds i8, ptr %0, i64 8
  %23 = load i32, ptr %22, align 8, !tbaa !19
  %24 = sext i32 %23 to i64
  %25 = tail call noalias ptr @calloc(i64 noundef %24, i64 noundef 56) #7
  store ptr %25, ptr %21, align 8, !tbaa !20
  %26 = getelementptr inbounds i8, ptr %6, i64 24
  store ptr null, ptr %26, align 8, !tbaa !21
  %.not = icmp eq ptr %25, null
  br i1 %.not, label %27, label %29

27:                                               ; preds = %11
  %28 = tail call i32 (ptr, ...) @TCOD_set_errorf(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 214, ptr noundef nonnull @.str.3) #6
  br label %107

29:                                               ; preds = %11
  %30 = call ptr @get_ray(ptr noundef nonnull %6, i32 noundef 0, i32 noundef 0)
  store ptr %30, ptr %26, align 8, !tbaa !21
  %31 = getelementptr inbounds i8, ptr %30, i64 48
  store i8 1, ptr %31, align 8, !tbaa !22
  call void @expand_perimeter_from(ptr noundef nonnull %6, ptr noundef %30)
  %32 = getelementptr inbounds i8, ptr %30, i64 40
  %33 = load ptr, ptr %32, align 8, !tbaa !24
  %.not4953 = icmp eq ptr %33, null
  br i1 %.not4953, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %29
  %34 = icmp eq i32 %3, 0
  br i1 %34, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph, %.backedge.us
  %35 = phi ptr [ %66, %.backedge.us ], [ %33, %.lr.ph ]
  call void @merge_input(ptr noundef nonnull %6, ptr noundef nonnull %35)
  call void @expand_perimeter_from(ptr noundef nonnull %6, ptr noundef nonnull %35)
  %36 = getelementptr inbounds i8, ptr %35, i64 49
  %37 = load i8, ptr %36, align 1, !tbaa !25, !range !26, !noundef !27
  %38 = trunc nuw i8 %37 to i1
  br i1 %38, label %.backedge.us, label %39

39:                                               ; preds = %.lr.ph.split.us
  %40 = getelementptr inbounds i8, ptr %35, i64 16
  %41 = load i32, ptr %40, align 8, !tbaa !28
  %42 = icmp sgt i32 %41, 0
  br i1 %42, label %43, label %46

43:                                               ; preds = %39
  %44 = getelementptr inbounds i8, ptr %35, i64 8
  %45 = load i32, ptr %44, align 8, !tbaa !29
  %.not51.us = icmp sgt i32 %41, %45
  br i1 %.not51.us, label %46, label %.backedge.us

46:                                               ; preds = %43, %39
  %47 = getelementptr inbounds i8, ptr %35, i64 20
  %48 = load i32, ptr %47, align 4, !tbaa !30
  %49 = icmp sgt i32 %48, 0
  br i1 %49, label %50, label %53

50:                                               ; preds = %46
  %51 = getelementptr inbounds i8, ptr %35, i64 12
  %52 = load i32, ptr %51, align 4, !tbaa !31
  %.not52.us = icmp sgt i32 %48, %52
  br i1 %.not52.us, label %53, label %.backedge.us

53:                                               ; preds = %50, %46
  %54 = load i32, ptr %35, align 8, !tbaa !32
  %55 = add nsw i32 %54, %1
  %56 = getelementptr inbounds i8, ptr %35, i64 4
  %57 = load i32, ptr %56, align 4, !tbaa !33
  %58 = add nsw i32 %57, %2
  %59 = load ptr, ptr %12, align 8, !tbaa !5
  %60 = load i32, ptr %0, align 8, !tbaa !11
  %61 = mul nsw i32 %60, %58
  %62 = add nsw i32 %55, %61
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds %struct.TCOD_MapCell, ptr %59, i64 %63, i32 2
  store i8 1, ptr %64, align 1, !tbaa !12
  br label %.backedge.us

.backedge.us:                                     ; preds = %53, %50, %43, %.lr.ph.split.us
  %65 = getelementptr inbounds i8, ptr %35, i64 40
  %66 = load ptr, ptr %65, align 8, !tbaa !24
  %.not49.us = icmp eq ptr %66, null
  br i1 %.not49.us, label %._crit_edge, label %.lr.ph.split.us, !llvm.loop !34

.lr.ph.split:                                     ; preds = %.lr.ph, %.backedge
  %67 = phi ptr [ %103, %.backedge ], [ %33, %.lr.ph ]
  %68 = call i32 @ray_length_sq(ptr noundef nonnull %67)
  %.not50 = icmp sgt i32 %68, %7
  br i1 %.not50, label %70, label %69

69:                                               ; preds = %.lr.ph.split
  call void @merge_input(ptr noundef nonnull %6, ptr noundef nonnull %67)
  br label %72

70:                                               ; preds = %.lr.ph.split
  %71 = getelementptr inbounds i8, ptr %67, i64 49
  store i8 1, ptr %71, align 1, !tbaa !25
  br label %72

72:                                               ; preds = %70, %69
  call void @expand_perimeter_from(ptr noundef nonnull %6, ptr noundef nonnull %67)
  %73 = getelementptr inbounds i8, ptr %67, i64 49
  %74 = load i8, ptr %73, align 1, !tbaa !25, !range !26, !noundef !27
  %75 = trunc nuw i8 %74 to i1
  br i1 %75, label %.backedge, label %76

76:                                               ; preds = %72
  %77 = getelementptr inbounds i8, ptr %67, i64 16
  %78 = load i32, ptr %77, align 8, !tbaa !28
  %79 = icmp sgt i32 %78, 0
  br i1 %79, label %80, label %83

80:                                               ; preds = %76
  %81 = getelementptr inbounds i8, ptr %67, i64 8
  %82 = load i32, ptr %81, align 8, !tbaa !29
  %.not51 = icmp sgt i32 %78, %82
  br i1 %.not51, label %83, label %.backedge

83:                                               ; preds = %80, %76
  %84 = getelementptr inbounds i8, ptr %67, i64 20
  %85 = load i32, ptr %84, align 4, !tbaa !30
  %86 = icmp sgt i32 %85, 0
  br i1 %86, label %87, label %90

87:                                               ; preds = %83
  %88 = getelementptr inbounds i8, ptr %67, i64 12
  %89 = load i32, ptr %88, align 4, !tbaa !31
  %.not52 = icmp sgt i32 %85, %89
  br i1 %.not52, label %90, label %.backedge

90:                                               ; preds = %87, %83
  %91 = load i32, ptr %67, align 8, !tbaa !32
  %92 = add nsw i32 %91, %1
  %93 = getelementptr inbounds i8, ptr %67, i64 4
  %94 = load i32, ptr %93, align 4, !tbaa !33
  %95 = add nsw i32 %94, %2
  %96 = load ptr, ptr %12, align 8, !tbaa !5
  %97 = load i32, ptr %0, align 8, !tbaa !11
  %98 = mul nsw i32 %97, %95
  %99 = add nsw i32 %92, %98
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds %struct.TCOD_MapCell, ptr %96, i64 %100, i32 2
  store i8 1, ptr %101, align 1, !tbaa !12
  br label %.backedge

.backedge:                                        ; preds = %90, %72, %80, %87
  %102 = getelementptr inbounds i8, ptr %67, i64 40
  %103 = load ptr, ptr %102, align 8, !tbaa !24
  %.not49 = icmp eq ptr %103, null
  br i1 %.not49, label %._crit_edge, label %.lr.ph.split, !llvm.loop !34

._crit_edge:                                      ; preds = %.backedge, %.backedge.us, %29
  %104 = load ptr, ptr %21, align 8, !tbaa !20
  call void @free(ptr noundef %104) #6
  br i1 %4, label %105, label %107

105:                                              ; preds = %._crit_edge
  %106 = call i32 @TCOD_map_postprocess(ptr noundef nonnull %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) #6
  br label %107

107:                                              ; preds = %._crit_edge, %105, %27
  %.0 = phi i32 [ -3, %27 ], [ 0, %105 ], [ 0, %._crit_edge ]
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %6) #6
  br label %108

108:                                              ; preds = %107, %9
  %.1 = phi i32 [ %.0, %107 ], [ -2, %9 ]
  ret i32 %.1
}

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

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

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

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

; Function Attrs: nounwind uwtable
declare hidden ptr @get_ray(ptr noalias noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @expand_perimeter_from(ptr noalias noundef, ptr noalias noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @ray_length_sq(ptr noalias noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @merge_input(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) #1

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

declare i32 @TCOD_map_postprocess(ptr noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { "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,zeroed") allocsize(0,1) 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 = { nounwind }
attributes #7 = { nounwind allocsize(0,1) }

!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 = !{!16, !10, i64 0}
!16 = !{!"DiamondFov", !10, i64 0, !7, i64 8, !7, i64 12, !10, i64 16, !10, i64 24}
!17 = !{!16, !7, i64 8}
!18 = !{!16, !7, i64 12}
!19 = !{!6, !7, i64 8}
!20 = !{!16, !10, i64 16}
!21 = !{!16, !10, i64 24}
!22 = !{!23, !14, i64 48}
!23 = !{!"RaycastTile", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !10, i64 24, !10, i64 32, !10, i64 40, !14, i64 48, !14, i64 49}
!24 = !{!23, !10, i64 40}
!25 = !{!23, !14, i64 49}
!26 = !{i8 0, i8 2}
!27 = !{}
!28 = !{!23, !7, i64 16}
!29 = !{!23, !7, i64 8}
!30 = !{!23, !7, i64 20}
!31 = !{!23, !7, i64 12}
!32 = !{!23, !7, i64 0}
!33 = !{!23, !7, i64 4}
!34 = distinct !{!34, !35}
!35 = !{!"llvm.loop.mustprogress"}


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