; LLVM IR from openappsec/openappsec :: external/yajl/src (yajl)

; 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.yajl_handle_t = type { ptr, ptr, ptr, ptr, i64, ptr, %struct.yajl_bytestack_t, %struct.yajl_alloc_funcs, i32 }
%struct.yajl_bytestack_t = type { ptr, i64, i64, ptr }
%struct.yajl_alloc_funcs = type { ptr, ptr, ptr, ptr }

; Function Attrs: nounwind uwtable
define dso_local void @yajl_free(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds %struct.yajl_handle_t, ptr %3, i32 0, i32 6
  %5 = getelementptr inbounds %struct.yajl_bytestack_t, ptr %4, i32 0, i32 0
  %6 = load ptr, ptr %5, align 8, !tbaa !9
  %7 = icmp ne ptr %6, null
  br i1 %7, label %8, label %25

8:                                                ; preds = %1
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.yajl_handle_t, ptr %9, i32 0, i32 6
  %11 = getelementptr inbounds %struct.yajl_bytestack_t, ptr %10, i32 0, i32 3
  %12 = load ptr, ptr %11, align 8, !tbaa !15
  %13 = getelementptr inbounds %struct.yajl_alloc_funcs, ptr %12, i32 0, i32 2
  %14 = load ptr, ptr %13, align 8, !tbaa !16
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.yajl_handle_t, ptr %15, i32 0, i32 6
  %17 = getelementptr inbounds %struct.yajl_bytestack_t, ptr %16, i32 0, i32 3
  %18 = load ptr, ptr %17, align 8, !tbaa !15
  %19 = getelementptr inbounds %struct.yajl_alloc_funcs, ptr %18, i32 0, i32 3
  %20 = load ptr, ptr %19, align 8, !tbaa !17
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.yajl_handle_t, ptr %21, i32 0, i32 6
  %23 = getelementptr inbounds %struct.yajl_bytestack_t, ptr %22, i32 0, i32 0
  %24 = load ptr, ptr %23, align 8, !tbaa !9
  call void %14(ptr noundef %20, ptr noundef %24)
  br label %25

25:                                               ; preds = %8, %1
  %26 = load ptr, ptr %2, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.yajl_handle_t, ptr %26, i32 0, i32 5
  %28 = load ptr, ptr %27, align 8, !tbaa !18
  call void @yajl_buf_free(ptr noundef %28)
  %29 = load ptr, ptr %2, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.yajl_handle_t, ptr %29, i32 0, i32 2
  %31 = load ptr, ptr %30, align 8, !tbaa !19
  %32 = icmp ne ptr %31, null
  br i1 %32, label %33, label %39

33:                                               ; preds = %25
  %34 = load ptr, ptr %2, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.yajl_handle_t, ptr %34, i32 0, i32 2
  %36 = load ptr, ptr %35, align 8, !tbaa !19
  call void @yajl_lex_free(ptr noundef %36)
  %37 = load ptr, ptr %2, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.yajl_handle_t, ptr %37, i32 0, i32 2
  store ptr null, ptr %38, align 8, !tbaa !19
  br label %39

39:                                               ; preds = %33, %25
  %40 = load ptr, ptr %2, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.yajl_handle_t, ptr %40, i32 0, i32 7
  %42 = getelementptr inbounds %struct.yajl_alloc_funcs, ptr %41, i32 0, i32 2
  %43 = load ptr, ptr %42, align 8, !tbaa !20
  %44 = load ptr, ptr %2, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.yajl_handle_t, ptr %44, i32 0, i32 7
  %46 = getelementptr inbounds %struct.yajl_alloc_funcs, ptr %45, i32 0, i32 3
  %47 = load ptr, ptr %46, align 8, !tbaa !21
  %48 = load ptr, ptr %2, align 8, !tbaa !5
  call void %43(ptr noundef %47, ptr noundef %48)
  ret void
}

declare void @yajl_buf_free(ptr noundef) #1

declare void @yajl_lex_free(ptr noundef) #1

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 = { "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, !6, i64 48}
!10 = !{!"yajl_handle_t", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !11, i64 32, !6, i64 40, !12, i64 48, !13, i64 80, !14, i64 112}
!11 = !{!"long", !7, i64 0}
!12 = !{!"yajl_bytestack_t", !6, i64 0, !11, i64 8, !11, i64 16, !6, i64 24}
!13 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!14 = !{!"int", !7, i64 0}
!15 = !{!10, !6, i64 72}
!16 = !{!13, !6, i64 16}
!17 = !{!13, !6, i64 24}
!18 = !{!10, !6, i64 40}
!19 = !{!10, !6, i64 16}
!20 = !{!10, !6, i64 96}
!21 = !{!10, !6, i64 104}


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

; Function Attrs: nounwind uwtable
define dso_local void @yajl_free(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 48
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %11, label %4

4:                                                ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 72
  %6 = load ptr, ptr %5, align 8, !tbaa !14
  %7 = getelementptr inbounds i8, ptr %6, i64 16
  %8 = load ptr, ptr %7, align 8, !tbaa !15
  %9 = getelementptr inbounds i8, ptr %6, i64 24
  %10 = load ptr, ptr %9, align 8, !tbaa !16
  tail call void %8(ptr noundef %10, ptr noundef nonnull %3) #2
  br label %11

11:                                               ; preds = %4, %1
  %12 = getelementptr inbounds i8, ptr %0, i64 40
  %13 = load ptr, ptr %12, align 8, !tbaa !17
  tail call void @yajl_buf_free(ptr noundef %13) #2
  %14 = getelementptr inbounds i8, ptr %0, i64 16
  %15 = load ptr, ptr %14, align 8, !tbaa !18
  %.not12 = icmp eq ptr %15, null
  br i1 %.not12, label %17, label %16

16:                                               ; preds = %11
  tail call void @yajl_lex_free(ptr noundef nonnull %15) #2
  store ptr null, ptr %14, align 8, !tbaa !18
  br label %17

17:                                               ; preds = %16, %11
  %18 = getelementptr inbounds i8, ptr %0, i64 96
  %19 = load ptr, ptr %18, align 8, !tbaa !19
  %20 = getelementptr inbounds i8, ptr %0, i64 104
  %21 = load ptr, ptr %20, align 8, !tbaa !20
  tail call void %19(ptr noundef %21, ptr noundef nonnull %0) #2
  ret void
}

declare void @yajl_buf_free(ptr noundef) local_unnamed_addr #1

declare void @yajl_lex_free(ptr noundef) local_unnamed_addr #1

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

!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 48}
!6 = !{!"yajl_handle_t", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !7, i64 40, !11, i64 48, !12, i64 80, !13, i64 112}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"yajl_bytestack_t", !7, i64 0, !10, i64 8, !10, i64 16, !7, i64 24}
!12 = !{!"", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!13 = !{!"int", !8, i64 0}
!14 = !{!6, !7, i64 72}
!15 = !{!12, !7, i64 16}
!16 = !{!12, !7, i64 24}
!17 = !{!6, !7, i64 40}
!18 = !{!6, !7, i64 16}
!19 = !{!6, !7, i64 96}
!20 = !{!6, !7, i64 104}


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