; 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_strcasecmp(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden void @allocate_tok(ptr noundef, i32 noundef) #1

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

12:                                               ; preds = %56, %1
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = load i32, ptr %5, align 4, !tbaa !15
  call void @allocate_tok(ptr noundef %13, i32 noundef %14)
  %15 = load i8, ptr %4, align 1, !tbaa !14
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.TCOD_lex_t, ptr %16, i32 0, i32 5
  %18 = load ptr, ptr %17, align 8, !tbaa !16
  %19 = load i32, ptr %5, align 4, !tbaa !15
  %20 = add nsw i32 %19, 1
  store i32 %20, ptr %5, align 4, !tbaa !15
  %21 = sext i32 %19 to i64
  %22 = getelementptr inbounds i8, ptr %18, i64 %21
  store i8 %15, ptr %22, align 1, !tbaa !14
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.TCOD_lex_t, ptr %23, i32 0, i32 8
  %25 = load ptr, ptr %24, align 8, !tbaa !9
  %26 = getelementptr inbounds i8, ptr %25, i32 1
  store ptr %26, ptr %24, align 8, !tbaa !9
  %27 = load i8, ptr %26, align 1, !tbaa !14
  store i8 %27, ptr %4, align 1, !tbaa !14
  br label %28

28:                                               ; preds = %12
  %29 = load i8, ptr %4, align 1, !tbaa !14
  %30 = sext i8 %29 to i32
  %31 = icmp sge i32 %30, 97
  br i1 %31, label %32, label %36

32:                                               ; preds = %28
  %33 = load i8, ptr %4, align 1, !tbaa !14
  %34 = sext i8 %33 to i32
  %35 = icmp sle i32 %34, 122
  br i1 %35, label %56, label %36

36:                                               ; preds = %32, %28
  %37 = load i8, ptr %4, align 1, !tbaa !14
  %38 = sext i8 %37 to i32
  %39 = icmp sge i32 %38, 65
  br i1 %39, label %40, label %44

40:                                               ; preds = %36
  %41 = load i8, ptr %4, align 1, !tbaa !14
  %42 = sext i8 %41 to i32
  %43 = icmp sle i32 %42, 90
  br i1 %43, label %56, label %44

44:                                               ; preds = %40, %36
  %45 = load i8, ptr %4, align 1, !tbaa !14
  %46 = sext i8 %45 to i32
  %47 = icmp sge i32 %46, 48
  br i1 %47, label %48, label %52

48:                                               ; preds = %44
  %49 = load i8, ptr %4, align 1, !tbaa !14
  %50 = sext i8 %49 to i32
  %51 = icmp sle i32 %50, 57
  br i1 %51, label %56, label %52

52:                                               ; preds = %48, %44
  %53 = load i8, ptr %4, align 1, !tbaa !14
  %54 = sext i8 %53 to i32
  %55 = icmp eq i32 %54, 95
  br label %56

56:                                               ; preds = %52, %48, %40, %32
  %57 = phi i1 [ true, %48 ], [ true, %40 ], [ true, %32 ], [ %55, %52 ]
  br i1 %57, label %12, label %58, !llvm.loop !17

58:                                               ; preds = %56
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = load i32, ptr %5, align 4, !tbaa !15
  call void @allocate_tok(ptr noundef %59, i32 noundef %60)
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.TCOD_lex_t, ptr %61, i32 0, i32 5
  %63 = load ptr, ptr %62, align 8, !tbaa !16
  %64 = load i32, ptr %5, align 4, !tbaa !15
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds i8, ptr %63, i64 %65
  store i8 0, ptr %66, align 1, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %6, align 4, !tbaa !15
  br label %67

67:                                               ; preds = %109, %58
  %68 = load i32, ptr %6, align 4, !tbaa !15
  %69 = load ptr, ptr %3, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.TCOD_lex_t, ptr %69, i32 0, i32 13
  %71 = load i32, ptr %70, align 4, !tbaa !19
  %72 = icmp slt i32 %68, %71
  br i1 %72, label %73, label %112

73:                                               ; preds = %67
  %74 = load ptr, ptr %3, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.TCOD_lex_t, ptr %74, i32 0, i32 5
  %76 = load ptr, ptr %75, align 8, !tbaa !16
  %77 = load ptr, ptr %3, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.TCOD_lex_t, ptr %77, i32 0, i32 16
  %79 = load i32, ptr %6, align 4, !tbaa !15
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [100 x [20 x i8]], ptr %78, i64 0, i64 %80
  %82 = getelementptr inbounds [20 x i8], ptr %81, i64 0, i64 0
  %83 = call i32 @strcmp(ptr noundef %76, ptr noundef %82) #4
  %84 = icmp eq i32 %83, 0
  br i1 %84, label %103, label %85

85:                                               ; preds = %73
  %86 = load ptr, ptr %3, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.TCOD_lex_t, ptr %86, i32 0, i32 14
  %88 = load i32, ptr %87, align 8, !tbaa !20
  %89 = and i32 %88, 1
  %90 = icmp ne i32 %89, 0
  br i1 %90, label %91, label %109

91:                                               ; preds = %85
  %92 = load ptr, ptr %3, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.TCOD_lex_t, ptr %92, i32 0, i32 5
  %94 = load ptr, ptr %93, align 8, !tbaa !16
  %95 = load ptr, ptr %3, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.TCOD_lex_t, ptr %95, i32 0, i32 16
  %97 = load i32, ptr %6, align 4, !tbaa !15
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [100 x [20 x i8]], ptr %96, i64 0, i64 %98
  %100 = getelementptr inbounds [20 x i8], ptr %99, i64 0, i64 0
  %101 = call i32 @TCOD_strcasecmp(ptr noundef %94, ptr noundef %100)
  %102 = icmp eq i32 %101, 0
  br i1 %102, label %103, label %109

103:                                              ; preds = %91, %73
  %104 = load ptr, ptr %3, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.TCOD_lex_t, ptr %104, i32 0, i32 1
  store i32 2, ptr %105, align 4, !tbaa !21
  %106 = load i32, ptr %6, align 4, !tbaa !15
  %107 = load ptr, ptr %3, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.TCOD_lex_t, ptr %107, i32 0, i32 3
  store i32 %106, ptr %108, align 4, !tbaa !22
  store i32 2, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %117

109:                                              ; preds = %91, %85
  %110 = load i32, ptr %6, align 4, !tbaa !15
  %111 = add nsw i32 %110, 1
  store i32 %111, ptr %6, align 4, !tbaa !15
  br label %67, !llvm.loop !23

112:                                              ; preds = %67
  %113 = load ptr, ptr %3, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.TCOD_lex_t, ptr %113, i32 0, i32 1
  store i32 3, ptr %114, align 4, !tbaa !21
  %115 = load ptr, ptr %3, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct.TCOD_lex_t, ptr %115, i32 0, i32 3
  store i32 -1, ptr %116, align 4, !tbaa !22
  store i32 3, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %117

117:                                              ; preds = %112, %103
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #3
  %118 = load i32, ptr %2, align 4
  ret i32 %118
}

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

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(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 }
attributes #4 = { nounwind willreturn memory(read) }

!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 = !{!11, !11, i64 0}
!16 = !{!10, !6, i64 24}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!10, !11, i64 76}
!20 = !{!10, !11, i64 80}
!21 = !{!10, !11, i64 4}
!22 = !{!10, !11, i64 12}
!23 = distinct !{!23, !18}


; 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_strcasecmp(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @allocate_tok(ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 2, 4) i32 @TCOD_lex_get_iden(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 40
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = load i8, ptr %3, align 1, !tbaa !13
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  br label %.critedge

.critedge:                                        ; preds = %.critedge, %1
  %indvars.iv = phi i64 [ %indvars.iv.next, %.critedge ], [ 0, %1 ]
  %.042 = phi i8 [ %11, %.critedge ], [ %4, %1 ]
  %6 = trunc nuw nsw i64 %indvars.iv to i32
  tail call void @allocate_tok(ptr noundef nonnull %0, i32 noundef %6)
  %7 = load ptr, ptr %5, align 8, !tbaa !14
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %8 = getelementptr inbounds i8, ptr %7, i64 %indvars.iv
  store i8 %.042, ptr %8, align 1, !tbaa !13
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %9, i64 1
  store ptr %10, ptr %2, align 8, !tbaa !5
  %11 = load i8, ptr %10, align 1, !tbaa !13
  %12 = and i8 %11, -33
  %13 = add i8 %12, -65
  %or.cond44 = icmp ult i8 %13, 26
  %14 = add i8 %11, -48
  %or.cond8 = icmp ult i8 %14, 10
  %or.cond45 = or i1 %or.cond8, %or.cond44
  %15 = icmp eq i8 %11, 95
  %or.cond46 = or i1 %15, %or.cond45
  br i1 %or.cond46, label %.critedge, label %16, !llvm.loop !15

16:                                               ; preds = %.critedge
  %17 = trunc nuw i64 %indvars.iv.next to i32
  tail call void @allocate_tok(ptr noundef nonnull %0, i32 noundef %17)
  %18 = load ptr, ptr %5, align 8, !tbaa !14
  %19 = and i64 %indvars.iv.next, 4294967295
  %20 = getelementptr inbounds i8, ptr %18, i64 %19
  store i8 0, ptr %20, align 1, !tbaa !13
  %21 = getelementptr inbounds i8, ptr %0, i64 76
  %22 = load i32, ptr %21, align 4, !tbaa !17
  %23 = icmp sgt i32 %22, 0
  br i1 %23, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %16
  %24 = getelementptr inbounds i8, ptr %0, i64 584
  %25 = getelementptr inbounds i8, ptr %0, i64 80
  br label %26

26:                                               ; preds = %.lr.ph, %40
  %27 = phi i32 [ %22, %.lr.ph ], [ %41, %40 ]
  %indvars.iv51 = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next52, %40 ]
  %28 = load ptr, ptr %5, align 8, !tbaa !14
  %29 = getelementptr inbounds [100 x [20 x i8]], ptr %24, i64 0, i64 %indvars.iv51
  %30 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %28, ptr noundef nonnull dereferenceable(1) %29) #2
  %31 = icmp eq i32 %30, 0
  br i1 %31, label %38, label %32

32:                                               ; preds = %26
  %33 = load i32, ptr %25, align 8, !tbaa !18
  %34 = and i32 %33, 1
  %.not = icmp eq i32 %34, 0
  br i1 %.not, label %40, label %35

35:                                               ; preds = %32
  %36 = tail call i32 @TCOD_strcasecmp(ptr noundef %28, ptr noundef nonnull %29)
  %37 = icmp eq i32 %36, 0
  br i1 %37, label %38, label %._crit_edge54

._crit_edge54:                                    ; preds = %35
  %.pre = load i32, ptr %21, align 4, !tbaa !17
  br label %40

38:                                               ; preds = %35, %26
  %39 = trunc nuw nsw i64 %indvars.iv51 to i32
  br label %._crit_edge

40:                                               ; preds = %._crit_edge54, %32
  %41 = phi i32 [ %.pre, %._crit_edge54 ], [ %27, %32 ]
  %indvars.iv.next52 = add nuw nsw i64 %indvars.iv51, 1
  %42 = sext i32 %41 to i64
  %43 = icmp slt i64 %indvars.iv.next52, %42
  br i1 %43, label %26, label %._crit_edge, !llvm.loop !19

._crit_edge:                                      ; preds = %40, %16, %38
  %.sink57 = phi i32 [ 2, %38 ], [ 3, %16 ], [ 3, %40 ]
  %.sink = phi i32 [ %39, %38 ], [ -1, %16 ], [ -1, %40 ]
  %44 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 %.sink57, ptr %44, align 4, !tbaa !20
  %45 = getelementptr inbounds i8, ptr %0, i64 12
  store i32 %.sink, ptr %45, align 4, !tbaa !21
  ret i32 %.sink57
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture 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 = { 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 #2 = { nounwind willreturn memory(read) }

!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 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!6, !7, i64 76}
!18 = !{!6, !7, i64 80}
!19 = distinct !{!19, !16}
!20 = !{!6, !7, i64 4}
!21 = !{!6, !7, i64 12}


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