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

; 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_Tileset = type { i32, i32, i32, i32, i32, ptr, i32, ptr, ptr, i32, i32 }
%struct.TCOD_Context = type { i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

@TCOD_ctx = external global %struct.TCOD_internal_context_t, align 8

; Function Attrs: nounwind uwtable
define dso_local void @TCOD_set_default_tileset(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr getelementptr inbounds (%struct.TCOD_internal_context_t, ptr @TCOD_ctx, i32 0, i32 28), align 8, !tbaa !9
  call void @TCOD_tileset_delete(ptr noundef %3)
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %4, ptr getelementptr inbounds (%struct.TCOD_internal_context_t, ptr @TCOD_ctx, i32 0, i32 28), align 8, !tbaa !9
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = icmp ne ptr %5, null
  br i1 %6, label %7, label %12

7:                                                ; preds = %1
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.TCOD_Tileset, ptr %8, i32 0, i32 10
  %10 = load volatile i32, ptr %9, align 4, !tbaa !15
  %11 = add nsw i32 %10, 1
  store volatile i32 %11, ptr %9, align 4, !tbaa !15
  br label %12

12:                                               ; preds = %7, %1
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = icmp ne ptr %13, null
  br i1 %14, label %15, label %25

15:                                               ; preds = %12
  %16 = load ptr, ptr getelementptr inbounds (%struct.TCOD_internal_context_t, ptr @TCOD_ctx, i32 0, i32 29), align 8, !tbaa !17
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %25

18:                                               ; preds = %15
  %19 = load ptr, ptr getelementptr inbounds (%struct.TCOD_internal_context_t, ptr @TCOD_ctx, i32 0, i32 29), align 8, !tbaa !17
  %20 = getelementptr inbounds %struct.TCOD_Context, ptr %19, i32 0, i32 9
  %21 = load ptr, ptr %20, align 8, !tbaa !18
  %22 = load ptr, ptr getelementptr inbounds (%struct.TCOD_internal_context_t, ptr @TCOD_ctx, i32 0, i32 29), align 8, !tbaa !17
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  %24 = call i32 %21(ptr noundef %22, ptr noundef %23)
  br label %25

25:                                               ; preds = %18, %15, %12
  ret void
}

declare void @TCOD_tileset_delete(ptr noundef) #1

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" }

!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 1168}
!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 = !{!16, !11, i64 60}
!16 = !{!"TCOD_Tileset", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !6, i64 24, !11, i64 32, !6, i64 40, !6, i64 48, !11, i64 56, !11, i64 60}
!17 = !{!10, !6, i64 1176}
!18 = !{!19, !6, i64 72}
!19 = !{!"TCOD_Context", !11, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96}


; 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 }

@TCOD_ctx = external local_unnamed_addr global %struct.TCOD_internal_context_t, align 8

; Function Attrs: nounwind uwtable
define dso_local void @TCOD_set_default_tileset(ptr noundef %0) local_unnamed_addr #0 {
  %2 = load ptr, ptr getelementptr inbounds (i8, ptr @TCOD_ctx, i64 1168), align 8, !tbaa !5
  tail call void @TCOD_tileset_delete(ptr noundef %2) #2
  store ptr %0, ptr getelementptr inbounds (i8, ptr @TCOD_ctx, i64 1168), align 8, !tbaa !5
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %.thread, label %3

3:                                                ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 60
  %5 = load volatile i32, ptr %4, align 4, !tbaa !14
  %6 = add nsw i32 %5, 1
  store volatile i32 %6, ptr %4, align 4, !tbaa !14
  %7 = load ptr, ptr getelementptr inbounds (i8, ptr @TCOD_ctx, i64 1176), align 8
  %.not8 = icmp eq ptr %7, null
  br i1 %.not8, label %.thread, label %8

8:                                                ; preds = %3
  %9 = getelementptr inbounds i8, ptr %7, i64 72
  %10 = load ptr, ptr %9, align 8, !tbaa !16
  %11 = tail call i32 %10(ptr noundef nonnull %7, ptr noundef nonnull %0) #2
  br label %.thread

.thread:                                          ; preds = %1, %8, %3
  ret void
}

declare void @TCOD_tileset_delete(ptr noundef) local_unnamed_addr #1

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 = { 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 1168}
!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 = !{!15, !7, i64 60}
!15 = !{!"TCOD_Tileset", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !11, i64 24, !7, i64 32, !11, i64 40, !11, i64 48, !7, i64 56, !7, i64 60}
!16 = !{!17, !11, i64 72}
!17 = !{!"TCOD_Context", !7, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !11, i64 80, !11, i64 88, !11, i64 96}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass,TailCallElimPass