; LLVM IR from libtcod/libtcod :: src/libtcod (parser_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_dice_t = type { i32, i32, float, float }
%union.TCOD_value_t = type { ptr, [8 x i8] }
%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 }

@lex = external hidden global ptr, align 8
@__const.TCOD_parse_dice_value.ret = external hidden unnamed_addr constant { %struct.TCOD_dice_t }, align 8
@.str.13 = external hidden unnamed_addr constant [91 x i8], align 1

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

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

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

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare i32 @atoi(ptr noundef nonnull) #4

; Function Attrs: nounwind uwtable
define dso_local { ptr, double } @TCOD_parse_dice_value() #0 {
  %1 = alloca %union.TCOD_value_t, align 8
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %1, ptr align 8 @__const.TCOD_parse_dice_value.ret, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #5
  %5 = load ptr, ptr @lex, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.TCOD_lex_t, ptr %5, i32 0, i32 5
  %7 = load ptr, ptr %6, align 8, !tbaa !9
  store ptr %7, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = call ptr @strchr(ptr noundef %8, i32 noundef 120) #6
  store ptr %9, ptr %3, align 8, !tbaa !5
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = icmp ne ptr %10, null
  br i1 %11, label %15, label %12

12:                                               ; preds = %0
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = call ptr @strchr(ptr noundef %13, i32 noundef 42) #6
  store ptr %14, ptr %3, align 8, !tbaa !5
  br label %15

15:                                               ; preds = %12, %0
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %28

18:                                               ; preds = %15
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  store i8 0, ptr %19, align 1, !tbaa !14
  %20 = load ptr, ptr @lex, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.TCOD_lex_t, ptr %20, i32 0, i32 5
  %22 = load ptr, ptr %21, align 8, !tbaa !9
  %23 = call double @atof(ptr noundef %22) #6
  %24 = fptrunc double %23 to float
  %25 = getelementptr inbounds %struct.TCOD_dice_t, ptr %1, i32 0, i32 2
  store float %24, ptr %25, align 8, !tbaa !14
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %26, i64 1
  store ptr %27, ptr %2, align 8, !tbaa !5
  br label %28

28:                                               ; preds = %18, %15
  %29 = load ptr, ptr %2, align 8, !tbaa !5
  %30 = call ptr @strchr(ptr noundef %29, i32 noundef 68) #6
  store ptr %30, ptr %3, align 8, !tbaa !5
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = icmp ne ptr %31, null
  br i1 %32, label %36, label %33

33:                                               ; preds = %28
  %34 = load ptr, ptr %2, align 8, !tbaa !5
  %35 = call ptr @strchr(ptr noundef %34, i32 noundef 100) #6
  store ptr %35, ptr %3, align 8, !tbaa !5
  br label %36

36:                                               ; preds = %33, %28
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = icmp ne ptr %37, null
  br i1 %38, label %43, label %39

39:                                               ; preds = %36
  %40 = load ptr, ptr @lex, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.TCOD_lex_t, ptr %40, i32 0, i32 5
  %42 = load ptr, ptr %41, align 8, !tbaa !9
  call void (ptr, ...) @TCOD_parser_error(ptr noundef @.str.13, ptr noundef %42)
  br label %43

43:                                               ; preds = %39, %36
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  store i8 0, ptr %44, align 1, !tbaa !14
  %45 = load ptr, ptr %2, align 8, !tbaa !5
  %46 = call i32 @atoi(ptr noundef %45) #6
  %47 = getelementptr inbounds %struct.TCOD_dice_t, ptr %1, i32 0, i32 0
  store i32 %46, ptr %47, align 8, !tbaa !14
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds i8, ptr %48, i64 1
  store ptr %49, ptr %2, align 8, !tbaa !5
  %50 = load ptr, ptr %2, align 8, !tbaa !5
  %51 = call ptr @strchr(ptr noundef %50, i32 noundef 43) #6
  store ptr %51, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %4) #5
  store i8 0, ptr %4, align 1, !tbaa !15
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = icmp ne ptr %52, null
  br i1 %53, label %61, label %54

54:                                               ; preds = %43
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  %56 = call ptr @strchr(ptr noundef %55, i32 noundef 45) #6
  store ptr %56, ptr %3, align 8, !tbaa !5
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = icmp ne ptr %57, null
  br i1 %58, label %59, label %60

59:                                               ; preds = %54
  store i8 1, ptr %4, align 1, !tbaa !15
  br label %60

60:                                               ; preds = %59, %54
  br label %61

61:                                               ; preds = %60, %43
  %62 = load ptr, ptr %3, align 8, !tbaa !5
  %63 = icmp ne ptr %62, null
  br i1 %63, label %64, label %66

64:                                               ; preds = %61
  %65 = load ptr, ptr %3, align 8, !tbaa !5
  store i8 0, ptr %65, align 1, !tbaa !14
  br label %66

66:                                               ; preds = %64, %61
  %67 = load ptr, ptr %2, align 8, !tbaa !5
  %68 = call i32 @atoi(ptr noundef %67) #6
  %69 = getelementptr inbounds %struct.TCOD_dice_t, ptr %1, i32 0, i32 1
  store i32 %68, ptr %69, align 4, !tbaa !14
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = icmp ne ptr %70, null
  br i1 %71, label %72, label %87

72:                                               ; preds = %66
  %73 = load ptr, ptr %3, align 8, !tbaa !5
  %74 = getelementptr inbounds i8, ptr %73, i64 1
  store ptr %74, ptr %2, align 8, !tbaa !5
  %75 = load ptr, ptr %2, align 8, !tbaa !5
  %76 = call double @atof(ptr noundef %75) #6
  %77 = fptrunc double %76 to float
  %78 = getelementptr inbounds %struct.TCOD_dice_t, ptr %1, i32 0, i32 3
  store float %77, ptr %78, align 4, !tbaa !14
  %79 = load i8, ptr %4, align 1, !tbaa !15, !range !16, !noundef !17
  %80 = trunc i8 %79 to i1
  br i1 %80, label %81, label %86

81:                                               ; preds = %72
  %82 = getelementptr inbounds %struct.TCOD_dice_t, ptr %1, i32 0, i32 3
  %83 = load float, ptr %82, align 4, !tbaa !14
  %84 = fneg float %83
  %85 = getelementptr inbounds %struct.TCOD_dice_t, ptr %1, i32 0, i32 3
  store float %84, ptr %85, align 4, !tbaa !14
  br label %86

86:                                               ; preds = %81, %72
  br label %87

