; LLVM IR from tezc/sc :: socket (sock_test)

; 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.sc_sock = type { %struct.sc_sock_fd, i8, i32, [128 x i8] }
%struct.sc_sock_fd = type { i32, i32, i32 }

@.str.3 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [43 x i8], align 1
@__PRETTY_FUNCTION__.server_unix = external hidden unnamed_addr constant [26 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [16 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(none)
declare ptr @__errno_location() #1

declare void @sc_sock_init(ptr noundef, i32 noundef, i1 noundef zeroext, i32 noundef) #2

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #3

declare void @sc_sock_print(ptr noundef, ptr noundef, i64 noundef) #2

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

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

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

declare i32 @sc_sock_term(ptr noundef) #2

declare i32 @printf(ptr noundef, ...) #2

; Function Attrs: nounwind uwtable
define dso_local ptr @server_unix(ptr noundef %0) #5 {
  %2 = alloca ptr, align 8
  %3 = alloca [5 x i8], align 1
  %4 = alloca [128 x i8], align 16
  %5 = alloca %struct.sc_sock, align 4
  %6 = alloca %struct.sc_sock, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 5, ptr %3) #6
  call void @llvm.lifetime.start.p0(i64 128, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 148, ptr %5) #6
  call void @llvm.lifetime.start.p0(i64 148, ptr %6) #6
  call void @sc_sock_init(ptr noundef %5, i32 noundef 0, i1 noundef zeroext true, i32 noundef 1)
  %9 = call i32 @sc_sock_listen(ptr noundef %5, ptr noundef @.str.30, ptr noundef null)
  %10 = icmp eq i32 %9, 0
  br i1 %10, label %11, label %12

11:                                               ; preds = %1
  br label %13

12:                                               ; preds = %1
  call void @__assert_fail(ptr noundef @.str.31, ptr noundef @.str.3, i32 noundef 315, ptr noundef @__PRETTY_FUNCTION__.server_unix) #7
  unreachable

13:                                               ; preds = %11
  %14 = getelementptr inbounds [128 x i8], ptr %4, i64 0, i64 0
  call void @sc_sock_print(ptr noundef %5, ptr noundef %14, i64 noundef 128)
  %15 = getelementptr inbounds [128 x i8], ptr %4, i64 0, i64 0
  %16 = call i32 @strcmp(ptr noundef %15, ptr noundef @.str.32) #8
  %17 = icmp eq i32 %16, 0
  br i1 %17, label %18, label %19

18:                                               ; preds = %13
  br label %20

19:                                               ; preds = %13
  call void @__assert_fail(ptr noundef @.str.33, ptr noundef @.str.3, i32 noundef 317, ptr noundef @__PRETTY_FUNCTION__.server_unix) #7
  unreachable

20:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  %21 = call i32 @sc_sock_accept(ptr noundef %5, ptr noundef %6)
  store i32 %21, ptr %7, align 4, !tbaa !9
  %22 = load i32, ptr %7, align 4, !tbaa !9
  %23 = icmp ne i32 %22, 0
  br i1 %23, label %24, label %30

24:                                               ; preds = %20
  %25 = call ptr @__errno_location() #9
  %26 = load i32, ptr %25, align 4, !tbaa !9
  %27 = getelementptr inbounds %struct.sc_sock, ptr %5, i32 0, i32 3
  %28 = getelementptr inbounds [128 x i8], ptr %27, i64 0, i64 0
  %29 = call i32 (ptr, ...) @printf(ptr noundef @.str.34, i32 noundef %26, ptr noundef %28)
  br label %30

30:                                               ; preds = %24, %20
  %31 = load i32, ptr %7, align 4, !tbaa !9
  %32 = icmp eq i32 %31, 0
  br i1 %32, label %33, label %34

33:                                               ; preds = %30
  br label %35

34:                                               ; preds = %30
  call void @__assert_fail(ptr noundef @.str.15, ptr noundef @.str.3, i32 noundef 323, ptr noundef @__PRETTY_FUNCTION__.server_unix) #7
  unreachable

35:                                               ; preds = %33
  %36 = getelementptr inbounds [5 x i8], ptr %3, i64 0, i64 0
  %37 = call i32 @sc_sock_recv(ptr noundef %6, ptr noundef %36, i32 noundef 5, i32 noundef 0)
  %38 = icmp eq i32 %37, 5
  br i1 %38, label %39, label %40

39:                                               ; preds = %35
  br label %41

40:                                               ; preds = %35
  call void @__assert_fail(ptr noundef @.str.7, ptr noundef @.str.3, i32 noundef 324, ptr noundef @__PRETTY_FUNCTION__.server_unix) #7
  unreachable

41:                                               ; preds = %39
  %42 = getelementptr inbounds [5 x i8], ptr %3, i64 0, i64 0
  %43 = call i32 @strcmp(ptr noundef @.str.8, ptr noundef %42) #8
  %44 = icmp eq i32 %43, 0
  br i1 %44, label %45, label %46

45:                                               ; preds = %41
  br label %47

46:                                               ; preds = %41
  call void @__assert_fail(ptr noundef @.str.9, ptr noundef @.str.3, i32 noundef 325, ptr noundef @__PRETTY_FUNCTION__.server_unix) #7
  unreachable

47:                                               ; preds = %45
  %48 = call i32 @sc_sock_term(ptr noundef %5)
  %49 = icmp eq i32 %48, 0
  br i1 %49, label %50, label %51

50:                                               ; preds = %47
  br label %52

51:                                               ; preds = %47
  call void @__assert_fail(ptr noundef @.str.10, ptr noundef @.str.3, i32 noundef 327, ptr noundef @__PRETTY_FUNCTION__.server_unix) #7
  unreachable

52:                                               ; preds = %50
  %53 = call i32 @sc_sock_term(ptr noundef %6)
  %54 = icmp eq i32 %53, 0
  br i1 %54, label %55, label %56

55:                                               ; preds = %52
  br label %57

56:                                               ; preds = %52
  call void @__assert_fail(ptr noundef @.str.11, ptr noundef @.str.3, i32 noundef 328, ptr noundef @__PRETTY_FUNCTION__.server_unix) #7
  unreachable

57:                                               ; preds = %55
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 148, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 148, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 128, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 5, ptr %3) #6
  ret ptr null
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind willreturn memory(none) "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 = { noreturn 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 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 #5 = { 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 #6 = { nounwind }
attributes #7 = { noreturn nounwind }
attributes #8 = { nounwind willreturn memory(read) }
attributes #9 = { nounwind willreturn memory(none) }

!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}


; 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.sc_sock = type { %struct.sc_sock_fd, i8, i32, [128 x i8] }
%struct.sc_sock_fd = type { i32, i32, i32 }

@.str.3 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [43 x i8], align 1
@__PRETTY_FUNCTION__.server_unix = external hidden unnamed_addr constant [26 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [16 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 nosync nounwind willreturn memory(none)
declare ptr @__errno_location() local_unnamed_addr #1

declare void @sc_sock_init(ptr noundef, i32 noundef, i1 noundef zeroext, i32 noundef) local_unnamed_addr #2

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

declare void @sc_sock_print(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

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

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

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

declare i32 @sc_sock_term(ptr noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #5

; Function Attrs: nounwind uwtable
define dso_local noalias noundef ptr @server_unix(ptr nocapture noundef readnone %0) local_unnamed_addr #6 {
  %2 = alloca [5 x i8], align 1
  %3 = alloca [128 x i8], align 16
  %4 = alloca %struct.sc_sock, align 4
  %5 = alloca %struct.sc_sock, align 4
  call void @llvm.lifetime.start.p0(i64 5, ptr nonnull %2) #7
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %3) #7
  call void @llvm.lifetime.start.p0(i64 148, ptr nonnull %4) #7
  call void @llvm.lifetime.start.p0(i64 148, ptr nonnull %5) #7
  call void @sc_sock_init(ptr noundef nonnull %4, i32 noundef 0, i1 noundef zeroext true, i32 noundef 1) #7
  %6 = call i32 @sc_sock_listen(ptr noundef nonnull %4, ptr noundef nonnull @.str.30, ptr noundef null) #7
  %7 = icmp eq i32 %6, 0
  br i1 %7, label %9, label %8

8:                                                ; preds = %1
  call void @__assert_fail(ptr noundef nonnull @.str.31, ptr noundef nonnull @.str.3, i32 noundef 315, ptr noundef nonnull @__PRETTY_FUNCTION__.server_unix) #8
  unreachable

9:                                                ; preds = %1
  call void @sc_sock_print(ptr noundef nonnull %4, ptr noundef nonnull %3, i64 noundef 128) #7
  %10 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %3, ptr noundef nonnull dereferenceable(1) @.str.32) #9
  %11 = icmp eq i32 %10, 0
  br i1 %11, label %13, label %12

12:                                               ; preds = %9
  call void @__assert_fail(ptr noundef nonnull @.str.33, ptr noundef nonnull @.str.3, i32 noundef 317, ptr noundef nonnull @__PRETTY_FUNCTION__.server_unix) #8
  unreachable

13:                                               ; preds = %9
  %14 = call i32 @sc_sock_accept(ptr noundef nonnull %4, ptr noundef nonnull %5) #7
  %cond = icmp eq i32 %14, 0
  br i1 %cond, label %20, label %15

15:                                               ; preds = %13
  %16 = tail call ptr @__errno_location() #10
  %17 = load i32, ptr %16, align 4, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %4, i64 20
  %19 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.34, i32 noundef %17, ptr noundef nonnull %18)
  call void @__assert_fail(ptr noundef nonnull @.str.15, ptr noundef nonnull @.str.3, i32 noundef 323, ptr noundef nonnull @__PRETTY_FUNCTION__.server_unix) #8
  unreachable

20:                                               ; preds = %13
  %21 = call i32 @sc_sock_recv(ptr noundef nonnull %5, ptr noundef nonnull %2, i32 noundef 5, i32 noundef 0) #7
  %22 = icmp eq i32 %21, 5
  br i1 %22, label %24, label %23

23:                                               ; preds = %20
  call void @__assert_fail(ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.3, i32 noundef 324, ptr noundef nonnull @__PRETTY_FUNCTION__.server_unix) #8
  unreachable

24:                                               ; preds = %20
  %25 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) @.str.8, ptr noundef nonnull dereferenceable(1) %2) #9
  %26 = icmp eq i32 %25, 0
  br i1 %26, label %28, label %27

27:                                               ; preds = %24
  call void @__assert_fail(ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.3, i32 noundef 325, ptr noundef nonnull @__PRETTY_FUNCTION__.server_unix) #8
  unreachable

28:                                               ; preds = %24
  %29 = call i32 @sc_sock_term(ptr noundef nonnull %4) #7
  %30 = icmp eq i32 %29, 0
  br i1 %30, label %32, label %31

31:                                               ; preds = %28
  call void @__assert_fail(ptr noundef nonnull @.str.10, ptr noundef nonnull @.str.3, i32 noundef 327, ptr noundef nonnull @__PRETTY_FUNCTION__.server_unix) #8
  unreachable

32:                                               ; preds = %28
  %33 = call i32 @sc_sock_term(ptr noundef nonnull %5) #7
  %34 = icmp eq i32 %33, 0
  br i1 %34, label %36, label %35

35:                                               ; preds = %32
  call void @__assert_fail(ptr noundef nonnull @.str.11, ptr noundef nonnull @.str.3, i32 noundef 328, ptr noundef nonnull @__PRETTY_FUNCTION__.server_unix) #8
  unreachable

36:                                               ; preds = %32
  call void @llvm.lifetime.end.p0(i64 148, ptr nonnull %5) #7
  call void @llvm.lifetime.end.p0(i64 148, ptr nonnull %4) #7
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %3) #7
  call void @llvm.lifetime.end.p0(i64 5, ptr nonnull %2) #7
  ret ptr null
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nofree nosync nounwind willreturn memory(none) "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 = { noreturn 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 = { 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 #5 = { nofree 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 #6 = { 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 #7 = { nounwind }
attributes #8 = { noreturn nounwind }
attributes #9 = { nounwind willreturn memory(read) }
attributes #10 = { nounwind willreturn memory(none) }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


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