; 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.5 = external hidden unnamed_addr constant [62 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_integer_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, 5
  br i1 %5, label %6, label %10

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

10:                                               ; preds = %6, %0
  %11 = load ptr, ptr @lex, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.TCOD_lex_t, ptr %11, i32 0, i32 2
  %13 = load i32, ptr %12, align 8, !tbaa !15
  store i32 %13, ptr %1, align 8, !tbaa !16
  %14 = load { ptr, double }, ptr %1, align 8
  ret { ptr, double } %14
}

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, !11, i64 8}
!16 = !{!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.5 = external hidden unnamed_addr constant [62 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_integer_value() local_unnamed_addr #0 {
  %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
  %.not = icmp eq i32 %3, 5
  br i1 %.not, 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.5, ptr noundef %6)
  %.pre = load ptr, ptr @lex, align 8, !tbaa !5
  br label %7

7:                                                ; preds = %4, %0
  %8 = phi ptr [ %.pre, %4 ], [ %1, %0 ]
  %9 = getelementptr inbounds i8, ptr %8, i64 8
  %10 = load i32, ptr %9, align 8, !tbaa !15
  %.sroa.0.0.insert.ext = zext i32 %10 to i64
  %11 = inttoptr i64 %.sroa.0.0.insert.ext to ptr
  %.fca.0.insert = insertvalue { ptr, double } poison, ptr %11, 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, !11, i64 8}


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