; 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._gqlSel = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct._gqlSelArg = type { ptr, ptr, ptr, ptr }
%struct._gqlVar = type { ptr, ptr, ptr, ptr }
%struct._gqlField = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct._gqlArg = type { ptr, ptr, ptr, ptr, ptr, ptr }
%struct._gqlValue = type { ptr, %union.anon }
%union.anon = type { %union.anon.0 }
%union.anon.0 = type { %struct.anon.1 }
%struct.anon.1 = type { i8, [7 x i8], ptr }
%struct._gqlType = type { ptr, ptr, ptr, i32, i32, i8, %union.anon.4 }
%union.anon.4 = type { %struct.anon.6 }
%struct.anon.6 = type { ptr, ptr, ptr }

; Function Attrs: nounwind uwtable
define dso_local ptr @gql_extract_arg(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %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 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 ptr %3, ptr %9, align 8, !tbaa !5
  %14 = load ptr, ptr %8, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct._gqlSel, ptr %14, i32 0, i32 5
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  %17 = icmp ne ptr null, %16
  br i1 %17, label %18, label %110

18:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  store ptr null, ptr %11, align 8, !tbaa !5
  %19 = load ptr, ptr %8, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct._gqlSel, ptr %19, i32 0, i32 5
  %21 = load ptr, ptr %20, align 8, !tbaa !9
  store ptr %21, ptr %10, align 8, !tbaa !5
  br label %22

22:                                               ; preds = %103, %18
  %23 = load ptr, ptr %10, align 8, !tbaa !5
  %24 = icmp ne ptr null, %23
  br i1 %24, label %25, label %107

25:                                               ; preds = %22
  %26 = load ptr, ptr %10, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct._gqlSelArg, ptr %26, i32 0, i32 1
  %28 = load ptr, ptr %27, align 8, !tbaa !11
  %29 = load ptr, ptr %9, align 8, !tbaa !5
  %30 = call i32 @strcmp(ptr noundef %28, ptr noundef %29) #5
  %31 = icmp ne i32 0, %30
  br i1 %31, label %32, label %33

32:                                               ; preds = %25
  br label %103

33:                                               ; preds = %25
  %34 = load ptr, ptr %10, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct._gqlSelArg, ptr %34, i32 0, i32 2
  %36 = load ptr, ptr %35, align 8, !tbaa !13
  %37 = icmp ne ptr null, %36
  br i1 %37, label %38, label %44

38:                                               ; preds = %33
  %39 = load ptr, ptr %10, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct._gqlSelArg, ptr %39, i32 0, i32 2
  %41 = load ptr, ptr %40, align 8, !tbaa !13
  %42 = getelementptr inbounds %struct._gqlVar, ptr %41, i32 0, i32 3
  %43 = load ptr, ptr %42, align 8, !tbaa !14
  store ptr %43, ptr %11, align 8, !tbaa !5
  br label %48

44:                                               ; preds = %33
  %45 = load ptr, ptr %10, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct._gqlSelArg, ptr %45, i32 0, i32 3
  %47 = load ptr, ptr %46, align 8, !tbaa !16
  store ptr %47, ptr %11, align 8, !tbaa !5
  br label %48

48:                                               ; preds = %44, %38
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = icmp ne ptr null, %49
  br i1 %50, label %51, label %102

51:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct._gqlField, ptr %52, i32 0, i32 4
  %54 = load ptr, ptr %53, align 8, !tbaa !17
  store ptr %54, ptr %12, align 8, !tbaa !5
  br label %55

55:                                               ; preds = %94, %51
  %56 = load ptr, ptr %12, align 8, !tbaa !5
  %57 = icmp ne ptr null, %56
  br i1 %57, label %58, label %98

58:                                               ; preds = %55
  %59 = load ptr, ptr %10, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct._gqlSelArg, ptr %59, i32 0, i32 1
  %61 = load ptr, ptr %60, align 8, !tbaa !11
  %62 = load ptr, ptr %12, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct._gqlArg, ptr %62, i32 0, i32 1
  %64 = load ptr, ptr %63, align 8, !tbaa !19
  %65 = call i32 @strcmp(ptr noundef %61, ptr noundef %64) #5
  %66 = icmp eq i32 0, %65
  br i1 %66, label %67, label %93

67:                                               ; preds = %58
  %68 = load ptr, ptr %11, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct._gqlValue, ptr %68, i32 0, i32 0
  %70 = load ptr, ptr %69, align 8, !tbaa !21
  %71 = load ptr, ptr %12, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct._gqlArg, ptr %71, i32 0, i32 3
  %73 = load ptr, ptr %72, align 8, !tbaa !23
  %74 = icmp ne ptr %70, %73
  br i1 %74, label %75, label %92

75:                                               ; preds = %67
  %76 = load ptr, ptr %11, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct._gqlValue, ptr %76, i32 0, i32 0
  %78 = load ptr, ptr %77, align 8, !tbaa !21
  %79 = getelementptr inbounds %struct._gqlType, ptr %78, i32 0, i32 4
  %80 = load i32, ptr %79, align 4, !tbaa !24
  %81 = icmp ne i32 8, %80
  br i1 %81, label %82, label %92

82:                                               ; preds = %75
  %83 = load ptr, ptr %6, align 8, !tbaa !5
  %84 = load ptr, ptr %11, align 8, !tbaa !5
  %85 = load ptr, ptr %12, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct._gqlArg, ptr %85, i32 0, i32 3
  %87 = load ptr, ptr %86, align 8, !tbaa !23
  %88 = call i32 @gql_value_convert(ptr noundef %83, ptr noundef %84, ptr noundef %87)
  %89 = icmp ne i32 0, %88
  br i1 %89, label %90, label %91

90:                                               ; preds = %82
  store ptr null, ptr %5, align 8
  store i32 1, ptr %13, align 4
  br label %99

91:                                               ; preds = %82
  br label %92

92:                                               ; preds = %91, %75, %67
  br label %98

93:                                               ; preds = %58
  br label %94

94:                                               ; preds = %93
  %95 = load ptr, ptr %12, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct._gqlArg, ptr %95, i32 0, i32 0
  %97 = load ptr, ptr %96, align 8, !tbaa !28
  store ptr %97, ptr %12, align 8, !tbaa !5
  br label %55, !llvm.loop !29

98:                                               ; preds = %92, %55
  store i32 0, ptr %13, align 4
  br label %99

99:                                               ; preds = %98, %90
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  %100 = load i32, ptr %13, align 4
  switch i32 %100, label %109 [
    i32 0, label %101
  ]

101:                                              ; preds = %99
  br label %102

102:                                              ; preds = %101, %48
  br label %103

103:                                              ; preds = %102, %32
  %104 = load ptr, ptr %10, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct._gqlSelArg, ptr %104, i32 0, i32 0
  %106 = load ptr, ptr %105, align 8, !tbaa !31
  store ptr %106, ptr %10, align 8, !tbaa !5
  br label %22, !llvm.loop !32

107:                                              ; preds = %22
  %108 = load ptr, ptr %11, align 8, !tbaa !5
  store ptr %108, ptr %5, align 8
  store i32 1, ptr %13, align 4
  br label %109

109:                                              ; preds = %107, %99
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %111

110:                                              ; preds = %4
  store ptr null, ptr %5, align 8
  br label %111

111:                                              ; preds = %110, %109
  %112 = load ptr, ptr %5, align 8
  ret ptr %112
}

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

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #2

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

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 }
attributes #5 = { 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, !6, i64 40}
!10 = !{!"_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}
!11 = !{!12, !6, i64 8}
!12 = !{!"_gqlSelArg", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!13 = !{!12, !6, i64 16}
!14 = !{!15, !6, i64 24}
!15 = !{!"_gqlVar", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!16 = !{!12, !6, i64 24}
!17 = !{!18, !6, i64 32}
!18 = !{!"_gqlField", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!19 = !{!20, !6, i64 8}
!20 = !{!"_gqlArg", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!21 = !{!22, !6, i64 0}
!22 = !{!"_gqlValue", !6, i64 0, !7, i64 8}
!23 = !{!20, !6, i64 24}
!24 = !{!25, !26, i64 28}
!25 = !{!"_gqlType", !6, i64 0, !6, i64 8, !6, i64 16, !26, i64 24, !26, i64 28, !27, i64 32, !7, i64 40}
!26 = !{!"int", !7, i64 0}
!27 = !{!"_Bool", !7, i64 0}
!28 = !{!20, !6, i64 0}
!29 = distinct !{!29, !30}
!30 = !{!"llvm.loop.mustprogress"}
!31 = !{!12, !6, i64 0}
!32 = distinct !{!32, !30}


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

; Function Attrs: nounwind uwtable
define dso_local ptr @gql_extract_arg(ptr noundef %0, ptr noundef readonly %1, ptr nocapture noundef readonly %2, ptr nocapture noundef readonly %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %2, i64 40
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %.not = icmp eq ptr %6, null
  br i1 %.not, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %4
  %.not37 = icmp eq ptr %1, null
  %7 = getelementptr inbounds i8, ptr %1, i64 32
  br i1 %.not37, label %.preheader.split.us, label %.preheader.split

.preheader.split.us:                              ; preds = %.preheader, %.critedge.us
  %.02444.us = phi ptr [ %.2.us, %.critedge.us ], [ null, %.preheader ]
  %.02543.us = phi ptr [ %14, %.critedge.us ], [ %6, %.preheader ]
  %8 = getelementptr inbounds i8, ptr %.02543.us, i64 8
  %9 = load ptr, ptr %8, align 8, !tbaa !10
  %10 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %9, ptr noundef nonnull dereferenceable(1) %3) #3
  %.not35.us = icmp eq i32 %10, 0
  br i1 %.not35.us, label %11, label %.critedge.us

11:                                               ; preds = %.preheader.split.us
  %12 = getelementptr inbounds i8, ptr %.02543.us, i64 16
  %13 = load ptr, ptr %12, align 8, !tbaa !12
  %.not36.us = icmp eq ptr %13, null
  %.025..us = select i1 %.not36.us, ptr %.02543.us, ptr %13
  %.1.in.us = getelementptr inbounds i8, ptr %.025..us, i64 24
  %.1.us = load ptr, ptr %.1.in.us, align 8, !tbaa !13
  br label %.critedge.us

.critedge.us:                                     ; preds = %11, %.preheader.split.us
  %.2.us = phi ptr [ %.02444.us, %.preheader.split.us ], [ %.1.us, %11 ]
  %14 = load ptr, ptr %.02543.us, align 8, !tbaa !14
  %.not34.us = icmp eq ptr %14, null
  br i1 %.not34.us, label %.loopexit, label %.preheader.split.us, !llvm.loop !15

.preheader.split:                                 ; preds = %.preheader, %.critedge
  %.02444 = phi ptr [ %.2, %.critedge ], [ null, %.preheader ]
  %.02543 = phi ptr [ %36, %.critedge ], [ %6, %.preheader ]
  %15 = getelementptr inbounds i8, ptr %.02543, i64 8
  %16 = load ptr, ptr %15, align 8, !tbaa !10
  %17 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %16, ptr noundef nonnull dereferenceable(1) %3) #3
  %.not35 = icmp eq i32 %17, 0
  br i1 %.not35, label %18, label %.critedge

18:                                               ; preds = %.preheader.split
  %19 = getelementptr inbounds i8, ptr %.02543, i64 16
  %20 = load ptr, ptr %19, align 8, !tbaa !12
  %.not36 = icmp eq ptr %20, null
  %.025. = select i1 %.not36, ptr %.02543, ptr %20
  %.1.in = getelementptr inbounds i8, ptr %.025., i64 24
  %.1 = load ptr, ptr %.1.in, align 8, !tbaa !13
  br label %21

21:                                               ; preds = %22, %18
  %.023.in = phi ptr [ %7, %18 ], [ %.023, %22 ]
  %.023 = load ptr, ptr %.023.in, align 8, !tbaa !13
  %.not38 = icmp eq ptr %.023, null
  br i1 %.not38, label %.critedge, label %22

22:                                               ; preds = %21
  %23 = getelementptr inbounds i8, ptr %.023, i64 8
  %24 = load ptr, ptr %23, align 8, !tbaa !17
  %25 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %16, ptr noundef nonnull dereferenceable(1) %24) #3
  %26 = icmp eq i32 %25, 0
  br i1 %26, label %27, label %21, !llvm.loop !19

27:                                               ; preds = %22
  %28 = load ptr, ptr %.1, align 8, !tbaa !20
  %29 = getelementptr inbounds i8, ptr %.023, i64 24
  %30 = load ptr, ptr %29, align 8, !tbaa !22
  %.not39 = icmp eq ptr %28, %30
  br i1 %.not39, label %.critedge, label %31

31:                                               ; preds = %27
  %32 = getelementptr inbounds i8, ptr %28, i64 28
  %33 = load i32, ptr %32, align 4, !tbaa !23
  %.not40 = icmp eq i32 %33, 8
  br i1 %.not40, label %.critedge, label %34

34:                                               ; preds = %31
  %35 = tail call i32 @gql_value_convert(ptr noundef %0, ptr noundef nonnull %.1, ptr noundef %30) #4
  %.not41 = icmp eq i32 %35, 0
  br i1 %.not41, label %.critedge, label %.loopexit

.critedge:                                        ; preds = %21, %34, %31, %27, %.preheader.split
  %.2 = phi ptr [ %.02444, %.preheader.split ], [ %.1, %27 ], [ %.1, %31 ], [ %.1, %34 ], [ %.1, %21 ]
  %36 = load ptr, ptr %.02543, align 8, !tbaa !14
  %.not34 = icmp eq ptr %36, null
  br i1 %.not34, label %.loopexit, label %.preheader.split, !llvm.loop !15

.loopexit:                                        ; preds = %.critedge, %34, %.critedge.us, %4
  %.4 = phi ptr [ null, %4 ], [ %.2.us, %.critedge.us ], [ %.2, %.critedge ], [ null, %34 ]
  ret ptr %.4
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #1

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

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 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 = { "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 willreturn memory(read) }
attributes #4 = { 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 40}
!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 8}
!11 = !{!"_gqlSelArg", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!12 = !{!11, !7, i64 16}
!13 = !{!7, !7, i64 0}
!14 = !{!11, !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!18, !7, i64 8}
!18 = !{!"_gqlArg", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40}
!19 = distinct !{!19, !16}
!20 = !{!21, !7, i64 0}
!21 = !{!"_gqlValue", !7, i64 0, !8, i64 8}
!22 = !{!18, !7, i64 24}
!23 = !{!24, !25, i64 28}
!24 = !{!"_gqlType", !7, i64 0, !7, i64 8, !7, i64 16, !25, i64 24, !25, i64 28, !26, i64 32, !8, i64 40}
!25 = !{!"int", !8, i64 0}
!26 = !{!"_Bool", !8, i64 0}


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