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

; 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.TCOD_ColorRGB = type { i8, i8, i8 }
%struct.TCOD_ColorRGBA = type { i8, i8, i8, i8 }
%struct.TCOD_Console = type { i32, i32, ptr, i32, i32, %struct.TCOD_ColorRGB, %struct.TCOD_ColorRGB, i8, %struct.TCOD_ColorRGB, i32, ptr, ptr }
%struct.TCOD_ConsoleTile = type { i32, %struct.TCOD_ColorRGBA, %struct.TCOD_ColorRGBA }

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @TCOD_console_validate_(ptr noundef) #1

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: nounwind uwtable
define dso_local void @TCOD_console_set_char_background(ptr noundef %0, i32 noundef %1, i32 noundef %2, i24 %3, i32 noundef %4) #3 {
  %6 = alloca %struct.TCOD_ColorRGB, align 1
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i8, align 1
  %13 = alloca %struct.TCOD_ColorRGBA, align 1
  %14 = alloca %struct.TCOD_ColorRGBA, align 1
  %15 = alloca %struct.TCOD_ColorRGBA, align 1
  %16 = alloca %struct.TCOD_ColorRGBA, align 1
  %17 = alloca %struct.TCOD_ColorRGBA, align 1
  %18 = alloca %struct.TCOD_ColorRGBA, align 1
  %19 = alloca %struct.TCOD_ColorRGBA, align 1
  %20 = alloca %struct.TCOD_ColorRGBA, align 1
  %21 = alloca %struct.TCOD_ColorRGBA, align 1
  %22 = alloca %struct.TCOD_ColorRGBA, align 1
  %23 = alloca %struct.TCOD_ColorRGBA, align 1
  store i24 %3, ptr %6, align 1
  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 %4, ptr %10, align 4, !tbaa !9
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = call ptr @TCOD_console_validate_(ptr noundef %24)
  store ptr %25, ptr %7, align 8, !tbaa !5
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = load i32, ptr %8, align 4, !tbaa !9
  %28 = load i32, ptr %9, align 4, !tbaa !9
  %29 = call zeroext i1 @TCOD_console_is_index_valid_(ptr noundef %26, i32 noundef %27, i32 noundef %28)
  br i1 %29, label %31, label %30

30:                                               ; preds = %5
  br label %172

31:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.TCOD_Console, ptr %32, i32 0, i32 2
  %34 = load ptr, ptr %33, align 8, !tbaa !11
  %35 = load i32, ptr %9, align 4, !tbaa !9
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.TCOD_Console, ptr %36, i32 0, i32 0
  %38 = load i32, ptr %37, align 8, !tbaa !15
  %39 = mul nsw i32 %35, %38
  %40 = load i32, ptr %8, align 4, !tbaa !9
  %41 = add nsw i32 %39, %40
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds %struct.TCOD_ConsoleTile, ptr %34, i64 %42
  %44 = getelementptr inbounds %struct.TCOD_ConsoleTile, ptr %43, i32 0, i32 2
  store ptr %44, ptr %11, align 8, !tbaa !5
  %45 = load i32, ptr %10, align 4, !tbaa !9
  %46 = icmp eq i32 %45, 13
  br i1 %46, label %47, label %51

47:                                               ; preds = %31
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.TCOD_Console, ptr %48, i32 0, i32 3
  %50 = load i32, ptr %49, align 8, !tbaa !16
  store i32 %50, ptr %10, align 4, !tbaa !9
  br label %51

51:                                               ; preds = %47, %31
  call void @llvm.lifetime.start.p0(i64 1, ptr %12) #4
  %52 = load i32, ptr %10, align 4, !tbaa !9
  %53 = lshr i32 %52, 8
  %54 = and i32 %53, 255
  %55 = trunc i32 %54 to i8
  store i8 %55, ptr %12, align 1, !tbaa !17
  %56 = load i32, ptr %10, align 4, !tbaa !9
  %57 = and i32 %56, 255
  switch i32 %57, label %170 [
    i32 1, label %58
    i32 2, label %71
    i32 3, label %75
    i32 4, label %79
    i32 5, label %83
    i32 6, label %87
    i32 7, label %91
    i32 8, label %95
    i32 9, label %99
    i32 10, label %145
    i32 11, label %149
    i32 12, label %153
  ]

