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

; 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: nounwind uwtable
declare dso_local i32 @TCOD_lex_get_space(ptr noundef) #1

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__ctype_b_loc() #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @TCOD_lex_get_string(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @TCOD_lex_get_number(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @TCOD_lex_get_char(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @TCOD_lex_get_symbol(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @TCOD_lex_get_iden(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @TCOD_lex_parse(ptr noundef %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = call i32 @TCOD_lex_get_space(ptr noundef %7)
  store i32 %8, ptr %4, align 4, !tbaa !9
  %9 = load i32, ptr %4, align 4, !tbaa !9
  %10 = icmp eq i32 %9, -1
  br i1 %10, label %11, label %13

11:                                               ; preds = %1
  %12 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %12, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %113

13:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.TCOD_lex_t, ptr %14, i32 0, i32 8
  %16 = load ptr, ptr %15, align 8, !tbaa !11
  store ptr %16, ptr %6, align 8, !tbaa !5
  %17 = load i32, ptr %4, align 4, !tbaa !9
  %18 = icmp ne i32 %17, 0
  br i1 %18, label %19, label %24

19:                                               ; preds = %13
  %20 = load i32, ptr %4, align 4, !tbaa !9
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.TCOD_lex_t, ptr %21, i32 0, i32 1
  store i32 %20, ptr %22, align 4, !tbaa !15
  %23 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %23, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %112

24:                                               ; preds = %13
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.TCOD_lex_t, ptr %25, i32 0, i32 21
  %27 = load ptr, ptr %26, align 8, !tbaa !16
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = load i8, ptr %28, align 1, !tbaa !17
  %30 = sext i8 %29 to i32
  %31 = call ptr @strchr(ptr noundef %27, i32 noundef %30) #5
  %32 = icmp ne ptr %31, null
  br i1 %32, label %33, label %40

33:                                               ; preds = %24
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = load i8, ptr %34, align 1, !tbaa !17
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.TCOD_lex_t, ptr %36, i32 0, i32 7
  store i8 %35, ptr %37, align 4, !tbaa !18
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = call i32 @TCOD_lex_get_string(ptr noundef %38)
  store i32 %39, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %112

40:                                               ; preds = %24
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = load i8, ptr %41, align 1, !tbaa !17
  %43 = sext i8 %42 to i32
  %44 = icmp eq i32 %43, 39
  br i1 %44, label %45, label %48

45:                                               ; preds = %40
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = call i32 @TCOD_lex_get_char(ptr noundef %46)
  store i32 %47, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %112

48:                                               ; preds = %40
  %49 = call ptr @__ctype_b_loc() #6
  %50 = load ptr, ptr %49, align 8, !tbaa !5
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = load i8, ptr %51, align 1, !tbaa !17
  %53 = sext i8 %52 to i32
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds i16, ptr %50, i64 %54
  %56 = load i16, ptr %55, align 2, !tbaa !19
  %57 = zext i16 %56 to i32
  %58 = and i32 %57, 2048
  %59 = icmp ne i32 %58, 0
  br i1 %59, label %78, label %60

60:                                               ; preds = %48
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = load i8, ptr %61, align 1, !tbaa !17
  %63 = sext i8 %62 to i32
  %64 = icmp eq i32 %63, 45
  br i1 %64, label %65, label %81

65:                                               ; preds = %60
  %66 = call ptr @__ctype_b_loc() #6
  %67 = load ptr, ptr %66, align 8, !tbaa !5
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = getelementptr inbounds i8, ptr %68, i64 1
  %70 = load i8, ptr %69, align 1, !tbaa !17
  %71 = sext i8 %70 to i32
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds i16, ptr %67, i64 %72
  %74 = load i16, ptr %73, align 2, !tbaa !19
  %75 = zext i16 %74 to i32
  %76 = and i32 %75, 2048
  %77 = icmp ne i32 %76, 0
  br i1 %77, label %78, label %81

