; 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.1 = external hidden unnamed_addr constant [83 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [27 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: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #1

; Function Attrs: nounwind
declare ptr @strcpy(ptr noundef, ptr noundef) #2

; 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_strncasecmp(ptr noundef, ptr noundef, i64 noundef) #3

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

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strncmp(ptr noundef, ptr noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @TCOD_lex_get_symbol(ptr noundef %0) #3 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %6

6:                                                ; preds = %83, %1
  %7 = load i32, ptr %4, align 4, !tbaa !9
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.TCOD_lex_t, ptr %8, i32 0, i32 12
  %10 = load i32, ptr %9, align 8, !tbaa !11
  %11 = icmp slt i32 %7, %10
  br i1 %11, label %12, label %86

12:                                               ; preds = %6
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.TCOD_lex_t, ptr %13, i32 0, i32 14
  %15 = load i32, ptr %14, align 8, !tbaa !15
  %16 = and i32 %15, 1
  %17 = icmp ne i32 %16, 0
  br i1 %17, label %18, label %37

18:                                               ; preds = %12
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.TCOD_lex_t, ptr %19, i32 0, i32 15
  %21 = load i32, ptr %4, align 4, !tbaa !9
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [100 x [5 x i8]], ptr %20, i64 0, i64 %22
  %24 = getelementptr inbounds [5 x i8], ptr %23, i64 0, i64 0
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.TCOD_lex_t, ptr %25, i32 0, i32 8
  %27 = load ptr, ptr %26, align 8, !tbaa !16
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.TCOD_lex_t, ptr %28, i32 0, i32 15
  %30 = load i32, ptr %4, align 4, !tbaa !9
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [100 x [5 x i8]], ptr %29, i64 0, i64 %31
  %33 = getelementptr inbounds [5 x i8], ptr %32, i64 0, i64 0
  %34 = call i64 @strlen(ptr noundef %33) #6
  %35 = call i32 @TCOD_strncasecmp(ptr noundef %24, ptr noundef %27, i64 noundef %34)
  %36 = icmp eq i32 %35, 0
  br i1 %36, label %56, label %37

37:                                               ; preds = %18, %12
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.TCOD_lex_t, ptr %38, i32 0, i32 15
  %40 = load i32, ptr %4, align 4, !tbaa !9
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [100 x [5 x i8]], ptr %39, i64 0, i64 %41
  %43 = getelementptr inbounds [5 x i8], ptr %42, i64 0, i64 0
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.TCOD_lex_t, ptr %44, i32 0, i32 8
  %46 = load ptr, ptr %45, align 8, !tbaa !16
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.TCOD_lex_t, ptr %47, i32 0, i32 15
  %49 = load i32, ptr %4, align 4, !tbaa !9
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [100 x [5 x i8]], ptr %48, i64 0, i64 %50
  %52 = getelementptr inbounds [5 x i8], ptr %51, i64 0, i64 0
  %53 = call i64 @strlen(ptr noundef %52) #6
  %54 = call i32 @strncmp(ptr noundef %43, ptr noundef %46, i64 noundef %53) #6
  %55 = icmp eq i32 %54, 0
  br i1 %55, label %56, label %83

56:                                               ; preds = %37, %18
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.TCOD_lex_t, ptr %57, i32 0, i32 5
  %59 = load ptr, ptr %58, align 8, !tbaa !17
  %60 = load ptr, ptr %3, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.TCOD_lex_t, ptr %60, i32 0, i32 15
  %62 = load i32, ptr %4, align 4, !tbaa !9
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [100 x [5 x i8]], ptr %61, i64 0, i64 %63
  %65 = getelementptr inbounds [5 x i8], ptr %64, i64 0, i64 0
  %66 = call ptr @strcpy(ptr noundef %59, ptr noundef %65) #5
  %67 = load ptr, ptr %3, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.TCOD_lex_t, ptr %67, i32 0, i32 15
  %69 = load i32, ptr %4, align 4, !tbaa !9
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [100 x [5 x i8]], ptr %68, i64 0, i64 %70
  %72 = getelementptr inbounds [5 x i8], ptr %71, i64 0, i64 0
  %73 = call i64 @strlen(ptr noundef %72) #6
  %74 = load ptr, ptr %3, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.TCOD_lex_t, ptr %74, i32 0, i32 8
  %76 = load ptr, ptr %75, align 8, !tbaa !16
  %77 = getelementptr inbounds i8, ptr %76, i64 %73
  store ptr %77, ptr %75, align 8, !tbaa !16
  %78 = load i32, ptr %4, align 4, !tbaa !9
  %79 = load ptr, ptr %3, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.TCOD_lex_t, ptr %79, i32 0, i32 3
  store i32 %78, ptr %80, align 4, !tbaa !18
  %81 = load ptr, ptr %3, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.TCOD_lex_t, ptr %81, i32 0, i32 1
  store i32 1, ptr %82, align 4, !tbaa !19
  store i32 1, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %96

83:                                               ; preds = %37
  %84 = load i32, ptr %4, align 4, !tbaa !9
  %85 = add nsw i32 %84, 1
  store i32 %85, ptr %4, align 4, !tbaa !9
  br label %6, !llvm.loop !20

86:                                               ; preds = %6
  %87 = load ptr, ptr %3, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.TCOD_lex_t, ptr %87, i32 0, i32 8
  %89 = load ptr, ptr %88, align 8, !tbaa !16
  %90 = getelementptr inbounds i8, ptr %89, i32 1
  store ptr %90, ptr %88, align 8, !tbaa !16
  %91 = load ptr, ptr %3, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.TCOD_lex_t, ptr %91, i32 0, i32 8
  %93 = load ptr, ptr %92, align 8, !tbaa !16
  %94 = getelementptr inbounds i8, ptr %93, i64 -1
  %95 = call i32 (ptr, ...) @TCOD_set_errorf(ptr noundef @.str.16, ptr noundef @.str.1, i32 noundef 479, ptr noundef %94)
  store i32 -1, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %96

96:                                               ; preds = %86, %56
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  %97 = load i32, ptr %2, align 4
  ret i32 %97
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { nounwind "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 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 #4 = { "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 #5 = { nounwind }
attributes #6 = { 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 72}
!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 80}
!16 = !{!12, !6, i64 40}
!17 = !{!12, !6, i64 24}
!18 = !{!12, !10, i64 12}
!19 = !{!12, !10, i64 4}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}


; 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.1 = external hidden unnamed_addr constant [83 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [27 x i8], align 1

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strcpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @TCOD_strncasecmp(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strncmp(ptr nocapture noundef, ptr nocapture noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 2) i32 @TCOD_lex_get_symbol(ptr noundef %0) local_unnamed_addr #2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 72
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %4 = icmp sgt i32 %3, 0
  br i1 %4, label %.lr.ph, label %.._crit_edge_crit_edge

.._crit_edge_crit_edge:                           ; preds = %1
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 40
  %.pre32 = load ptr, ptr %.phi.trans.insert, align 8, !tbaa !13
  br label %._crit_edge

.lr.ph:                                           ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 80
  %6 = getelementptr inbounds i8, ptr %0, i64 84
  %7 = getelementptr inbounds i8, ptr %0, i64 40
  %.pre31.pre = load ptr, ptr %7, align 8, !tbaa !13
  br label %8

8:                                                ; preds = %.lr.ph, %33
  %.pre31 = phi ptr [ %.pre31.pre, %.lr.ph ], [ %.pre3133, %33 ]
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %33 ]
  %9 = load i32, ptr %5, align 8, !tbaa !14
  %10 = and i32 %9, 1
  %.not = icmp eq i32 %10, 0
  br i1 %.not, label %16, label %11

11:                                               ; preds = %8
  %12 = getelementptr inbounds [100 x [5 x i8]], ptr %6, i64 0, i64 %indvars.iv
  %13 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %12) #4
  %14 = tail call i32 @TCOD_strncasecmp(ptr noundef nonnull %12, ptr noundef %.pre31, i64 noundef %13)
  %15 = icmp eq i32 %14, 0
  br i1 %15, label %21, label %._crit_edge30

._crit_edge30:                                    ; preds = %11
  %.pre = load ptr, ptr %7, align 8, !tbaa !13
  br label %16

16:                                               ; preds = %._crit_edge30, %8
  %.pre3133 = phi ptr [ %.pre, %._crit_edge30 ], [ %.pre31, %8 ]
  %17 = getelementptr inbounds [100 x [5 x i8]], ptr %6, i64 0, i64 %indvars.iv
  %18 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %17) #4
  %19 = tail call i32 @strncmp(ptr noundef nonnull %17, ptr noundef %.pre3133, i64 noundef %18) #4
  %20 = icmp eq i32 %19, 0
  br i1 %20, label %21, label %33

21:                                               ; preds = %16, %11
  %22 = trunc nuw nsw i64 %indvars.iv to i32
  %23 = getelementptr inbounds i8, ptr %0, i64 24
  %24 = load ptr, ptr %23, align 8, !tbaa !15
  %25 = and i64 %indvars.iv, 4294967295
  %26 = getelementptr inbounds [100 x [5 x i8]], ptr %6, i64 0, i64 %25
  %27 = tail call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %24, ptr noundef nonnull dereferenceable(1) %26) #5
  %28 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %26) #4
  %29 = load ptr, ptr %7, align 8, !tbaa !13
  %30 = getelementptr inbounds i8, ptr %29, i64 %28
  store ptr %30, ptr %7, align 8, !tbaa !13
  %31 = getelementptr inbounds i8, ptr %0, i64 12
  store i32 %22, ptr %31, align 4, !tbaa !16
  %32 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 1, ptr %32, align 4, !tbaa !17
  br label %41