58:                                               ; preds = %51
  %59 = getelementptr inbounds %struct.TCOD_ColorRGB, ptr %6, i32 0, i32 0
  %60 = load i8, ptr %59, align 1, !tbaa !18
  %61 = load ptr, ptr %11, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.TCOD_ColorRGBA, ptr %61, i32 0, i32 0
  store i8 %60, ptr %62, align 1, !tbaa !19
  %63 = getelementptr inbounds %struct.TCOD_ColorRGB, ptr %6, i32 0, i32 1
  %64 = load i8, ptr %63, align 1, !tbaa !21
  %65 = load ptr, ptr %11, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.TCOD_ColorRGBA, ptr %65, i32 0, i32 1
  store i8 %64, ptr %66, align 1, !tbaa !22
  %67 = getelementptr inbounds %struct.TCOD_ColorRGB, ptr %6, i32 0, i32 2
  %68 = load i8, ptr %67, align 1, !tbaa !23
  %69 = load ptr, ptr %11, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.TCOD_ColorRGBA, ptr %69, i32 0, i32 2
  store i8 %68, ptr %70, align 1, !tbaa !24
  br label %171

71:                                               ; preds = %51
  %72 = load ptr, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %73 = load ptr, ptr %11, align 8, !tbaa !5
  %74 = call i32 @blend_color_(ptr noundef %73, ptr noundef %6, ptr noundef @channel_multiply)
  store i32 %74, ptr %13, align 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %72, ptr align 1 %13, i64 4, i1 false), !tbaa.struct !25
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  br label %171

75:                                               ; preds = %51
  %76 = load ptr, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %77 = load ptr, ptr %11, align 8, !tbaa !5
  %78 = call i32 @blend_color_(ptr noundef %77, ptr noundef %6, ptr noundef @channel_lighten)
  store i32 %78, ptr %14, align 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %76, ptr align 1 %14, i64 4, i1 false), !tbaa.struct !25
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  br label %171

79:                                               ; preds = %51
  %80 = load ptr, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  %81 = load ptr, ptr %11, align 8, !tbaa !5
  %82 = call i32 @blend_color_(ptr noundef %81, ptr noundef %6, ptr noundef @channel_darken)
  store i32 %82, ptr %15, align 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %80, ptr align 1 %15, i64 4, i1 false), !tbaa.struct !25
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  br label %171

83:                                               ; preds = %51
  %84 = load ptr, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  %85 = load ptr, ptr %11, align 8, !tbaa !5
  %86 = call i32 @blend_color_(ptr noundef %85, ptr noundef %6, ptr noundef @channel_screen)
  store i32 %86, ptr %16, align 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %84, ptr align 1 %16, i64 4, i1 false), !tbaa.struct !25
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  br label %171

87:                                               ; preds = %51
  %88 = load ptr, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  %89 = load ptr, ptr %11, align 8, !tbaa !5
  %90 = call i32 @blend_color_(ptr noundef %89, ptr noundef %6, ptr noundef @channel_color_dodge)
  store i32 %90, ptr %17, align 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %88, ptr align 1 %17, i64 4, i1 false), !tbaa.struct !25
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  br label %171

91:                                               ; preds = %51
  %92 = load ptr, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  %93 = load ptr, ptr %11, align 8, !tbaa !5
  %94 = call i32 @blend_color_(ptr noundef %93, ptr noundef %6, ptr noundef @channel_color_burn)
  store i32 %94, ptr %18, align 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %92, ptr align 1 %18, i64 4, i1 false), !tbaa.struct !25
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  br label %171