78:                                               ; preds = %65, %48
  %79 = load ptr, ptr %3, align 8, !tbaa !5
  %80 = call i32 @TCOD_lex_get_number(ptr noundef %79)
  store i32 %80, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %112

81:                                               ; preds = %65, %60
  %82 = load ptr, ptr %6, align 8, !tbaa !5
  %83 = load i8, ptr %82, align 1, !tbaa !17
  %84 = sext i8 %83 to i32
  %85 = icmp sge i32 %84, 97
  br i1 %85, label %86, label %91

86:                                               ; preds = %81
  %87 = load ptr, ptr %6, align 8, !tbaa !5
  %88 = load i8, ptr %87, align 1, !tbaa !17
  %89 = sext i8 %88 to i32
  %90 = icmp sle i32 %89, 122
  br i1 %90, label %106, label %91

91:                                               ; preds = %86, %81
  %92 = load ptr, ptr %6, align 8, !tbaa !5
  %93 = load i8, ptr %92, align 1, !tbaa !17
  %94 = sext i8 %93 to i32
  %95 = icmp sge i32 %94, 65
  br i1 %95, label %96, label %101

96:                                               ; preds = %91
  %97 = load ptr, ptr %6, align 8, !tbaa !5
  %98 = load i8, ptr %97, align 1, !tbaa !17
  %99 = sext i8 %98 to i32
  %100 = icmp sle i32 %99, 90
  br i1 %100, label %106, label %101

101:                                              ; preds = %96, %91
  %102 = load ptr, ptr %6, align 8, !tbaa !5
  %103 = load i8, ptr %102, align 1, !tbaa !17
  %104 = sext i8 %103 to i32
  %105 = icmp eq i32 %104, 95
  br i1 %105, label %106, label %109

106:                                              ; preds = %101, %96, %86
  %107 = load ptr, ptr %3, align 8, !tbaa !5
  %108 = call i32 @TCOD_lex_get_iden(ptr noundef %107)
  store i32 %108, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %112

109:                                              ; preds = %101
  %110 = load ptr, ptr %3, align 8, !tbaa !5
  %111 = call i32 @TCOD_lex_get_symbol(ptr noundef %110)
  store i32 %111, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %112

112:                                              ; preds = %109, %106, %78, %45, %33, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  br label %113

113:                                              ; preds = %112, %11
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  %114 = load i32, ptr %2, align 4
  ret i32 %114
}

; Function Attrs: nounwind willreturn memory(read)
declare ptr @strchr(ptr noundef, i32 noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #2 = { nounwind willreturn memory(none) "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 willreturn memory(read) "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 }
attributes #5 = { nounwind willreturn memory(read) }
attributes #6 = { nounwind willreturn memory(none) }

!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 40}
!12 = !{!"TCOD_lex_t", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !13, i64 16, !6, i64 24, !10, i64 32, !7, i64 36, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !10, i64 72, !10, i64 76, !10, i64 80, !7, i64 84, !7, i64 584, !6, i64 2584, !6, i64 2592, !6, i64 2600, !6, i64 2608, !6, i64 2616, !14, i64 2624, !14, i64 2625, !14, i64 2626}
!13 = !{!"float", !7, i64 0}
!14 = !{!"_Bool", !7, i64 0}
!15 = !{!12, !10, i64 4}
!16 = !{!12, !6, i64 2616}
!17 = !{!7, !7, i64 0}
!18 = !{!12, !7, i64 36}
!19 = !{!20, !20, i64 0}
!20 = !{!"short", !7, i64 0}


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

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

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__ctype_b_loc() local_unnamed_addr #1

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

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @TCOD_lex_parse(ptr noundef %0) local_unnamed_addr #0 {
  %2 = tail call i32 @TCOD_lex_get_space(ptr noundef %0)
  %3 = icmp eq i32 %2, -1
  br i1 %3, label %48, label %4

4:                                                ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 40
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %.not = icmp eq i32 %2, 0
  br i1 %.not, label %9, label %7

7:                                                ; preds = %4
  %8 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 %2, ptr %8, align 4, !tbaa !13
  br label %48

