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

; 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._gqlCclass = type { ptr, ptr }
%struct._gqlField = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct._gqlCobj = type { ptr, ptr }
%struct._gqlSel = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct._gqlDoc = type { ptr, ptr, ptr, ptr, %struct._gqlFuncs, ptr, ptr, ptr }
%struct._gqlFuncs = type { ptr, ptr }

@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [45 x i8], align 1
@root_class = external hidden global %struct._gqlCclass, align 8
@.str.2 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [43 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: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #1

; 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
define dso_local i32 @gql_intro_eval(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4) #2 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca %struct._gqlField, align 8
  %13 = alloca %struct._gqlCobj, align 8
  %14 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store i32 %4, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 56, ptr %12) #5
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #5
  %15 = load ptr, ptr %9, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct._gqlSel, ptr %15, i32 0, i32 2
  %17 = load ptr, ptr %16, align 8, !tbaa !11
  %18 = call i32 @strcmp(ptr noundef @.str, ptr noundef %17) #6
  %19 = icmp eq i32 0, %18
  br i1 %19, label %20, label %29

20:                                               ; preds = %5
  %21 = load i32, ptr %11, align 4, !tbaa !9
  %22 = icmp slt i32 2, %21
  br i1 %22, label %23, label %26

23:                                               ; preds = %20
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = call i32 (ptr, i32, ptr, ...) @agoo_err_set(ptr noundef %24, i32 noundef 313, ptr noundef @.str.1)
  store i32 %25, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %72

26:                                               ; preds = %20
  %27 = getelementptr inbounds %struct._gqlCobj, ptr %13, i32 0, i32 0
  store ptr @root_class, ptr %27, align 8, !tbaa !13
  %28 = getelementptr inbounds %struct._gqlCobj, ptr %13, i32 0, i32 1
  store ptr null, ptr %28, align 8, !tbaa !15
  br label %51

29:                                               ; preds = %5
  %30 = load ptr, ptr %9, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct._gqlSel, ptr %30, i32 0, i32 2
  %32 = load ptr, ptr %31, align 8, !tbaa !11
  %33 = call i32 @strcmp(ptr noundef @.str.2, ptr noundef %32) #6
  %34 = icmp eq i32 0, %33
  br i1 %34, label %35, label %44

35:                                               ; preds = %29
  %36 = load i32, ptr %11, align 4, !tbaa !9
  %37 = icmp slt i32 2, %36
  br i1 %37, label %38, label %41

38:                                               ; preds = %35
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = call i32 (ptr, i32, ptr, ...) @agoo_err_set(ptr noundef %39, i32 noundef 313, ptr noundef @.str.3)
  store i32 %40, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %72

41:                                               ; preds = %35
  %42 = getelementptr inbounds %struct._gqlCobj, ptr %13, i32 0, i32 0
  store ptr @root_class, ptr %42, align 8, !tbaa !13
  %43 = getelementptr inbounds %struct._gqlCobj, ptr %13, i32 0, i32 1
  store ptr null, ptr %43, align 8, !tbaa !15
  br label %50

44:                                               ; preds = %29
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  %46 = load ptr, ptr %9, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct._gqlSel, ptr %46, i32 0, i32 2
  %48 = load ptr, ptr %47, align 8, !tbaa !11
  %49 = call i32 (ptr, i32, ptr, ...) @agoo_err_set(ptr noundef %45, i32 noundef 313, ptr noundef @.str.4, ptr noundef %48)
  store i32 %49, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %72

50:                                               ; preds = %41
  br label %51

51:                                               ; preds = %50, %26
  call void @llvm.memset.p0.i64(ptr align 8 %12, i8 0, i64 56, i1 false)
  %52 = load ptr, ptr %9, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct._gqlSel, ptr %52, i32 0, i32 2
  %54 = load ptr, ptr %53, align 8, !tbaa !11
  %55 = getelementptr inbounds %struct._gqlField, ptr %12, i32 0, i32 1
  store ptr %54, ptr %55, align 8, !tbaa !16
  %56 = load ptr, ptr %9, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct._gqlSel, ptr %56, i32 0, i32 3
  %58 = load ptr, ptr %57, align 8, !tbaa !18
  %59 = getelementptr inbounds %struct._gqlField, ptr %12, i32 0, i32 2
  store ptr %58, ptr %59, align 8, !tbaa !19
  %60 = load ptr, ptr %8, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct._gqlDoc, ptr %60, i32 0, i32 4
  %62 = getelementptr inbounds %struct._gqlFuncs, ptr %61, i32 0, i32 0
  store ptr @gql_cobj_resolve, ptr %62, align 8, !tbaa !20
  %63 = load ptr, ptr %8, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct._gqlDoc, ptr %63, i32 0, i32 4
  %65 = getelementptr inbounds %struct._gqlFuncs, ptr %64, i32 0, i32 1
  store ptr @gql_cobj_ref_type, ptr %65, align 8, !tbaa !23
  %66 = load ptr, ptr %7, align 8, !tbaa !5
  %67 = load ptr, ptr %8, align 8, !tbaa !5
  %68 = load ptr, ptr %9, align 8, !tbaa !5
  %69 = load ptr, ptr %10, align 8, !tbaa !5
  %70 = load i32, ptr %11, align 4, !tbaa !9
  %71 = call i32 @gql_cobj_resolve(ptr noundef %66, ptr noundef %67, ptr noundef %13, ptr noundef %12, ptr noundef %68, ptr noundef %69, i32 noundef %70)
  store i32 %71, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %72

72:                                               ; preds = %51, %44, %38, %23
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 56, ptr %12) #5
  %73 = load i32, ptr %6, align 4
  ret i32 %73
}

declare i32 @agoo_err_set(ptr noundef, i32 noundef, ptr noundef, ...) #3

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

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

declare ptr @gql_cobj_ref_type(ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 16}
!12 = !{!"_gqlSel", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64}
!13 = !{!14, !6, i64 0}
!14 = !{!"_gqlCobj", !6, i64 0, !6, i64 8}
!15 = !{!14, !6, i64 8}
!16 = !{!17, !6, i64 8}
!17 = !{!"_gqlField", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!18 = !{!12, !6, i64 24}
!19 = !{!17, !6, i64 16}
!20 = !{!21, !6, i64 32}
!21 = !{!"_gqlDoc", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !22, i64 32, !6, i64 48, !6, i64 56, !6, i64 64}
!22 = !{!"_gqlFuncs", !6, i64 0, !6, i64 8}
!23 = !{!21, !6, i64 40}


; 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._gqlCclass = type { ptr, ptr }
%struct._gqlField = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct._gqlCobj = type { ptr, ptr }

@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [45 x i8], align 1
@root_class = external hidden global %struct._gqlCclass, align 8
@.str.2 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [43 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 nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local i32 @gql_intro_eval(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4) local_unnamed_addr #2 {
  %6 = alloca %struct._gqlField, align 8
  %7 = alloca %struct._gqlCobj, align 8
  call void @llvm.lifetime.start.p0(i64 56, ptr nonnull %6) #5
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %7) #5
  %8 = getelementptr inbounds i8, ptr %2, i64 16
  %9 = load ptr, ptr %8, align 8, !tbaa !5
  %10 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) @.str, ptr noundef nonnull dereferenceable(1) %9) #6
  %11 = icmp eq i32 %10, 0
  br i1 %11, label %12, label %16

12:                                               ; preds = %5
  %13 = icmp sgt i32 %4, 2
  br i1 %13, label %14, label %25

14:                                               ; preds = %12
  %15 = tail call i32 (ptr, i32, ptr, ...) @agoo_err_set(ptr noundef %0, i32 noundef 313, ptr noundef nonnull @.str.1) #5
  br label %34

16:                                               ; preds = %5
  %17 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef nonnull dereferenceable(1) %9) #6
  %18 = icmp eq i32 %17, 0
  br i1 %18, label %19, label %23

19:                                               ; preds = %16
  %20 = icmp sgt i32 %4, 2
  br i1 %20, label %21, label %25

21:                                               ; preds = %19
  %22 = tail call i32 (ptr, i32, ptr, ...) @agoo_err_set(ptr noundef %0, i32 noundef 313, ptr noundef nonnull @.str.3) #5
  br label %34

23:                                               ; preds = %16
  %24 = tail call i32 (ptr, i32, ptr, ...) @agoo_err_set(ptr noundef %0, i32 noundef 313, ptr noundef nonnull @.str.4, ptr noundef %9) #5
  br label %34

25:                                               ; preds = %19, %12
  store ptr @root_class, ptr %7, align 8, !tbaa !10
  %26 = getelementptr inbounds i8, ptr %7, i64 8
  store ptr null, ptr %26, align 8, !tbaa !12
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(56) %6, i8 0, i64 56, i1 false)
  %27 = getelementptr inbounds i8, ptr %6, i64 8
  store ptr %9, ptr %27, align 8, !tbaa !13
  %28 = getelementptr inbounds i8, ptr %2, i64 24
  %29 = load ptr, ptr %28, align 8, !tbaa !15
  %30 = getelementptr inbounds i8, ptr %6, i64 16
  store ptr %29, ptr %30, align 8, !tbaa !16
  %31 = getelementptr inbounds i8, ptr %1, i64 32
  store ptr @gql_cobj_resolve, ptr %31, align 8, !tbaa !17
  %32 = getelementptr inbounds i8, ptr %1, i64 40
  store ptr @gql_cobj_ref_type, ptr %32, align 8, !tbaa !20
  %33 = call i32 @gql_cobj_resolve(ptr noundef %0, ptr noundef %1, ptr noundef nonnull %7, ptr noundef nonnull %6, ptr noundef nonnull %2, ptr noundef %3, i32 noundef %4) #5
  br label %34

34:                                               ; preds = %25, %23, %21, %14
  %.0 = phi i32 [ %15, %14 ], [ %33, %25 ], [ %22, %21 ], [ %24, %23 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 56, ptr nonnull %6) #5
  ret i32 %.0
}

declare i32 @agoo_err_set(ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #3

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

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

declare ptr @gql_cobj_ref_type(ptr noundef) #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nofree nounwind willreturn memory(argmem: 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 #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 nocallback nofree nounwind willreturn memory(argmem: write) }
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, !7, i64 16}
!6 = !{!"_gqlSel", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !7, i64 0}
!11 = !{!"_gqlCobj", !7, i64 0, !7, i64 8}
!12 = !{!11, !7, i64 8}
!13 = !{!14, !7, i64 8}
!14 = !{!"_gqlField", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48}
!15 = !{!6, !7, i64 24}
!16 = !{!14, !7, i64 16}
!17 = !{!18, !7, i64 32}
!18 = !{!"_gqlDoc", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !19, i64 32, !7, i64 48, !7, i64 56, !7, i64 64}
!19 = !{!"_gqlFuncs", !7, i64 0, !7, i64 8}
!20 = !{!18, !7, i64 40}


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