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

@gql_directives = external dso_local global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [65 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [18 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 dso_local ptr @gql_directive_get(ptr noundef) #1

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

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

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

; Function Attrs: nounwind
declare noalias ptr @strdup(ptr noundef) #4

; Function Attrs: nounwind uwtable
declare hidden ptr @alloc_string(ptr noundef, ptr noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @gql_directive_create(ptr noundef %0, ptr noundef %1, ptr noundef %2, i64 noundef %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i64 %3, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %12 = load ptr, ptr %7, align 8, !tbaa !5
  %13 = call ptr @gql_directive_get(ptr noundef %12)
  store ptr %13, ptr %10, align 8, !tbaa !5
  %14 = load ptr, ptr %10, align 8, !tbaa !5
  %15 = icmp ne ptr null, %14
  br i1 %15, label %16, label %61

16:                                               ; preds = %4
  %17 = load ptr, ptr %10, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct._gqlDir, ptr %17, i32 0, i32 5
  %19 = load i8, ptr %18, align 8, !tbaa !11, !range !14, !noundef !15
  %20 = trunc i8 %19 to i1
  br i1 %20, label %38, label %21

21:                                               ; preds = %16
  %22 = load ptr, ptr %10, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct._gqlDir, ptr %22, i32 0, i32 5
  store i8 1, ptr %23, align 8, !tbaa !11
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = load i64, ptr %9, align 8, !tbaa !9
  %27 = call ptr @alloc_string(ptr noundef %24, ptr noundef %25, i64 noundef %26)
  %28 = load ptr, ptr %10, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct._gqlDir, ptr %28, i32 0, i32 2
  store ptr %27, ptr %29, align 8, !tbaa !16
  %30 = icmp eq ptr null, %27
  br i1 %30, label %31, label %37

31:                                               ; preds = %21
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct._agooErr, ptr %32, i32 0, i32 0
  %34 = load i32, ptr %33, align 4, !tbaa !17
  %35 = icmp ne i32 0, %34
  br i1 %35, label %36, label %37

36:                                               ; preds = %31
  store ptr null, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %107

37:                                               ; preds = %31, %21
  br label %60

38:                                               ; preds = %16
  %39 = load ptr, ptr %10, align 8, !tbaa !5
  call void @dir_clean(ptr noundef %39)
  %40 = load ptr, ptr %10, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct._gqlDir, ptr %40, i32 0, i32 3
  store ptr null, ptr %41, align 8, !tbaa !20
  %42 = load ptr, ptr %10, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct._gqlDir, ptr %42, i32 0, i32 4
  store ptr null, ptr %43, align 8, !tbaa !21
  %44 = load ptr, ptr %10, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct._gqlDir, ptr %44, i32 0, i32 5
  store i8 1, ptr %45, align 8, !tbaa !11
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  %48 = load i64, ptr %9, align 8, !tbaa !9
  %49 = call ptr @alloc_string(ptr noundef %46, ptr noundef %47, i64 noundef %48)
  %50 = load ptr, ptr %10, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct._gqlDir, ptr %50, i32 0, i32 2
  store ptr %49, ptr %51, align 8, !tbaa !16
  %52 = icmp eq ptr null, %49
  br i1 %52, label %53, label %59

53:                                               ; preds = %38
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct._agooErr, ptr %54, i32 0, i32 0
  %56 = load i32, ptr %55, align 4, !tbaa !17
  %57 = icmp ne i32 0, %56
  br i1 %57, label %58, label %59

58:                                               ; preds = %53
  store ptr null, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %107

59:                                               ; preds = %53, %38
  br label %60

60:                                               ; preds = %59, %37
  br label %105

61:                                               ; preds = %4
  %62 = call noalias ptr @malloc(i64 noundef 48) #6
  store ptr %62, ptr %10, align 8, !tbaa !5
  %63 = icmp eq ptr null, %62
  br i1 %63, label %64, label %67

64:                                               ; preds = %61
  %65 = load ptr, ptr %6, align 8, !tbaa !5
  %66 = call i32 @agoo_err_memory(ptr noundef %65, ptr noundef @.str.11, ptr noundef @.str.2, i32 noundef 769)
  store ptr null, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %107

67:                                               ; preds = %61
  %68 = load ptr, ptr %7, align 8, !tbaa !5
  %69 = call noalias ptr @strdup(ptr noundef %68) #5
  %70 = load ptr, ptr %10, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct._gqlDir, ptr %70, i32 0, i32 1
  store ptr %69, ptr %71, align 8, !tbaa !22
  %72 = icmp eq ptr null, %69
  br i1 %72, label %73, label %77

73:                                               ; preds = %67
  %74 = load ptr, ptr %6, align 8, !tbaa !5
  %75 = call i32 @agoo_err_memory(ptr noundef %74, ptr noundef @.str.5, ptr noundef @.str.2, i32 noundef 773)
  %76 = load ptr, ptr %10, align 8, !tbaa !5
  call void @free(ptr noundef %76) #5
  store ptr null, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %107

77:                                               ; preds = %67
  %78 = load ptr, ptr %10, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct._gqlDir, ptr %78, i32 0, i32 3
  store ptr null, ptr %79, align 8, !tbaa !20
  %80 = load ptr, ptr %10, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct._gqlDir, ptr %80, i32 0, i32 4
  store ptr null, ptr %81, align 8, !tbaa !21
  %82 = load ptr, ptr %10, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct._gqlDir, ptr %82, i32 0, i32 5
  store i8 1, ptr %83, align 8, !tbaa !11
  %84 = load ptr, ptr %10, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct._gqlDir, ptr %84, i32 0, i32 6
  store i8 0, ptr %85, align 1, !tbaa !23
  %86 = load ptr, ptr %6, align 8, !tbaa !5
  %87 = load ptr, ptr %8, align 8, !tbaa !5
  %88 = load i64, ptr %9, align 8, !tbaa !9
  %89 = call ptr @alloc_string(ptr noundef %86, ptr noundef %87, i64 noundef %88)
  %90 = load ptr, ptr %10, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct._gqlDir, ptr %90, i32 0, i32 2
  store ptr %89, ptr %91, align 8, !tbaa !16
  %92 = icmp eq ptr null, %89
  br i1 %92, label %93, label %100

93:                                               ; preds = %77
  %94 = load ptr, ptr %6, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct._agooErr, ptr %94, i32 0, i32 0
  %96 = load i32, ptr %95, align 4, !tbaa !17
  %97 = icmp ne i32 0, %96
  br i1 %97, label %98, label %100

98:                                               ; preds = %93
  %99 = load ptr, ptr %10, align 8, !tbaa !5
  call void @free(ptr noundef %99) #5
  store ptr null, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %107

100:                                              ; preds = %93, %77
  %101 = load ptr, ptr @gql_directives, align 8, !tbaa !5
  %102 = load ptr, ptr %10, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct._gqlDir, ptr %102, i32 0, i32 0
  store ptr %101, ptr %103, align 8, !tbaa !24
  %104 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %104, ptr @gql_directives, align 8, !tbaa !5
  br label %105

105:                                              ; preds = %100, %60
  %106 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %106, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %107

107:                                              ; preds = %105, %98, %73, %64, %58, %36
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  %108 = load ptr, ptr %5, align 8
  ret ptr %108
}

; Function Attrs: nounwind uwtable
declare hidden void @dir_clean(ptr noundef) #1

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 = { nounwind allocsize(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 "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 allocsize(0) }

!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 = !{!"long", !7, i64 0}
!11 = !{!12, !13, i64 40}
!12 = !{!"_gqlDir", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !13, i64 40, !13, i64 41}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = !{!12, !6, i64 16}
!17 = !{!18, !19, i64 0}
!18 = !{!"_agooErr", !19, i64 0, !7, i64 4}
!19 = !{!"int", !7, i64 0}
!20 = !{!12, !6, i64 24}
!21 = !{!12, !6, i64 32}
!22 = !{!12, !6, i64 8}
!23 = !{!12, !13, i64 41}
!24 = !{!12, !6, 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"

@gql_directives = external dso_local local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [65 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [18 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local ptr @gql_directive_get(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

declare i32 @agoo_err_memory(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite, inaccessiblemem: readwrite)
declare noalias ptr @strdup(ptr nocapture noundef readonly) local_unnamed_addr #4

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

; Function Attrs: nounwind uwtable
define dso_local ptr @gql_directive_create(ptr noundef %0, ptr noundef %1, ptr noundef %2, i64 noundef %3) local_unnamed_addr #0 {
  %5 = tail call ptr @gql_directive_get(ptr noundef %1)
  %.not = icmp eq ptr %5, null
  br i1 %.not, label %23, label %6

6:                                                ; preds = %4
  %7 = getelementptr inbounds i8, ptr %5, i64 40
  %8 = load i8, ptr %7, align 8, !tbaa !5, !range !11, !noundef !12
  %9 = trunc nuw i8 %8 to i1
  br i1 %9, label %16, label %10

10:                                               ; preds = %6
  store i8 1, ptr %7, align 8, !tbaa !5
  %11 = tail call ptr @alloc_string(ptr noundef %0, ptr noundef %2, i64 noundef %3)
  %12 = getelementptr inbounds i8, ptr %5, i64 16
  store ptr %11, ptr %12, align 8, !tbaa !13
  %13 = icmp eq ptr %11, null
  br i1 %13, label %14, label %46

14:                                               ; preds = %10
  %15 = load i32, ptr %0, align 4, !tbaa !14
  %.not40 = icmp eq i32 %15, 0
  br i1 %.not40, label %46, label %47

16:                                               ; preds = %6
  tail call void @dir_clean(ptr noundef nonnull %5)
  %17 = getelementptr inbounds i8, ptr %5, i64 24
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %17, i8 0, i64 16, i1 false)
  store i8 1, ptr %7, align 8, !tbaa !5
  %18 = tail call ptr @alloc_string(ptr noundef %0, ptr noundef %2, i64 noundef %3)
  %19 = getelementptr inbounds i8, ptr %5, i64 16
  store ptr %18, ptr %19, align 8, !tbaa !13
  %20 = icmp eq ptr %18, null
  br i1 %20, label %21, label %46

21:                                               ; preds = %16
  %22 = load i32, ptr %0, align 4, !tbaa !14
  %.not41 = icmp eq i32 %22, 0
  br i1 %.not41, label %46, label %47

23:                                               ; preds = %4
  %24 = tail call noalias dereferenceable_or_null(48) ptr @malloc(i64 noundef 48) #6
  %25 = icmp eq ptr %24, null
  br i1 %25, label %26, label %28

26:                                               ; preds = %23
  %27 = tail call i32 @agoo_err_memory(ptr noundef %0, ptr noundef nonnull @.str.11, ptr noundef nonnull @.str.2, i32 noundef 769) #7
  br label %47

28:                                               ; preds = %23
  %29 = tail call noalias ptr @strdup(ptr noundef %1) #7
  %30 = getelementptr inbounds i8, ptr %24, i64 8
  store ptr %29, ptr %30, align 8, !tbaa !17
  %31 = icmp eq ptr %29, null
  br i1 %31, label %32, label %34

32:                                               ; preds = %28
  %33 = tail call i32 @agoo_err_memory(ptr noundef %0, ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.2, i32 noundef 773) #7
  tail call void @free(ptr noundef nonnull %24) #7
  br label %47

34:                                               ; preds = %28
  %35 = getelementptr inbounds i8, ptr %24, i64 24
  %36 = getelementptr inbounds i8, ptr %24, i64 40
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %35, i8 0, i64 16, i1 false)
  store i8 1, ptr %36, align 8, !tbaa !5
  %37 = getelementptr inbounds i8, ptr %24, i64 41
  store i8 0, ptr %37, align 1, !tbaa !18
  %38 = tail call ptr @alloc_string(ptr noundef %0, ptr noundef %2, i64 noundef %3)
  %39 = getelementptr inbounds i8, ptr %24, i64 16
  store ptr %38, ptr %39, align 8, !tbaa !13
  %40 = icmp eq ptr %38, null
  br i1 %40, label %41, label %44

41:                                               ; preds = %34
  %42 = load i32, ptr %0, align 4, !tbaa !14
  %.not39 = icmp eq i32 %42, 0
  br i1 %.not39, label %44, label %43

43:                                               ; preds = %41
  tail call void @free(ptr noundef nonnull %24) #7
  br label %47

44:                                               ; preds = %41, %34
  %45 = load ptr, ptr @gql_directives, align 8, !tbaa !19
  store ptr %45, ptr %24, align 8, !tbaa !20
  store ptr %24, ptr @gql_directives, align 8, !tbaa !19
  br label %46

46:                                               ; preds = %14, %10, %21, %16, %44
  %.0 = phi ptr [ %5, %21 ], [ %5, %16 ], [ %5, %14 ], [ %5, %10 ], [ %24, %44 ]
  br label %47

47:                                               ; preds = %21, %14, %46, %43, %32, %26
  %.036 = phi ptr [ %.0, %46 ], [ null, %26 ], [ null, %32 ], [ null, %43 ], [ null, %14 ], [ null, %21 ]
  ret ptr %.036
}

; Function Attrs: nounwind uwtable
declare hidden void @dir_clean(ptr noundef) local_unnamed_addr #0

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5

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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(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 = { "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 = { 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 #4 = { mustprogress nofree nounwind willreturn 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 #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { nounwind allocsize(0) }
attributes #7 = { 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, !10, i64 40}
!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 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!6, !7, i64 16}
!14 = !{!15, !16, i64 0}
!15 = !{!"_agooErr", !16, i64 0, !8, i64 4}
!16 = !{!"int", !8, i64 0}
!17 = !{!6, !7, i64 8}
!18 = !{!6, !10, i64 41}
!19 = !{!7, !7, i64 0}
!20 = !{!6, !7, i64 0}


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