; LLVM IR from buaazp/zimg :: deps/hiredis (net)

; 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_un = type { i16, [108 x i8] }
%struct.redisContext = type { i32, [128 x i8], i32, i32, ptr, ptr }

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

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__errno_location() #1

; 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
declare hidden i32 @redisSetBlocking(ptr noundef, i32 noundef, i32 noundef) #2

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

; Function Attrs: nounwind uwtable
declare hidden i32 @redisContextWaitReady(ptr noundef, i32 noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @redisContextConnectUnix(ptr noundef %0, ptr noundef %1, ptr noundef %2) #2 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca %struct.sockaddr_un, align 2
  %11 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.redisContext, ptr %12, i32 0, i32 3
  %14 = load i32, ptr %13, align 8, !tbaa !9
  %15 = and i32 %14, 1
  store i32 %15, ptr %9, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 110, ptr %10) #5
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = call i32 @redisCreateSocket(ptr noundef %16, i32 noundef 1)
  store i32 %17, ptr %8, align 4, !tbaa !12
  %18 = icmp slt i32 %17, 0
  br i1 %18, label %19, label %20

19:                                               ; preds = %3
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %69

20:                                               ; preds = %3
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = load i32, ptr %8, align 4, !tbaa !12
  %23 = call i32 @redisSetBlocking(ptr noundef %21, i32 noundef %22, i32 noundef 0)
  %24 = icmp ne i32 %23, 0
  br i1 %24, label %25, label %26

25:                                               ; preds = %20
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %69

26:                                               ; preds = %20
  %27 = getelementptr inbounds %struct.sockaddr_un, ptr %10, i32 0, i32 0
  store i16 1, ptr %27, align 2, !tbaa !13
  %28 = getelementptr inbounds %struct.sockaddr_un, ptr %10, i32 0, i32 1
  %29 = getelementptr inbounds [108 x i8], ptr %28, i64 0, i64 0
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = call ptr @strncpy(ptr noundef %29, ptr noundef %30, i64 noundef 107) #5
  %32 = load i32, ptr %8, align 4, !tbaa !12
  %33 = call i32 @connect(i32 noundef %32, ptr noundef %10, i32 noundef 110)
  %34 = icmp eq i32 %33, -1
  br i1 %34, label %35, label %52

35:                                               ; preds = %26
  %36 = call ptr @__errno_location() #6
  %37 = load i32, ptr %36, align 4, !tbaa !12
  %38 = icmp eq i32 %37, 115
  br i1 %38, label %39, label %43

39:                                               ; preds = %35
  %40 = load i32, ptr %9, align 4, !tbaa !12
  %41 = icmp ne i32 %40, 0
  br i1 %41, label %43, label %42

42:                                               ; preds = %39
  br label %51

43:                                               ; preds = %39, %35
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = load i32, ptr %8, align 4, !tbaa !12
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = call i32 @redisContextWaitReady(ptr noundef %44, i32 noundef %45, ptr noundef %46)
  %48 = icmp ne i32 %47, 0
  br i1 %48, label %49, label %50

49:                                               ; preds = %43
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %69

50:                                               ; preds = %43
  br label %51

51:                                               ; preds = %50, %42
  br label %52

52:                                               ; preds = %51, %26
  %53 = load i32, ptr %9, align 4, !tbaa !12
  %54 = icmp ne i32 %53, 0
  br i1 %54, label %55, label %61

55:                                               ; preds = %52
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = load i32, ptr %8, align 4, !tbaa !12
  %58 = call i32 @redisSetBlocking(ptr noundef %56, i32 noundef %57, i32 noundef 1)
  %59 = icmp ne i32 %58, 0
  br i1 %59, label %60, label %61

60:                                               ; preds = %55
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %69

61:                                               ; preds = %55, %52
  %62 = load i32, ptr %8, align 4, !tbaa !12
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.redisContext, ptr %63, i32 0, i32 2
  store i32 %62, ptr %64, align 4, !tbaa !16
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.redisContext, ptr %65, i32 0, i32 3
  %67 = load i32, ptr %66, align 8, !tbaa !9
  %68 = or i32 %67, 2
  store i32 %68, ptr %66, align 8, !tbaa !9
  store i32 0, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %69

69:                                               ; preds = %61, %60, %49, %25, %19
  call void @llvm.lifetime.end.p0(i64 110, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  %70 = load i32, ptr %4, align 4
  ret i32 %70
}

; Function Attrs: nounwind uwtable
declare hidden i32 @redisCreateSocket(ptr noundef, i32 noundef) #2

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

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 = { 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 #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 "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 = { 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, !11, i64 136}
!10 = !{!"redisContext", !11, i64 0, !7, i64 4, !11, i64 132, !11, i64 136, !6, i64 144, !6, i64 152}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!14, !15, i64 0}
!14 = !{!"sockaddr_un", !15, i64 0, !7, i64 2}
!15 = !{!"short", !7, i64 0}
!16 = !{!10, !11, i64 132}


; 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_un = type { i16, [108 x i8] }

; 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 nofree nosync nounwind willreturn memory(none)
declare ptr @__errno_location() local_unnamed_addr #1

; 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
declare hidden i32 @redisSetBlocking(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

declare i32 @connect(i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden i32 @redisContextWaitReady(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @redisContextConnectUnix(ptr noundef %0, ptr nocapture noundef readonly %1, ptr noundef %2) local_unnamed_addr #2 {
  %4 = alloca %struct.sockaddr_un, align 2
  %5 = getelementptr inbounds i8, ptr %0, i64 136
  %6 = load i32, ptr %5, align 8, !tbaa !5
  %7 = and i32 %6, 1
  call void @llvm.lifetime.start.p0(i64 110, ptr nonnull %4) #5
  %8 = tail call i32 @redisCreateSocket(ptr noundef %0, i32 noundef 1)
  %9 = icmp slt i32 %8, 0
  br i1 %9, label %30, label %10

10:                                               ; preds = %3
  %11 = tail call i32 @redisSetBlocking(ptr noundef nonnull %0, i32 noundef %8, i32 noundef 0)
  %.not = icmp eq i32 %11, 0
  br i1 %.not, label %12, label %30

12:                                               ; preds = %10
  store i16 1, ptr %4, align 2, !tbaa !11
  %13 = getelementptr inbounds i8, ptr %4, i64 2
  %14 = call ptr @strncpy(ptr noundef nonnull dereferenceable(1) %13, ptr noundef nonnull dereferenceable(1) %1, i64 noundef 107) #5
  %15 = call i32 @connect(i32 noundef %8, ptr noundef nonnull %4, i32 noundef 110) #5
  %16 = icmp eq i32 %15, -1
  br i1 %16, label %17, label %24

17:                                               ; preds = %12
  %18 = tail call ptr @__errno_location() #6
  %19 = load i32, ptr %18, align 4, !tbaa !14
  %20 = icmp ne i32 %19, 115
  %21 = icmp ne i32 %7, 0
  %or.cond = select i1 %20, i1 true, i1 %21
  br i1 %or.cond, label %22, label %.thread

22:                                               ; preds = %17
  %23 = call i32 @redisContextWaitReady(ptr noundef nonnull %0, i32 noundef %8, ptr noundef %2)
  %.not18 = icmp eq i32 %23, 0
  br i1 %.not18, label %24, label %30

24:                                               ; preds = %22, %12
  %.not19 = icmp eq i32 %7, 0
  br i1 %.not19, label %.thread, label %25

25:                                               ; preds = %24
  %26 = call i32 @redisSetBlocking(ptr noundef nonnull %0, i32 noundef %8, i32 noundef 1)
  %.not20 = icmp eq i32 %26, 0
  br i1 %.not20, label %.thread, label %30

.thread:                                          ; preds = %17, %25, %24
  %27 = getelementptr inbounds i8, ptr %0, i64 132
  store i32 %8, ptr %27, align 4, !tbaa !15
  %28 = load i32, ptr %5, align 8, !tbaa !5
  %29 = or i32 %28, 2
  store i32 %29, ptr %5, align 8, !tbaa !5
  br label %30

30:                                               ; preds = %25, %22, %10, %3, %.thread
  %.0 = phi i32 [ 0, %.thread ], [ -1, %3 ], [ -1, %10 ], [ -1, %22 ], [ -1, %25 ]
  call void @llvm.lifetime.end.p0(i64 110, ptr nonnull %4) #5
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare hidden i32 @redisCreateSocket(ptr noundef, i32 noundef) local_unnamed_addr #2

; 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 #4

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 = { 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 #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 = { 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 #5 = { nounwind }
attributes #6 = { 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, !7, i64 136}
!6 = !{!"redisContext", !7, i64 0, !8, i64 4, !7, i64 132, !7, i64 136, !10, i64 144, !10, i64 152}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"sockaddr_un", !13, i64 0, !8, i64 2}
!13 = !{!"short", !8, i64 0}
!14 = !{!7, !7, i64 0}
!15 = !{!6, !7, i64 132}


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