95:                                               ; preds = %51
  %96 = load ptr, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #4
  %97 = load ptr, ptr %11, align 8, !tbaa !5
  %98 = call i32 @blend_color_(ptr noundef %97, ptr noundef %6, ptr noundef @channel_add)
  store i32 %98, ptr %19, align 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %96, ptr align 1 %19, i64 4, i1 false), !tbaa.struct !25
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #4
  br label %171

99:                                               ; preds = %51
  %100 = load ptr, ptr %11, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.TCOD_ColorRGBA, ptr %100, i32 0, i32 0
  %102 = load i8, ptr %101, align 1, !tbaa !19
  %103 = zext i8 %102 to i32
  %104 = load i8, ptr %12, align 1, !tbaa !17
  %105 = zext i8 %104 to i32
  %106 = getelementptr inbounds %struct.TCOD_ColorRGB, ptr %6, i32 0, i32 0
  %107 = load i8, ptr %106, align 1, !tbaa !18
  %108 = zext i8 %107 to i32
  %109 = mul nsw i32 %105, %108
  %110 = sdiv i32 %109, 255
  %111 = add nsw i32 %103, %110
  %112 = call zeroext i8 @clamp_color_(i32 noundef %111)
  %113 = load ptr, ptr %11, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.TCOD_ColorRGBA, ptr %113, i32 0, i32 0
  store i8 %112, ptr %114, align 1, !tbaa !19
  %115 = load ptr, ptr %11, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct.TCOD_ColorRGBA, ptr %115, i32 0, i32 1
  %117 = load i8, ptr %116, align 1, !tbaa !22
  %118 = zext i8 %117 to i32
  %119 = load i8, ptr %12, align 1, !tbaa !17
  %120 = zext i8 %119 to i32
  %121 = getelementptr inbounds %struct.TCOD_ColorRGB, ptr %6, i32 0, i32 1
  %122 = load i8, ptr %121, align 1, !tbaa !21
  %123 = zext i8 %122 to i32
  %124 = mul nsw i32 %120, %123
  %125 = sdiv i32 %124, 255
  %126 = add nsw i32 %118, %125
  %127 = call zeroext i8 @clamp_color_(i32 noundef %126)
  %128 = load ptr, ptr %11, align 8, !tbaa !5
  %129 = getelementptr inbounds %struct.TCOD_ColorRGBA, ptr %128, i32 0, i32 1
  store i8 %127, ptr %129, align 1, !tbaa !22
  %130 = load ptr, ptr %11, align 8, !tbaa !5
  %131 = getelementptr inbounds %struct.TCOD_ColorRGBA, ptr %130, i32 0, i32 2
  %132 = load i8, ptr %131, align 1, !tbaa !24
  %133 = zext i8 %132 to i32
  %134 = load i8, ptr %12, align 1, !tbaa !17
  %135 = zext i8 %134 to i32
  %136 = getelementptr inbounds %struct.TCOD_ColorRGB, ptr %6, i32 0, i32 2
  %137 = load i8, ptr %136, align 1, !tbaa !23
  %138 = zext i8 %137 to i32
  %139 = mul nsw i32 %135, %138
  %140 = sdiv i32 %139, 255
  %141 = add nsw i32 %133, %140
  %142 = call zeroext i8 @clamp_color_(i32 noundef %141)
  %143 = load ptr, ptr %11, align 8, !tbaa !5
  %144 = getelementptr inbounds %struct.TCOD_ColorRGBA, ptr %143, i32 0, i32 2
  store i8 %142, ptr %144, align 1, !tbaa !24
  br label %171

145:                                              ; preds = %51
  %146 = load ptr, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #4
  %147 = load ptr, ptr %11, align 8, !tbaa !5
  %148 = call i32 @blend_color_(ptr noundef %147, ptr noundef %6, ptr noundef @channel_burn)
  store i32 %148, ptr %20, align 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %146, ptr align 1 %20, i64 4, i1 false), !tbaa.struct !25
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #4
  br label %171

149:                                              ; preds = %51
  %150 = load ptr, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #4
  %151 = load ptr, ptr %11, align 8, !tbaa !5
  %152 = call i32 @blend_color_(ptr noundef %151, ptr noundef %6, ptr noundef @channel_overlay)
  store i32 %152, ptr %21, align 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %150, ptr align 1 %21, i64 4, i1 false), !tbaa.struct !25
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #4
  br label %171

153:                                              ; preds = %51
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #4
  %154 = getelementptr inbounds %struct.TCOD_ColorRGBA, ptr %22, i32 0, i32 0
  %155 = getelementptr inbounds %struct.TCOD_ColorRGB, ptr %6, i32 0, i32 0
  %156 = load i8, ptr %155, align 1, !tbaa !18
  store i8 %156, ptr %154, align 1, !tbaa !19
  %157 = getelementptr inbounds %struct.TCOD_ColorRGBA, ptr %22, i32 0, i32 1
  %158 = getelementptr inbounds %struct.TCOD_ColorRGB, ptr %6, i32 0, i32 1
  %159 = load i8, ptr %158, align 1, !tbaa !21
  store i8 %159, ptr %157, align 1, !tbaa !22
  %160 = getelementptr inbounds %struct.TCOD_ColorRGBA, ptr %22, i32 0, i32 2
  %161 = getelementptr inbounds %struct.TCOD_ColorRGB, ptr %6, i32 0, i32 2
  %162 = load i8, ptr %161, align 1, !tbaa !23
  store i8 %162, ptr %160, align 1, !tbaa !24
  %163 = getelementptr inbounds %struct.TCOD_ColorRGBA, ptr %22, i32 0, i32 3
  %164 = load i8, ptr %12, align 1, !tbaa !17
  store i8 %164, ptr %163, align 1, !tbaa !26
  %165 = load ptr, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #4
  %166 = load ptr, ptr %11, align 8, !tbaa !5
  %167 = load i32, ptr %166, align 1
  %168 = load i32, ptr %22, align 1
  %169 = call i32 @TCOD_console_blit_lerp_(i32 %167, i32 %168, float noundef 1.000000e+00)
  store i32 %169, ptr %23, align 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %165, ptr align 1 %23, i64 4, i1 false), !tbaa.struct !25
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #4
  br label %171

170:                                              ; preds = %51
  br label %171

171:                                              ; preds = %170, %153, %149, %145, %99, %95, %91, %87, %83, %79, %75, %71, %58
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %172

