; 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.8 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [30 x i8], align 1
@__PRETTY_FUNCTION__.client_unix = external hidden unnamed_addr constant [26 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

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

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

declare i32 @sc_sock_term(ptr noundef) #1

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

declare i32 @sc_sock_connect(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

declare i32 @sleep(i32 noundef) #1

declare i32 @sc_sock_send(ptr noundef, ptr noundef, i32 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @client_unix(ptr noundef %0) #3 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca %struct.sc_sock, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 148, ptr %4) #4
  %8 = call i32 @sleep(i32 noundef 3)
  call void @sc_sock_init(ptr noundef %4, i32 noundef 0, i1 noundef zeroext true, i32 noundef 1)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %9

9:                                                ; preds = %23, %1
  %10 = load i32, ptr %5, align 4, !tbaa !9
  %11 = icmp slt i32 %10, 10
  br i1 %11, label %13, label %12

12:                                               ; preds = %9
  store i32 2, ptr %6, align 4
  br label %26

13:                                               ; preds = %9
  %14 = call i32 (ptr, ...) @printf(ptr noundef @.str.35)
  %15 = call i32 @sc_sock_connect(ptr noundef %4, ptr noundef @.str.30, ptr noundef null, ptr noundef null, ptr noundef null)
  store i32 %15, ptr %3, align 4, !tbaa !9
  %16 = load i32, ptr %3, align 4, !tbaa !9
  %17 = icmp eq i32 %16, 0
  br i1 %17, label %18, label %20

18:                                               ; preds = %13
  %19 = call i32 (ptr, ...) @printf(ptr noundef @.str.36)
  store i32 2, ptr %6, align 4
  br label %26

20:                                               ; preds = %13
  %21 = call i32 (ptr, ...) @printf(ptr noundef @.str.37)
  %22 = call i32 @sleep(i32 noundef 1)
  br label %23

23:                                               ; preds = %20
  %24 = load i32, ptr %5, align 4, !tbaa !9
  %25 = add nsw i32 %24, 1
  store i32 %25, ptr %5, align 4, !tbaa !9
  br label %9, !llvm.loop !11

26:                                               ; preds = %18, %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %27

27:                                               ; preds = %26
  %28 = load i32, ptr %3, align 4, !tbaa !9
  %29 = icmp eq i32 %28, 0
  br i1 %29, label %30, label %31

30:                                               ; preds = %27
  br label %32

31:                                               ; preds = %27
  call void @__assert_fail(ptr noundef @.str.15, ptr noundef @.str.3, i32 noundef 353, ptr noundef @__PRETTY_FUNCTION__.client_unix) #5
  unreachable

32:                                               ; preds = %30
  %33 = call i32 @sc_sock_send(ptr noundef %4, ptr noundef @.str.8, i32 noundef 5, i32 noundef 0)
  %34 = icmp eq i32 %33, 5
  br i1 %34, label %35, label %36

35:                                               ; preds = %32
  br label %37

36:                                               ; preds = %32
  call void @__assert_fail(ptr noundef @.str.18, ptr noundef @.str.3, i32 noundef 354, ptr noundef @__PRETTY_FUNCTION__.client_unix) #5
  unreachable

37:                                               ; preds = %35
  %38 = call i32 @sc_sock_term(ptr noundef %4)
  %39 = icmp eq i32 %38, 0
  br i1 %39, label %40, label %41

40:                                               ; preds = %37
  br label %42

41:                                               ; preds = %37
  call void @__assert_fail(ptr noundef @.str.10, ptr noundef @.str.3, i32 noundef 355, ptr noundef @__PRETTY_FUNCTION__.client_unix) #5
  unreachable

42:                                               ; preds = %40
  store i32 1, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 148, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  ret ptr null
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { 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 #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 = { nounwind }
attributes #5 = { noreturn 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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; 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.8 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [30 x i8], align 1
@__PRETTY_FUNCTION__.client_unix = external hidden unnamed_addr constant [26 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

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

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

declare i32 @sc_sock_term(ptr noundef) local_unnamed_addr #1

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

declare i32 @sc_sock_connect(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare i32 @sleep(i32 noundef) local_unnamed_addr #1

declare i32 @sc_sock_send(ptr noundef, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noalias noundef ptr @client_unix(ptr nocapture noundef readnone %0) local_unnamed_addr #4 {
  %2 = alloca %struct.sc_sock, align 4
  call void @llvm.lifetime.start.p0(i64 148, ptr nonnull %2) #5
  %3 = tail call i32 @sleep(i32 noundef 3) #5
  call void @sc_sock_init(ptr noundef nonnull %2, i32 noundef 0, i1 noundef zeroext true, i32 noundef 1) #5
  %4 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.35)
  %5 = call i32 @sc_sock_connect(ptr noundef nonnull %2, ptr noundef nonnull @.str.30, ptr noundef null, ptr noundef null, ptr noundef null) #5
  %6 = icmp eq i32 %5, 0
  br i1 %6, label %63, label %7

7:                                                ; preds = %1
  %8 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.37)
  %9 = call i32 @sleep(i32 noundef 1) #5
  %10 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.35)
  %11 = call i32 @sc_sock_connect(ptr noundef nonnull %2, ptr noundef nonnull @.str.30, ptr noundef null, ptr noundef null, ptr noundef null) #5
  %12 = icmp eq i32 %11, 0
  br i1 %12, label %63, label %13

13:                                               ; preds = %7
  %14 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.37)
  %15 = call i32 @sleep(i32 noundef 1) #5
  %16 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.35)
  %17 = call i32 @sc_sock_connect(ptr noundef nonnull %2, ptr noundef nonnull @.str.30, ptr noundef null, ptr noundef null, ptr noundef null) #5
  %18 = icmp eq i32 %17, 0
  br i1 %18, label %63, label %19

19:                                               ; preds = %13
  %20 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.37)
  %21 = call i32 @sleep(i32 noundef 1) #5
  %22 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.35)
  %23 = call i32 @sc_sock_connect(ptr noundef nonnull %2, ptr noundef nonnull @.str.30, ptr noundef null, ptr noundef null, ptr noundef null) #5
  %24 = icmp eq i32 %23, 0
  br i1 %24, label %63, label %25

25:                                               ; preds = %19
  %26 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.37)
  %27 = call i32 @sleep(i32 noundef 1) #5
  %28 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.35)
  %29 = call i32 @sc_sock_connect(ptr noundef nonnull %2, ptr noundef nonnull @.str.30, ptr noundef null, ptr noundef null, ptr noundef null) #5
  %30 = icmp eq i32 %29, 0
  br i1 %30, label %63, label %31

31:                                               ; preds = %25
  %32 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.37)
  %33 = call i32 @sleep(i32 noundef 1) #5
  %34 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.35)
  %35 = call i32 @sc_sock_connect(ptr noundef nonnull %2, ptr noundef nonnull @.str.30, ptr noundef null, ptr noundef null, ptr noundef null) #5
  %36 = icmp eq i32 %35, 0
  br i1 %36, label %63, label %37

37:                                               ; preds = %31
  %38 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.37)
  %39 = call i32 @sleep(i32 noundef 1) #5
  %40 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.35)
  %41 = call i32 @sc_sock_connect(ptr noundef nonnull %2, ptr noundef nonnull @.str.30, ptr noundef null, ptr noundef null, ptr noundef null) #5
  %42 = icmp eq i32 %41, 0
  br i1 %42, label %63, label %43

43:                                               ; preds = %37
  %44 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.37)
  %45 = call i32 @sleep(i32 noundef 1) #5
  %46 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.35)
  %47 = call i32 @sc_sock_connect(ptr noundef nonnull %2, ptr noundef nonnull @.str.30, ptr noundef null, ptr noundef null, ptr noundef null) #5
  %48 = icmp eq i32 %47, 0
  br i1 %48, label %63, label %49

49:                                               ; preds = %43
  %50 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.37)
  %51 = call i32 @sleep(i32 noundef 1) #5
  %52 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.35)
  %53 = call i32 @sc_sock_connect(ptr noundef nonnull %2, ptr noundef nonnull @.str.30, ptr noundef null, ptr noundef null, ptr noundef null) #5
  %54 = icmp eq i32 %53, 0
  br i1 %54, label %63, label %55

55:                                               ; preds = %49
  %56 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.37)
  %57 = call i32 @sleep(i32 noundef 1) #5
  %58 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.35)
  %59 = call i32 @sc_sock_connect(ptr noundef nonnull %2, ptr noundef nonnull @.str.30, ptr noundef null, ptr noundef null, ptr noundef null) #5
  %60 = icmp eq i32 %59, 0
  br i1 %60, label %63, label %.critedge

.critedge:                                        ; preds = %55
  %61 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.37)
  %62 = call i32 @sleep(i32 noundef 1) #5
  call void @__assert_fail(ptr noundef nonnull @.str.15, ptr noundef nonnull @.str.3, i32 noundef 353, ptr noundef nonnull @__PRETTY_FUNCTION__.client_unix) #6
  unreachable

63:                                               ; preds = %55, %49, %43, %37, %31, %25, %19, %13, %7, %1
  %64 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.36)
  %65 = call i32 @sc_sock_send(ptr noundef nonnull %2, ptr noundef nonnull @.str.8, i32 noundef 5, i32 noundef 0) #5
  %66 = icmp eq i32 %65, 5
  br i1 %66, label %68, label %67

67:                                               ; preds = %63
  call void @__assert_fail(ptr noundef nonnull @.str.18, ptr noundef nonnull @.str.3, i32 noundef 354, ptr noundef nonnull @__PRETTY_FUNCTION__.client_unix) #6
  unreachable

68:                                               ; preds = %63
  %69 = call i32 @sc_sock_term(ptr noundef nonnull %2) #5
  %70 = icmp eq i32 %69, 0
  br i1 %70, label %72, label %71

71:                                               ; preds = %68
  call void @__assert_fail(ptr noundef nonnull @.str.10, ptr noundef nonnull @.str.3, i32 noundef 355, ptr noundef nonnull @__PRETTY_FUNCTION__.client_unix) #6
  unreachable

72:                                               ; preds = %68
  call void @llvm.lifetime.end.p0(i64 148, ptr nonnull %2) #5
  ret ptr null
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { 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 #3 = { 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 #4 = { 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 = { nounwind }
attributes #6 = { noreturn 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)"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass