; LLVM IR from ohler55/agoo :: ext/agoo (graphql)

; 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._agooLogCat = type { ptr, [32 x i8], ptr, i32, i8 }
%struct._agooText = type { ptr, i64, i64, %struct._agooAtom, i8, [8 x i8] }
%struct._agooAtom = type { ptr, %union.pthread_mutex_t }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%struct._agooReq = type { i32, ptr, i32, ptr, %struct._agooStr, %struct._agooStr, %struct._agooStr, %struct._agooStr, %struct._agooStr, [46 x i8], ptr, ptr, i64, [8 x i8] }
%struct._agooStr = type { ptr, i32 }

@.str.40 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.41 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.42 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.43 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.44 = external hidden unnamed_addr constant [78 x i8], align 1
@agoo_error_cat = external global %struct._agooLogCat, align 8
@.str.45 = external hidden unnamed_addr constant [46 x i8], align 1

; 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

; Function Attrs: nounwind
declare i32 @snprintf(ptr noundef, i64 noundef, ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @gql_schema_sdl(ptr noundef, i1 noundef zeroext, i1 noundef zeroext) #2

; Function Attrs: nounwind uwtable
define dso_local void @gql_dump_hook(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca [256 x i8], align 16
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  %7 = alloca i8, align 1
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 256, ptr %3) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %10 = call ptr @agoo_text_allocate(i32 noundef 4094)
  store ptr %10, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #5
  store i8 0, ptr %6, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #5
  store i8 1, ptr %7, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = call ptr @agoo_req_query_value(ptr noundef %11, ptr noundef @.str.40, i32 noundef 3, ptr noundef %8)
  store ptr %12, ptr %9, align 8, !tbaa !5
  %13 = load ptr, ptr %9, align 8, !tbaa !5
  %14 = icmp ne ptr null, %13
  br i1 %14, label %15, label %23

15:                                               ; preds = %1
  %16 = load i32, ptr %8, align 4, !tbaa !11
  %17 = icmp eq i32 4, %16
  br i1 %17, label %18, label %23

18:                                               ; preds = %15
  %19 = load ptr, ptr %9, align 8, !tbaa !5
  %20 = call i32 @strncasecmp(ptr noundef @.str.41, ptr noundef %19, i64 noundef 4) #6
  %21 = icmp eq i32 0, %20
  br i1 %21, label %22, label %23

22:                                               ; preds = %18
  store i8 1, ptr %6, align 1, !tbaa !9
  br label %23

23:                                               ; preds = %22, %18, %15, %1
  %24 = load ptr, ptr %2, align 8, !tbaa !5
  %25 = call ptr @agoo_req_query_value(ptr noundef %24, ptr noundef @.str.42, i32 noundef 9, ptr noundef %8)
  store ptr %25, ptr %9, align 8, !tbaa !5
  %26 = load ptr, ptr %9, align 8, !tbaa !5
  %27 = icmp ne ptr null, %26
  br i1 %27, label %28, label %36

28:                                               ; preds = %23
  %29 = load i32, ptr %8, align 4, !tbaa !11
  %30 = icmp eq i32 5, %29
  br i1 %30, label %31, label %36

31:                                               ; preds = %28
  %32 = load ptr, ptr %9, align 8, !tbaa !5
  %33 = call i32 @strncasecmp(ptr noundef @.str.43, ptr noundef %32, i64 noundef 5) #6
  %34 = icmp eq i32 0, %33
  br i1 %34, label %35, label %36

35:                                               ; preds = %31
  store i8 0, ptr %7, align 1, !tbaa !9
  br label %36

36:                                               ; preds = %35, %31, %28, %23
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = load i8, ptr %7, align 1, !tbaa !9, !range !13, !noundef !14
  %39 = trunc i8 %38 to i1
  %40 = load i8, ptr %6, align 1, !tbaa !9, !range !13, !noundef !14
  %41 = trunc i8 %40 to i1
  %42 = call ptr @gql_schema_sdl(ptr noundef %37, i1 noundef zeroext %39, i1 noundef zeroext %41)
  store ptr %42, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds [256 x i8], ptr %3, i64 0, i64 0
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct._agooText, ptr %44, i32 0, i32 1
  %46 = load i64, ptr %45, align 8, !tbaa !15
  %47 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %43, i64 noundef 256, ptr noundef @.str.44, i64 noundef %46) #5
  store i32 %47, ptr %4, align 4, !tbaa !11
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds [256 x i8], ptr %3, i64 0, i64 0
  %50 = load i32, ptr %4, align 4, !tbaa !11
  %51 = call ptr @agoo_text_prepend(ptr noundef %48, ptr noundef %49, i32 noundef %50)
  store ptr %51, ptr %5, align 8, !tbaa !5
  %52 = icmp eq ptr null, %51
  br i1 %52, label %53, label %54

53:                                               ; preds = %36
  call void (ptr, ptr, ...) @agoo_log_cat(ptr noundef @agoo_error_cat, ptr noundef @.str.45)
  br label %54

54:                                               ; preds = %53, %36
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct._agooReq, ptr %55, i32 0, i32 1
  %57 = load ptr, ptr %56, align 8, !tbaa !19
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  call void @agoo_res_message_push(ptr noundef %57, ptr noundef %58)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 256, ptr %3) #5
  ret void
}

declare ptr @agoo_text_allocate(i32 noundef) #3

declare ptr @agoo_req_query_value(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #3

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strncasecmp(ptr noundef, ptr noundef, i64 noundef) #4

declare ptr @agoo_text_prepend(ptr noundef, ptr noundef, i32 noundef) #3

declare void @agoo_log_cat(ptr noundef, ptr noundef, ...) #3

declare void @agoo_res_message_push(ptr noundef, ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { "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 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 #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, !10, i64 0}
!10 = !{!"_Bool", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!16, !17, i64 8}
!16 = !{!"_agooText", !6, i64 0, !17, i64 8, !17, i64 16, !18, i64 24, !10, i64 72, !7, i64 73}
!17 = !{!"long", !7, i64 0}
!18 = !{!"_agooAtom", !6, i64 0, !7, i64 8}
!19 = !{!20, !6, i64 8}
!20 = !{!"_agooReq", !12, i64 0, !6, i64 8, !12, i64 16, !6, i64 24, !21, i64 32, !21, i64 48, !21, i64 64, !21, i64 80, !21, i64 96, !7, i64 112, !6, i64 160, !6, i64 168, !17, i64 176, !7, i64 184}
!21 = !{!"_agooStr", !6, i64 0, !12, i64 8}


; 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._agooLogCat = type { ptr, [32 x i8], ptr, i32, i8 }

@.str.40 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.41 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.42 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.43 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.44 = external hidden unnamed_addr constant [78 x i8], align 1
@agoo_error_cat = external global %struct._agooLogCat, align 8
@.str.45 = external hidden unnamed_addr constant [46 x i8], align 1

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @snprintf(ptr noalias nocapture noundef writeonly, i64 noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @gql_schema_sdl(ptr noundef, i1 noundef zeroext, i1 noundef zeroext) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @gql_dump_hook(ptr noundef %0) local_unnamed_addr #2 {
  %2 = alloca [256 x i8], align 16
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %2) #5
  %4 = tail call ptr @agoo_text_allocate(i32 noundef 4094) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #5
  %5 = call ptr @agoo_req_query_value(ptr noundef %0, ptr noundef nonnull @.str.40, i32 noundef 3, ptr noundef nonnull %3) #5
  %6 = icmp ne ptr %5, null
  %7 = load i32, ptr %3, align 4
  %8 = icmp eq i32 %7, 4
  %or.cond = select i1 %6, i1 %8, i1 false
  br i1 %or.cond, label %9, label %12

9:                                                ; preds = %1
  %10 = call i32 @strncasecmp(ptr noundef nonnull @.str.41, ptr noundef nonnull %5, i64 noundef 4) #6
  %11 = icmp eq i32 %10, 0
  br label %12

12:                                               ; preds = %9, %1
  %.016 = phi i1 [ false, %1 ], [ %11, %9 ]
  %13 = call ptr @agoo_req_query_value(ptr noundef %0, ptr noundef nonnull @.str.42, i32 noundef 9, ptr noundef nonnull %3) #5
  %14 = icmp ne ptr %13, null
  %15 = load i32, ptr %3, align 4
  %16 = icmp eq i32 %15, 5
  %or.cond3 = select i1 %14, i1 %16, i1 false
  br i1 %or.cond3, label %17, label %20

17:                                               ; preds = %12
  %18 = call i32 @strncasecmp(ptr noundef nonnull @.str.43, ptr noundef nonnull %13, i64 noundef 5) #6
  %19 = icmp ne i32 %18, 0
  br label %20

20:                                               ; preds = %17, %12
  %.0 = phi i1 [ true, %12 ], [ %19, %17 ]
  %21 = call ptr @gql_schema_sdl(ptr noundef %4, i1 noundef zeroext %.0, i1 noundef zeroext %.016)
  %22 = getelementptr inbounds i8, ptr %21, i64 8
  %23 = load i64, ptr %22, align 8, !tbaa !5
  %24 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %2, i64 noundef 256, ptr noundef nonnull @.str.44, i64 noundef %23) #5
  %25 = call ptr @agoo_text_prepend(ptr noundef %21, ptr noundef nonnull %2, i32 noundef %24) #5
  %26 = icmp eq ptr %25, null
  br i1 %26, label %27, label %28

27:                                               ; preds = %20
  call void (ptr, ptr, ...) @agoo_log_cat(ptr noundef nonnull @agoo_error_cat, ptr noundef nonnull @.str.45) #5
  br label %28

28:                                               ; preds = %27, %20
  %29 = getelementptr inbounds i8, ptr %0, i64 8
  %30 = load ptr, ptr %29, align 8, !tbaa !13
  call void @agoo_res_message_push(ptr noundef %30, ptr noundef %25) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %2) #5
  ret void
}

declare ptr @agoo_text_allocate(i32 noundef) local_unnamed_addr #3

declare ptr @agoo_req_query_value(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn memory(read)
declare i32 @strncasecmp(ptr nocapture noundef, ptr nocapture noundef, i64 noundef) local_unnamed_addr #4

declare ptr @agoo_text_prepend(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

declare void @agoo_log_cat(ptr noundef, ptr noundef, ...) local_unnamed_addr #3

declare void @agoo_res_message_push(ptr noundef, ptr noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nofree 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 #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 = { "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 = { mustprogress nofree 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 #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, !10, i64 8}
!6 = !{!"_agooText", !7, i64 0, !10, i64 8, !10, i64 16, !11, i64 24, !12, i64 72, !8, i64 73}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"_agooAtom", !7, i64 0, !8, i64 8}
!12 = !{!"_Bool", !8, i64 0}
!13 = !{!14, !7, i64 8}
!14 = !{!"_agooReq", !15, i64 0, !7, i64 8, !15, i64 16, !7, i64 24, !16, i64 32, !16, i64 48, !16, i64 64, !16, i64 80, !16, i64 96, !8, i64 112, !7, i64 160, !7, i64 168, !10, i64 176, !8, i64 184}
!15 = !{!"int", !8, i64 0}
!16 = !{!"_agooStr", !7, i64 0, !15, i64 8}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass