; 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_Parser = type { ptr, [16 x ptr], i8, ptr }
%struct.TCOD_ParserStruct = type { ptr, ptr, ptr, ptr, ptr }
%struct.TCOD_struct_prop_t = type { ptr, i32, 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

declare ptr @TCOD_list_begin(ptr noundef) #1

declare ptr @TCOD_list_end(ptr noundef) #1

; Function Attrs: nounwind
declare void @free(ptr noundef) #2

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

12:                                               ; preds = %93, %1
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.TCOD_Parser, ptr %14, i32 0, i32 0
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  %17 = call ptr @TCOD_list_end(ptr noundef %16)
  %18 = icmp ne ptr %13, %17
  br i1 %18, label %20, label %19

19:                                               ; preds = %12
  store i32 2, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  br label %96

20:                                               ; preds = %12
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = load ptr, ptr %21, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.TCOD_ParserStruct, ptr %22, i32 0, i32 0
  %24 = load ptr, ptr %23, align 8, !tbaa !12
  call void @free(ptr noundef %24) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = load ptr, ptr %25, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.TCOD_ParserStruct, ptr %26, i32 0, i32 2
  %28 = load ptr, ptr %27, align 8, !tbaa !14
  %29 = call ptr @TCOD_list_begin(ptr noundef %28)
  store ptr %29, ptr %5, align 8, !tbaa !5
  br label %30

30:                                               ; preds = %44, %20
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = load ptr, ptr %32, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.TCOD_ParserStruct, ptr %33, i32 0, i32 2
  %35 = load ptr, ptr %34, align 8, !tbaa !14
  %36 = call ptr @TCOD_list_end(ptr noundef %35)
  %37 = icmp ne ptr %31, %36
  br i1 %37, label %39, label %38

38:                                               ; preds = %30
  store i32 5, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  br label %47

39:                                               ; preds = %30
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = load ptr, ptr %40, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.TCOD_struct_prop_t, ptr %41, i32 0, i32 0
  %43 = load ptr, ptr %42, align 8, !tbaa !15
  call void @free(ptr noundef %43) #4
  br label %44

44:                                               ; preds = %39
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = getelementptr inbounds ptr, ptr %45, i32 1
  store ptr %46, ptr %5, align 8, !tbaa !5
  br label %30, !llvm.loop !18

47:                                               ; preds = %38
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = load ptr, ptr %48, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.TCOD_ParserStruct, ptr %49, i32 0, i32 2
  %51 = load ptr, ptr %50, align 8, !tbaa !14
  call void @TCOD_list_clear_and_delete(ptr noundef %51)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = load ptr, ptr %52, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.TCOD_ParserStruct, ptr %53, i32 0, i32 3
  %55 = load ptr, ptr %54, align 8, !tbaa !21
  %56 = call ptr @TCOD_list_begin(ptr noundef %55)
  store ptr %56, ptr %7, align 8, !tbaa !5
  br label %57

57:                                               ; preds = %85, %47
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = load ptr, ptr %59, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.TCOD_ParserStruct, ptr %60, i32 0, i32 3
  %62 = load ptr, ptr %61, align 8, !tbaa !21
  %63 = call ptr @TCOD_list_end(ptr noundef %62)
  %64 = icmp ne ptr %58, %63
  br i1 %64, label %66, label %65

65:                                               ; preds = %57
  store i32 8, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  br label %88

66:                                               ; preds = %57
  br label %67

67:                                               ; preds = %75, %66
  %68 = load ptr, ptr %7, align 8, !tbaa !5
  %69 = load ptr, ptr %68, align 8, !tbaa !5
  %70 = load i32, ptr %6, align 4, !tbaa !20
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds ptr, ptr %69, i64 %71
  %73 = load ptr, ptr %72, align 8, !tbaa !5
  %74 = icmp ne ptr %73, null
  br i1 %74, label %75, label %84

75:                                               ; preds = %67
  %76 = load ptr, ptr %7, align 8, !tbaa !5
  %77 = load ptr, ptr %76, align 8, !tbaa !5
  %78 = load i32, ptr %6, align 4, !tbaa !20
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds ptr, ptr %77, i64 %79
  %81 = load ptr, ptr %80, align 8, !tbaa !5
  call void @free(ptr noundef %81) #4
  %82 = load i32, ptr %6, align 4, !tbaa !20
  %83 = add nsw i32 %82, 1
  store i32 %83, ptr %6, align 4, !tbaa !20
  br label %67, !llvm.loop !22

84:                                               ; preds = %67
  br label %85

85:                                               ; preds = %84
  %86 = load ptr, ptr %7, align 8, !tbaa !5
  %87 = getelementptr inbounds ptr, ptr %86, i32 1
  store ptr %87, ptr %7, align 8, !tbaa !5
  br label %57, !llvm.loop !23

88:                                               ; preds = %65
  %89 = load ptr, ptr %3, align 8, !tbaa !5
  %90 = load ptr, ptr %89, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.TCOD_ParserStruct, ptr %90, i32 0, i32 3
  %92 = load ptr, ptr %91, align 8, !tbaa !21
  call void @TCOD_list_clear_and_delete(ptr noundef %92)
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %93

93:                                               ; preds = %88
  %94 = load ptr, ptr %3, align 8, !tbaa !5
  %95 = getelementptr inbounds ptr, ptr %94, i32 1
  store ptr %95, ptr %3, align 8, !tbaa !5
  br label %12, !llvm.loop !24

96:                                               ; preds = %19
  %97 = load ptr, ptr %2, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.TCOD_Parser, ptr %97, i32 0, i32 0
  %99 = load ptr, ptr %98, align 8, !tbaa !9
  call void @TCOD_list_clear_and_delete(ptr noundef %99)
  ret void
}

declare void @TCOD_list_clear_and_delete(ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { 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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"TCOD_Parser", !6, i64 0, !7, i64 8, !11, i64 136, !6, i64 144}
!11 = !{!"_Bool", !7, i64 0}
!12 = !{!13, !6, i64 0}
!13 = !{!"TCOD_ParserStruct", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!14 = !{!13, !6, i64 16}
!15 = !{!16, !6, i64 0}
!16 = !{!"TCOD_struct_prop_t", !6, i64 0, !17, i64 8, !11, i64 12}
!17 = !{!"int", !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!17, !17, i64 0}
!21 = !{!13, !6, i64 24}
!22 = distinct !{!22, !19}
!23 = distinct !{!23, !19}
!24 = distinct !{!24, !19}


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

declare ptr @TCOD_list_begin(ptr noundef) local_unnamed_addr #0

declare ptr @TCOD_list_end(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @TCOD_parser_delete(ptr nocapture noundef readonly %0) local_unnamed_addr #2 {
  %2 = load ptr, ptr %0, align 8, !tbaa !5
  %3 = tail call ptr @TCOD_list_begin(ptr noundef %2) #3
  %4 = load ptr, ptr %0, align 8, !tbaa !5
  %5 = tail call ptr @TCOD_list_end(ptr noundef %4) #3
  %.not38 = icmp eq ptr %3, %5
  br i1 %.not38, label %._crit_edge42, label %.lr.ph41

._crit_edge42:                                    ; preds = %._crit_edge37, %1
  %6 = load ptr, ptr %0, align 8, !tbaa !5
  tail call void @TCOD_list_clear_and_delete(ptr noundef %6) #3
  ret void

.lr.ph41:                                         ; preds = %1, %._crit_edge37
  %.02339 = phi ptr [ %42, %._crit_edge37 ], [ %3, %1 ]
  %7 = load ptr, ptr %.02339, align 8, !tbaa !11
  %8 = load ptr, ptr %7, align 8, !tbaa !12
  tail call void @free(ptr noundef %8) #3
  %9 = load ptr, ptr %.02339, align 8, !tbaa !11
  %10 = getelementptr inbounds i8, ptr %9, i64 16
  %11 = load ptr, ptr %10, align 8, !tbaa !14
  %12 = tail call ptr @TCOD_list_begin(ptr noundef %11) #3
  %13 = load ptr, ptr %.02339, align 8, !tbaa !11
  %14 = getelementptr inbounds i8, ptr %13, i64 16
  %15 = load ptr, ptr %14, align 8, !tbaa !14
  %16 = tail call ptr @TCOD_list_end(ptr noundef %15) #3
  %.not2528 = icmp eq ptr %12, %16
  br i1 %.not2528, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph41
  %17 = load ptr, ptr %.02339, align 8, !tbaa !11
  %18 = getelementptr inbounds i8, ptr %17, i64 16
  %19 = load ptr, ptr %18, align 8, !tbaa !14
  tail call void @TCOD_list_clear_and_delete(ptr noundef %19) #3
  %20 = load ptr, ptr %.02339, align 8, !tbaa !11
  %21 = getelementptr inbounds i8, ptr %20, i64 24
  %22 = load ptr, ptr %21, align 8, !tbaa !15
  %23 = tail call ptr @TCOD_list_begin(ptr noundef %22) #3
  %24 = load ptr, ptr %.02339, align 8, !tbaa !11
  %25 = getelementptr inbounds i8, ptr %24, i64 24
  %26 = load ptr, ptr %25, align 8, !tbaa !15
  %27 = tail call ptr @TCOD_list_end(ptr noundef %26) #3
  %.not2634 = icmp eq ptr %23, %27
  br i1 %.not2634, label %._crit_edge37, label %.preheader

.lr.ph:                                           ; preds = %.lr.ph41, %.lr.ph
  %.02229 = phi ptr [ %30, %.lr.ph ], [ %12, %.lr.ph41 ]
  %28 = load ptr, ptr %.02229, align 8, !tbaa !11
  %29 = load ptr, ptr %28, align 8, !tbaa !16
  tail call void @free(ptr noundef %29) #3
  %30 = getelementptr inbounds i8, ptr %.02229, i64 8
  %31 = load ptr, ptr %.02339, align 8, !tbaa !11
  %32 = getelementptr inbounds i8, ptr %31, i64 16
  %33 = load ptr, ptr %32, align 8, !tbaa !14
  %34 = tail call ptr @TCOD_list_end(ptr noundef %33) #3
  %.not25 = icmp eq ptr %30, %34
  br i1 %.not25, label %._crit_edge, label %.lr.ph, !llvm.loop !19

.preheader:                                       ; preds = %._crit_edge, %._crit_edge33
  %.036 = phi ptr [ %50, %._crit_edge33 ], [ %23, %._crit_edge ]
  %.02135 = phi i32 [ %.1.lcssa, %._crit_edge33 ], [ 0, %._crit_edge ]
  %35 = load ptr, ptr %.036, align 8, !tbaa !11
  %36 = sext i32 %.02135 to i64
  %37 = getelementptr inbounds ptr, ptr %35, i64 %36
  %38 = load ptr, ptr %37, align 8, !tbaa !11
  %.not2730 = icmp eq ptr %38, null
  br i1 %.not2730, label %._crit_edge33, label %.lr.ph32

._crit_edge37:                                    ; preds = %._crit_edge33, %._crit_edge
  %39 = load ptr, ptr %.02339, align 8, !tbaa !11
  %40 = getelementptr inbounds i8, ptr %39, i64 24
  %41 = load ptr, ptr %40, align 8, !tbaa !15
  tail call void @TCOD_list_clear_and_delete(ptr noundef %41) #3
  %42 = getelementptr inbounds i8, ptr %.02339, i64 8
  %43 = load ptr, ptr %0, align 8, !tbaa !5
  %44 = tail call ptr @TCOD_list_end(ptr noundef %43) #3
  %.not = icmp eq ptr %42, %44
  br i1 %.not, label %._crit_edge42, label %.lr.ph41, !llvm.loop !21

.lr.ph32:                                         ; preds = %.preheader, %.lr.ph32
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph32 ], [ %36, %.preheader ]
  %45 = phi ptr [ %48, %.lr.ph32 ], [ %38, %.preheader ]
  tail call void @free(ptr noundef nonnull %45) #3
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %46 = load ptr, ptr %.036, align 8, !tbaa !11
  %47 = getelementptr inbounds ptr, ptr %46, i64 %indvars.iv.next
  %48 = load ptr, ptr %47, align 8, !tbaa !11
  %.not27 = icmp eq ptr %48, null
  br i1 %.not27, label %._crit_edge33.loopexit, label %.lr.ph32, !llvm.loop !22

._crit_edge33.loopexit:                           ; preds = %.lr.ph32
  %49 = trunc nsw i64 %indvars.iv.next to i32
  br label %._crit_edge33

._crit_edge33:                                    ; preds = %._crit_edge33.loopexit, %.preheader
  %.1.lcssa = phi i32 [ %.02135, %.preheader ], [ %49, %._crit_edge33.loopexit ]
  %50 = getelementptr inbounds i8, ptr %.036, i64 8
  %51 = load ptr, ptr %.02339, align 8, !tbaa !11
  %52 = getelementptr inbounds i8, ptr %51, i64 24
  %53 = load ptr, ptr %52, align 8, !tbaa !15
  %54 = tail call ptr @TCOD_list_end(ptr noundef %53) #3
  %.not26 = icmp eq ptr %50, %54
  br i1 %.not26, label %._crit_edge37, label %.preheader, !llvm.loop !23
}

declare void @TCOD_list_clear_and_delete(ptr noundef) local_unnamed_addr #0

attributes #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 nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { 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 0}
!6 = !{!"TCOD_Parser", !7, i64 0, !8, i64 8, !10, i64 136, !7, i64 144}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"_Bool", !8, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !7, i64 0}
!13 = !{!"TCOD_ParserStruct", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32}
!14 = !{!13, !7, i64 16}
!15 = !{!13, !7, i64 24}
!16 = !{!17, !7, i64 0}
!17 = !{!"TCOD_struct_prop_t", !7, i64 0, !18, i64 8, !10, i64 12}
!18 = !{!"int", !8, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}
!22 = distinct !{!22, !20}
!23 = distinct !{!23, !20}


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