; LLVM IR from aap/pdp6 :: emu (main_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.Task = type { ptr, ptr, ptr, i32, i32 }
%struct.Foo = type { ptr, ptr, [4 x ptr] }

@stderr = external global ptr, align 8
@argv0 = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [10 x i8], align 1
@dotrace = external global i32, align 4
@.str.3 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@debugfp = external global ptr, align 8
@.str.5 = external hidden unnamed_addr constant [15 x i8], align 1
@rtcchan = external global ptr, align 8
@.str.6 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @talknetwork(i32 noundef, ptr noundef) #0

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

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

; Function Attrs: nounwind uwtable
declare dso_local void @usage() #0

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #3

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #4

; Function Attrs: nounwind uwtable
define dso_local i32 @threadmain(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca [2 x ptr], align 16
  %9 = alloca %struct.Task, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i8, align 1
  %15 = alloca i32, align 4
  %16 = alloca %struct.Task, align 8
  %17 = alloca %struct.Foo, align 8
  store i32 %0, ptr %3, align 4, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #7
  call void @llvm.lifetime.start.p0(i64 32, ptr %9) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  store ptr @.str.2, ptr %5, align 8, !tbaa !9
  store ptr null, ptr %6, align 8, !tbaa !9
  %18 = load ptr, ptr @argv0, align 8, !tbaa !9
  %19 = icmp ne ptr %18, null
  br i1 %19, label %24, label %20

20:                                               ; preds = %2
  %21 = load ptr, ptr %4, align 8, !tbaa !9
  %22 = load ptr, ptr %21, align 8, !tbaa !9
  store ptr %22, ptr @argv0, align 8, !tbaa !9
  %23 = icmp ne ptr %22, null
  br label %24

24:                                               ; preds = %20, %2
  %25 = phi i1 [ true, %2 ], [ %23, %20 ]
  %26 = zext i1 %25 to i32
  %27 = load ptr, ptr %4, align 8, !tbaa !9
  %28 = getelementptr inbounds ptr, ptr %27, i32 1
  store ptr %28, ptr %4, align 8, !tbaa !9
  %29 = load i32, ptr %3, align 4, !tbaa !5
  %30 = add nsw i32 %29, -1
  store i32 %30, ptr %3, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %152, %24
  %32 = load ptr, ptr %4, align 8, !tbaa !9
  %33 = getelementptr inbounds ptr, ptr %32, i64 0
  %34 = load ptr, ptr %33, align 8, !tbaa !9
  %35 = icmp ne ptr %34, null
  br i1 %35, label %36, label %52

36:                                               ; preds = %31
  %37 = load ptr, ptr %4, align 8, !tbaa !9
  %38 = getelementptr inbounds ptr, ptr %37, i64 0
  %39 = load ptr, ptr %38, align 8, !tbaa !9
  %40 = getelementptr inbounds i8, ptr %39, i64 0
  %41 = load i8, ptr %40, align 1, !tbaa !11
  %42 = sext i8 %41 to i32
  %43 = icmp eq i32 %42, 45
  br i1 %43, label %44, label %52

44:                                               ; preds = %36
  %45 = load ptr, ptr %4, align 8, !tbaa !9
  %46 = getelementptr inbounds ptr, ptr %45, i64 0
  %47 = load ptr, ptr %46, align 8, !tbaa !9
  %48 = getelementptr inbounds i8, ptr %47, i64 1
  %49 = load i8, ptr %48, align 1, !tbaa !11
  %50 = sext i8 %49 to i32
  %51 = icmp ne i32 %50, 0
  br label %52

52:                                               ; preds = %44, %36, %31
  %53 = phi i1 [ false, %36 ], [ false, %31 ], [ %51, %44 ]
  br i1 %53, label %54, label %157

54:                                               ; preds = %52
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  call void @llvm.lifetime.start.p0(i64 1, ptr %14) #7
  %55 = load ptr, ptr %4, align 8, !tbaa !9
  %56 = getelementptr inbounds ptr, ptr %55, i64 0
  %57 = load ptr, ptr %56, align 8, !tbaa !9
  %58 = getelementptr inbounds i8, ptr %57, i64 1
  store ptr %58, ptr %12, align 8, !tbaa !9
  %59 = load ptr, ptr %12, align 8, !tbaa !9
  %60 = getelementptr inbounds i8, ptr %59, i64 0
  %61 = load i8, ptr %60, align 1, !tbaa !11
  %62 = sext i8 %61 to i32
  %63 = icmp eq i32 %62, 45
  br i1 %63, label %64, label %75

64:                                               ; preds = %54
  %65 = load ptr, ptr %12, align 8, !tbaa !9
  %66 = getelementptr inbounds i8, ptr %65, i64 1
  %67 = load i8, ptr %66, align 1, !tbaa !11
  %68 = sext i8 %67 to i32
  %69 = icmp eq i32 %68, 0
  br i1 %69, label %70, label %75

70:                                               ; preds = %64
  %71 = load i32, ptr %3, align 4, !tbaa !5
  %72 = add nsw i32 %71, -1
  store i32 %72, ptr %3, align 4, !tbaa !5
  %73 = load ptr, ptr %4, align 8, !tbaa !9
  %74 = getelementptr inbounds ptr, ptr %73, i32 1
  store ptr %74, ptr %4, align 8, !tbaa !9
  store i32 2, ptr %15, align 4
  br label %149

75:                                               ; preds = %64, %54
  store i8 0, ptr %14, align 1, !tbaa !11
  br label %76

76:                                               ; preds = %144, %75
  %77 = load ptr, ptr %12, align 8, !tbaa !9
  %78 = load i8, ptr %77, align 1, !tbaa !11
  %79 = sext i8 %78 to i32
  %80 = icmp ne i32 %79, 0
  br i1 %80, label %81, label %87

81:                                               ; preds = %76
  %82 = load ptr, ptr %12, align 8, !tbaa !9
  %83 = getelementptr inbounds i8, ptr %82, i32 1
  store ptr %83, ptr %12, align 8, !tbaa !9
  %84 = load i8, ptr %82, align 1, !tbaa !11
  store i8 %84, ptr %14, align 1, !tbaa !11
  %85 = sext i8 %84 to i32
  %86 = icmp ne i32 %85, 0
  br label %87

87:                                               ; preds = %81, %76
  %88 = phi i1 [ false, %76 ], [ %86, %81 ]
  br i1 %88, label %89, label %145

89:                                               ; preds = %87
  %90 = load i8, ptr %14, align 1, !tbaa !11
  %91 = sext i8 %90 to i32
  switch i32 %91, label %143 [
    i32 116, label %92
    i32 100, label %93
    i32 112, label %118
  ]

92:                                               ; preds = %89
  store i32 1, ptr @dotrace, align 4, !tbaa !5
  br label %144

93:                                               ; preds = %89
  %94 = load ptr, ptr %12, align 8, !tbaa !9
  store ptr %94, ptr %13, align 8, !tbaa !9
  store ptr @.str.3, ptr %12, align 8, !tbaa !9
  %95 = load ptr, ptr %13, align 8, !tbaa !9
  %96 = load i8, ptr %95, align 1, !tbaa !11
  %97 = sext i8 %96 to i32
  %98 = icmp ne i32 %97, 0
  br i1 %98, label %99, label %101

99:                                               ; preds = %93
  %100 = load ptr, ptr %13, align 8, !tbaa !9
  br label %116

101:                                              ; preds = %93
  %102 = load ptr, ptr %4, align 8, !tbaa !9
  %103 = getelementptr inbounds ptr, ptr %102, i64 1
  %104 = load ptr, ptr %103, align 8, !tbaa !9
  %105 = icmp ne ptr %104, null
  br i1 %105, label %106, label %112

106:                                              ; preds = %101
  %107 = load i32, ptr %3, align 4, !tbaa !5
  %108 = add nsw i32 %107, -1
  store i32 %108, ptr %3, align 4, !tbaa !5
  %109 = load ptr, ptr %4, align 8, !tbaa !9
  %110 = getelementptr inbounds ptr, ptr %109, i32 1
  store ptr %110, ptr %4, align 8, !tbaa !9
  %111 = load ptr, ptr %110, align 8, !tbaa !9
  br label %114

112:                                              ; preds = %101
  call void @usage()
  call void @abort() #8
  unreachable

113:                                              ; No predecessors!
  br label %114

114:                                              ; preds = %113, %106
  %115 = phi ptr [ %111, %106 ], [ null, %113 ]
  br label %116

116:                                              ; preds = %114, %99
  %117 = phi ptr [ %100, %99 ], [ %115, %114 ]
  store ptr %117, ptr %5, align 8, !tbaa !9
  br label %144

118:                                              ; preds = %89
  %119 = load ptr, ptr %12, align 8, !tbaa !9
  store ptr %119, ptr %13, align 8, !tbaa !9
  store ptr @.str.3, ptr %12, align 8, !tbaa !9
  %120 = load ptr, ptr %13, align 8, !tbaa !9
  %121 = load i8, ptr %120, align 1, !tbaa !11
  %122 = sext i8 %121 to i32
  %123 = icmp ne i32 %122, 0
  br i1 %123, label %124, label %126

124:                                              ; preds = %118
  %125 = load ptr, ptr %13, align 8, !tbaa !9
  br label %141

126:                                              ; preds = %118
  %127 = load ptr, ptr %4, align 8, !tbaa !9
  %128 = getelementptr inbounds ptr, ptr %127, i64 1
  %129 = load ptr, ptr %128, align 8, !tbaa !9
  %130 = icmp ne ptr %129, null
  br i1 %130, label %131, label %137

131:                                              ; preds = %126
  %132 = load i32, ptr %3, align 4, !tbaa !5
  %133 = add nsw i32 %132, -1
  store i32 %133, ptr %3, align 4, !tbaa !5
  %134 = load ptr, ptr %4, align 8, !tbaa !9
  %135 = getelementptr inbounds ptr, ptr %134, i32 1
  store ptr %135, ptr %4, align 8, !tbaa !9
  %136 = load ptr, ptr %135, align 8, !tbaa !9
  br label %139

137:                                              ; preds = %126
  call void @usage()
  call void @abort() #8
  unreachable

138:                                              ; No predecessors!
  br label %139

139:                                              ; preds = %138, %131
  %140 = phi ptr [ %136, %131 ], [ null, %138 ]
  br label %141

141:                                              ; preds = %139, %124
  %142 = phi ptr [ %125, %124 ], [ %140, %139 ]
  store ptr %142, ptr %6, align 8, !tbaa !9
  br label %144

143:                                              ; preds = %89
  call void @usage()
  br label %144

144:                                              ; preds = %143, %141, %116, %92
  br label %76, !llvm.loop !12

145:                                              ; preds = %87
  store ptr null, ptr %13, align 8, !tbaa !9
  %146 = load ptr, ptr %13, align 8, !tbaa !9
  %147 = load i8, ptr %14, align 1, !tbaa !11
  %148 = load ptr, ptr %12, align 8, !tbaa !9
  store i32 0, ptr %15, align 4
  br label %149

149:                                              ; preds = %145, %70
  call void @llvm.lifetime.end.p0(i64 1, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  %150 = load i32, ptr %15, align 4
  switch i32 %150, label %212 [
    i32 0, label %151
    i32 2, label %157
  ]

151:                                              ; preds = %149
  br label %152

152:                                              ; preds = %151
  %153 = load i32, ptr %3, align 4, !tbaa !5
  %154 = add nsw i32 %153, -1
  store i32 %154, ptr %3, align 4, !tbaa !5
  %155 = load ptr, ptr %4, align 8, !tbaa !9
  %156 = getelementptr inbounds ptr, ptr %155, i32 1
  store ptr %156, ptr %4, align 8, !tbaa !9
  br label %31, !llvm.loop !14

157:                                              ; preds = %149, %52
  %158 = load ptr, ptr %4, align 8, !tbaa !9
  %159 = load i32, ptr %3, align 4, !tbaa !5
  %160 = load ptr, ptr %5, align 8, !tbaa !9
  %161 = call noalias ptr @fopen(ptr noundef %160, ptr noundef @.str.4)
  store ptr %161, ptr @debugfp, align 8, !tbaa !9
  %162 = load ptr, ptr @debugfp, align 8, !tbaa !9
  %163 = icmp eq ptr %162, null
  br i1 %163, label %164, label %168

164:                                              ; preds = %157
  %165 = load ptr, ptr @stderr, align 8, !tbaa !9
  %166 = load ptr, ptr %5, align 8, !tbaa !9
  %167 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %165, ptr noundef @.str.5, ptr noundef %166) #7
  call void @exit(i32 noundef 1) #8
  unreachable

168:                                              ; preds = %157
  %169 = call ptr @chancreate(i32 noundef 24, i32 noundef 20)
  store ptr %169, ptr @rtcchan, align 8, !tbaa !9
  %170 = call i32 @dofile(ptr noundef @.str.6)
  %171 = icmp ne i32 %170, 0
  br i1 %171, label %172, label %173

172:                                              ; preds = %168
  call void @defaultconfig()
  br label %173

173:                                              ; preds = %172, %168
  %174 = call ptr @getdevice(ptr noundef @.str.7)
  store ptr %174, ptr %10, align 8, !tbaa !9
  %175 = call ptr @getdevice(ptr noundef @.str.8)
  store ptr %175, ptr %11, align 8, !tbaa !9
  %176 = load ptr, ptr %10, align 8, !tbaa !9
  %177 = icmp eq ptr %176, null
  br i1 %177, label %181, label %178

178:                                              ; preds = %173
  %179 = load ptr, ptr %11, align 8, !tbaa !9
  %180 = icmp eq ptr %179, null
  br i1 %180, label %181, label %182

181:                                              ; preds = %178, %173
  call void (ptr, ...) @err(ptr noundef @.str.9)
  br label %182

182:                                              ; preds = %181, %178
  %183 = call ptr @chancreate(i32 noundef 8, i32 noundef 1)
  %184 = getelementptr inbounds [2 x ptr], ptr %8, i64 0, i64 0
  store ptr %183, ptr %184, align 16, !tbaa !9
  %185 = call ptr @chancreate(i32 noundef 8, i32 noundef 1)
  %186 = getelementptr inbounds [2 x ptr], ptr %8, i64 0, i64 1
  store ptr %185, ptr %186, align 8, !tbaa !9
  %187 = getelementptr inbounds %struct.Task, ptr %16, i32 0, i32 0
  store ptr null, ptr %187, align 8, !tbaa !15
  %188 = getelementptr inbounds %struct.Task, ptr %16, i32 0, i32 1
  store ptr @readcmdchan, ptr %188, align 8, !tbaa !17
  %189 = getelementptr inbounds %struct.Task, ptr %16, i32 0, i32 2
  %190 = getelementptr inbounds [2 x ptr], ptr %8, i64 0, i64 0
  store ptr %190, ptr %189, align 8, !tbaa !18
  %191 = getelementptr inbounds %struct.Task, ptr %16, i32 0, i32 3
  store i32 10, ptr %191, align 8, !tbaa !19
  %192 = getelementptr inbounds %struct.Task, ptr %16, i32 0, i32 4
  store i32 0, ptr %192, align 4, !tbaa !20
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %9, ptr align 8 %16, i64 32, i1 false), !tbaa.struct !21
  call void @addtask(ptr noundef byval(%struct.Task) align 8 %9)
  %193 = call i32 @threadcreate(ptr noundef @simthread, ptr noundef null)
  %194 = getelementptr inbounds [2 x ptr], ptr %8, i64 0, i64 0
  %195 = call i32 @threadcreate(ptr noundef @cmdthread, ptr noundef %194)
  %196 = call i32 @threadcreate(ptr noundef @rtcthread, ptr noundef null)
  call void @llvm.lifetime.start.p0(i64 48, ptr %17) #7
  %197 = getelementptr inbounds %struct.Foo, ptr %17, i32 0, i32 0
  %198 = load ptr, ptr %10, align 8, !tbaa !9
  store ptr %198, ptr %197, align 8, !tbaa !22
  %199 = getelementptr inbounds %struct.Foo, ptr %17, i32 0, i32 1
  %200 = load ptr, ptr %11, align 8, !tbaa !9
  store ptr %200, ptr %199, align 8, !tbaa !24
  %201 = getelementptr inbounds %struct.Foo, ptr %17, i32 0, i32 2
  call void @llvm.memset.p0.i64(ptr align 8 %201, i8 0, i64 32, i1 false)
  %202 = call ptr @getdevice(ptr noundef @.str.10)
  %203 = getelementptr inbounds %struct.Foo, ptr %17, i32 0, i32 2
  %204 = getelementptr inbounds [4 x ptr], ptr %203, i64 0, i64 0
  store ptr %202, ptr %204, align 8, !tbaa !9
  %205 = call ptr @getdevice(ptr noundef @.str.11)
  %206 = getelementptr inbounds %struct.Foo, ptr %17, i32 0, i32 2
  %207 = getelementptr inbounds [4 x ptr], ptr %206, i64 0, i64 1
  store ptr %205, ptr %207, align 8, !tbaa !9
  %208 = getelementptr inbounds %struct.Foo, ptr %17, i32 0, i32 2
  %209 = getelementptr inbounds [4 x ptr], ptr %208, i64 0, i64 2
  store ptr null, ptr %209, align 8, !tbaa !9
  %210 = getelementptr inbounds %struct.Foo, ptr %17, i32 0, i32 2
  %211 = getelementptr inbounds [4 x ptr], ptr %210, i64 0, i64 3
  store ptr null, ptr %211, align 8, !tbaa !9
  call void @serve(i32 noundef 2000, ptr noundef @talknetwork, ptr noundef %17)
  store i32 1, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 48, ptr %17) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #7
  ret i32 0

212:                                              ; preds = %149
  unreachable
}

; Function Attrs: noreturn nounwind
declare void @abort() #4

declare noalias ptr @fopen(ptr noundef, ptr noundef) #5

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

declare i32 @dofile(ptr noundef) #5

declare void @defaultconfig() #5

declare ptr @getdevice(ptr noundef) #5

declare void @err(ptr noundef, ...) #5

declare void @readcmdchan(ptr noundef) #5

declare void @addtask(ptr noundef byval(%struct.Task) align 8) #5

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

declare ptr @simthread(ptr noundef) #5

declare ptr @cmdthread(ptr noundef) #5

declare ptr @rtcthread(ptr noundef) #5

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

declare void @serve(i32 noundef, ptr noundef, ptr noundef) #5

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 = { 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 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #7 = { nounwind }
attributes #8 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = !{!16, !10, i64 0}
!16 = !{!"Task", !10, i64 0, !10, i64 8, !10, i64 16, !6, i64 24, !6, i64 28}
!17 = !{!16, !10, i64 8}
!18 = !{!16, !10, i64 16}
!19 = !{!16, !6, i64 24}
!20 = !{!16, !6, i64 28}
!21 = !{i64 0, i64 8, !9, i64 8, i64 8, !9, i64 16, i64 8, !9, i64 24, i64 4, !5, i64 28, i64 4, !5}
!22 = !{!23, !10, i64 0}
!23 = !{!"Foo", !10, i64 0, !10, i64 8, !7, i64 16}
!24 = !{!23, !10, i64 8}


; 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.Task = type { ptr, ptr, ptr, i32, i32 }
%struct.Foo = type { ptr, ptr, [4 x ptr] }

@stderr = external local_unnamed_addr global ptr, align 8
@argv0 = external local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [10 x i8], align 1
@dotrace = external local_unnamed_addr global i32, align 4
@.str.3 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@debugfp = external local_unnamed_addr global ptr, align 8
@.str.5 = external hidden unnamed_addr constant [15 x i8], align 1
@rtcchan = external local_unnamed_addr global ptr, align 8
@.str.6 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @talknetwork(i32 noundef, ptr noundef) #0

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @usage() local_unnamed_addr #0

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

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @threadmain(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = alloca [2 x ptr], align 16
  %4 = alloca %struct.Task, align 8
  %5 = alloca %struct.Foo, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #6
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %4) #6
  %6 = load ptr, ptr @argv0, align 8, !tbaa !5
  %.not = icmp eq ptr %6, null
  br i1 %.not, label %7, label %9

7:                                                ; preds = %2
  %8 = load ptr, ptr %1, align 8, !tbaa !5
  store ptr %8, ptr @argv0, align 8, !tbaa !5
  br label %9

9:                                                ; preds = %7, %2
  %.04292 = getelementptr inbounds i8, ptr %1, i64 8
  %10 = load ptr, ptr %.04292, align 8, !tbaa !5
  %.not6494 = icmp eq ptr %10, null
  br i1 %.not6494, label %.critedge, label %.lr.ph98

.critedge2.loopexit:                              ; preds = %38
  %.042 = getelementptr inbounds i8, ptr %.446, i64 8
  %11 = load ptr, ptr %.042, align 8, !tbaa !5
  %.not64 = icmp eq ptr %11, null
  br i1 %.not64, label %.critedge, label %.lr.ph98, !llvm.loop !9

.lr.ph98:                                         ; preds = %9, %.critedge2.loopexit
  %12 = phi ptr [ %11, %.critedge2.loopexit ], [ %10, %9 ]
  %.04296 = phi ptr [ %.042, %.critedge2.loopexit ], [ %.04292, %9 ]
  %.04995 = phi ptr [ %.251, %.critedge2.loopexit ], [ @.str.2, %9 ]
  %13 = load i8, ptr %12, align 1, !tbaa !11
  %14 = icmp eq i8 %13, 45
  br i1 %14, label %15, label %.critedge

15:                                               ; preds = %.lr.ph98
  %16 = getelementptr inbounds i8, ptr %12, i64 1
  %17 = load i8, ptr %16, align 1, !tbaa !11
  switch i8 %17, label %.lr.ph.preheader [
    i8 0, label %.critedge
    i8 45, label %18
  ]

18:                                               ; preds = %15
  %19 = getelementptr inbounds i8, ptr %12, i64 2
  %20 = load i8, ptr %19, align 1, !tbaa !11
  %21 = icmp eq i8 %20, 0
  br i1 %21, label %.critedge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %15, %18
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %38
  %22 = phi i8 [ %39, %38 ], [ %17, %.lr.ph.preheader ]
  %.14388 = phi ptr [ %.446, %38 ], [ %.04296, %.lr.ph.preheader ]
  %.15087 = phi ptr [ %.251, %38 ], [ %.04995, %.lr.ph.preheader ]
  %.05486 = phi ptr [ %.155, %38 ], [ %16, %.lr.ph.preheader ]
  %23 = getelementptr inbounds i8, ptr %.05486, i64 1
  switch i8 %22, label %37 [
    i8 116, label %24
    i8 100, label %25
    i8 112, label %31
  ]

24:                                               ; preds = %.lr.ph
  store i32 1, ptr @dotrace, align 4, !tbaa !12
  br label %38

25:                                               ; preds = %.lr.ph
  %26 = load i8, ptr %23, align 1, !tbaa !11
  %.not69 = icmp eq i8 %26, 0
  br i1 %.not69, label %27, label %38

27:                                               ; preds = %25
  %28 = getelementptr inbounds i8, ptr %.14388, i64 8
  %29 = load ptr, ptr %28, align 8, !tbaa !5
  %.not70 = icmp eq ptr %29, null
  br i1 %.not70, label %30, label %38

30:                                               ; preds = %27
  tail call void @usage()
  tail call void @abort() #7
  unreachable

31:                                               ; preds = %.lr.ph
  %32 = load i8, ptr %23, align 1, !tbaa !11
  %.not67 = icmp eq i8 %32, 0
  br i1 %.not67, label %33, label %38

33:                                               ; preds = %31
  %34 = getelementptr inbounds i8, ptr %.14388, i64 8
  %35 = load ptr, ptr %34, align 8, !tbaa !5
  %.not68 = icmp eq ptr %35, null
  br i1 %.not68, label %36, label %38

36:                                               ; preds = %33
  tail call void @usage()
  tail call void @abort() #7
  unreachable

37:                                               ; preds = %.lr.ph
  tail call void @usage()
  br label %38

38:                                               ; preds = %33, %27, %31, %25, %37, %24
  %.155 = phi ptr [ %23, %37 ], [ %23, %24 ], [ @.str.3, %25 ], [ @.str.3, %31 ], [ @.str.3, %27 ], [ @.str.3, %33 ]
  %.251 = phi ptr [ %.15087, %37 ], [ %.15087, %24 ], [ %23, %25 ], [ %.15087, %31 ], [ %29, %27 ], [ %.15087, %33 ]
  %.446 = phi ptr [ %.14388, %37 ], [ %.14388, %24 ], [ %.14388, %25 ], [ %.14388, %31 ], [ %28, %27 ], [ %34, %33 ]
  %39 = load i8, ptr %.155, align 1, !tbaa !11
  %.not66 = icmp eq i8 %39, 0
  br i1 %.not66, label %.critedge2.loopexit, label %.lr.ph, !llvm.loop !14

.critedge:                                        ; preds = %.critedge2.loopexit, %.lr.ph98, %15, %18, %9
  %.049.lcssa = phi ptr [ @.str.2, %9 ], [ %.04995, %18 ], [ %.04995, %15 ], [ %.04995, %.lr.ph98 ], [ %.251, %.critedge2.loopexit ]
  %40 = tail call noalias ptr @fopen(ptr noundef %.049.lcssa, ptr noundef nonnull @.str.4)
  store ptr %40, ptr @debugfp, align 8, !tbaa !5
  %41 = icmp eq ptr %40, null
  br i1 %41, label %42, label %45

42:                                               ; preds = %.critedge
  %43 = load ptr, ptr @stderr, align 8, !tbaa !5
  %44 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %43, ptr noundef nonnull @.str.5, ptr noundef %.049.lcssa) #8
  tail call void @exit(i32 noundef 1) #7
  unreachable

45:                                               ; preds = %.critedge
  %46 = tail call ptr @chancreate(i32 noundef 24, i32 noundef 20) #6
  store ptr %46, ptr @rtcchan, align 8, !tbaa !5
  %47 = tail call i32 @dofile(ptr noundef nonnull @.str.6) #6
  %.not71 = icmp eq i32 %47, 0
  br i1 %.not71, label %49, label %48

48:                                               ; preds = %45
  tail call void @defaultconfig() #6
  br label %49

49:                                               ; preds = %48, %45
  %50 = tail call ptr @getdevice(ptr noundef nonnull @.str.7) #6
  %51 = tail call ptr @getdevice(ptr noundef nonnull @.str.8) #6
  %52 = icmp eq ptr %50, null
  %53 = icmp eq ptr %51, null
  %or.cond = select i1 %52, i1 true, i1 %53
  br i1 %or.cond, label %54, label %55

54:                                               ; preds = %49
  tail call void (ptr, ...) @err(ptr noundef nonnull @.str.9) #6
  br label %55

55:                                               ; preds = %49, %54
  %56 = tail call ptr @chancreate(i32 noundef 8, i32 noundef 1) #6
  store ptr %56, ptr %3, align 16, !tbaa !5
  %57 = tail call ptr @chancreate(i32 noundef 8, i32 noundef 1) #6
  %58 = getelementptr inbounds i8, ptr %3, i64 8
  store ptr %57, ptr %58, align 8, !tbaa !5
  store ptr null, ptr %4, align 8, !tbaa !5
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %4, i64 8
  store ptr @readcmdchan, ptr %.sroa.2.0..sroa_idx, align 8, !tbaa !5
  %.sroa.3.0..sroa_idx = getelementptr inbounds i8, ptr %4, i64 16
  store ptr %3, ptr %.sroa.3.0..sroa_idx, align 8, !tbaa !5
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %4, i64 24
  store i32 10, ptr %.sroa.4.0..sroa_idx, align 8, !tbaa !12
  %.sroa.5.0..sroa_idx = getelementptr inbounds i8, ptr %4, i64 28
  store i32 0, ptr %.sroa.5.0..sroa_idx, align 4, !tbaa !12
  call void @addtask(ptr noundef nonnull byval(%struct.Task) align 8 %4) #6
  %59 = call i32 @threadcreate(ptr noundef nonnull @simthread, ptr noundef null) #6
  %60 = call i32 @threadcreate(ptr noundef nonnull @cmdthread, ptr noundef nonnull %3) #6
  %61 = call i32 @threadcreate(ptr noundef nonnull @rtcthread, ptr noundef null) #6
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %5) #6
  store ptr %50, ptr %5, align 8, !tbaa !15
  %62 = getelementptr inbounds i8, ptr %5, i64 8
  store ptr %51, ptr %62, align 8, !tbaa !17
  %63 = getelementptr inbounds i8, ptr %5, i64 16
  %64 = call ptr @getdevice(ptr noundef nonnull @.str.10) #6
  store ptr %64, ptr %63, align 8, !tbaa !5
  %65 = call ptr @getdevice(ptr noundef nonnull @.str.11) #6
  %66 = getelementptr inbounds i8, ptr %5, i64 24
  store ptr %65, ptr %66, align 8, !tbaa !5
  %67 = getelementptr inbounds i8, ptr %5, i64 32
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %67, i8 0, i64 16, i1 false)
  call void @serve(i32 noundef 2000, ptr noundef nonnull @talknetwork, ptr noundef nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #6
  ret i32 0
}

; Function Attrs: noreturn nounwind
declare void @abort() local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #2

declare ptr @chancreate(i32 noundef, i32 noundef) local_unnamed_addr #4

declare i32 @dofile(ptr noundef) local_unnamed_addr #4

declare void @defaultconfig() local_unnamed_addr #4

declare ptr @getdevice(ptr noundef) local_unnamed_addr #4

declare void @err(ptr noundef, ...) local_unnamed_addr #4

declare void @readcmdchan(ptr noundef) #4

declare void @addtask(ptr noundef byval(%struct.Task) align 8) local_unnamed_addr #4

declare i32 @threadcreate(ptr noundef, ptr noundef) local_unnamed_addr #4

declare ptr @simthread(ptr noundef) #4

declare ptr @cmdthread(ptr noundef) #4

declare ptr @rtcthread(ptr noundef) #4

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

declare void @serve(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = { "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 nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { nounwind }
attributes #7 = { noreturn nounwind }
attributes #8 = { cold 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = distinct !{!14, !10}
!15 = !{!16, !6, i64 0}
!16 = !{!"Foo", !6, i64 0, !6, i64 8, !7, i64 16}
!17 = !{!16, !6, i64 8}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass