; 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._gqlField = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct._agooErr = type { i32, [256 x i8] }
%struct._gqlType = type { ptr, ptr, ptr, i32, i32, i8, %union.anon }
%union.anon = type { %struct.anon.0 }
%struct.anon.0 = type { ptr, ptr, ptr }
%struct.anon = type { ptr, ptr }

@.str.2 = external hidden unnamed_addr constant [65 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [9 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 allocsize(0)
declare noalias ptr @malloc(i64 noundef) #1

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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @gql_type_field(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, i64 noundef %6) #4 {
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i64, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca ptr, align 8
  store ptr %0, ptr %9, align 8, !tbaa !5
  store ptr %1, ptr %10, align 8, !tbaa !5
  store ptr %2, ptr %11, align 8, !tbaa !5
  store ptr %3, ptr %12, align 8, !tbaa !5
  store ptr %4, ptr %13, align 8, !tbaa !5
  store ptr %5, ptr %14, align 8, !tbaa !5
  store i64 %6, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %19 = call noalias ptr @malloc(i64 noundef 56) #6
  store ptr %19, ptr %16, align 8, !tbaa !5
  %20 = load ptr, ptr %16, align 8, !tbaa !5
  %21 = icmp eq ptr null, %20
  br i1 %21, label %22, label %25

22:                                               ; preds = %7
  %23 = load ptr, ptr %9, align 8, !tbaa !5
  %24 = call i32 @agoo_err_memory(ptr noundef %23, ptr noundef @.str.4, ptr noundef @.str.2, i32 noundef 524)
  br label %93

25:                                               ; preds = %7
  %26 = load ptr, ptr %16, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct._gqlField, ptr %26, i32 0, i32 0
  store ptr null, ptr %27, align 8, !tbaa !11
  %28 = load ptr, ptr %11, align 8, !tbaa !5
  %29 = call noalias ptr @strdup(ptr noundef %28) #5
  %30 = load ptr, ptr %16, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct._gqlField, ptr %30, i32 0, i32 1
  store ptr %29, ptr %31, align 8, !tbaa !13
  %32 = icmp eq ptr null, %29
  br i1 %32, label %33, label %37

33:                                               ; preds = %25
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = call i32 @agoo_err_memory(ptr noundef %34, ptr noundef @.str.5, ptr noundef @.str.2, i32 noundef 528)
  %36 = load ptr, ptr %16, align 8, !tbaa !5
  call void @free(ptr noundef %36) #5
  store ptr null, ptr %8, align 8
  store i32 1, ptr %17, align 4
  br label %95

37:                                               ; preds = %25
  %38 = load ptr, ptr %12, align 8, !tbaa !5
  %39 = load ptr, ptr %16, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct._gqlField, ptr %39, i32 0, i32 2
  store ptr %38, ptr %40, align 8, !tbaa !14
  %41 = load ptr, ptr %9, align 8, !tbaa !5
  %42 = load ptr, ptr %14, align 8, !tbaa !5
  %43 = load i64, ptr %15, align 8, !tbaa !9
  %44 = call ptr @alloc_string(ptr noundef %41, ptr noundef %42, i64 noundef %43)
  %45 = load ptr, ptr %16, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct._gqlField, ptr %45, i32 0, i32 3
  store ptr %44, ptr %46, align 8, !tbaa !15
  %47 = icmp eq ptr null, %44
  br i1 %47, label %48, label %55

48:                                               ; preds = %37
  %49 = load ptr, ptr %9, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct._agooErr, ptr %49, i32 0, i32 0
  %51 = load i32, ptr %50, align 4, !tbaa !16
  %52 = icmp ne i32 0, %51
  br i1 %52, label %53, label %55

53:                                               ; preds = %48
  %54 = load ptr, ptr %16, align 8, !tbaa !5
  call void @free(ptr noundef %54) #5
  store ptr null, ptr %8, align 8
  store i32 1, ptr %17, align 4
  br label %95

55:                                               ; preds = %48, %37
  %56 = load ptr, ptr %16, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct._gqlField, ptr %56, i32 0, i32 4
  store ptr null, ptr %57, align 8, !tbaa !19
  %58 = load ptr, ptr %16, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct._gqlField, ptr %58, i32 0, i32 5
  store ptr null, ptr %59, align 8, !tbaa !20
  %60 = load ptr, ptr %13, align 8, !tbaa !5
  %61 = load ptr, ptr %16, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct._gqlField, ptr %61, i32 0, i32 6
  store ptr %60, ptr %62, align 8, !tbaa !21
  %63 = load ptr, ptr %10, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct._gqlType, ptr %63, i32 0, i32 6
  %65 = getelementptr inbounds %struct.anon, ptr %64, i32 0, i32 0
  %66 = load ptr, ptr %65, align 8, !tbaa !22
  %67 = icmp eq ptr null, %66
  br i1 %67, label %68, label %73

68:                                               ; preds = %55
  %69 = load ptr, ptr %16, align 8, !tbaa !5
  %70 = load ptr, ptr %10, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct._gqlType, ptr %70, i32 0, i32 6
  %72 = getelementptr inbounds %struct.anon, ptr %71, i32 0, i32 0
  store ptr %69, ptr %72, align 8, !tbaa !22
  br label %92

73:                                               ; preds = %55
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  %74 = load ptr, ptr %10, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct._gqlType, ptr %74, i32 0, i32 6
  %76 = getelementptr inbounds %struct.anon, ptr %75, i32 0, i32 0
  %77 = load ptr, ptr %76, align 8, !tbaa !22
  store ptr %77, ptr %18, align 8, !tbaa !5
  br label %78

78:                                               ; preds = %84, %73
  %79 = load ptr, ptr %18, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct._gqlField, ptr %79, i32 0, i32 0
  %81 = load ptr, ptr %80, align 8, !tbaa !11
  %82 = icmp ne ptr null, %81
  br i1 %82, label %83, label %88

83:                                               ; preds = %78
  br label %84

84:                                               ; preds = %83
  %85 = load ptr, ptr %18, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct._gqlField, ptr %85, i32 0, i32 0
  %87 = load ptr, ptr %86, align 8, !tbaa !11
  store ptr %87, ptr %18, align 8, !tbaa !5
  br label %78, !llvm.loop !23

88:                                               ; preds = %78
  %89 = load ptr, ptr %16, align 8, !tbaa !5
  %90 = load ptr, ptr %18, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct._gqlField, ptr %90, i32 0, i32 0
  store ptr %89, ptr %91, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  br label %92

92:                                               ; preds = %88, %68
  br label %93

93:                                               ; preds = %92, %22
  %94 = load ptr, ptr %16, align 8, !tbaa !5
  store ptr %94, ptr %8, align 8
  store i32 1, ptr %17, align 4
  br label %95

95:                                               ; preds = %93, %53, %33
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  %96 = load ptr, ptr %8, align 8
  ret ptr %96
}

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

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

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


; 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.2 = external hidden unnamed_addr constant [65 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [9 x i8], align 1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @gql_type_field(ptr noundef %0, ptr nocapture noundef %1, ptr nocapture noundef readonly %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, i64 noundef %6) local_unnamed_addr #3 {
  %8 = tail call noalias dereferenceable_or_null(56) ptr @malloc(i64 noundef 56) #6
  %9 = icmp eq ptr %8, null
  br i1 %9, label %10, label %12

10:                                               ; preds = %7
  %11 = tail call i32 @agoo_err_memory(ptr noundef %0, ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.2, i32 noundef 524) #7
  br label %35

12:                                               ; preds = %7
  store ptr null, ptr %8, align 8, !tbaa !5
  %13 = tail call noalias ptr @strdup(ptr noundef %2) #7
  %14 = getelementptr inbounds i8, ptr %8, i64 8
  store ptr %13, ptr %14, align 8, !tbaa !10
  %15 = icmp eq ptr %13, null
  br i1 %15, label %16, label %18

16:                                               ; preds = %12
  %17 = tail call i32 @agoo_err_memory(ptr noundef %0, ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.2, i32 noundef 528) #7
  tail call void @free(ptr noundef nonnull %8) #7
  br label %35

18:                                               ; preds = %12
  %19 = getelementptr inbounds i8, ptr %8, i64 16
  store ptr %3, ptr %19, align 8, !tbaa !11
  %20 = tail call ptr @alloc_string(ptr noundef %0, ptr noundef %5, i64 noundef %6)
  %21 = getelementptr inbounds i8, ptr %8, i64 24
  store ptr %20, ptr %21, align 8, !tbaa !12
  %22 = icmp eq ptr %20, null
  br i1 %22, label %23, label %26

23:                                               ; preds = %18
  %24 = load i32, ptr %0, align 4, !tbaa !13
  %.not = icmp eq i32 %24, 0
  br i1 %.not, label %26, label %25

25:                                               ; preds = %23
  tail call void @free(ptr noundef nonnull %8) #7
  br label %35

26:                                               ; preds = %23, %18
  %27 = getelementptr inbounds i8, ptr %8, i64 32
  %28 = getelementptr inbounds i8, ptr %8, i64 48
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %27, i8 0, i64 16, i1 false)
  store ptr %4, ptr %28, align 8, !tbaa !16
  %29 = getelementptr inbounds i8, ptr %1, i64 40
  %30 = load ptr, ptr %29, align 8, !tbaa !17
  %31 = icmp eq ptr %30, null
  br i1 %31, label %32, label %.preheader

32:                                               ; preds = %26
  store ptr %8, ptr %29, align 8, !tbaa !17
  br label %35

.preheader:                                       ; preds = %26, %.preheader
  %.0 = phi ptr [ %33, %.preheader ], [ %30, %26 ]
  %33 = load ptr, ptr %.0, align 8, !tbaa !5
  %.not32 = icmp eq ptr %33, null
  br i1 %.not32, label %34, label %.preheader, !llvm.loop !18

34:                                               ; preds = %.preheader
  store ptr %8, ptr %.0, align 8, !tbaa !5
  br label %35

35:                                               ; preds = %10, %34, %32, %25, %16
  %.028 = phi ptr [ null, %16 ], [ null, %25 ], [ %8, %32 ], [ %8, %34 ], [ null, %10 ]
  ret ptr %.028
}

; 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 #3

; 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 = { 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 #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 = { 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 #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 = { 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, !7, i64 0}
!6 = !{!"_gqlField", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 8}
!11 = !{!6, !7, i64 16}
!12 = !{!6, !7, i64 24}
!13 = !{!14, !15, i64 0}
!14 = !{!"_agooErr", !15, i64 0, !8, i64 4}
!15 = !{!"int", !8, i64 0}
!16 = !{!6, !7, i64 48}
!17 = !{!8, !8, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


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