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

; 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.namegen_syllables_t = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.TCOD_NameGen = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

@namegen_generators_list = external dso_local global ptr, align 8
@parser_data = external dso_local global ptr, align 8
@parser_output = external dso_local global ptr, align 8
@namegen_random = external dso_local global ptr, align 8

; Function Attrs: nounwind uwtable
declare dso_local void @namegen_syllables_delete(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @namegen_generator_new() #0

declare ptr @TCOD_list_new() #1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @namegen_generator_check(ptr noundef) #0

declare void @TCOD_list_push(ptr noundef, ptr noundef) #1

declare ptr @TCOD_strdup(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @namegen_populate(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @namegen_parser_end_struct(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %3, align 8, !tbaa !5
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  %7 = call zeroext i1 @namegen_generator_check(ptr noundef %6)
  %8 = zext i1 %7 to i32
  %9 = icmp eq i32 %8, 0
  br i1 %9, label %10, label %28

10:                                               ; preds = %2
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = call ptr @TCOD_strdup(ptr noundef %11)
  %13 = load ptr, ptr @parser_data, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.namegen_syllables_t, ptr %13, i32 0, i32 0
  store ptr %12, ptr %14, align 8, !tbaa !9
  %15 = call ptr @namegen_generator_new()
  store ptr %15, ptr @parser_output, align 8, !tbaa !5
  %16 = load ptr, ptr @parser_output, align 8, !tbaa !5
  %17 = load ptr, ptr @parser_data, align 8, !tbaa !5
  call void @namegen_populate(ptr noundef %16, ptr noundef %17)
  %18 = load ptr, ptr @namegen_random, align 8, !tbaa !5
  %19 = load ptr, ptr @parser_output, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.TCOD_NameGen, ptr %19, i32 0, i32 1
  store ptr %18, ptr %20, align 8, !tbaa !11
  %21 = load ptr, ptr @namegen_generators_list, align 8, !tbaa !5
  %22 = icmp eq ptr %21, null
  br i1 %22, label %23, label %25

23:                                               ; preds = %10
  %24 = call ptr @TCOD_list_new()
  store ptr %24, ptr @namegen_generators_list, align 8, !tbaa !5
  br label %25

25:                                               ; preds = %23, %10
  %26 = load ptr, ptr @namegen_generators_list, align 8, !tbaa !5
  %27 = load ptr, ptr @parser_output, align 8, !tbaa !5
  call void @TCOD_list_push(ptr noundef %26, ptr noundef %27)
  br label %28

28:                                               ; preds = %25, %2
  %29 = load ptr, ptr @parser_data, align 8, !tbaa !5
  call void @namegen_syllables_delete(ptr noundef %29)
  ret i1 true
}

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 0}
!10 = !{!"", !6, 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}
!11 = !{!12, !6, i64 8}
!12 = !{!"TCOD_NameGen", !6, 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}


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

@namegen_generators_list = external dso_local local_unnamed_addr global ptr, align 8
@parser_data = external dso_local local_unnamed_addr global ptr, align 8
@parser_output = external dso_local local_unnamed_addr global ptr, align 8
@namegen_random = external dso_local local_unnamed_addr global ptr, align 8

; Function Attrs: nounwind uwtable
declare dso_local void @namegen_syllables_delete(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @namegen_generator_new() local_unnamed_addr #0

declare ptr @TCOD_list_new() local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @namegen_generator_check(ptr noundef) local_unnamed_addr #0

declare void @TCOD_list_push(ptr noundef, ptr noundef) local_unnamed_addr #1

declare ptr @TCOD_strdup(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @namegen_populate(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @namegen_parser_end_struct(ptr nocapture noundef readnone %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = tail call zeroext i1 @namegen_generator_check(ptr noundef %1)
  br i1 %3, label %19, label %4

4:                                                ; preds = %2
  %5 = tail call ptr @TCOD_strdup(ptr noundef %1) #2
  %6 = load ptr, ptr @parser_data, align 8, !tbaa !5
  store ptr %5, ptr %6, align 8, !tbaa !9
  %7 = tail call ptr @namegen_generator_new()
  store ptr %7, ptr @parser_output, align 8, !tbaa !5
  %8 = load ptr, ptr @parser_data, align 8, !tbaa !5
  tail call void @namegen_populate(ptr noundef %7, ptr noundef %8)
  %9 = load ptr, ptr @namegen_random, align 8, !tbaa !5
  %10 = load ptr, ptr @parser_output, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %10, i64 8
  store ptr %9, ptr %11, align 8, !tbaa !11
  %12 = load ptr, ptr @namegen_generators_list, align 8, !tbaa !5
  %13 = icmp eq ptr %12, null
  br i1 %13, label %14, label %16

14:                                               ; preds = %4
  %15 = tail call ptr @TCOD_list_new() #2
  store ptr %15, ptr @namegen_generators_list, align 8, !tbaa !5
  %.pre = load ptr, ptr @parser_output, align 8, !tbaa !5
  br label %16

16:                                               ; preds = %14, %4
  %17 = phi ptr [ %.pre, %14 ], [ %10, %4 ]
  %18 = phi ptr [ %15, %14 ], [ %12, %4 ]
  tail call void @TCOD_list_push(ptr noundef %18, ptr noundef %17) #2
  br label %19

19:                                               ; preds = %16, %2
  %20 = load ptr, ptr @parser_data, align 8, !tbaa !5
  tail call void @namegen_syllables_delete(ptr noundef %20)
  ret i1 true
}

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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"", !6, 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}
!11 = !{!12, !6, i64 8}
!12 = !{!"TCOD_NameGen", !6, 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}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,TailCallElimPass