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

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

@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [7 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
define dso_local ptr @agoo_bind_url(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca [8 x i8], align 1
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = call i32 @strncasecmp(ptr noundef @.str.3, ptr noundef %10, i64 noundef 6) #4
  %12 = icmp eq i32 0, %11
  br i1 %12, label %13, label %29

13:                                               ; preds = %2
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %14, i64 6
  %16 = load i8, ptr %15, align 1, !tbaa !9
  %17 = sext i8 %16 to i32
  %18 = icmp eq i32 91, %17
  br i1 %18, label %19, label %24

19:                                               ; preds = %13
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %21, i64 6
  %23 = call ptr @url_tcp6(ptr noundef %20, ptr noundef %22, ptr noundef @.str.4)
  store ptr %23, ptr %3, align 8
  br label %134

24:                                               ; preds = %13
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %26, i64 6
  %28 = call ptr @url_tcp(ptr noundef %25, ptr noundef %27, ptr noundef @.str.4)
  store ptr %28, ptr %3, align 8
  br label %134

29:                                               ; preds = %2
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = call i32 @strncasecmp(ptr noundef @.str.5, ptr noundef %30, i64 noundef 7) #4
  %32 = icmp eq i32 0, %31
  br i1 %32, label %33, label %49

33:                                               ; preds = %29
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %34, i64 7
  %36 = load i8, ptr %35, align 1, !tbaa !9
  %37 = sext i8 %36 to i32
  %38 = icmp eq i32 91, %37
  br i1 %38, label %39, label %44

39:                                               ; preds = %33
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds i8, ptr %41, i64 7
  %43 = call ptr @url_tcp6(ptr noundef %40, ptr noundef %42, ptr noundef @.str.6)
  store ptr %43, ptr %3, align 8
  br label %134

44:                                               ; preds = %33
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = getelementptr inbounds i8, ptr %46, i64 7
  %48 = call ptr @url_tcp(ptr noundef %45, ptr noundef %47, ptr noundef @.str.6)
  store ptr %48, ptr %3, align 8
  br label %134

49:                                               ; preds = %29
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = call i32 @strncasecmp(ptr noundef @.str.7, ptr noundef %50, i64 noundef 7) #4
  %52 = icmp eq i32 0, %51
  br i1 %52, label %53, label %58

53:                                               ; preds = %49
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = getelementptr inbounds i8, ptr %55, i64 7
  %57 = call ptr @url_named(ptr noundef %54, ptr noundef %56)
  store ptr %57, ptr %3, align 8
  br label %134

58:                                               ; preds = %49
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = call i32 @strncasecmp(ptr noundef @.str.8, ptr noundef %59, i64 noundef 8) #4
  %61 = icmp eq i32 0, %60
  br i1 %61, label %62, label %67

62:                                               ; preds = %58
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  %65 = getelementptr inbounds i8, ptr %64, i64 8
  %66 = call ptr @url_ssl(ptr noundef %63, ptr noundef %65)
  store ptr %66, ptr %3, align 8
  br label %134

67:                                               ; preds = %58
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = call i32 @strncasecmp(ptr noundef @.str.9, ptr noundef %68, i64 noundef 6) #4
  %70 = icmp eq i32 0, %69
  br i1 %70, label %71, label %76

71:                                               ; preds = %67
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = getelementptr inbounds i8, ptr %73, i64 6
  %75 = call ptr @url_ssl(ptr noundef %72, ptr noundef %74)
  store ptr %75, ptr %3, align 8
  br label %134

76:                                               ; preds = %67
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  %78 = call ptr @index(ptr noundef %77, i32 noundef 58) #4
  store ptr %78, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %79 = load ptr, ptr %6, align 8, !tbaa !5
  %80 = icmp ne ptr null, %79
  br i1 %80, label %81, label %129

81:                                               ; preds = %76
  %82 = load ptr, ptr %6, align 8, !tbaa !5
  %83 = load ptr, ptr %5, align 8, !tbaa !5
  %84 = ptrtoint ptr %82 to i64
  %85 = ptrtoint ptr %83 to i64
  %86 = sub i64 %84, %85
  %87 = icmp slt i64 %86, 8
  br i1 %87, label %88, label %129

88:                                               ; preds = %81
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %89 = load ptr, ptr %6, align 8, !tbaa !5
  %90 = load ptr, ptr %5, align 8, !tbaa !5
  %91 = ptrtoint ptr %89 to i64
  %92 = ptrtoint ptr %90 to i64
  %93 = sub i64 %91, %92
  %94 = trunc i64 %93 to i32
  store i32 %94, ptr %8, align 4, !tbaa !10
  %95 = getelementptr inbounds [8 x i8], ptr %7, i64 0, i64 0
  %96 = load ptr, ptr %5, align 8, !tbaa !5
  %97 = load i32, ptr %8, align 4, !tbaa !10
  %98 = sext i32 %97 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %95, ptr align 1 %96, i64 %98, i1 false)
  %99 = load i32, ptr %8, align 4, !tbaa !10
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [8 x i8], ptr %7, i64 0, i64 %100
  store i8 0, ptr %101, align 1, !tbaa !9
  %102 = load ptr, ptr %5, align 8, !tbaa !5
  %103 = load i32, ptr %8, align 4, !tbaa !10
  %104 = add nsw i32 %103, 3
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds i8, ptr %102, i64 %105
  %107 = load i8, ptr %106, align 1, !tbaa !9
  %108 = sext i8 %107 to i32
  %109 = icmp eq i32 91, %108
  br i1 %109, label %110, label %119

110:                                              ; preds = %88
  %111 = load ptr, ptr %4, align 8, !tbaa !5
  %112 = load ptr, ptr %5, align 8, !tbaa !5
  %113 = load i32, ptr %8, align 4, !tbaa !10
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds i8, ptr %112, i64 %114
  %116 = getelementptr inbounds i8, ptr %115, i64 3
  %117 = getelementptr inbounds [8 x i8], ptr %7, i64 0, i64 0
  %118 = call ptr @url_tcp6(ptr noundef %111, ptr noundef %116, ptr noundef %117)
  store ptr %118, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %128

119:                                              ; preds = %88
  %120 = load ptr, ptr %4, align 8, !tbaa !5
  %121 = load ptr, ptr %5, align 8, !tbaa !5
  %122 = load i32, ptr %8, align 4, !tbaa !10
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds i8, ptr %121, i64 %123
  %125 = getelementptr inbounds i8, ptr %124, i64 3
  %126 = getelementptr inbounds [8 x i8], ptr %7, i64 0, i64 0
  %127 = call ptr @url_tcp(ptr noundef %120, ptr noundef %125, ptr noundef %126)
  store ptr %127, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %128

128:                                              ; preds = %119, %110
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %133

129:                                              ; preds = %81, %76
  %130 = load ptr, ptr %4, align 8, !tbaa !5
  %131 = load ptr, ptr %5, align 8, !tbaa !5
  %132 = call ptr @url_tcp(ptr noundef %130, ptr noundef %131, ptr noundef @.str.6)
  store ptr %132, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %133

133:                                              ; preds = %129, %128
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  br label %134

134:                                              ; preds = %133, %71, %62, %53, %44, %39, %24, %19
  %135 = load ptr, ptr %3, align 8
  ret ptr %135
}

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

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

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

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

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

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 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nounwind willreturn memory(read) }
attributes #5 = { 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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, 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"

@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [7 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 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 ptr @agoo_bind_url(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = alloca [8 x i8], align 1
  %4 = tail call i32 @strncasecmp(ptr noundef nonnull @.str.3, ptr noundef %1, i64 noundef 6) #4
  %5 = icmp eq i32 %4, 0
  br i1 %5, label %6, label %14

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %1, i64 6
  %8 = load i8, ptr %7, align 1, !tbaa !5
  %9 = icmp eq i8 %8, 91
  br i1 %9, label %10, label %12

10:                                               ; preds = %6
  %11 = tail call ptr @url_tcp6(ptr noundef %0, ptr noundef nonnull %7, ptr noundef nonnull @.str.4)
  br label %66

12:                                               ; preds = %6
  %13 = tail call ptr @url_tcp(ptr noundef %0, ptr noundef nonnull %7, ptr noundef nonnull @.str.4)
  br label %66

14:                                               ; preds = %2
  %15 = tail call i32 @strncasecmp(ptr noundef nonnull @.str.5, ptr noundef %1, i64 noundef 7) #4
  %16 = icmp eq i32 %15, 0
  br i1 %16, label %17, label %25

17:                                               ; preds = %14
  %18 = getelementptr inbounds i8, ptr %1, i64 7
  %19 = load i8, ptr %18, align 1, !tbaa !5
  %20 = icmp eq i8 %19, 91
  br i1 %20, label %21, label %23

21:                                               ; preds = %17
  %22 = tail call ptr @url_tcp6(ptr noundef %0, ptr noundef nonnull %18, ptr noundef nonnull @.str.6)
  br label %66

23:                                               ; preds = %17
  %24 = tail call ptr @url_tcp(ptr noundef %0, ptr noundef nonnull %18, ptr noundef nonnull @.str.6)
  br label %66

25:                                               ; preds = %14
  %26 = tail call i32 @strncasecmp(ptr noundef nonnull @.str.7, ptr noundef %1, i64 noundef 7) #4
  %27 = icmp eq i32 %26, 0
  br i1 %27, label %28, label %31

28:                                               ; preds = %25
  %29 = getelementptr inbounds i8, ptr %1, i64 7
  %30 = tail call ptr @url_named(ptr noundef %0, ptr noundef nonnull %29)
  br label %66

31:                                               ; preds = %25
  %32 = tail call i32 @strncasecmp(ptr noundef nonnull @.str.8, ptr noundef %1, i64 noundef 8) #4
  %33 = icmp eq i32 %32, 0
  br i1 %33, label %34, label %37

34:                                               ; preds = %31
  %35 = getelementptr inbounds i8, ptr %1, i64 8
  %36 = tail call ptr @url_ssl(ptr noundef %0, ptr noundef nonnull %35)
  br label %66

37:                                               ; preds = %31
  %38 = tail call i32 @strncasecmp(ptr noundef nonnull @.str.9, ptr noundef %1, i64 noundef 6) #4
  %39 = icmp eq i32 %38, 0
  br i1 %39, label %40, label %43

40:                                               ; preds = %37
  %41 = getelementptr inbounds i8, ptr %1, i64 6
  %42 = tail call ptr @url_ssl(ptr noundef %0, ptr noundef nonnull %41)
  br label %66

43:                                               ; preds = %37
  %44 = tail call ptr @index(ptr noundef %1, i32 noundef 58) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  %.not = icmp eq ptr %44, null
  br i1 %.not, label %63, label %45

45:                                               ; preds = %43
  %46 = ptrtoint ptr %44 to i64
  %47 = ptrtoint ptr %1 to i64
  %48 = sub i64 %46, %47
  %49 = icmp slt i64 %48, 8
  br i1 %49, label %50, label %63

50:                                               ; preds = %45
  %sext = shl i64 %48, 32
  %51 = ashr exact i64 %sext, 32
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %3, ptr align 1 %1, i64 %51, i1 false)
  %52 = getelementptr inbounds [8 x i8], ptr %3, i64 0, i64 %51
  store i8 0, ptr %52, align 1, !tbaa !5
  %sext42 = add i64 %sext, 12884901888
  %53 = ashr exact i64 %sext42, 32
  %54 = getelementptr inbounds i8, ptr %1, i64 %53
  %55 = load i8, ptr %54, align 1, !tbaa !5
  %56 = icmp eq i8 %55, 91
  %57 = getelementptr inbounds i8, ptr %1, i64 %51
  %58 = getelementptr inbounds i8, ptr %57, i64 3
  br i1 %56, label %59, label %61

59:                                               ; preds = %50
  %60 = call ptr @url_tcp6(ptr noundef %0, ptr noundef nonnull %58, ptr noundef nonnull %3)
  br label %65

61:                                               ; preds = %50
  %62 = call ptr @url_tcp(ptr noundef %0, ptr noundef nonnull %58, ptr noundef nonnull %3)
  br label %65

63:                                               ; preds = %45, %43
  %64 = tail call ptr @url_tcp(ptr noundef %0, ptr noundef %1, ptr noundef nonnull @.str.6)
  br label %65

65:                                               ; preds = %59, %61, %63
  %.1 = phi ptr [ %64, %63 ], [ %60, %59 ], [ %62, %61 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  br label %66

66:                                               ; preds = %65, %40, %34, %28, %23, %21, %12, %10
  %.2 = phi ptr [ %11, %10 ], [ %13, %12 ], [ %22, %21 ], [ %24, %23 ], [ %30, %28 ], [ %36, %34 ], [ %42, %40 ], [ %.1, %65 ]
  ret ptr %.2
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(read)
declare i32 @strncasecmp(ptr nocapture noundef, ptr nocapture noundef, i64 noundef) local_unnamed_addr #2

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

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

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

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(read)
declare ptr @index(ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

attributes #0 = { mustprogress 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 = { mustprogress nofree 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nounwind willreturn memory(read) }
attributes #5 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}


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