87:                                               ; preds = %86, %66
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #5
  %88 = load { ptr, double }, ptr %1, align 8
  ret { ptr, double } %88
}

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare double @atof(ptr noundef nonnull) #4

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { inlinehint nounwind willreturn memory(read) 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 #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, !6, i64 24}
!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 = !{!13, !13, i64 0}
!16 = !{i8 0, i8 2}
!17 = !{}


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

%struct.TCOD_dice_t = type { i32, i32, float, float }

@lex = external hidden local_unnamed_addr global ptr, align 8
@__const.TCOD_parse_dice_value.ret = external hidden unnamed_addr constant { %struct.TCOD_dice_t }, align 8
@.str.13 = external hidden unnamed_addr constant [91 x i8], align 1

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare ptr @strchr(ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare i32 @atoi(ptr nocapture noundef nonnull) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local { ptr, double } @TCOD_parse_dice_value() local_unnamed_addr #0 {
  %.sroa.4 = alloca double, align 8
  %.sroa.4.0.copyload = load double, ptr getelementptr inbounds (i8, ptr @__const.TCOD_parse_dice_value.ret, i64 8), align 8
  store double %.sroa.4.0.copyload, ptr %.sroa.4, align 8
  %1 = load ptr, ptr @lex, align 8, !tbaa !5
  %2 = getelementptr inbounds i8, ptr %1, i64 24
  %3 = load ptr, ptr %2, align 8, !tbaa !9
  %4 = tail call ptr @strchr(ptr noundef nonnull dereferenceable(1) %3, i32 noundef 120) #3
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %5, label %.thread

5:                                                ; preds = %0
  %6 = tail call ptr @strchr(ptr noundef nonnull dereferenceable(1) %3, i32 noundef 42) #3
  %.not34 = icmp eq ptr %6, null
  br i1 %.not34, label %13, label %.thread

.thread:                                          ; preds = %0, %5
  %.02745 = phi ptr [ %6, %5 ], [ %4, %0 ]
  store i8 0, ptr %.02745, align 1, !tbaa !14
  %7 = load ptr, ptr @lex, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %7, i64 24
  %9 = load ptr, ptr %8, align 8, !tbaa !9
  %10 = tail call double @atof(ptr noundef %9) #3
  %11 = fptrunc double %10 to float
  store float %11, ptr %.sroa.4, align 8, !tbaa !14
  %12 = getelementptr inbounds i8, ptr %.02745, i64 1
  br label %13

13:                                               ; preds = %.thread, %5
  %14 = phi ptr [ %9, %.thread ], [ %3, %5 ]
  %.028 = phi ptr [ %12, %.thread ], [ %3, %5 ]
  %15 = tail call ptr @strchr(ptr noundef nonnull dereferenceable(1) %.028, i32 noundef 68) #3
  %.not35 = icmp eq ptr %15, null
  br i1 %.not35, label %16, label %.thread46

16:                                               ; preds = %13
  %17 = tail call ptr @strchr(ptr noundef nonnull dereferenceable(1) %.028, i32 noundef 100) #3
  %.not36 = icmp eq ptr %17, null
  br i1 %.not36, label %18, label %.thread46

18:                                               ; preds = %16
  tail call void (ptr, ...) @TCOD_parser_error(ptr noundef nonnull @.str.13, ptr noundef %14)
  br label %.thread46

.thread46:                                        ; preds = %13, %18, %16
  %.149 = phi ptr [ null, %18 ], [ %17, %16 ], [ %15, %13 ]
  store i8 0, ptr %.149, align 1, !tbaa !14
  %19 = tail call i32 @atoi(ptr nocapture noundef %.028) #3
  %20 = getelementptr inbounds i8, ptr %.149, i64 1
  %21 = tail call ptr @strchr(ptr noundef nonnull dereferenceable(1) %20, i32 noundef 43) #3
  %.not37 = icmp eq ptr %21, null
  br i1 %.not37, label %22, label %.thread50

22:                                               ; preds = %.thread46
  %23 = tail call ptr @strchr(ptr noundef nonnull dereferenceable(1) %20, i32 noundef 45) #3
  %.not38 = icmp ne ptr %23, null
  %.not39 = icmp eq ptr %23, null
  br i1 %.not39, label %.thread60, label %.thread50

.thread60:                                        ; preds = %22
  %24 = tail call i32 @atoi(ptr nocapture noundef %20) #3
  br label %31

.thread50:                                        ; preds = %.thread46, %22
  %.056 = phi i1 [ %.not38, %22 ], [ false, %.thread46 ]
  %.254 = phi ptr [ %23, %22 ], [ %21, %.thread46 ]
  store i8 0, ptr %.254, align 1, !tbaa !14
  %25 = tail call i32 @atoi(ptr nocapture noundef %20) #3
  %26 = getelementptr inbounds i8, ptr %.254, i64 1
  %27 = tail call double @atof(ptr noundef %26) #3
  %28 = fptrunc double %27 to float
  %.sroa.4.4.sroa_idx65 = getelementptr inbounds i8, ptr %.sroa.4, i64 4
  store float %28, ptr %.sroa.4.4.sroa_idx65, align 4, !tbaa !14
  br i1 %.056, label %29, label %31

29:                                               ; preds = %.thread50
  %30 = fneg float %28
  %.sroa.4.4.sroa_idx66 = getelementptr inbounds i8, ptr %.sroa.4, i64 4
  store float %30, ptr %.sroa.4.4.sroa_idx66, align 4, !tbaa !14
  br label %31

31:                                               ; preds = %.thread60, %.thread50, %29
  %32 = phi i32 [ %24, %.thread60 ], [ %25, %.thread50 ], [ %25, %29 ]
  %.sroa.0.4.insert.ext = zext i32 %32 to i64
  %.sroa.0.4.insert.shift = shl nuw i64 %.sroa.0.4.insert.ext, 32
  %.sroa.0.0.insert.ext = zext i32 %19 to i64
  %.sroa.0.4.insert.insert = or disjoint i64 %.sroa.0.4.insert.shift, %.sroa.0.0.insert.ext
  %33 = inttoptr i64 %.sroa.0.4.insert.insert to ptr
  %.fca.0.insert = insertvalue { ptr, double } poison, ptr %33, 0
  %.sroa.4.0..sroa.4.0..sroa.4.0..sroa.4.0..sroa.4.8..fca.1.load = load double, ptr %.sroa.4, align 8
  %.fca.1.insert = insertvalue { ptr, double } %.fca.0.insert, double %.sroa.4.0..sroa.4.0..sroa.4.0..sroa.4.0..sroa.4.8..fca.1.load, 1
  ret { ptr, double } %.fca.1.insert
}

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare double @atof(ptr nocapture noundef nonnull) 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 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 = { inlinehint mustprogress nofree nounwind willreturn memory(read) 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 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 24}
!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}


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