9:                                                ; preds = %4
  %10 = getelementptr inbounds i8, ptr %0, i64 2616
  %11 = load ptr, ptr %10, align 8, !tbaa !14
  %12 = load i8, ptr %6, align 1, !tbaa !15
  %13 = sext i8 %12 to i32
  %14 = tail call ptr @strchr(ptr noundef nonnull dereferenceable(1) %11, i32 noundef %13) #3
  %.not31 = icmp eq ptr %14, null
  br i1 %.not31, label %18, label %15

15:                                               ; preds = %9
  %16 = getelementptr inbounds i8, ptr %0, i64 36
  store i8 %12, ptr %16, align 4, !tbaa !16
  %17 = tail call i32 @TCOD_lex_get_string(ptr noundef nonnull %0)
  br label %48

18:                                               ; preds = %9
  %19 = icmp eq i8 %12, 39
  br i1 %19, label %20, label %22

20:                                               ; preds = %18
  %21 = tail call i32 @TCOD_lex_get_char(ptr noundef nonnull %0)
  br label %48

22:                                               ; preds = %18
  %23 = tail call ptr @__ctype_b_loc() #4
  %24 = load ptr, ptr %23, align 8, !tbaa !17
  %25 = sext i8 %12 to i64
  %26 = getelementptr inbounds i16, ptr %24, i64 %25
  %27 = load i16, ptr %26, align 2, !tbaa !18
  %28 = and i16 %27, 2048
  %.not32 = icmp eq i16 %28, 0
  br i1 %.not32, label %29, label %38

29:                                               ; preds = %22
  %30 = icmp eq i8 %12, 45
  br i1 %30, label %31, label %40

31:                                               ; preds = %29
  %32 = getelementptr inbounds i8, ptr %6, i64 1
  %33 = load i8, ptr %32, align 1, !tbaa !15
  %34 = sext i8 %33 to i64
  %35 = getelementptr inbounds i16, ptr %24, i64 %34
  %36 = load i16, ptr %35, align 2, !tbaa !18
  %37 = and i16 %36, 2048
  %.not33 = icmp eq i16 %37, 0
  br i1 %.not33, label %.thread38, label %38

38:                                               ; preds = %31, %22
  %39 = tail call i32 @TCOD_lex_get_number(ptr noundef nonnull %0)
  br label %48

40:                                               ; preds = %29
  %41 = add i8 %12, -97
  %or.cond = icmp ult i8 %41, 26
  br i1 %or.cond, label %45, label %42

42:                                               ; preds = %40
  %43 = add i8 %12, -65
  %or.cond34 = icmp ult i8 %43, 26
  %44 = icmp eq i8 %12, 95
  %or.cond39 = or i1 %44, %or.cond34
  br i1 %or.cond39, label %45, label %.thread38

45:                                               ; preds = %42, %40
  %46 = tail call i32 @TCOD_lex_get_iden(ptr noundef nonnull %0)
  br label %48

.thread38:                                        ; preds = %42, %31
  %47 = tail call i32 @TCOD_lex_get_symbol(ptr noundef nonnull %0)
  br label %48

48:                                               ; preds = %7, %15, %20, %38, %45, %.thread38, %1
  %.1 = phi i32 [ -1, %1 ], [ %2, %7 ], [ %17, %15 ], [ %21, %20 ], [ %39, %38 ], [ %46, %45 ], [ %47, %.thread38 ]
  ret i32 %.1
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare ptr @strchr(ptr noundef, i32 noundef) 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 = { mustprogress nofree nosync nounwind willreturn memory(none) "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 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 willreturn memory(read) }
attributes #4 = { nounwind willreturn memory(none) }

!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 = !{!6, !7, i64 4}
!14 = !{!6, !11, i64 2616}
!15 = !{!8, !8, i64 0}
!16 = !{!6, !8, i64 36}
!17 = !{!11, !11, i64 0}
!18 = !{!19, !19, i64 0}
!19 = !{!"short", !8, i64 0}


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