; LLVM IR from buaazp/zimg :: deps/libevhtp (evhtp)

; 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.sockaddr_in = type { i16, i16, %struct.in_addr, [8 x i8] }
%struct.in_addr = type { i32 }
%struct.sockaddr_in6 = type { i16, i16, i32, %struct.in6_addr, i32 }
%struct.in6_addr = type { %union.anon }
%union.anon = type { [4 x i32] }
%struct.sockaddr_un = type { i16, [108 x i8] }

@.str.55 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.56 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.57 = external hidden unnamed_addr constant [6 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 willreturn memory(read)
declare i64 @strlen(ptr noundef) #1

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @evhtp_bind_sockaddr(ptr noundef, ptr noundef, i64 noundef, i32 noundef) #3

; Function Attrs: nounwind uwtable
define dso_local i32 @evhtp_bind_socket(ptr noundef %0, ptr noundef %1, i16 noundef zeroext %2, i32 noundef %3) #3 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i16, align 2
  %9 = alloca i32, align 4
  %10 = alloca %struct.sockaddr_in, align 4
  %11 = alloca %struct.sockaddr_in6, align 4
  %12 = alloca %struct.sockaddr_un, align 2
  %13 = alloca ptr, align 8
  %14 = alloca i64, align 8
  %15 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i16 %2, ptr %8, align 2, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #7
  call void @llvm.lifetime.start.p0(i64 28, ptr %11) #7
  call void @llvm.lifetime.start.p0(i64 110, ptr %12) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  call void @llvm.memset.p0.i64(ptr align 4 %10, i8 0, i64 16, i1 false)
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = call i32 @strncmp(ptr noundef %16, ptr noundef @.str.55, i64 noundef 5) #8
  %18 = icmp ne i32 %17, 0
  br i1 %18, label %29, label %19

19:                                               ; preds = %4
  call void @llvm.memset.p0.i64(ptr align 4 %11, i8 0, i64 28, i1 false)
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %20, i64 5
  store ptr %21, ptr %7, align 8, !tbaa !5
  store i64 28, ptr %14, align 8, !tbaa !13
  %22 = load i16, ptr %8, align 2, !tbaa !9
  %23 = call zeroext i16 @__bswap_16(i16 noundef zeroext %22)
  %24 = getelementptr inbounds %struct.sockaddr_in6, ptr %11, i32 0, i32 1
  store i16 %23, ptr %24, align 2, !tbaa !15
  %25 = getelementptr inbounds %struct.sockaddr_in6, ptr %11, i32 0, i32 0
  store i16 10, ptr %25, align 4, !tbaa !18
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.sockaddr_in6, ptr %11, i32 0, i32 3
  %28 = call i32 @evutil_inet_pton(i32 noundef 10, ptr noundef %26, ptr noundef %27)
  store ptr %11, ptr %13, align 8, !tbaa !5
  br label %65

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

33:                                               ; preds = %29
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %34, i64 5
  store ptr %35, ptr %7, align 8, !tbaa !5
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = call i64 @strlen(ptr noundef %36) #8
  %38 = icmp uge i64 %37, 108
  br i1 %38, label %39, label %40

39:                                               ; preds = %33
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %15, align 4
  br label %71

40:                                               ; preds = %33
  call void @llvm.memset.p0.i64(ptr align 2 %12, i8 0, i64 110, i1 false)
  store i64 110, ptr %14, align 8, !tbaa !13
  %41 = getelementptr inbounds %struct.sockaddr_un, ptr %12, i32 0, i32 0
  store i16 1, ptr %41, align 2, !tbaa !19
  %42 = getelementptr inbounds %struct.sockaddr_un, ptr %12, i32 0, i32 1
  %43 = getelementptr inbounds [108 x i8], ptr %42, i64 0, i64 0
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  %46 = call i64 @strlen(ptr noundef %45) #8
  %47 = call ptr @strncpy(ptr noundef %43, ptr noundef %44, i64 noundef %46) #7
  store ptr %12, ptr %13, align 8, !tbaa !5
  br label %64

48:                                               ; preds = %29
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = call i32 @strncmp(ptr noundef %49, ptr noundef @.str.57, i64 noundef 5) #8
  %51 = icmp ne i32 %50, 0
  br i1 %51, label %55, label %52

52:                                               ; preds = %48
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  %54 = getelementptr inbounds i8, ptr %53, i64 5
  store ptr %54, ptr %7, align 8, !tbaa !5
  br label %55

55:                                               ; preds = %52, %48
  store i64 16, ptr %14, align 8, !tbaa !13
  %56 = getelementptr inbounds %struct.sockaddr_in, ptr %10, i32 0, i32 0
  store i16 2, ptr %56, align 4, !tbaa !21
  %57 = load i16, ptr %8, align 2, !tbaa !9
  %58 = call zeroext i16 @__bswap_16(i16 noundef zeroext %57)
  %59 = getelementptr inbounds %struct.sockaddr_in, ptr %10, i32 0, i32 1
  store i16 %58, ptr %59, align 2, !tbaa !24
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  %61 = call i32 @inet_addr(ptr noundef %60) #7
  %62 = getelementptr inbounds %struct.sockaddr_in, ptr %10, i32 0, i32 2
  %63 = getelementptr inbounds %struct.in_addr, ptr %62, i32 0, i32 0
  store i32 %61, ptr %63, align 4, !tbaa !25
  store ptr %10, ptr %13, align 8, !tbaa !5
  br label %64

64:                                               ; preds = %55, %40
  br label %65

65:                                               ; preds = %64, %19
  %66 = load ptr, ptr %6, align 8, !tbaa !5
  %67 = load ptr, ptr %13, align 8, !tbaa !5
  %68 = load i64, ptr %14, align 8, !tbaa !13
  %69 = load i32, ptr %9, align 4, !tbaa !11
  %70 = call i32 @evhtp_bind_sockaddr(ptr noundef %66, ptr noundef %67, i64 noundef %68, i32 noundef %69)
  store i32 %70, ptr %5, align 4
  store i32 1, ptr %15, align 4
  br label %71

71:                                               ; preds = %65, %39
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 110, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 28, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #7
  %72 = load i32, ptr %5, align 4
  ret i32 %72
}

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i16 @__bswap_16(i16 noundef zeroext) #4

declare i32 @evutil_inet_pton(i32 noundef, ptr noundef, ptr noundef) #5

; Function Attrs: nounwind
declare ptr @strncpy(ptr noundef, ptr noundef, i64 noundef) #6

; Function Attrs: nounwind
declare i32 @inet_addr(ptr noundef) #6

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { inlinehint 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 = { "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 #6 = { 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 #7 = { nounwind }
attributes #8 = { 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 = !{!"short", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!16, !10, i64 2}
!16 = !{!"sockaddr_in6", !10, i64 0, !10, i64 2, !12, i64 4, !17, i64 8, !12, i64 24}
!17 = !{!"in6_addr", !7, i64 0}
!18 = !{!16, !10, i64 0}
!19 = !{!20, !10, i64 0}
!20 = !{!"sockaddr_un", !10, i64 0, !7, i64 2}
!21 = !{!22, !10, i64 0}
!22 = !{!"sockaddr_in", !10, i64 0, !10, i64 2, !23, i64 4, !7, i64 8}
!23 = !{!"in_addr", !12, i64 0}
!24 = !{!22, !10, i64 2}
!25 = !{!22, !12, i64 4}


; 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.sockaddr_in = type { i16, i16, %struct.in_addr, [8 x i8] }
%struct.in_addr = type { i32 }
%struct.sockaddr_in6 = type { i16, i16, i32, %struct.in6_addr, i32 }
%struct.in6_addr = type { %union.anon }
%union.anon = type { [4 x i32] }
%struct.sockaddr_un = type { i16, [108 x i8] }

@.str.55 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.56 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.57 = external hidden unnamed_addr constant [6 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: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @evhtp_bind_sockaddr(ptr noundef, ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local i32 @evhtp_bind_socket(ptr noundef %0, ptr noundef %1, i16 noundef zeroext %2, i32 noundef %3) local_unnamed_addr #3 {
  %5 = alloca %struct.sockaddr_in, align 4
  %6 = alloca %struct.sockaddr_in6, align 4
  %7 = alloca %struct.sockaddr_un, align 2
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #8
  call void @llvm.lifetime.start.p0(i64 28, ptr nonnull %6) #8
  call void @llvm.lifetime.start.p0(i64 110, ptr nonnull %7) #8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(16) %5, i8 0, i64 16, i1 false)
  %8 = tail call i32 @strncmp(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) @.str.55, i64 noundef 5) #9
  %.not = icmp eq i32 %8, 0
  br i1 %.not, label %9, label %16

9:                                                ; preds = %4
  %10 = getelementptr inbounds i8, ptr %6, i64 4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(28) %10, i8 0, i64 24, i1 false)
  %11 = getelementptr inbounds i8, ptr %1, i64 5
  %12 = tail call zeroext i16 @__bswap_16(i16 noundef zeroext %2)
  %13 = getelementptr inbounds i8, ptr %6, i64 2
  store i16 %12, ptr %13, align 2, !tbaa !5
  store i16 10, ptr %6, align 4, !tbaa !12
  %14 = getelementptr inbounds i8, ptr %6, i64 8
  %15 = call i32 @evutil_inet_pton(i32 noundef 10, ptr noundef nonnull %11, ptr noundef nonnull %14) #8
  br label %32

16:                                               ; preds = %4
  %17 = tail call i32 @strncmp(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) @.str.56, i64 noundef 5) #9
  %.not20 = icmp eq i32 %17, 0
  br i1 %.not20, label %18, label %26

18:                                               ; preds = %16
  %19 = getelementptr inbounds i8, ptr %1, i64 5
  %20 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %19) #9
  %21 = icmp ugt i64 %20, 107
  br i1 %21, label %34, label %22

22:                                               ; preds = %18
  %23 = getelementptr inbounds i8, ptr %7, i64 2
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 2 dereferenceable(110) %23, i8 0, i64 108, i1 false)
  store i16 1, ptr %7, align 2, !tbaa !13
  %24 = getelementptr inbounds i8, ptr %7, i64 2
  %25 = call ptr @strncpy(ptr noundef nonnull %24, ptr noundef nonnull %19, i64 noundef %20) #8
  br label %32

26:                                               ; preds = %16
  %27 = tail call i32 @strncmp(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) @.str.57, i64 noundef 5) #9
  %.not21 = icmp eq i32 %27, 0
  %spec.select.idx = select i1 %.not21, i64 5, i64 0
  %spec.select = getelementptr inbounds i8, ptr %1, i64 %spec.select.idx
  store i16 2, ptr %5, align 4, !tbaa !15
  %28 = tail call zeroext i16 @__bswap_16(i16 noundef zeroext %2)
  %29 = getelementptr inbounds i8, ptr %5, i64 2
  store i16 %28, ptr %29, align 2, !tbaa !18
  %30 = tail call i32 @inet_addr(ptr noundef %spec.select) #8
  %31 = getelementptr inbounds i8, ptr %5, i64 4
  store i32 %30, ptr %31, align 4, !tbaa !19
  br label %32

32:                                               ; preds = %22, %26, %9
  %.017 = phi ptr [ %5, %26 ], [ %7, %22 ], [ %6, %9 ]
  %.0 = phi i64 [ 16, %26 ], [ 110, %22 ], [ 28, %9 ]
  %33 = call i32 @evhtp_bind_sockaddr(ptr noundef %0, ptr noundef nonnull %.017, i64 noundef %.0, i32 noundef %3)
  br label %34

34:                                               ; preds = %18, %32
  %.018 = phi i32 [ %33, %32 ], [ -1, %18 ]
  call void @llvm.lifetime.end.p0(i64 110, ptr nonnull %7) #8
  call void @llvm.lifetime.end.p0(i64 28, ptr nonnull %6) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #8
  ret i32 %.018
}

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i16 @__bswap_16(i16 noundef zeroext) local_unnamed_addr #4

declare i32 @evutil_inet_pton(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #5

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strncpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly, i64 noundef) local_unnamed_addr #6

; Function Attrs: nounwind
declare i32 @inet_addr(ptr noundef) local_unnamed_addr #7

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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { inlinehint 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 = { "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 #6 = { mustprogress nofree nounwind willreturn memory(argmem: readwrite) "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 #7 = { 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 #8 = { nounwind }
attributes #9 = { 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 2}
!6 = !{!"sockaddr_in6", !7, i64 0, !7, i64 2, !10, i64 4, !11, i64 8, !10, i64 24}
!7 = !{!"short", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"in6_addr", !8, i64 0}
!12 = !{!6, !7, i64 0}
!13 = !{!14, !7, i64 0}
!14 = !{!"sockaddr_un", !7, i64 0, !8, i64 2}
!15 = !{!16, !7, i64 0}
!16 = !{!"sockaddr_in", !7, i64 0, !7, i64 2, !17, i64 4, !8, i64 8}
!17 = !{!"in_addr", !10, i64 0}
!18 = !{!16, !7, i64 2}
!19 = !{!16, !10, i64 4}


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