; 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._gqlDir = type { ptr, ptr, ptr, ptr, ptr, i8, i8 }
%struct._gqlArg = type { ptr, ptr, ptr, ptr, ptr, ptr }
%struct._gqlStrLink = type { ptr, ptr }

@.str.24 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [5 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 uwtable
declare hidden ptr @desc_sdl(ptr noundef, ptr noundef, i32 noundef) #1

declare ptr @agoo_text_append(ptr noundef, ptr noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
declare hidden ptr @arg_sdl(ptr noundef, ptr noundef, i1 noundef zeroext, i1 noundef zeroext, i1 noundef zeroext) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @gql_directive_sdl(ptr noundef %0, ptr noundef %1, i1 noundef zeroext %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %9 = zext i1 %2 to i8
  store i8 %9, ptr %6, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %10 = load i8, ptr %6, align 1, !tbaa !9, !range !11, !noundef !12
  %11 = trunc i8 %10 to i1
  br i1 %11, label %12, label %18

12:                                               ; preds = %3
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct._gqlDir, ptr %14, i32 0, i32 2
  %16 = load ptr, ptr %15, align 8, !tbaa !13
  %17 = call ptr @desc_sdl(ptr noundef %13, ptr noundef %16, i32 noundef 0)
  store ptr %17, ptr %4, align 8, !tbaa !5
  br label %18

18:                                               ; preds = %12, %3
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = call ptr @agoo_text_append(ptr noundef %19, ptr noundef @.str.31, i32 noundef 11)
  store ptr %20, ptr %4, align 8, !tbaa !5
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct._gqlDir, ptr %22, i32 0, i32 1
  %24 = load ptr, ptr %23, align 8, !tbaa !15
  %25 = call ptr @agoo_text_append(ptr noundef %21, ptr noundef %24, i32 noundef -1)
  store ptr %25, ptr %4, align 8, !tbaa !5
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct._gqlDir, ptr %26, i32 0, i32 3
  %28 = load ptr, ptr %27, align 8, !tbaa !16
  %29 = icmp ne ptr null, %28
  br i1 %29, label %30, label %56

30:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = call ptr @agoo_text_append(ptr noundef %31, ptr noundef @.str.32, i32 noundef 1)
  store ptr %32, ptr %4, align 8, !tbaa !5
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct._gqlDir, ptr %33, i32 0, i32 3
  %35 = load ptr, ptr %34, align 8, !tbaa !16
  store ptr %35, ptr %8, align 8, !tbaa !5
  br label %36

36:                                               ; preds = %49, %30
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = icmp ne ptr null, %37
  br i1 %38, label %39, label %53

39:                                               ; preds = %36
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = load i8, ptr %6, align 1, !tbaa !9, !range !11, !noundef !12
  %43 = trunc i8 %42 to i1
  %44 = load ptr, ptr %8, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct._gqlArg, ptr %44, i32 0, i32 0
  %46 = load ptr, ptr %45, align 8, !tbaa !17
  %47 = icmp eq ptr null, %46
  %48 = call ptr @arg_sdl(ptr noundef %40, ptr noundef %41, i1 noundef zeroext %43, i1 noundef zeroext true, i1 noundef zeroext %47)
  store ptr %48, ptr %4, align 8, !tbaa !5
  br label %49

49:                                               ; preds = %39
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct._gqlArg, ptr %50, i32 0, i32 0
  %52 = load ptr, ptr %51, align 8, !tbaa !17
  store ptr %52, ptr %8, align 8, !tbaa !5
  br label %36, !llvm.loop !19

53:                                               ; preds = %36
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = call ptr @agoo_text_append(ptr noundef %54, ptr noundef @.str.33, i32 noundef 1)
  store ptr %55, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %56

56:                                               ; preds = %53, %18
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = call ptr @agoo_text_append(ptr noundef %57, ptr noundef @.str.34, i32 noundef 4)
  store ptr %58, ptr %4, align 8, !tbaa !5
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct._gqlDir, ptr %59, i32 0, i32 4
  %61 = load ptr, ptr %60, align 8, !tbaa !21
  store ptr %61, ptr %7, align 8, !tbaa !5
  br label %62

62:                                               ; preds = %79, %56
  %63 = load ptr, ptr %7, align 8, !tbaa !5
  %64 = icmp ne ptr null, %63
  br i1 %64, label %65, label %83

65:                                               ; preds = %62
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = load ptr, ptr %7, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct._gqlStrLink, ptr %67, i32 0, i32 1
  %69 = load ptr, ptr %68, align 8, !tbaa !22
  %70 = call ptr @agoo_text_append(ptr noundef %66, ptr noundef %69, i32 noundef -1)
  store ptr %70, ptr %4, align 8, !tbaa !5
  %71 = load ptr, ptr %7, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct._gqlStrLink, ptr %71, i32 0, i32 0
  %73 = load ptr, ptr %72, align 8, !tbaa !24
  %74 = icmp ne ptr null, %73
  br i1 %74, label %75, label %78

75:                                               ; preds = %65
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = call ptr @agoo_text_append(ptr noundef %76, ptr noundef @.str.24, i32 noundef 3)
  store ptr %77, ptr %4, align 8, !tbaa !5
  br label %78

78:                                               ; preds = %75, %65
  br label %79

79:                                               ; preds = %78
  %80 = load ptr, ptr %7, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct._gqlStrLink, ptr %80, i32 0, i32 0
  %82 = load ptr, ptr %81, align 8, !tbaa !24
  store ptr %82, ptr %7, align 8, !tbaa !5
  br label %62, !llvm.loop !25

83:                                               ; preds = %62
  %84 = load ptr, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret ptr %84
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { "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, !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 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !6, i64 16}
!14 = !{!"_gqlDir", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !10, i64 40, !10, i64 41}
!15 = !{!14, !6, i64 8}
!16 = !{!14, !6, i64 24}
!17 = !{!18, !6, i64 0}
!18 = !{!"_gqlArg", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!14, !6, i64 32}
!22 = !{!23, !6, i64 8}
!23 = !{!"_gqlStrLink", !6, i64 0, !6, i64 8}
!24 = !{!23, !6, i64 0}
!25 = distinct !{!25, !20}


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

@.str.24 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: nounwind uwtable
declare hidden ptr @desc_sdl(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

declare ptr @agoo_text_append(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden ptr @arg_sdl(ptr noundef, ptr noundef, i1 noundef zeroext, i1 noundef zeroext, i1 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local ptr @gql_directive_sdl(ptr noundef %0, ptr nocapture noundef readonly %1, i1 noundef zeroext %2) local_unnamed_addr #0 {
  br i1 %2, label %4, label %8

4:                                                ; preds = %3
  %5 = getelementptr inbounds i8, ptr %1, i64 16
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = tail call ptr @desc_sdl(ptr noundef %0, ptr noundef %6, i32 noundef 0)
  br label %8

8:                                                ; preds = %4, %3
  %.025 = phi ptr [ %7, %4 ], [ %0, %3 ]
  %9 = tail call ptr @agoo_text_append(ptr noundef %.025, ptr noundef nonnull @.str.31, i32 noundef 11) #2
  %10 = getelementptr inbounds i8, ptr %1, i64 8
  %11 = load ptr, ptr %10, align 8, !tbaa !11
  %12 = tail call ptr @agoo_text_append(ptr noundef %9, ptr noundef %11, i32 noundef -1) #2
  %13 = getelementptr inbounds i8, ptr %1, i64 24
  %14 = load ptr, ptr %13, align 8, !tbaa !12
  %.not = icmp eq ptr %14, null
  br i1 %.not, label %21, label %15

15:                                               ; preds = %8
  %16 = tail call ptr @agoo_text_append(ptr noundef %12, ptr noundef nonnull @.str.32, i32 noundef 1) #2
  %.029 = load ptr, ptr %13, align 8, !tbaa !13
  %.not2630 = icmp eq ptr %.029, null
  br i1 %.not2630, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %15, %.lr.ph
  %.032 = phi ptr [ %.0, %.lr.ph ], [ %.029, %15 ]
  %.131 = phi ptr [ %19, %.lr.ph ], [ %16, %15 ]
  %17 = load ptr, ptr %.032, align 8, !tbaa !14
  %18 = icmp eq ptr %17, null
  %19 = tail call ptr @arg_sdl(ptr noundef %.131, ptr noundef nonnull %.032, i1 noundef zeroext %2, i1 noundef zeroext true, i1 noundef zeroext %18)
  %.0 = load ptr, ptr %.032, align 8, !tbaa !13
  %.not26 = icmp eq ptr %.0, null
  br i1 %.not26, label %._crit_edge, label %.lr.ph, !llvm.loop !16

._crit_edge:                                      ; preds = %.lr.ph, %15
  %.1.lcssa = phi ptr [ %16, %15 ], [ %19, %.lr.ph ]
  %20 = tail call ptr @agoo_text_append(ptr noundef %.1.lcssa, ptr noundef nonnull @.str.33, i32 noundef 1) #2
  br label %21

21:                                               ; preds = %._crit_edge, %8
  %.2 = phi ptr [ %20, %._crit_edge ], [ %12, %8 ]
  %22 = tail call ptr @agoo_text_append(ptr noundef %.2, ptr noundef nonnull @.str.34, i32 noundef 4) #2
  %23 = getelementptr inbounds i8, ptr %1, i64 32
  %.02433 = load ptr, ptr %23, align 8, !tbaa !13
  %.not2734 = icmp eq ptr %.02433, null
  br i1 %.not2734, label %._crit_edge39, label %.lr.ph38

.lr.ph38:                                         ; preds = %21, %28
  %.02436 = phi ptr [ %.024.pre, %28 ], [ %.02433, %21 ]
  %.335 = phi ptr [ %29, %28 ], [ %22, %21 ]
  %24 = getelementptr inbounds i8, ptr %.02436, i64 8
  %25 = load ptr, ptr %24, align 8, !tbaa !18
  %26 = tail call ptr @agoo_text_append(ptr noundef %.335, ptr noundef %25, i32 noundef -1) #2
  %27 = load ptr, ptr %.02436, align 8, !tbaa !13
  %.not28 = icmp eq ptr %27, null
  br i1 %.not28, label %._crit_edge39, label %28

28:                                               ; preds = %.lr.ph38
  %29 = tail call ptr @agoo_text_append(ptr noundef %26, ptr noundef nonnull @.str.24, i32 noundef 3) #2
  %.024.pre = load ptr, ptr %.02436, align 8, !tbaa !13
  %.not27 = icmp eq ptr %.024.pre, null
  br i1 %.not27, label %._crit_edge39, label %.lr.ph38, !llvm.loop !20

._crit_edge39:                                    ; preds = %.lr.ph38, %28, %21
  %.3.lcssa = phi ptr [ %22, %21 ], [ %26, %.lr.ph38 ], [ %29, %28 ]
  ret ptr %.3.lcssa
}

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 16}
!6 = !{!"_gqlDir", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !10, i64 40, !10, i64 41}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"_Bool", !8, i64 0}
!11 = !{!6, !7, i64 8}
!12 = !{!6, !7, i64 24}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !7, i64 0}
!15 = !{!"_gqlArg", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!19, !7, i64 8}
!19 = !{!"_gqlStrLink", !7, i64 0, !7, i64 8}
!20 = distinct !{!20, !17}


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