172:                                              ; preds = %171, %30
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden i32 @blend_color_(ptr noundef, ptr noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
declare hidden i32 @channel_multiply(i8 noundef zeroext, i8 noundef zeroext) #3

; Function Attrs: nounwind uwtable
declare hidden i32 @channel_lighten(i8 noundef zeroext, i8 noundef zeroext) #3

; Function Attrs: nounwind uwtable
declare hidden i32 @channel_darken(i8 noundef zeroext, i8 noundef zeroext) #3

; Function Attrs: nounwind uwtable
declare hidden i32 @channel_screen(i8 noundef zeroext, i8 noundef zeroext) #3

; Function Attrs: nounwind uwtable
declare hidden i32 @channel_color_dodge(i8 noundef zeroext, i8 noundef zeroext) #3

; Function Attrs: nounwind uwtable
declare hidden i32 @channel_color_burn(i8 noundef zeroext, i8 noundef zeroext) #3

; Function Attrs: nounwind uwtable
declare hidden i32 @channel_add(i8 noundef zeroext, i8 noundef zeroext) #3

; Function Attrs: nounwind uwtable
declare hidden zeroext i8 @clamp_color_(i32 noundef) #3

; Function Attrs: nounwind uwtable
declare hidden i32 @channel_burn(i8 noundef zeroext, i8 noundef zeroext) #3

; Function Attrs: nounwind uwtable
declare hidden i32 @channel_overlay(i8 noundef zeroext, i8 noundef zeroext) #3

; Function Attrs: nounwind uwtable
declare hidden i32 @TCOD_console_blit_lerp_(i32, i32, float noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 }

!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 8}
!12 = !{!"TCOD_Console", !10, i64 0, !10, i64 4, !6, i64 8, !10, i64 16, !10, i64 20, !13, i64 24, !13, i64 27, !14, i64 30, !13, i64 31, !10, i64 36, !6, i64 40, !6, i64 48}
!13 = !{!"TCOD_ColorRGB", !7, i64 0, !7, i64 1, !7, i64 2}
!14 = !{!"_Bool", !7, i64 0}
!15 = !{!12, !10, i64 0}
!16 = !{!12, !10, i64 16}
!17 = !{!7, !7, i64 0}
!18 = !{!13, !7, i64 0}
!19 = !{!20, !7, i64 0}
!20 = !{!"TCOD_ColorRGBA", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3}
!21 = !{!13, !7, i64 1}
!22 = !{!20, !7, i64 1}
!23 = !{!13, !7, i64 2}
!24 = !{!20, !7, i64 2}
!25 = !{i64 0, i64 1, !17, i64 1, i64 1, !17, i64 2, i64 1, !17, i64 3, i64 1, !17}
!26 = !{!20, !7, i64 3}


; 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.TCOD_ColorRGB = type { i8, i8, i8 }
%struct.TCOD_ConsoleTile = type { i32, %struct.TCOD_ColorRGBA, %struct.TCOD_ColorRGBA }
%struct.TCOD_ColorRGBA = type { i8, i8, i8, i8 }

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @TCOD_console_validate_(ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local void @TCOD_console_set_char_background(ptr noundef %0, i32 noundef %1, i32 noundef %2, i24 %3, i32 noundef %4) local_unnamed_addr #1 {
  %6 = alloca %struct.TCOD_ColorRGB, align 4
  store i24 %3, ptr %6, align 4
  %7 = tail call ptr @TCOD_console_validate_(ptr noundef %0)
  %8 = tail call zeroext i1 @TCOD_console_is_index_valid_(ptr noundef %7, i32 noundef %1, i32 noundef %2)
  %9 = trunc i24 %3 to i8
  %10 = lshr i24 %3, 8
  %11 = trunc i24 %10 to i8
  %12 = lshr i24 %3, 16
  %13 = trunc nuw i24 %12 to i8
  br i1 %8, label %14, label %79

14:                                               ; preds = %5
  %15 = getelementptr inbounds i8, ptr %7, i64 8
  %16 = load ptr, ptr %15, align 8, !tbaa !5
  %17 = load i32, ptr %7, align 8, !tbaa !13
  %18 = mul nsw i32 %17, %2
  %19 = add nsw i32 %18, %1
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds %struct.TCOD_ConsoleTile, ptr %16, i64 %20, i32 2
  %22 = icmp eq i32 %4, 13
  br i1 %22, label %23, label %26

23:                                               ; preds = %14
  %24 = getelementptr inbounds i8, ptr %7, i64 16
  %25 = load i32, ptr %24, align 8, !tbaa !14
  br label %26

26:                                               ; preds = %23, %14
  %.0 = phi i32 [ %25, %23 ], [ %4, %14 ]
  %27 = lshr i32 %.0, 8
  %trunc = trunc i32 %.0 to i8
  switch i8 %trunc, label %79 [
    i8 1, label %28
    i8 2, label %31
    i8 3, label %33
    i8 4, label %35
    i8 5, label %37
    i8 6, label %39
    i8 7, label %41
    i8 8, label %43
    i8 9, label %45
    i8 10, label %70
    i8 11, label %72
    i8 12, label %74
  ]

28:                                               ; preds = %26
  store i8 %9, ptr %21, align 1, !tbaa !15
  %29 = getelementptr inbounds i8, ptr %21, i64 1
  store i8 %11, ptr %29, align 1, !tbaa !17
  %30 = getelementptr inbounds i8, ptr %21, i64 2
  store i8 %13, ptr %30, align 1, !tbaa !18
  br label %79

31:                                               ; preds = %26
  %32 = call i32 @blend_color_(ptr noundef nonnull %21, ptr noundef nonnull %6, ptr noundef nonnull @channel_multiply)
  store i32 %32, ptr %21, align 1
  br label %79

33:                                               ; preds = %26
  %34 = call i32 @blend_color_(ptr noundef nonnull %21, ptr noundef nonnull %6, ptr noundef nonnull @channel_lighten)
  store i32 %34, ptr %21, align 1
  br label %79

35:                                               ; preds = %26
  %36 = call i32 @blend_color_(ptr noundef nonnull %21, ptr noundef nonnull %6, ptr noundef nonnull @channel_darken)
  store i32 %36, ptr %21, align 1
  br label %79

37:                                               ; preds = %26
  %38 = call i32 @blend_color_(ptr noundef nonnull %21, ptr noundef nonnull %6, ptr noundef nonnull @channel_screen)
  store i32 %38, ptr %21, align 1
  br label %79

39:                                               ; preds = %26
  %40 = call i32 @blend_color_(ptr noundef nonnull %21, ptr noundef nonnull %6, ptr noundef nonnull @channel_color_dodge)
  store i32 %40, ptr %21, align 1
  br label %79

41:                                               ; preds = %26
  %42 = call i32 @blend_color_(ptr noundef nonnull %21, ptr noundef nonnull %6, ptr noundef nonnull @channel_color_burn)
  store i32 %42, ptr %21, align 1
  br label %79

43:                                               ; preds = %26
  %44 = call i32 @blend_color_(ptr noundef nonnull %21, ptr noundef nonnull %6, ptr noundef nonnull @channel_add)
  store i32 %44, ptr %21, align 1
  br label %79

45:                                               ; preds = %26
  %46 = load i8, ptr %21, align 1, !tbaa !15
  %47 = zext i8 %46 to i32
  %48 = and i32 %27, 255
  %.mask59 = and i24 %3, 255
  %49 = zext nneg i24 %.mask59 to i32
  %50 = mul nuw nsw i32 %48, %49
  %.lhs.trunc = trunc nuw i32 %50 to i16
  %51 = udiv i16 %.lhs.trunc, 255
  %.zext = zext nneg i16 %51 to i32
  %52 = add nuw nsw i32 %.zext, %47
  %53 = tail call zeroext i8 @clamp_color_(i32 noundef %52)
  store i8 %53, ptr %21, align 1, !tbaa !15
  %54 = getelementptr inbounds i8, ptr %21, i64 1
  %55 = load i8, ptr %54, align 1, !tbaa !17
  %56 = zext i8 %55 to i32
  %.mask60 = and i24 %10, 255
  %57 = zext nneg i24 %.mask60 to i32
  %58 = mul nuw nsw i32 %48, %57
  %.lhs.trunc55 = trunc nuw i32 %58 to i16
  %59 = udiv i16 %.lhs.trunc55, 255
  %.zext56 = zext nneg i16 %59 to i32
  %60 = add nuw nsw i32 %.zext56, %56
  %61 = tail call zeroext i8 @clamp_color_(i32 noundef %60)
  store i8 %61, ptr %54, align 1, !tbaa !17
  %62 = getelementptr inbounds i8, ptr %21, i64 2
  %63 = load i8, ptr %62, align 1, !tbaa !18
  %64 = zext i8 %63 to i32
  %65 = zext nneg i24 %12 to i32
  %66 = mul nuw nsw i32 %48, %65
  %.lhs.trunc57 = trunc nuw i32 %66 to i16
  %67 = udiv i16 %.lhs.trunc57, 255
  %.zext58 = zext nneg i16 %67 to i32
  %68 = add nuw nsw i32 %.zext58, %64
  %69 = tail call zeroext i8 @clamp_color_(i32 noundef %68)
  store i8 %69, ptr %62, align 1, !tbaa !18
  br label %79

70:                                               ; preds = %26
  %71 = call i32 @blend_color_(ptr noundef nonnull %21, ptr noundef nonnull %6, ptr noundef nonnull @channel_burn)
  store i32 %71, ptr %21, align 1
  br label %79

72:                                               ; preds = %26
  %73 = call i32 @blend_color_(ptr noundef nonnull %21, ptr noundef nonnull %6, ptr noundef nonnull @channel_overlay)
  store i32 %73, ptr %21, align 1
  br label %79

74:                                               ; preds = %26
  %75 = load i32, ptr %21, align 1
  %.sroa.6.0.insert.ext = shl i32 %27, 24
  %76 = and i24 %3, -65536
  %.sroa.5.0.insert.shift = zext i24 %76 to i32
  %.sroa.5.0.insert.insert = or disjoint i32 %.sroa.6.0.insert.ext, %.sroa.5.0.insert.shift
  %77 = and i24 %3, 65280
  %.sroa.4.0.insert.shift = zext nneg i24 %77 to i32
  %.sroa.4.0.insert.insert = or disjoint i32 %.sroa.5.0.insert.insert, %.sroa.4.0.insert.shift
  %.mask = and i24 %3, 255
  %.sroa.01.0.insert.ext = zext nneg i24 %.mask to i32
  %.sroa.01.0.insert.insert = or disjoint i32 %.sroa.4.0.insert.insert, %.sroa.01.0.insert.ext
  %78 = tail call i32 @TCOD_console_blit_lerp_(i32 %75, i32 %.sroa.01.0.insert.insert, float noundef 1.000000e+00)
  store i32 %78, ptr %21, align 1
  br label %79

79:                                               ; preds = %28, %31, %33, %35, %37, %39, %41, %43, %45, %70, %72, %74, %26, %5
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden i32 @blend_color_(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i32 @channel_multiply(i8 noundef zeroext, i8 noundef zeroext) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @channel_lighten(i8 noundef zeroext, i8 noundef zeroext) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @channel_darken(i8 noundef zeroext, i8 noundef zeroext) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @channel_screen(i8 noundef zeroext, i8 noundef zeroext) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @channel_color_dodge(i8 noundef zeroext, i8 noundef zeroext) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @channel_color_burn(i8 noundef zeroext, i8 noundef zeroext) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @channel_add(i8 noundef zeroext, i8 noundef zeroext) #1

; Function Attrs: nounwind uwtable
declare hidden zeroext i8 @clamp_color_(i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i32 @channel_burn(i8 noundef zeroext, i8 noundef zeroext) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @channel_overlay(i8 noundef zeroext, i8 noundef zeroext) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @TCOD_console_blit_lerp_(i32, i32, float noundef) local_unnamed_addr #1

attributes #0 = { 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 #1 = { 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" }

!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 8}
!6 = !{!"TCOD_Console", !7, i64 0, !7, i64 4, !10, i64 8, !7, i64 16, !7, i64 20, !11, i64 24, !11, i64 27, !12, i64 30, !11, i64 31, !7, i64 36, !10, i64 40, !10, i64 48}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"TCOD_ColorRGB", !8, i64 0, !8, i64 1, !8, i64 2}
!12 = !{!"_Bool", !8, i64 0}
!13 = !{!6, !7, i64 0}
!14 = !{!6, !7, i64 16}
!15 = !{!16, !8, i64 0}
!16 = !{!"TCOD_ColorRGBA", !8, i64 0, !8, i64 1, !8, i64 2, !8, i64 3}
!17 = !{!16, !8, i64 1}
!18 = !{!16, !8, i64 2}


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