; LLVM IR from golems/ach :: src/achd (client)

; 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.achd_cx = type { %struct.achd_headers, i32, i32, i32, i32, ptr, i32, %struct.ach_channel, ptr }
%struct.achd_headers = type { ptr, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i64, ptr, ptr, i32, i32, ptr }
%struct.ach_channel = type { %union.anon }
%union.anon = type { [16 x i64] }
%struct.achd_conn = type { i32, %struct.timespec, %struct.timespec, %struct.achd_headers, %struct.achd_headers, i32, i32, i32, i64, ptr, ptr, ptr }
%struct.timespec = type { i64, i64 }
%struct.achd_conn_vtab = type { ptr, i32, ptr, ptr }
%struct.ach_header = type { i32, i64, [65 x i8], %union.anon.1, %struct.anon.3, i64 }
%union.anon.1 = type { [16 x i64] }
%struct.anon.3 = type { %union.pthread_mutex_t, %union.pthread_cond_t, i32 }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%union.pthread_cond_t = type { %struct.__pthread_cond_s }
%struct.__pthread_cond_s = type { %union.__atomic_wide_counter, %union.__atomic_wide_counter, [2 x i32], [2 x i32], i32, i32, [2 x i32] }
%union.__atomic_wide_counter = type { i64 }
%struct.anon.2 = type { i64, i64, i64, i64, i64, i64, i32, i32 }

@.str = external hidden unnamed_addr constant [12 x i8], align 1
@opt_posarg = external global [2 x ptr], align 16
@cx = external global %struct.achd_cx, align 8
@.str.1 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [62 x i8], align 1
@__PRETTY_FUNCTION__.achd_client = external hidden unnamed_addr constant [19 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [91 x i8], align 1
@ach_verbosity = external global i32, align 4
@.str.9 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [13 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @achd_client() #0 {
  %1 = alloca %struct.achd_conn, align 8
  %2 = alloca [512 x i8], align 16
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  call void @openlog(ptr noundef @.str, i32 noundef 1, i32 noundef 24)
  call void @llvm.lifetime.start.p0(i64 264, ptr %1) #7
  call void @llvm.memset.p0.i64(ptr align 8 %1, i8 0, i64 264, i1 false)
  %7 = load ptr, ptr getelementptr inbounds ([2 x ptr], ptr @opt_posarg, i64 0, i64 1), align 8, !tbaa !5
  %8 = icmp ne ptr %7, null
  br i1 %8, label %9, label %11

9:                                                ; preds = %0
  %10 = load ptr, ptr getelementptr inbounds ([2 x ptr], ptr @opt_posarg, i64 0, i64 1), align 8, !tbaa !5
  store ptr %10, ptr @cx, align 8, !tbaa !9
  br label %19

11:                                               ; preds = %0
  %12 = load ptr, ptr @opt_posarg, align 16, !tbaa !5
  %13 = icmp ne ptr %12, null
  br i1 %13, label %14, label %16

14:                                               ; preds = %11
  %15 = load ptr, ptr @opt_posarg, align 16, !tbaa !5
  store ptr %15, ptr @cx, align 8, !tbaa !9
  br label %18

16:                                               ; preds = %11
  %17 = load ptr, ptr getelementptr inbounds (%struct.achd_cx, ptr @cx, i32 0, i32 8), align 8, !tbaa !15
  call void (i32, ptr, ...) %17(i32 noundef 14, ptr noundef @.str.1)
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.3, i32 noundef 90, ptr noundef @__PRETTY_FUNCTION__.achd_client) #8
  unreachable

18:                                               ; preds = %14
  br label %19

19:                                               ; preds = %18, %9
  %20 = load ptr, ptr getelementptr inbounds (%struct.achd_headers, ptr @cx, i32 0, i32 1), align 8, !tbaa !16
  %21 = icmp ne ptr %20, null
  br i1 %21, label %22, label %26

22:                                               ; preds = %19
  %23 = load ptr, ptr getelementptr inbounds (%struct.achd_headers, ptr @cx, i32 0, i32 1), align 8, !tbaa !16
  %24 = getelementptr inbounds %struct.achd_conn, ptr %1, i32 0, i32 3
  %25 = getelementptr inbounds %struct.achd_headers, ptr %24, i32 0, i32 0
  store ptr %23, ptr %25, align 8, !tbaa !17
  br label %30

26:                                               ; preds = %19
  %27 = load ptr, ptr @cx, align 8, !tbaa !9
  %28 = getelementptr inbounds %struct.achd_conn, ptr %1, i32 0, i32 3
  %29 = getelementptr inbounds %struct.achd_headers, ptr %28, i32 0, i32 0
  store ptr %27, ptr %29, align 8, !tbaa !17
  br label %30

30:                                               ; preds = %26, %22
  %31 = load ptr, ptr getelementptr inbounds ([2 x ptr], ptr @opt_posarg, i64 0, i64 1), align 8, !tbaa !5
  %32 = icmp ne ptr %31, null
  br i1 %32, label %33, label %35

33:                                               ; preds = %30
  %34 = load ptr, ptr @opt_posarg, align 16, !tbaa !5
  store ptr %34, ptr getelementptr inbounds (%struct.achd_headers, ptr @cx, i32 0, i32 11), align 8, !tbaa !20
  br label %52

35:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 512, ptr %2) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  %36 = getelementptr inbounds %struct.achd_conn, ptr %1, i32 0, i32 3
  %37 = getelementptr inbounds %struct.achd_headers, ptr %36, i32 0, i32 0
  %38 = load ptr, ptr %37, align 8, !tbaa !17
  %39 = getelementptr inbounds [512 x i8], ptr %2, i64 0, i64 0
  %40 = call i32 @ach_srv_search(ptr noundef %38, ptr noundef @.str.4, ptr noundef %39, i64 noundef 512, ptr noundef %3)
  store i32 %40, ptr %4, align 4, !tbaa !21
  %41 = load i32, ptr %4, align 4, !tbaa !21
  %42 = icmp ne i32 0, %41
  br i1 %42, label %43, label %49

43:                                               ; preds = %35
  %44 = load ptr, ptr getelementptr inbounds (%struct.achd_cx, ptr @cx, i32 0, i32 8), align 8, !tbaa !15
  %45 = load i32, ptr %4, align 4, !tbaa !21
  %46 = getelementptr inbounds %struct.achd_conn, ptr %1, i32 0, i32 3
  %47 = getelementptr inbounds %struct.achd_headers, ptr %46, i32 0, i32 0
  %48 = load ptr, ptr %47, align 8, !tbaa !17
  call void (i32, ptr, ...) %44(i32 noundef %45, ptr noundef @.str.5, ptr noundef %48)
  br label %49

49:                                               ; preds = %43, %35
  %50 = getelementptr inbounds [512 x i8], ptr %2, i64 0, i64 0
  %51 = call noalias ptr @strdup(ptr noundef %50) #7
  store ptr %51, ptr getelementptr inbounds (%struct.achd_headers, ptr @cx, i32 0, i32 11), align 8, !tbaa !20
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  call void @llvm.lifetime.end.p0(i64 512, ptr %2) #7
  br label %52

52:                                               ; preds = %49, %33
  %53 = load ptr, ptr getelementptr inbounds (%struct.achd_headers, ptr @cx, i32 0, i32 12), align 8, !tbaa !22
  %54 = load i32, ptr getelementptr inbounds (%struct.achd_headers, ptr @cx, i32 0, i32 13), align 8, !tbaa !23
  %55 = call ptr @achd_get_vtab(ptr noundef %53, i32 noundef %54)
  %56 = getelementptr inbounds %struct.achd_conn, ptr %1, i32 0, i32 10
  store ptr %55, ptr %56, align 8, !tbaa !24
  %57 = getelementptr inbounds %struct.achd_conn, ptr %1, i32 0, i32 10
  %58 = load ptr, ptr %57, align 8, !tbaa !24
  %59 = icmp ne ptr %58, null
  br i1 %59, label %60, label %67

60:                                               ; preds = %52
  %61 = getelementptr inbounds %struct.achd_conn, ptr %1, i32 0, i32 10
  %62 = load ptr, ptr %61, align 8, !tbaa !24
  %63 = getelementptr inbounds %struct.achd_conn_vtab, ptr %62, i32 0, i32 3
  %64 = load ptr, ptr %63, align 8, !tbaa !25
  %65 = icmp ne ptr %64, null
  br i1 %65, label %66, label %67

66:                                               ; preds = %60
  br label %68

67:                                               ; preds = %60, %52
  call void @__assert_fail(ptr noundef @.str.6, ptr noundef @.str.3, i32 noundef 116, ptr noundef @__PRETTY_FUNCTION__.achd_client) #8
  unreachable

68:                                               ; preds = %66
  %69 = load ptr, ptr getelementptr inbounds (%struct.achd_headers, ptr @cx, i32 0, i32 12), align 8, !tbaa !22
  %70 = icmp ne ptr %69, null
  br i1 %70, label %71, label %72

71:                                               ; preds = %68
  br label %73

72:                                               ; preds = %68
  call void @__assert_fail(ptr noundef @.str.7, ptr noundef @.str.3, i32 noundef 118, ptr noundef @__PRETTY_FUNCTION__.achd_client) #8
  unreachable

73:                                               ; preds = %71
  %74 = load i32, ptr getelementptr inbounds (%struct.achd_headers, ptr @cx, i32 0, i32 13), align 8, !tbaa !23
  %75 = icmp eq i32 %74, 1
  br i1 %75, label %79, label %76

76:                                               ; preds = %73
  %77 = load i32, ptr getelementptr inbounds (%struct.achd_headers, ptr @cx, i32 0, i32 13), align 8, !tbaa !23
  %78 = icmp eq i32 %77, 2
  br i1 %78, label %79, label %80

79:                                               ; preds = %76, %73
  br label %81

80:                                               ; preds = %76
  call void @__assert_fail(ptr noundef @.str.8, ptr noundef @.str.3, i32 noundef 120, ptr noundef @__PRETTY_FUNCTION__.achd_client) #8
  unreachable

81:                                               ; preds = %79
  %82 = load ptr, ptr getelementptr inbounds (%struct.achd_headers, ptr @cx, i32 0, i32 12), align 8, !tbaa !22
  %83 = getelementptr inbounds %struct.achd_conn, ptr %1, i32 0, i32 3
  %84 = getelementptr inbounds %struct.achd_headers, ptr %83, i32 0, i32 12
  store ptr %82, ptr %84, align 8, !tbaa !27
  %85 = load i64, ptr getelementptr inbounds (%struct.achd_headers, ptr @cx, i32 0, i32 10), align 8, !tbaa !28
  %86 = getelementptr inbounds %struct.achd_conn, ptr %1, i32 0, i32 3
  %87 = getelementptr inbounds %struct.achd_headers, ptr %86, i32 0, i32 10
  store i64 %85, ptr %87, align 8, !tbaa !29
  %88 = load i32, ptr getelementptr inbounds (%struct.achd_headers, ptr @cx, i32 0, i32 8), align 8, !tbaa !30
  %89 = getelementptr inbounds %struct.achd_conn, ptr %1, i32 0, i32 3
  %90 = getelementptr inbounds %struct.achd_headers, ptr %89, i32 0, i32 8
  store i32 %88, ptr %90, align 8, !tbaa !31
  call void @sighandler_install()
  %91 = load i32, ptr getelementptr inbounds (%struct.achd_cx, ptr @cx, i32 0, i32 4), align 4, !tbaa !32
  %92 = icmp ne i32 %91, 0
  br i1 %92, label %93, label %132

93:                                               ; preds = %81
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  %94 = call i32 @ach_detach(i32 noundef 3)
  store i32 %94, ptr %5, align 4, !tbaa !21
  %95 = call i32 @close(i32 noundef 1)
  %96 = icmp ne i32 %95, 0
  br i1 %96, label %97, label %106

97:                                               ; preds = %93
  %98 = load i32, ptr @ach_verbosity, align 4, !tbaa !21
  %99 = add nsw i32 5, %98
  %100 = icmp sle i32 3, %99
  br i1 %100, label %101, label %105

101:                                              ; preds = %97
  %102 = call ptr @__errno_location() #9
  %103 = load i32, ptr %102, align 4, !tbaa !21
  %104 = call ptr @strerror(i32 noundef %103) #7
  call void (i32, ptr, ...) @ach_log(i32 noundef 3, ptr noundef @.str.9, ptr noundef %104)
  br label %105

105:                                              ; preds = %101, %97
  br label %106

106:                                              ; preds = %105, %93
  %107 = call i32 @close(i32 noundef 2)
  %108 = icmp ne i32 %107, 0
  br i1 %108, label %109, label %118

109:                                              ; preds = %106
  %110 = load i32, ptr @ach_verbosity, align 4, !tbaa !21
  %111 = add nsw i32 5, %110
  %112 = icmp sle i32 3, %111
  br i1 %112, label %113, label %117

113:                                              ; preds = %109
  %114 = call ptr @__errno_location() #9
  %115 = load i32, ptr %114, align 4, !tbaa !21
  %116 = call ptr @strerror(i32 noundef %115) #7
  call void (i32, ptr, ...) @ach_log(i32 noundef 3, ptr noundef @.str.10, ptr noundef %116)
  br label %117

117:                                              ; preds = %113, %109
  br label %118

118:                                              ; preds = %117, %106
  %119 = load i32, ptr %5, align 4, !tbaa !21
  %120 = call i32 @kill(i32 noundef %119, i32 noundef 10) #7
  %121 = icmp ne i32 %120, 0
  br i1 %121, label %122, label %131

122:                                              ; preds = %118
  %123 = load i32, ptr @ach_verbosity, align 4, !tbaa !21
  %124 = add nsw i32 5, %123
  %125 = icmp sle i32 3, %124
  br i1 %125, label %126, label %130

126:                                              ; preds = %122
  %127 = call ptr @__errno_location() #9
  %128 = load i32, ptr %127, align 4, !tbaa !21
  %129 = call ptr @strerror(i32 noundef %128) #7
  call void (i32, ptr, ...) @ach_log(i32 noundef 3, ptr noundef @.str.11, ptr noundef %129)
  br label %130

130:                                              ; preds = %126, %122
  br label %131

131:                                              ; preds = %130, %118
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  br label %132

132:                                              ; preds = %131, %81
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  %133 = call i32 @server_connect(ptr noundef %1)
  store i32 %133, ptr %6, align 4, !tbaa !21
  %134 = load i32, ptr %6, align 4, !tbaa !21
  %135 = icmp slt i32 %134, 0
  br i1 %135, label %136, label %142

136:                                              ; preds = %132
  %137 = load i32, ptr @ach_verbosity, align 4, !tbaa !21
  %138 = add nsw i32 5, %137
  %139 = icmp sle i32 3, %138
  br i1 %139, label %140, label %141

140:                                              ; preds = %136
  call void (i32, ptr, ...) @ach_log(i32 noundef 3, ptr noundef @.str.12)
  br label %141

141:                                              ; preds = %140, %136
  call void @ach_die()
  br label %142

142:                                              ; preds = %141, %132
  %143 = load ptr, ptr getelementptr inbounds (%struct.achd_cx, ptr @cx, i32 0, i32 7), align 8, !tbaa !33
  %144 = getelementptr inbounds %struct.ach_header, ptr %143, i32 0, i32 3
  %145 = getelementptr inbounds %struct.anon.2, ptr %144, i32 0, i32 1
  %146 = load i64, ptr %145, align 8, !tbaa !33
  %147 = load ptr, ptr getelementptr inbounds (%struct.achd_cx, ptr @cx, i32 0, i32 7), align 8, !tbaa !33
  %148 = getelementptr inbounds %struct.ach_header, ptr %147, i32 0, i32 3
  %149 = getelementptr inbounds %struct.anon.2, ptr %148, i32 0, i32 0
  %150 = load i64, ptr %149, align 8, !tbaa !33
  %151 = udiv i64 %146, %150
  %152 = getelementptr inbounds %struct.achd_conn, ptr %1, i32 0, i32 8
  store i64 %151, ptr %152, align 8, !tbaa !34
  %153 = getelementptr inbounds %struct.achd_conn, ptr %1, i32 0, i32 8
  %154 = load i64, ptr %153, align 8, !tbaa !34
  %155 = call ptr @ach_pipe_alloc(i64 noundef %154)
  %156 = getelementptr inbounds %struct.achd_conn, ptr %1, i32 0, i32 9
  store ptr %155, ptr %156, align 8, !tbaa !35
  call void @ach_notify(i32 noundef 10)
  %157 = load i32, ptr %6, align 4, !tbaa !21
  %158 = icmp sge i32 %157, 0
  br i1 %158, label %159, label %177

159:                                              ; preds = %142
  %160 = load i32, ptr getelementptr inbounds (%struct.achd_cx, ptr @cx, i32 0, i32 6), align 8, !tbaa !36
  %161 = icmp ne i32 %160, 0
  br i1 %161, label %177, label %162

162:                                              ; preds = %159
  %163 = load i32, ptr @ach_verbosity, align 4, !tbaa !21
  %164 = add nsw i32 5, %163
  %165 = icmp sle i32 6, %164
  br i1 %165, label %166, label %167

166:                                              ; preds = %162
  call void (i32, ptr, ...) @ach_log(i32 noundef 6, ptr noundef @.str.13)
  br label %167

167:                                              ; preds = %166, %162
  %168 = getelementptr inbounds %struct.achd_conn, ptr %1, i32 0, i32 10
  %169 = load ptr, ptr %168, align 8, !tbaa !24
  %170 = getelementptr inbounds %struct.achd_conn_vtab, ptr %169, i32 0, i32 3
  %171 = load ptr, ptr %170, align 8, !tbaa !25
  call void %171(ptr noundef %1)
  %172 = load i32, ptr @ach_verbosity, align 4, !tbaa !21
  %173 = add nsw i32 5, %172
  %174 = icmp sle i32 6, %173
  br i1 %174, label %175, label %176

175:                                              ; preds = %167
  call void (i32, ptr, ...) @ach_log(i32 noundef 6, ptr noundef @.str.14)
  br label %176

176:                                              ; preds = %175, %167
  br label %177

177:                                              ; preds = %176, %159, %142
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 264, ptr %1) #7
  ret void
}

declare void @openlog(ptr noundef, i32 noundef, i32 noundef) #1

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

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

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

declare i32 @ach_srv_search(ptr noundef, ptr noundef, ptr noundef, i64 noundef, ptr noundef) #1

; Function Attrs: nounwind
declare noalias ptr @strdup(ptr noundef) #5

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

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

declare void @sighandler_install() #1

declare i32 @ach_detach(i32 noundef) #1

declare i32 @close(i32 noundef) #1

declare void @ach_log(i32 noundef, ptr noundef, ...) #1

; Function Attrs: nounwind
declare ptr @strerror(i32 noundef) #5

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

; Function Attrs: nounwind
declare i32 @kill(i32 noundef, i32 noundef) #5

; Function Attrs: nounwind uwtable
declare hidden i32 @server_connect(ptr noundef) #0

declare void @ach_die() #1

declare ptr @ach_pipe_alloc(i64 noundef) #1

declare void @ach_notify(i32 noundef) #1

attributes #0 = { 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 #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 #5 = { 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 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 #7 = { nounwind }
attributes #8 = { noreturn nounwind }
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, !6, i64 0}
!10 = !{!"achd_cx", !11, i64 0, !12, i64 88, !12, i64 92, !12, i64 96, !12, i64 100, !6, i64 104, !12, i64 112, !14, i64 120, !6, i64 248}
!11 = !{!"achd_headers", !6, i64 0, !6, i64 8, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !12, i64 40, !12, i64 44, !13, i64 48, !6, i64 56, !6, i64 64, !12, i64 72, !12, i64 76, !6, i64 80}
!12 = !{!"int", !7, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!"ach_channel", !7, i64 0}
!15 = !{!10, !6, i64 248}
!16 = !{!10, !6, i64 8}
!17 = !{!18, !6, i64 40}
!18 = !{!"achd_conn", !12, i64 0, !19, i64 8, !19, i64 24, !11, i64 40, !11, i64 128, !12, i64 216, !12, i64 220, !12, i64 224, !13, i64 232, !6, i64 240, !6, i64 248, !6, i64 256}
!19 = !{!"timespec", !13, i64 0, !13, i64 8}
!20 = !{!10, !6, i64 56}
!21 = !{!12, !12, i64 0}
!22 = !{!10, !6, i64 64}
!23 = !{!10, !12, i64 72}
!24 = !{!18, !6, i64 248}
!25 = !{!26, !6, i64 24}
!26 = !{!"achd_conn_vtab", !6, i64 0, !12, i64 8, !6, i64 16, !6, i64 24}
!27 = !{!18, !6, i64 104}
!28 = !{!10, !13, i64 48}
!29 = !{!18, !13, i64 88}
!30 = !{!10, !12, i64 40}
!31 = !{!18, !12, i64 80}
!32 = !{!10, !12, i64 100}
!33 = !{!7, !7, i64 0}
!34 = !{!18, !13, i64 232}
!35 = !{!18, !6, i64 240}
!36 = !{!10, !12, i64 112}


; 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.achd_cx = type { %struct.achd_headers, i32, i32, i32, i32, ptr, i32, %struct.ach_channel, ptr }
%struct.achd_headers = type { ptr, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i64, ptr, ptr, i32, i32, ptr }
%struct.ach_channel = type { %union.anon }
%union.anon = type { [16 x i64] }
%struct.achd_conn = type { i32, %struct.timespec, %struct.timespec, %struct.achd_headers, %struct.achd_headers, i32, i32, i32, i64, ptr, ptr, ptr }
%struct.timespec = type { i64, i64 }

@.str = external hidden unnamed_addr constant [12 x i8], align 1
@opt_posarg = external local_unnamed_addr global [2 x ptr], align 16
@cx = external local_unnamed_addr global %struct.achd_cx, align 8
@.str.1 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [62 x i8], align 1
@__PRETTY_FUNCTION__.achd_client = external hidden unnamed_addr constant [19 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [91 x i8], align 1
@ach_verbosity = external local_unnamed_addr global i32, align 4
@.str.9 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [13 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @achd_client() local_unnamed_addr #0 {
  %1 = alloca %struct.achd_conn, align 8
  %2 = alloca [512 x i8], align 16
  %3 = alloca i32, align 4
  tail call void @openlog(ptr noundef nonnull @.str, i32 noundef 1, i32 noundef 24) #8
  call void @llvm.lifetime.start.p0(i64 264, ptr nonnull %1) #8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(264) %1, i8 0, i64 264, i1 false)
  %4 = load ptr, ptr getelementptr inbounds (i8, ptr @opt_posarg, i64 8), align 8, !tbaa !5
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %5, label %9

5:                                                ; preds = %0
  %6 = load ptr, ptr @opt_posarg, align 16, !tbaa !5
  %.not13 = icmp eq ptr %6, null
  br i1 %.not13, label %7, label %9

7:                                                ; preds = %5
  %8 = load ptr, ptr getelementptr inbounds (i8, ptr @cx, i64 248), align 8, !tbaa !9
  tail call void (i32, ptr, ...) %8(i32 noundef 14, ptr noundef nonnull @.str.1) #8
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, i32 noundef 90, ptr noundef nonnull @__PRETTY_FUNCTION__.achd_client) #9
  unreachable

9:                                                ; preds = %5, %0
  %storemerge = phi ptr [ %4, %0 ], [ %6, %5 ]
  store ptr %storemerge, ptr @cx, align 8, !tbaa !15
  %10 = load ptr, ptr getelementptr inbounds (i8, ptr @cx, i64 8), align 8, !tbaa !16
  %.not14 = icmp eq ptr %10, null
  %spec.select = select i1 %.not14, ptr %storemerge, ptr %10
  %11 = getelementptr inbounds i8, ptr %1, i64 40
  store ptr %spec.select, ptr %11, align 8
  br i1 %.not, label %14, label %12

12:                                               ; preds = %9
  %13 = load ptr, ptr @opt_posarg, align 16, !tbaa !5
  store ptr %13, ptr getelementptr inbounds (i8, ptr @cx, i64 56), align 8, !tbaa !17
  br label %21

14:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 512, ptr nonnull %2) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #8
  %15 = call i32 @ach_srv_search(ptr noundef nonnull %spec.select, ptr noundef nonnull @.str.4, ptr noundef nonnull %2, i64 noundef 512, ptr noundef nonnull %3) #8
  %.not16 = icmp eq i32 %15, 0
  br i1 %.not16, label %19, label %16

16:                                               ; preds = %14
  %17 = load ptr, ptr getelementptr inbounds (i8, ptr @cx, i64 248), align 8, !tbaa !9
  %18 = load ptr, ptr %11, align 8, !tbaa !18
  call void (i32, ptr, ...) %17(i32 noundef %15, ptr noundef nonnull @.str.5, ptr noundef %18) #8
  br label %19

19:                                               ; preds = %16, %14
  %20 = call noalias ptr @strdup(ptr noundef nonnull %2) #8
  store ptr %20, ptr getelementptr inbounds (i8, ptr @cx, i64 56), align 8, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #8
  call void @llvm.lifetime.end.p0(i64 512, ptr nonnull %2) #8
  br label %21

21:                                               ; preds = %19, %12
  %22 = load ptr, ptr getelementptr inbounds (i8, ptr @cx, i64 64), align 8, !tbaa !21
  %23 = load i32, ptr getelementptr inbounds (i8, ptr @cx, i64 72), align 8, !tbaa !22
  %24 = call ptr @achd_get_vtab(ptr noundef %22, i32 noundef %23) #8
  %25 = getelementptr inbounds i8, ptr %1, i64 248
  store ptr %24, ptr %25, align 8, !tbaa !23
  %.not17 = icmp eq ptr %24, null
  br i1 %.not17, label %29, label %26

26:                                               ; preds = %21
  %27 = getelementptr inbounds i8, ptr %24, i64 24
  %28 = load ptr, ptr %27, align 8, !tbaa !24
  %.not18 = icmp eq ptr %28, null
  br i1 %.not18, label %29, label %30

29:                                               ; preds = %26, %21
  call void @__assert_fail(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.3, i32 noundef 116, ptr noundef nonnull @__PRETTY_FUNCTION__.achd_client) #9
  unreachable

30:                                               ; preds = %26
  %31 = load ptr, ptr getelementptr inbounds (i8, ptr @cx, i64 64), align 8, !tbaa !21
  %.not19 = icmp eq ptr %31, null
  br i1 %.not19, label %32, label %33

32:                                               ; preds = %30
  call void @__assert_fail(ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.3, i32 noundef 118, ptr noundef nonnull @__PRETTY_FUNCTION__.achd_client) #9
  unreachable

33:                                               ; preds = %30
  %34 = load i32, ptr getelementptr inbounds (i8, ptr @cx, i64 72), align 8
  %35 = add i32 %34, -1
  %or.cond = icmp ult i32 %35, 2
  br i1 %or.cond, label %37, label %36

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

37:                                               ; preds = %33
  %38 = getelementptr inbounds i8, ptr %1, i64 104
  store ptr %31, ptr %38, align 8, !tbaa !26
  %39 = load i64, ptr getelementptr inbounds (i8, ptr @cx, i64 48), align 8, !tbaa !27
  %40 = getelementptr inbounds i8, ptr %1, i64 88
  store i64 %39, ptr %40, align 8, !tbaa !28
  %41 = load i32, ptr getelementptr inbounds (i8, ptr @cx, i64 40), align 8, !tbaa !29
  %42 = getelementptr inbounds i8, ptr %1, i64 80
  store i32 %41, ptr %42, align 8, !tbaa !30
  call void @sighandler_install() #8
  %43 = load i32, ptr getelementptr inbounds (i8, ptr @cx, i64 100), align 4, !tbaa !31
  %.not20 = icmp eq i32 %43, 0
  br i1 %.not20, label %69, label %44

44:                                               ; preds = %37
  %45 = call i32 @ach_detach(i32 noundef 3) #8
  %46 = call i32 @close(i32 noundef 1) #8
  %.not21 = icmp ne i32 %46, 0
  %47 = load i32, ptr @ach_verbosity, align 4
  %48 = icmp sgt i32 %47, -3
  %or.cond25 = select i1 %.not21, i1 %48, i1 false
  br i1 %or.cond25, label %49, label %53

49:                                               ; preds = %44
  %50 = tail call ptr @__errno_location() #10
  %51 = load i32, ptr %50, align 4, !tbaa !32
  %52 = call ptr @strerror(i32 noundef %51) #8
  call void (i32, ptr, ...) @ach_log(i32 noundef 3, ptr noundef nonnull @.str.9, ptr noundef %52) #8
  br label %53

53:                                               ; preds = %49, %44
  %54 = call i32 @close(i32 noundef 2) #8
  %.not22 = icmp ne i32 %54, 0
  %55 = load i32, ptr @ach_verbosity, align 4
  %56 = icmp sgt i32 %55, -3
  %or.cond27 = select i1 %.not22, i1 %56, i1 false
  br i1 %or.cond27, label %57, label %61

57:                                               ; preds = %53
  %58 = tail call ptr @__errno_location() #10
  %59 = load i32, ptr %58, align 4, !tbaa !32
  %60 = call ptr @strerror(i32 noundef %59) #8
  call void (i32, ptr, ...) @ach_log(i32 noundef 3, ptr noundef nonnull @.str.10, ptr noundef %60) #8
  br label %61

61:                                               ; preds = %57, %53
  %62 = call i32 @kill(i32 noundef %45, i32 noundef 10) #8
  %.not23 = icmp ne i32 %62, 0
  %63 = load i32, ptr @ach_verbosity, align 4
  %64 = icmp sgt i32 %63, -3
  %or.cond29 = select i1 %.not23, i1 %64, i1 false
  br i1 %or.cond29, label %65, label %69

65:                                               ; preds = %61
  %66 = tail call ptr @__errno_location() #10
  %67 = load i32, ptr %66, align 4, !tbaa !32
  %68 = call ptr @strerror(i32 noundef %67) #8
  call void (i32, ptr, ...) @ach_log(i32 noundef 3, ptr noundef nonnull @.str.11, ptr noundef %68) #8
  br label %69

69:                                               ; preds = %61, %65, %37
  %70 = call i32 @server_connect(ptr noundef nonnull %1)
  %71 = icmp slt i32 %70, 0
  br i1 %71, label %72, label %77

72:                                               ; preds = %69
  %73 = load i32, ptr @ach_verbosity, align 4, !tbaa !32
  %74 = icmp sgt i32 %73, -3
  br i1 %74, label %75, label %76

75:                                               ; preds = %72
  call void (i32, ptr, ...) @ach_log(i32 noundef 3, ptr noundef nonnull @.str.12) #8
  br label %76

76:                                               ; preds = %75, %72
  call void @ach_die() #8
  br label %77

77:                                               ; preds = %76, %69
  %78 = load ptr, ptr getelementptr inbounds (i8, ptr @cx, i64 120), align 8, !tbaa !33
  %79 = getelementptr inbounds i8, ptr %78, i64 88
  %80 = getelementptr inbounds i8, ptr %78, i64 96
  %81 = load i64, ptr %80, align 8, !tbaa !33
  %82 = load i64, ptr %79, align 8, !tbaa !33
  %83 = udiv i64 %81, %82
  %84 = getelementptr inbounds i8, ptr %1, i64 232
  store i64 %83, ptr %84, align 8, !tbaa !34
  %85 = call ptr @ach_pipe_alloc(i64 noundef %83) #8
  %86 = getelementptr inbounds i8, ptr %1, i64 240
  store ptr %85, ptr %86, align 8, !tbaa !35
  call void @ach_notify(i32 noundef 10) #8
  %87 = load i32, ptr getelementptr inbounds (i8, ptr @cx, i64 112), align 8
  %88 = icmp ne i32 %87, 0
  %or.cond3 = select i1 %71, i1 true, i1 %88
  br i1 %or.cond3, label %100, label %89

89:                                               ; preds = %77
  %90 = load i32, ptr @ach_verbosity, align 4, !tbaa !32
  %91 = icmp sgt i32 %90, 0
  br i1 %91, label %92, label %93

92:                                               ; preds = %89
  call void (i32, ptr, ...) @ach_log(i32 noundef 6, ptr noundef nonnull @.str.13) #8
  br label %93

93:                                               ; preds = %92, %89
  %94 = load ptr, ptr %25, align 8, !tbaa !23
  %95 = getelementptr inbounds i8, ptr %94, i64 24
  %96 = load ptr, ptr %95, align 8, !tbaa !24
  call void %96(ptr noundef nonnull %1) #8
  %97 = load i32, ptr @ach_verbosity, align 4, !tbaa !32
  %98 = icmp sgt i32 %97, 0
  br i1 %98, label %99, label %100

99:                                               ; preds = %93
  call void (i32, ptr, ...) @ach_log(i32 noundef 6, ptr noundef nonnull @.str.14) #8
  br label %100

100:                                              ; preds = %93, %99, %77
  call void @llvm.lifetime.end.p0(i64 264, ptr nonnull %1) #8
  ret void
}

declare void @openlog(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

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

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

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

declare i32 @ach_srv_search(ptr noundef, ptr noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite, inaccessiblemem: readwrite)
declare noalias ptr @strdup(ptr nocapture noundef readonly) local_unnamed_addr #5

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

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

declare void @sighandler_install() local_unnamed_addr #1

declare i32 @ach_detach(i32 noundef) local_unnamed_addr #1

declare i32 @close(i32 noundef) local_unnamed_addr #1

declare void @ach_log(i32 noundef, ptr noundef, ...) local_unnamed_addr #1

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

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__errno_location() local_unnamed_addr #7

; Function Attrs: nounwind
declare i32 @kill(i32 noundef, i32 noundef) local_unnamed_addr #6

; Function Attrs: nounwind uwtable
declare hidden i32 @server_connect(ptr noundef) local_unnamed_addr #0

declare void @ach_die() local_unnamed_addr #1

declare ptr @ach_pipe_alloc(i64 noundef) local_unnamed_addr #1

declare void @ach_notify(i32 noundef) local_unnamed_addr #1

attributes #0 = { 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 #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 #5 = { mustprogress nofree nounwind willreturn memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { 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 #8 = { nounwind }
attributes #9 = { noreturn nounwind }
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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 248}
!10 = !{!"achd_cx", !11, i64 0, !12, i64 88, !12, i64 92, !12, i64 96, !12, i64 100, !6, i64 104, !12, i64 112, !14, i64 120, !6, i64 248}
!11 = !{!"achd_headers", !6, i64 0, !6, i64 8, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !12, i64 40, !12, i64 44, !13, i64 48, !6, i64 56, !6, i64 64, !12, i64 72, !12, i64 76, !6, i64 80}
!12 = !{!"int", !7, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!"ach_channel", !7, i64 0}
!15 = !{!10, !6, i64 0}
!16 = !{!10, !6, i64 8}
!17 = !{!10, !6, i64 56}
!18 = !{!19, !6, i64 40}
!19 = !{!"achd_conn", !12, i64 0, !20, i64 8, !20, i64 24, !11, i64 40, !11, i64 128, !12, i64 216, !12, i64 220, !12, i64 224, !13, i64 232, !6, i64 240, !6, i64 248, !6, i64 256}
!20 = !{!"timespec", !13, i64 0, !13, i64 8}
!21 = !{!10, !6, i64 64}
!22 = !{!10, !12, i64 72}
!23 = !{!19, !6, i64 248}
!24 = !{!25, !6, i64 24}
!25 = !{!"achd_conn_vtab", !6, i64 0, !12, i64 8, !6, i64 16, !6, i64 24}
!26 = !{!19, !6, i64 104}
!27 = !{!10, !13, i64 48}
!28 = !{!19, !13, i64 88}
!29 = !{!10, !12, i64 40}
!30 = !{!19, !12, i64 80}
!31 = !{!10, !12, i64 100}
!32 = !{!12, !12, i64 0}
!33 = !{!7, !7, i64 0}
!34 = !{!19, !13, i64 232}
!35 = !{!19, !6, i64 240}


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