33:                                               ; preds = %16
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %34 = load i32, ptr %2, align 8, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = icmp slt i64 %indvars.iv.next, %35
  br i1 %36, label %8, label %._crit_edge, !llvm.loop !18

._crit_edge:                                      ; preds = %33, %.._crit_edge_crit_edge
  %37 = phi ptr [ %.pre32, %.._crit_edge_crit_edge ], [ %.pre3133, %33 ]
  %38 = getelementptr inbounds i8, ptr %0, i64 40
  %39 = getelementptr inbounds i8, ptr %37, i64 1
  store ptr %39, ptr %38, align 8, !tbaa !13
  %40 = tail call i32 (ptr, ...) @TCOD_set_errorf(ptr noundef nonnull @.str.16, ptr noundef nonnull @.str.1, i32 noundef 479, ptr noundef %37) #5
  br label %41

41:                                               ; preds = %._crit_edge, %21
  %.025 = phi i32 [ 1, %21 ], [ -1, %._crit_edge ]
  ret i32 %.025
}

attributes #0 = { 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 #1 = { mustprogress nofree nounwind willreturn memory(argmem: readwrite) "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 = { "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 willreturn memory(read) }
attributes #5 = { 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, !7, i64 72}
!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, !11, i64 40}
!14 = !{!6, !7, i64 80}
!15 = !{!6, !11, i64 24}
!16 = !{!6, !7, i64 12}
!17 = !{!6, !7, i64 4}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


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