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

; 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_internal_context_t = type { i32, i32, i8, i8, i8, i32, i32, i32, [512 x i8], [512 x i8], ptr, ptr, ptr, i32, i8, i32, i32, i32, i32, i32, i32, ptr, %struct.TCOD_ColorRGB, i8, %struct.TCOD_key_t, i8, i8, i8, ptr, ptr }
%struct.TCOD_ColorRGB = type { i8, i8, i8 }
%struct.TCOD_key_t = type { i32, i8, [32 x i8], i8, i8, i8, i8, i8, 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 }

@TCOD_ctx = external dso_local global %struct.TCOD_internal_context_t, align 8
@.str = external hidden unnamed_addr constant [9 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [89 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [53 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [42 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @TCOD_console_flush_ex(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca %struct.TCOD_ColorRGBA, align 1
  %10 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = call ptr @TCOD_console_validate_(ptr noundef %11)
  store ptr %12, ptr %4, align 8, !tbaa !5
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = icmp ne ptr %13, null
  br i1 %14, label %17, label %15

15:                                               ; preds = %2
  %16 = call i32 (ptr, ...) @TCOD_set_errorf(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 101, ptr noundef @.str.2)
  store i32 -2, ptr %3, align 4
  br label %103

17:                                               ; preds = %2
  %18 = load ptr, ptr getelementptr inbounds (%struct.TCOD_internal_context_t, ptr @TCOD_ctx, i32 0, i32 29), align 8, !tbaa !9
  %19 = icmp ne ptr %18, null
  br i1 %19, label %22, label %20

20:                                               ; preds = %17
  %21 = call i32 (ptr, ...) @TCOD_set_errorf(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 105, ptr noundef @.str.3)
  store i32 %21, ptr %3, align 4
  br label %103

22:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 0, ptr %6, align 4, !tbaa !15
  %23 = load i8, ptr getelementptr inbounds (%struct.TCOD_internal_context_t, ptr @TCOD_ctx, i32 0, i32 23), align 1, !tbaa !16
  %24 = zext i8 %23 to i32
  %25 = icmp eq i32 %24, 255
  br i1 %25, label %26, label %31

26:                                               ; preds = %22
  %27 = load ptr, ptr getelementptr inbounds (%struct.TCOD_internal_context_t, ptr @TCOD_ctx, i32 0, i32 29), align 8, !tbaa !9
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = call i32 @TCOD_context_present(ptr noundef %27, ptr noundef %28, ptr noundef %29)
  store i32 %30, ptr %6, align 4, !tbaa !15
  br label %100

31:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %32 = load ptr, ptr getelementptr inbounds (%struct.TCOD_internal_context_t, ptr @TCOD_ctx, i32 0, i32 12), align 8, !tbaa !17
  %33 = getelementptr inbounds %struct.TCOD_Console, ptr %32, i32 0, i32 0
  %34 = load i32, ptr %33, align 8, !tbaa !18
  %35 = load ptr, ptr getelementptr inbounds (%struct.TCOD_internal_context_t, ptr @TCOD_ctx, i32 0, i32 12), align 8, !tbaa !17
  %36 = getelementptr inbounds %struct.TCOD_Console, ptr %35, i32 0, i32 1
  %37 = load i32, ptr %36, align 4, !tbaa !20
  %38 = call ptr @TCOD_console_new(i32 noundef %34, i32 noundef %37)
  store ptr %38, ptr %7, align 8, !tbaa !5
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = icmp ne ptr %39, null
  br i1 %40, label %42, label %41

41:                                               ; preds = %31
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %97

42:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %43 = getelementptr inbounds %struct.TCOD_ColorRGBA, ptr %9, i32 0, i32 0
  %44 = load i8, ptr getelementptr inbounds (%struct.TCOD_internal_context_t, ptr @TCOD_ctx, i32 0, i32 22), align 8, !tbaa !21
  store i8 %44, ptr %43, align 1, !tbaa !22
  %45 = getelementptr inbounds %struct.TCOD_ColorRGBA, ptr %9, i32 0, i32 1
  %46 = load i8, ptr getelementptr inbounds (%struct.TCOD_ColorRGB, ptr getelementptr inbounds (%struct.TCOD_internal_context_t, ptr @TCOD_ctx, i32 0, i32 22), i32 0, i32 1), align 1, !tbaa !24
  store i8 %46, ptr %45, align 1, !tbaa !25
  %47 = getelementptr inbounds %struct.TCOD_ColorRGBA, ptr %9, i32 0, i32 2
  %48 = load i8, ptr getelementptr inbounds (%struct.TCOD_ColorRGB, ptr getelementptr inbounds (%struct.TCOD_internal_context_t, ptr @TCOD_ctx, i32 0, i32 22), i32 0, i32 2), align 2, !tbaa !26
  store i8 %48, ptr %47, align 1, !tbaa !27
  %49 = getelementptr inbounds %struct.TCOD_ColorRGBA, ptr %9, i32 0, i32 3
  %50 = load i8, ptr getelementptr inbounds (%struct.TCOD_internal_context_t, ptr @TCOD_ctx, i32 0, i32 23), align 1, !tbaa !16
  %51 = zext i8 %50 to i32
  %52 = sub nsw i32 255, %51
  %53 = trunc i32 %52 to i8
  store i8 %53, ptr %49, align 1, !tbaa !28
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store i32 0, ptr %10, align 4, !tbaa !15
  br label %54

54:                                               ; preds = %88, %42
  %55 = load i32, ptr %10, align 4, !tbaa !15
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.TCOD_Console, ptr %56, i32 0, i32 9
  %58 = load i32, ptr %57, align 4, !tbaa !29
  %59 = icmp slt i32 %55, %58
  br i1 %59, label %61, label %60

60:                                               ; preds = %54
  store i32 2, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %91

61:                                               ; preds = %54
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.TCOD_Console, ptr %62, i32 0, i32 2
  %64 = load ptr, ptr %63, align 8, !tbaa !30
  %65 = load i32, ptr %10, align 4, !tbaa !15
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds %struct.TCOD_ConsoleTile, ptr %64, i64 %66
  %68 = load ptr, ptr getelementptr inbounds (%struct.TCOD_internal_context_t, ptr @TCOD_ctx, i32 0, i32 12), align 8, !tbaa !17
  %69 = getelementptr inbounds %struct.TCOD_Console, ptr %68, i32 0, i32 2
  %70 = load ptr, ptr %69, align 8, !tbaa !30
  %71 = load i32, ptr %10, align 4, !tbaa !15
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds %struct.TCOD_ConsoleTile, ptr %70, i64 %72
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %67, ptr align 4 %73, i64 12, i1 false), !tbaa.struct !31
  %74 = load ptr, ptr %7, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.TCOD_Console, ptr %74, i32 0, i32 2
  %76 = load ptr, ptr %75, align 8, !tbaa !30
  %77 = load i32, ptr %10, align 4, !tbaa !15
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds %struct.TCOD_ConsoleTile, ptr %76, i64 %78
  %80 = getelementptr inbounds %struct.TCOD_ConsoleTile, ptr %79, i32 0, i32 1
  call void @TCOD_color_alpha_blend(ptr noundef %80, ptr noundef %9)
  %81 = load ptr, ptr %7, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.TCOD_Console, ptr %81, i32 0, i32 2
  %83 = load ptr, ptr %82, align 8, !tbaa !30
  %84 = load i32, ptr %10, align 4, !tbaa !15
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds %struct.TCOD_ConsoleTile, ptr %83, i64 %85
  %87 = getelementptr inbounds %struct.TCOD_ConsoleTile, ptr %86, i32 0, i32 2
  call void @TCOD_color_alpha_blend(ptr noundef %87, ptr noundef %9)
  br label %88

88:                                               ; preds = %61
  %89 = load i32, ptr %10, align 4, !tbaa !15
  %90 = add nsw i32 %89, 1
  store i32 %90, ptr %10, align 4, !tbaa !15
  br label %54, !llvm.loop !33

91:                                               ; preds = %60
  %92 = load ptr, ptr getelementptr inbounds (%struct.TCOD_internal_context_t, ptr @TCOD_ctx, i32 0, i32 29), align 8, !tbaa !9
  %93 = load ptr, ptr %7, align 8, !tbaa !5
  %94 = load ptr, ptr %5, align 8, !tbaa !5
  %95 = call i32 @TCOD_context_present(ptr noundef %92, ptr noundef %93, ptr noundef %94)
  store i32 %95, ptr %6, align 4, !tbaa !15
  %96 = load ptr, ptr %7, align 8, !tbaa !5
  call void @TCOD_console_delete(ptr noundef %96)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  store i32 0, ptr %8, align 4
  br label %97

97:                                               ; preds = %91, %41
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  %98 = load i32, ptr %8, align 4
  switch i32 %98, label %102 [
    i32 0, label %99
  ]

99:                                               ; preds = %97
  br label %100

100:                                              ; preds = %99, %26
  call void @sync_time_()
  %101 = load i32, ptr %6, align 4, !tbaa !15
  store i32 %101, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %102

102:                                              ; preds = %100, %97
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %103

103:                                              ; preds = %102, %20, %15
  %104 = load i32, ptr %3, align 4
  ret i32 %104
}

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

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

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

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

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

; 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) #4

declare void @TCOD_color_alpha_blend(ptr noundef, ptr noundef) #2

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

declare void @TCOD_console_delete(ptr noundef) #2

declare void @sync_time_() #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 = { 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 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 1176}
!10 = !{!"TCOD_internal_context_t", !11, i64 0, !11, i64 4, !12, i64 8, !12, i64 9, !12, i64 10, !11, i64 12, !11, i64 16, !11, i64 20, !7, i64 24, !7, i64 536, !6, i64 1048, !6, i64 1056, !6, i64 1064, !11, i64 1072, !12, i64 1076, !11, i64 1080, !11, i64 1084, !11, i64 1088, !11, i64 1092, !11, i64 1096, !11, i64 1100, !6, i64 1104, !13, i64 1112, !7, i64 1115, !14, i64 1116, !12, i64 1164, !12, i64 1165, !12, i64 1166, !6, i64 1168, !6, i64 1176}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!"TCOD_ColorRGB", !7, i64 0, !7, i64 1, !7, i64 2}
!14 = !{!"TCOD_key_t", !11, i64 0, !7, i64 4, !7, i64 5, !12, i64 37, !12, i64 38, !12, i64 39, !12, i64 40, !12, i64 41, !12, i64 42, !12, i64 43, !12, i64 44}
!15 = !{!11, !11, i64 0}
!16 = !{!10, !7, i64 1115}
!17 = !{!10, !6, i64 1064}
!18 = !{!19, !11, i64 0}
!19 = !{!"TCOD_Console", !11, i64 0, !11, i64 4, !6, i64 8, !11, i64 16, !11, i64 20, !13, i64 24, !13, i64 27, !12, i64 30, !13, i64 31, !11, i64 36, !6, i64 40, !6, i64 48}
!20 = !{!19, !11, i64 4}
!21 = !{!10, !7, i64 1112}
!22 = !{!23, !7, i64 0}
!23 = !{!"TCOD_ColorRGBA", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3}
!24 = !{!10, !7, i64 1113}
!25 = !{!23, !7, i64 1}
!26 = !{!10, !7, i64 1114}
!27 = !{!23, !7, i64 2}
!28 = !{!23, !7, i64 3}
!29 = !{!19, !11, i64 36}
!30 = !{!19, !6, i64 8}
!31 = !{i64 0, i64 4, !15, i64 4, i64 1, !32, i64 5, i64 1, !32, i64 6, i64 1, !32, i64 7, i64 1, !32, i64 8, i64 1, !32, i64 9, i64 1, !32, i64 10, i64 1, !32, i64 11, i64 1, !32}
!32 = !{!7, !7, i64 0}
!33 = distinct !{!33, !34}
!34 = !{!"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.TCOD_internal_context_t = type { i32, i32, i8, i8, i8, i32, i32, i32, [512 x i8], [512 x i8], ptr, ptr, ptr, i32, i8, i32, i32, i32, i32, i32, i32, ptr, %struct.TCOD_ColorRGB, i8, %struct.TCOD_key_t, i8, i8, i8, ptr, ptr }
%struct.TCOD_ColorRGB = type { i8, i8, i8 }
%struct.TCOD_key_t = type { i32, i8, [32 x i8], i8, i8, i8, i8, i8, i8, i8, i8 }
%struct.TCOD_ColorRGBA = type { i8, i8, i8, i8 }
%struct.TCOD_ConsoleTile = type { i32, %struct.TCOD_ColorRGBA, %struct.TCOD_ColorRGBA }

@TCOD_ctx = external dso_local local_unnamed_addr global %struct.TCOD_internal_context_t, align 8
@.str = external hidden unnamed_addr constant [9 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [89 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [53 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [42 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @TCOD_console_flush_ex(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = alloca %struct.TCOD_ColorRGBA, align 1
  %4 = tail call ptr @TCOD_console_validate_(ptr noundef %0)
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %5, label %7

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

7:                                                ; preds = %2
  %8 = load ptr, ptr getelementptr inbounds (i8, ptr @TCOD_ctx, i64 1176), align 8, !tbaa !5
  %.not27 = icmp eq ptr %8, null
  br i1 %.not27, label %9, label %11

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

11:                                               ; preds = %7
  %12 = load i8, ptr getelementptr inbounds (i8, ptr @TCOD_ctx, i64 1115), align 1, !tbaa !14
  %13 = icmp eq i8 %12, -1
  br i1 %13, label %14, label %16

14:                                               ; preds = %11
  %15 = tail call i32 @TCOD_context_present(ptr noundef nonnull %8, ptr noundef nonnull %4, ptr noundef %1) #5
  br label %51

16:                                               ; preds = %11
  %17 = load ptr, ptr getelementptr inbounds (i8, ptr @TCOD_ctx, i64 1064), align 8, !tbaa !15
  %18 = load i32, ptr %17, align 8, !tbaa !16
  %19 = getelementptr inbounds i8, ptr %17, i64 4
  %20 = load i32, ptr %19, align 4, !tbaa !18
  %21 = tail call ptr @TCOD_console_new(i32 noundef %18, i32 noundef %20) #5
  %.not28.not = icmp eq ptr %21, null
  br i1 %.not28.not, label %.thread, label %22

22:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #5
  %23 = load i8, ptr getelementptr inbounds (i8, ptr @TCOD_ctx, i64 1112), align 8, !tbaa !19
  store i8 %23, ptr %3, align 1, !tbaa !20
  %24 = getelementptr inbounds i8, ptr %3, i64 1
  %25 = load i8, ptr getelementptr inbounds (i8, ptr @TCOD_ctx, i64 1113), align 1, !tbaa !22
  store i8 %25, ptr %24, align 1, !tbaa !23
  %26 = getelementptr inbounds i8, ptr %3, i64 2
  %27 = load i8, ptr getelementptr inbounds (i8, ptr @TCOD_ctx, i64 1114), align 2, !tbaa !24
  store i8 %27, ptr %26, align 1, !tbaa !25
  %28 = getelementptr inbounds i8, ptr %3, i64 3
  %29 = load i8, ptr getelementptr inbounds (i8, ptr @TCOD_ctx, i64 1115), align 1, !tbaa !14
  %30 = xor i8 %29, -1
  store i8 %30, ptr %28, align 1, !tbaa !26
  %31 = getelementptr inbounds i8, ptr %21, i64 36
  %32 = load i32, ptr %31, align 4, !tbaa !27
  %33 = icmp sgt i32 %32, 0
  br i1 %33, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %22
  %34 = getelementptr inbounds i8, ptr %21, i64 8
  br label %35

35:                                               ; preds = %.lr.ph, %35
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %35 ]
  %36 = load ptr, ptr %34, align 8, !tbaa !28
  %37 = getelementptr inbounds %struct.TCOD_ConsoleTile, ptr %36, i64 %indvars.iv
  %38 = load ptr, ptr getelementptr inbounds (i8, ptr @TCOD_ctx, i64 1064), align 8, !tbaa !15
  %39 = getelementptr inbounds i8, ptr %38, i64 8
  %40 = load ptr, ptr %39, align 8, !tbaa !28
  %41 = getelementptr inbounds %struct.TCOD_ConsoleTile, ptr %40, i64 %indvars.iv
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %37, ptr noundef nonnull align 4 dereferenceable(12) %41, i64 12, i1 false), !tbaa.struct !29
  %42 = load ptr, ptr %34, align 8, !tbaa !28
  %43 = getelementptr inbounds %struct.TCOD_ConsoleTile, ptr %42, i64 %indvars.iv, i32 1
  call void @TCOD_color_alpha_blend(ptr noundef nonnull %43, ptr noundef nonnull %3) #5
  %44 = load ptr, ptr %34, align 8, !tbaa !28
  %45 = getelementptr inbounds %struct.TCOD_ConsoleTile, ptr %44, i64 %indvars.iv, i32 2
  call void @TCOD_color_alpha_blend(ptr noundef nonnull %45, ptr noundef nonnull %3) #5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %46 = load i32, ptr %31, align 4, !tbaa !27
  %47 = sext i32 %46 to i64
  %48 = icmp slt i64 %indvars.iv.next, %47
  br i1 %48, label %35, label %._crit_edge, !llvm.loop !32

._crit_edge:                                      ; preds = %35, %22
  %49 = load ptr, ptr getelementptr inbounds (i8, ptr @TCOD_ctx, i64 1176), align 8, !tbaa !5
  %50 = call i32 @TCOD_context_present(ptr noundef %49, ptr noundef nonnull %21, ptr noundef %1) #5
  call void @TCOD_console_delete(ptr noundef nonnull %21) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #5
  br label %51

51:                                               ; preds = %._crit_edge, %14
  %.123 = phi i32 [ %15, %14 ], [ %50, %._crit_edge ]
  call void @sync_time_() #5
  br label %.thread

.thread:                                          ; preds = %16, %51, %9, %5
  %.2 = phi i32 [ %10, %9 ], [ -2, %5 ], [ %.123, %51 ], [ -1, %16 ]
  ret i32 %.2
}

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

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

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

declare i32 @TCOD_context_present(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare ptr @TCOD_console_new(i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress 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) #4

declare void @TCOD_color_alpha_blend(ptr noundef, ptr noundef) local_unnamed_addr #2

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

declare void @TCOD_console_delete(ptr noundef) local_unnamed_addr #2

declare void @sync_time_() local_unnamed_addr #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 = { 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 = { "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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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, !11, i64 1176}
!6 = !{!"TCOD_internal_context_t", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 9, !10, i64 10, !7, i64 12, !7, i64 16, !7, i64 20, !8, i64 24, !8, i64 536, !11, i64 1048, !11, i64 1056, !11, i64 1064, !7, i64 1072, !10, i64 1076, !7, i64 1080, !7, i64 1084, !7, i64 1088, !7, i64 1092, !7, i64 1096, !7, i64 1100, !11, i64 1104, !12, i64 1112, !8, i64 1115, !13, i64 1116, !10, i64 1164, !10, i64 1165, !10, i64 1166, !11, i64 1168, !11, i64 1176}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"_Bool", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"TCOD_ColorRGB", !8, i64 0, !8, i64 1, !8, i64 2}
!13 = !{!"TCOD_key_t", !7, i64 0, !8, i64 4, !8, i64 5, !10, i64 37, !10, i64 38, !10, i64 39, !10, i64 40, !10, i64 41, !10, i64 42, !10, i64 43, !10, i64 44}
!14 = !{!6, !8, i64 1115}
!15 = !{!6, !11, i64 1064}
!16 = !{!17, !7, i64 0}
!17 = !{!"TCOD_Console", !7, i64 0, !7, i64 4, !11, i64 8, !7, i64 16, !7, i64 20, !12, i64 24, !12, i64 27, !10, i64 30, !12, i64 31, !7, i64 36, !11, i64 40, !11, i64 48}
!18 = !{!17, !7, i64 4}
!19 = !{!6, !8, i64 1112}
!20 = !{!21, !8, i64 0}
!21 = !{!"TCOD_ColorRGBA", !8, i64 0, !8, i64 1, !8, i64 2, !8, i64 3}
!22 = !{!6, !8, i64 1113}
!23 = !{!21, !8, i64 1}
!24 = !{!6, !8, i64 1114}
!25 = !{!21, !8, i64 2}
!26 = !{!21, !8, i64 3}
!27 = !{!17, !7, i64 36}
!28 = !{!17, !11, i64 8}
!29 = !{i64 0, i64 4, !30, i64 4, i64 1, !31, i64 5, i64 1, !31, i64 6, i64 1, !31, i64 7, i64 1, !31, i64 8, i64 1, !31, i64 9, i64 1, !31, i64 10, i64 1, !31, i64 11, i64 1, !31}
!30 = !{!7, !7, i64 0}
!31 = !{!8, !8, i64 0}
!32 = distinct !{!32, !33}
!33 = !{!"llvm.loop.mustprogress"}


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