; LLVM IR from libtcod/libtcod :: src/libtcod (lex_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.TCOD_lex_t = type { i32, i32, i32, i32, float, ptr, i32, i8, ptr, ptr, ptr, ptr, i32, i32, i32, [100 x [5 x i8]], [100 x [20 x i8]], ptr, ptr, ptr, ptr, ptr, i8, i8, i8 }

@.str = external hidden unnamed_addr constant [9 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [83 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [34 x i8], align 1

; 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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @TCOD_lex_get_char(ptr noundef %0) #2 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %4) #3
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.TCOD_lex_t, ptr %6, i32 0, i32 8
  %8 = load ptr, ptr %7, align 8, !tbaa !9
  %9 = getelementptr inbounds i8, ptr %8, i32 1
  store ptr %9, ptr %7, align 8, !tbaa !9
  %10 = load i8, ptr %9, align 1, !tbaa !14
  store i8 %10, ptr %4, align 1, !tbaa !14
  %11 = load i8, ptr %4, align 1, !tbaa !14
  %12 = sext i8 %11 to i32
  %13 = icmp eq i32 %12, 0
  br i1 %13, label %14, label %16

14:                                               ; preds = %1
  %15 = call i32 (ptr, ...) @TCOD_set_errorf(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 437, ptr noundef @.str.13)
  store i32 -1, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %71

16:                                               ; preds = %1
  %17 = load i8, ptr %4, align 1, !tbaa !14
  %18 = sext i8 %17 to i32
  %19 = icmp eq i32 %18, 10
  br i1 %19, label %20, label %22

20:                                               ; preds = %16
  %21 = call i32 (ptr, ...) @TCOD_set_errorf(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 441, ptr noundef @.str.14)
  store i32 -1, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %71

22:                                               ; preds = %16
  %23 = load i8, ptr %4, align 1, !tbaa !14
  %24 = sext i8 %23 to i32
  %25 = icmp eq i32 %24, 92
  br i1 %25, label %26, label %35

26:                                               ; preds = %22
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = call zeroext i1 @TCOD_lex_get_special_char(ptr noundef %27, ptr noundef %4)
  br i1 %28, label %30, label %29

29:                                               ; preds = %26
  store i32 -1, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %71

30:                                               ; preds = %26
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.TCOD_lex_t, ptr %31, i32 0, i32 8
  %33 = load ptr, ptr %32, align 8, !tbaa !9
  %34 = getelementptr inbounds i8, ptr %33, i32 1
  store ptr %34, ptr %32, align 8, !tbaa !9
  br label %40

35:                                               ; preds = %22
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.TCOD_lex_t, ptr %36, i32 0, i32 8
  %38 = load ptr, ptr %37, align 8, !tbaa !9
  %39 = getelementptr inbounds i8, ptr %38, i32 1
  store ptr %39, ptr %37, align 8, !tbaa !9
  br label %40

40:                                               ; preds = %35, %30
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.TCOD_lex_t, ptr %41, i32 0, i32 8
  %43 = load ptr, ptr %42, align 8, !tbaa !9
  %44 = load i8, ptr %43, align 1, !tbaa !14
  %45 = sext i8 %44 to i32
  %46 = icmp ne i32 %45, 39
  br i1 %46, label %47, label %49

47:                                               ; preds = %40
  %48 = call i32 (ptr, ...) @TCOD_set_errorf(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 451, ptr noundef @.str.15)
  store i32 -1, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %71

49:                                               ; preds = %40
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.TCOD_lex_t, ptr %50, i32 0, i32 8
  %52 = load ptr, ptr %51, align 8, !tbaa !9
  %53 = getelementptr inbounds i8, ptr %52, i32 1
  store ptr %53, ptr %51, align 8, !tbaa !9
  %54 = load i8, ptr %4, align 1, !tbaa !14
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.TCOD_lex_t, ptr %55, i32 0, i32 5
  %57 = load ptr, ptr %56, align 8, !tbaa !15
  %58 = getelementptr inbounds i8, ptr %57, i64 0
  store i8 %54, ptr %58, align 1, !tbaa !14
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.TCOD_lex_t, ptr %59, i32 0, i32 5
  %61 = load ptr, ptr %60, align 8, !tbaa !15
  %62 = getelementptr inbounds i8, ptr %61, i64 1
  store i8 0, ptr %62, align 1, !tbaa !14
  %63 = load ptr, ptr %3, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.TCOD_lex_t, ptr %63, i32 0, i32 1
  store i32 7, ptr %64, align 4, !tbaa !16
  %65 = load i8, ptr %4, align 1, !tbaa !14
  %66 = sext i8 %65 to i32
  %67 = load ptr, ptr %3, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.TCOD_lex_t, ptr %67, i32 0, i32 2
  store i32 %66, ptr %68, align 8, !tbaa !17
  %69 = load ptr, ptr %3, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.TCOD_lex_t, ptr %69, i32 0, i32 3
  store i32 -1, ptr %70, align 4, !tbaa !18
  store i32 7, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %71

71:                                               ; preds = %49, %47, %29, %20, %14
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #3
  %72 = load i32, ptr %2, align 4
  ret i32 %72
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 = { 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 40}
!10 = !{!"TCOD_lex_t", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !12, i64 16, !6, i64 24, !11, i64 32, !7, i64 36, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !11, i64 72, !11, i64 76, !11, i64 80, !7, i64 84, !7, i64 584, !6, i64 2584, !6, i64 2592, !6, i64 2600, !6, i64 2608, !6, i64 2616, !13, i64 2624, !13, i64 2625, !13, i64 2626}
!11 = !{!"int", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!7, !7, i64 0}
!15 = !{!10, !6, i64 24}
!16 = !{!10, !11, i64 4}
!17 = !{!10, !11, i64 8}
!18 = !{!10, !11, i64 12}


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

@.str = external hidden unnamed_addr constant [9 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [83 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [34 x i8], align 1

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 8) i32 @TCOD_lex_get_char(ptr noundef %0) local_unnamed_addr #2 {
  %2 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %2) #3
  %3 = getelementptr inbounds i8, ptr %0, i64 40
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %4, i64 1
  store ptr %5, ptr %3, align 8, !tbaa !5
  %6 = load i8, ptr %5, align 1, !tbaa !13
  store i8 %6, ptr %2, align 1, !tbaa !13
  switch i8 %6, label %13 [
    i8 0, label %7
    i8 10, label %9
    i8 92, label %11
  ]

7:                                                ; preds = %1
  %8 = tail call i32 (ptr, ...) @TCOD_set_errorf(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 437, ptr noundef nonnull @.str.13) #3
  br label %28

9:                                                ; preds = %1
  %10 = tail call i32 (ptr, ...) @TCOD_set_errorf(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 441, ptr noundef nonnull @.str.14) #3
  br label %28

11:                                               ; preds = %1
  %12 = call zeroext i1 @TCOD_lex_get_special_char(ptr noundef nonnull %0, ptr noundef nonnull %2)
  br i1 %12, label %._crit_edge, label %28

._crit_edge:                                      ; preds = %11
  %.pn.pre = load ptr, ptr %3, align 8, !tbaa !5
  br label %13

13:                                               ; preds = %._crit_edge, %1
  %.pn = phi ptr [ %.pn.pre, %._crit_edge ], [ %5, %1 ]
  %storemerge = getelementptr inbounds i8, ptr %.pn, i64 1
  store ptr %storemerge, ptr %3, align 8, !tbaa !5
  %14 = load i8, ptr %storemerge, align 1, !tbaa !13
  %.not = icmp eq i8 %14, 39
  br i1 %.not, label %17, label %15

15:                                               ; preds = %13
  %16 = call i32 (ptr, ...) @TCOD_set_errorf(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 451, ptr noundef nonnull @.str.15) #3
  br label %28

17:                                               ; preds = %13
  %18 = getelementptr inbounds i8, ptr %.pn, i64 2
  store ptr %18, ptr %3, align 8, !tbaa !5
  %19 = load i8, ptr %2, align 1, !tbaa !13
  %20 = getelementptr inbounds i8, ptr %0, i64 24
  %21 = load ptr, ptr %20, align 8, !tbaa !14
  store i8 %19, ptr %21, align 1, !tbaa !13
  %22 = load ptr, ptr %20, align 8, !tbaa !14
  %23 = getelementptr inbounds i8, ptr %22, i64 1
  store i8 0, ptr %23, align 1, !tbaa !13
  %24 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 7, ptr %24, align 4, !tbaa !15
  %25 = sext i8 %19 to i32
  %26 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %25, ptr %26, align 8, !tbaa !16
  %27 = getelementptr inbounds i8, ptr %0, i64 12
  store i32 -1, ptr %27, align 4, !tbaa !17
  br label %28

28:                                               ; preds = %11, %17, %15, %9, %7
  %.0 = phi i32 [ -1, %7 ], [ -1, %9 ], [ -1, %15 ], [ 7, %17 ], [ -1, %11 ]
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %2) #3
  ret i32 %.0
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 = { 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 40}
!6 = !{!"TCOD_lex_t", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !10, i64 16, !11, i64 24, !7, i64 32, !8, i64 36, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !7, i64 72, !7, i64 76, !7, i64 80, !8, i64 84, !8, i64 584, !11, i64 2584, !11, i64 2592, !11, i64 2600, !11, i64 2608, !11, i64 2616, !12, i64 2624, !12, i64 2625, !12, i64 2626}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"_Bool", !8, i64 0}
!13 = !{!8, !8, i64 0}
!14 = !{!6, !11, i64 24}
!15 = !{!6, !7, i64 4}
!16 = !{!6, !7, i64 8}
!17 = !{!6, !7, i64 12}


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