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

%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
@.str.6 = external hidden unnamed_addr constant [58 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local { ptr, double } @TCOD_parse_float_value() #0 {
  %1 = alloca %union.TCOD_value_t, align 8
  %2 = load ptr, ptr @lex, align 8, !tbaa !5
  %3 = getelementptr inbounds %struct.TCOD_lex_t, ptr %2, i32 0, i32 1
  %4 = load i32, ptr %3, align 4, !tbaa !9
  %5 = icmp ne i32 %4, 6
  br i1 %5, label %6, label %15

6:                                                ; preds = %0
  %7 = load ptr, ptr @lex, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.TCOD_lex_t, ptr %7, i32 0, i32 1
  %9 = load i32, ptr %8, align 4, !tbaa !9
  %10 = icmp ne i32 %9, 5
  br i1 %10, label %11, label %15

11:                                               ; preds = %6
  %12 = load ptr, ptr @lex, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.TCOD_lex_t, ptr %12, i32 0, i32 5
  %14 = load ptr, ptr %13, align 8, !tbaa !14
  call void (ptr, ...) @TCOD_parser_error(ptr noundef @.str.6, ptr noundef %14)
  br label %15

15:                                               ; preds = %11, %6, %0
  %16 = load ptr, ptr @lex, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.TCOD_lex_t, ptr %16, i32 0, i32 1
  %18 = load i32, ptr %17, align 4, !tbaa !9
  %19 = icmp eq i32 %18, 6
  br i1 %19, label %20, label %24

20:                                               ; preds = %15
  %21 = load ptr, ptr @lex, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.TCOD_lex_t, ptr %21, i32 0, i32 4
  %23 = load float, ptr %22, align 8, !tbaa !15
  br label %29

24:                                               ; preds = %15
  %25 = load ptr, ptr @lex, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.TCOD_lex_t, ptr %25, i32 0, i32 2
  %27 = load i32, ptr %26, align 8, !tbaa !16
  %28 = sitofp i32 %27 to float
  br label %29

29:                                               ; preds = %24, %20
  %30 = phi float [ %23, %20 ], [ %28, %24 ]
  store float %30, ptr %1, align 8, !tbaa !17
  %31 = load { ptr, double }, ptr %1, align 8
  ret { ptr, double } %31
}

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

!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, !11, i64 4}
!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 = !{!10, !6, i64 24}
!15 = !{!10, !12, i64 16}
!16 = !{!10, !11, i64 8}
!17 = !{!7, !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"

@lex = external hidden local_unnamed_addr global ptr, align 8
@.str.6 = external hidden unnamed_addr constant [58 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local { ptr, double } @TCOD_parse_float_value() local_unnamed_addr #0 {
  %.sroa.0 = alloca ptr, align 8
  %1 = load ptr, ptr @lex, align 8, !tbaa !5
  %2 = getelementptr inbounds i8, ptr %1, i64 4
  %3 = load i32, ptr %2, align 4, !tbaa !9
  %.off = add i32 %3, -5
  %switch = icmp ult i32 %.off, 2
  br i1 %switch, label %7, label %4

4:                                                ; preds = %0
  %5 = getelementptr inbounds i8, ptr %1, i64 24
  %6 = load ptr, ptr %5, align 8, !tbaa !14
  tail call void (ptr, ...) @TCOD_parser_error(ptr noundef nonnull @.str.6, ptr noundef %6)
  %.pre = load ptr, ptr @lex, align 8, !tbaa !5
  %.phi.trans.insert = getelementptr inbounds i8, ptr %.pre, i64 4
  %.pre2 = load i32, ptr %.phi.trans.insert, align 4, !tbaa !9
  br label %7

7:                                                ; preds = %0, %4
  %8 = phi i32 [ %3, %0 ], [ %.pre2, %4 ]
  %9 = phi ptr [ %1, %0 ], [ %.pre, %4 ]
  %10 = icmp eq i32 %8, 6
  br i1 %10, label %11, label %14

11:                                               ; preds = %7
  %12 = getelementptr inbounds i8, ptr %9, i64 16
  %13 = load float, ptr %12, align 8, !tbaa !15
  br label %18

14:                                               ; preds = %7
  %15 = getelementptr inbounds i8, ptr %9, i64 8
  %16 = load i32, ptr %15, align 8, !tbaa !16
  %17 = sitofp i32 %16 to float
  br label %18

18:                                               ; preds = %14, %11
  %19 = phi float [ %13, %11 ], [ %17, %14 ]
  store float %19, ptr %.sroa.0, align 8, !tbaa !17
  %.sroa.0.0..sroa.0.0..sroa.0.0..sroa.0.0..sroa.0.0..fca.0.load = load ptr, ptr %.sroa.0, align 8
  %.fca.0.insert = insertvalue { ptr, double } poison, ptr %.sroa.0.0..sroa.0.0..sroa.0.0..sroa.0.0..sroa.0.0..fca.0.load, 0
  %.fca.1.insert = insertvalue { ptr, double } %.fca.0.insert, double undef, 1
  ret { ptr, double } %.fca.1.insert
}

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

!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, !11, i64 4}
!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 = !{!10, !6, i64 24}
!15 = !{!10, !12, i64 16}
!16 = !{!10, !11, i64 8}
!17 = !{!7, !7, i64 0}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass