; LLVM IR from aap/pdp6 :: emu (main_serial)

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @talkserial(i32 noundef, ptr 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
  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) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 32, ptr %9) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  store ptr @.str.1, ptr %5, align 8, !tbaa !9
  store ptr null, ptr %6, align 8, !tbaa !9
  %17 = load ptr, ptr @argv0, align 8, !tbaa !9
  %18 = icmp ne ptr %17, null
  br i1 %18, label %23, label %19

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

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

30:                                               ; preds = %151, %23
  %31 = load ptr, ptr %4, align 8, !tbaa !9
  %32 = getelementptr inbounds ptr, ptr %31, i64 0
  %33 = load ptr, ptr %32, align 8, !tbaa !9
  %34 = icmp ne ptr %33, null
  br i1 %34, label %35, label %51

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

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

51:                                               ; preds = %43, %35, %30
  %52 = phi i1 [ false, %35 ], [ false, %30 ], [ %50, %43 ]
  br i1 %52, label %53, label %156

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

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

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

74:                                               ; preds = %63, %53
  store i8 0, ptr %14, align 1, !tbaa !11
  br label %75

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

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

86:                                               ; preds = %80, %75
  %87 = phi i1 [ false, %75 ], [ %85, %80 ]
  br i1 %87, label %88, label %144

88:                                               ; preds = %86
  %89 = load i8, ptr %14, align 1, !tbaa !11
  %90 = sext i8 %89 to i32
  switch i32 %90, label %142 [
    i32 116, label %91
    i32 100, label %92
    i32 112, label %117
  ]

91:                                               ; preds = %88
  store i32 1, ptr @dotrace, align 4, !tbaa !5
  br label %143

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

98:                                               ; preds = %92
  %99 = load ptr, ptr %13, align 8, !tbaa !9
  br label %115

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

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

111:                                              ; preds = %100
  call void @usage()
  call void @abort() #7
  unreachable

112:                                              ; No predecessors!
  br label %113

113:                                              ; preds = %112, %105
  %114 = phi ptr [ %110, %105 ], [ null, %112 ]
  br label %115

115:                                              ; preds = %113, %98
  %116 = phi ptr [ %99, %98 ], [ %114, %113 ]
  store ptr %116, ptr %5, align 8, !tbaa !9
  br label %143

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

123:                                              ; preds = %117
  %124 = load ptr, ptr %13, align 8, !tbaa !9
  br label %140

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

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

136:                                              ; preds = %125
  call void @usage()
  call void @abort() #7
  unreachable

137:                                              ; No predecessors!
  br label %138

138:                                              ; preds = %137, %130
  %139 = phi ptr [ %135, %130 ], [ null, %137 ]
  br label %140

140:                                              ; preds = %138, %123
  %141 = phi ptr [ %124, %123 ], [ %139, %138 ]
  store ptr %141, ptr %6, align 8, !tbaa !9
  br label %143

142:                                              ; preds = %88
  call void @usage()
  br label %143

143:                                              ; preds = %142, %140, %115, %91
  br label %75, !llvm.loop !12

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

148:                                              ; preds = %144, %69
  call void @llvm.lifetime.end.p0(i64 1, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  %149 = load i32, ptr %15, align 4
  switch i32 %149, label %216 [
    i32 0, label %150
    i32 2, label %156
  ]

150:                                              ; preds = %148
  br label %151

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

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

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

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

171:                                              ; preds = %167
  call void @defaultconfig()
  br label %172

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

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

180:                                              ; preds = %177, %172
  call void (ptr, ...) @err(ptr noundef @.str.8)
  br label %181

181:                                              ; preds = %180, %177
  %182 = call ptr @chancreate(i32 noundef 8, i32 noundef 1)
  %183 = getelementptr inbounds [2 x ptr], ptr %8, i64 0, i64 0
  store ptr %182, ptr %183, align 16, !tbaa !9
  %184 = call ptr @chancreate(i32 noundef 8, i32 noundef 1)
  %185 = getelementptr inbounds [2 x ptr], ptr %8, i64 0, i64 1
  store ptr %184, ptr %185, align 8, !tbaa !9
  %186 = getelementptr inbounds %struct.Task, ptr %16, i32 0, i32 0
  store ptr null, ptr %186, align 8, !tbaa !15
  %187 = getelementptr inbounds %struct.Task, ptr %16, i32 0, i32 1
  store ptr @readcmdchan, ptr %187, align 8, !tbaa !17
  %188 = getelementptr inbounds %struct.Task, ptr %16, i32 0, i32 2
  %189 = getelementptr inbounds [2 x ptr], ptr %8, i64 0, i64 0
  store ptr %189, ptr %188, align 8, !tbaa !18
  %190 = getelementptr inbounds %struct.Task, ptr %16, i32 0, i32 3
  store i32 10, ptr %190, align 8, !tbaa !19
  %191 = getelementptr inbounds %struct.Task, ptr %16, i32 0, i32 4
  store i32 0, ptr %191, 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)
  %192 = call i32 @threadcreate(ptr noundef @simthread, ptr noundef null)
  %193 = getelementptr inbounds [2 x ptr], ptr %8, i64 0, i64 0
  %194 = call i32 @threadcreate(ptr noundef @cmdthread, ptr noundef %193)
  %195 = call i32 @threadcreate(ptr noundef @rtcthread, ptr noundef null)
  %196 = load ptr, ptr %6, align 8, !tbaa !9
  %197 = icmp ne ptr %196, null
  br i1 %197, label %198, label %206

198:                                              ; preds = %181
  %199 = load ptr, ptr %6, align 8, !tbaa !9
  %200 = call i32 (ptr, i32, ...) @open(ptr noundef %199, i32 noundef 2)
  store i32 %200, ptr %7, align 4, !tbaa !5
  %201 = load i32, ptr %7, align 4, !tbaa !5
  %202 = icmp slt i32 %201, 0
  br i1 %202, label %203, label %205

203:                                              ; preds = %198
  %204 = load ptr, ptr %6, align 8, !tbaa !9
  call void (ptr, ...) @err(ptr noundef @.str.9, ptr noundef %204)
  br label %205

205:                                              ; preds = %203, %198
  br label %212

206:                                              ; preds = %181
  %207 = call i32 @dial(ptr noundef @.str.10, i32 noundef 2000)
  store i32 %207, ptr %7, align 4, !tbaa !5
  %208 = load i32, ptr %7, align 4, !tbaa !5
  %209 = icmp slt i32 %208, 0
  br i1 %209, label %210, label %211

210:                                              ; preds = %206
  call void (ptr, ...) @err(ptr noundef @.str.11)
  br label %211

211:                                              ; preds = %210, %206
  br label %212

212:                                              ; preds = %211, %205
  %213 = load i32, ptr %7, align 4, !tbaa !5
  %214 = load ptr, ptr %10, align 8, !tbaa !9
  %215 = load ptr, ptr %11, align 8, !tbaa !9
  call void @talkserial(i32 noundef %213, ptr noundef %214, ptr noundef %215)
  store i32 1, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  ret i32 0

216:                                              ; preds = %148
  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

declare i32 @open(ptr noundef, i32 noundef, ...) #5

declare i32 @dial(ptr noundef, i32 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 = { nounwind }
attributes #7 = { 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}


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

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

; Function Attrs: nounwind uwtable
declare dso_local void @talkserial(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #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
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #6
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %4) #6
  %5 = load ptr, ptr @argv0, align 8, !tbaa !5
  %.not = icmp eq ptr %5, null
  br i1 %.not, label %6, label %8

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

8:                                                ; preds = %6, %2
  %.048117 = getelementptr inbounds i8, ptr %1, i64 8
  %9 = load ptr, ptr %.048117, align 8, !tbaa !5
  %.not81119 = icmp eq ptr %9, null
  br i1 %.not81119, label %.critedge, label %.lr.ph124

.critedge2.loopexit:                              ; preds = %37
  %.048 = getelementptr inbounds i8, ptr %.452, i64 8
  %10 = load ptr, ptr %.048, align 8, !tbaa !5
  %.not81 = icmp eq ptr %10, null
  br i1 %.not81, label %.critedge, label %.lr.ph124, !llvm.loop !9

.lr.ph124:                                        ; preds = %8, %.critedge2.loopexit
  %11 = phi ptr [ %10, %.critedge2.loopexit ], [ %9, %8 ]
  %.048122 = phi ptr [ %.048, %.critedge2.loopexit ], [ %.048117, %8 ]
  %.055121 = phi ptr [ %.257, %.critedge2.loopexit ], [ @.str.1, %8 ]
  %.060120 = phi ptr [ %.262, %.critedge2.loopexit ], [ null, %8 ]
  %12 = load i8, ptr %11, align 1, !tbaa !11
  %13 = icmp eq i8 %12, 45
  br i1 %13, label %14, label %.critedge

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

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

.lr.ph.preheader:                                 ; preds = %14, %17
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %37
  %21 = phi i8 [ %38, %37 ], [ %16, %.lr.ph.preheader ]
  %.149112 = phi ptr [ %.452, %37 ], [ %.048122, %.lr.ph.preheader ]
  %.156111 = phi ptr [ %.257, %37 ], [ %.055121, %.lr.ph.preheader ]
  %.161110 = phi ptr [ %.262, %37 ], [ %.060120, %.lr.ph.preheader ]
  %.069109 = phi ptr [ %.170, %37 ], [ %15, %.lr.ph.preheader ]
  %22 = getelementptr inbounds i8, ptr %.069109, i64 1
  switch i8 %21, label %36 [
    i8 116, label %23
    i8 100, label %24
    i8 112, label %30
  ]

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

24:                                               ; preds = %.lr.ph
  %25 = load i8, ptr %22, align 1, !tbaa !11
  %.not86 = icmp eq i8 %25, 0
  br i1 %.not86, label %26, label %37

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

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

30:                                               ; preds = %.lr.ph
  %31 = load i8, ptr %22, align 1, !tbaa !11
  %.not84 = icmp eq i8 %31, 0
  br i1 %.not84, label %32, label %37

32:                                               ; preds = %30
  %33 = getelementptr inbounds i8, ptr %.149112, i64 8
  %34 = load ptr, ptr %33, align 8, !tbaa !5
  %.not85 = icmp eq ptr %34, null
  br i1 %.not85, label %35, label %37

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

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

37:                                               ; preds = %32, %26, %30, %24, %36, %23
  %.170 = phi ptr [ %22, %36 ], [ %22, %23 ], [ @.str.2, %24 ], [ @.str.2, %30 ], [ @.str.2, %26 ], [ @.str.2, %32 ]
  %.262 = phi ptr [ %.161110, %36 ], [ %.161110, %23 ], [ %.161110, %24 ], [ %22, %30 ], [ %.161110, %26 ], [ %34, %32 ]
  %.257 = phi ptr [ %.156111, %36 ], [ %.156111, %23 ], [ %22, %24 ], [ %.156111, %30 ], [ %28, %26 ], [ %.156111, %32 ]
  %.452 = phi ptr [ %.149112, %36 ], [ %.149112, %23 ], [ %.149112, %24 ], [ %.149112, %30 ], [ %27, %26 ], [ %33, %32 ]
  %38 = load i8, ptr %.170, align 1, !tbaa !11
  %.not83 = icmp eq i8 %38, 0
  br i1 %.not83, label %.critedge2.loopexit, label %.lr.ph, !llvm.loop !14

.critedge:                                        ; preds = %.critedge2.loopexit, %.lr.ph124, %14, %17, %8
  %.060.lcssa = phi ptr [ null, %8 ], [ %.060120, %17 ], [ %.060120, %14 ], [ %.060120, %.lr.ph124 ], [ %.262, %.critedge2.loopexit ]
  %.055.lcssa = phi ptr [ @.str.1, %8 ], [ %.055121, %17 ], [ %.055121, %14 ], [ %.055121, %.lr.ph124 ], [ %.257, %.critedge2.loopexit ]
  %39 = tail call noalias ptr @fopen(ptr noundef %.055.lcssa, ptr noundef nonnull @.str.3)
  store ptr %39, ptr @debugfp, align 8, !tbaa !5
  %40 = icmp eq ptr %39, null
  br i1 %40, label %41, label %44

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

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

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

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

53:                                               ; preds = %48
  tail call void (ptr, ...) @err(ptr noundef nonnull @.str.8) #6
  br label %54

54:                                               ; preds = %48, %53
  %55 = tail call ptr @chancreate(i32 noundef 8, i32 noundef 1) #6
  store ptr %55, ptr %3, align 16, !tbaa !5
  %56 = tail call ptr @chancreate(i32 noundef 8, i32 noundef 1) #6
  %57 = getelementptr inbounds i8, ptr %3, i64 8
  store ptr %56, ptr %57, 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
  %58 = call i32 @threadcreate(ptr noundef nonnull @simthread, ptr noundef null) #6
  %59 = call i32 @threadcreate(ptr noundef nonnull @cmdthread, ptr noundef nonnull %3) #6
  %60 = call i32 @threadcreate(ptr noundef nonnull @rtcthread, ptr noundef null) #6
  %.not89 = icmp eq ptr %.060.lcssa, null
  br i1 %.not89, label %65, label %61

61:                                               ; preds = %54
  %62 = call i32 (ptr, i32, ...) @open(ptr noundef nonnull %.060.lcssa, i32 noundef 2) #6
  %63 = icmp slt i32 %62, 0
  br i1 %63, label %64, label %69

64:                                               ; preds = %61
  call void (ptr, ...) @err(ptr noundef nonnull @.str.9, ptr noundef nonnull %.060.lcssa) #6
  br label %69

65:                                               ; preds = %54
  %66 = call i32 @dial(ptr noundef nonnull @.str.10, i32 noundef 2000) #6
  %67 = icmp slt i32 %66, 0
  br i1 %67, label %68, label %69

68:                                               ; preds = %65
  call void (ptr, ...) @err(ptr noundef nonnull @.str.11) #6
  br label %69

69:                                               ; preds = %65, %68, %61, %64
  %.065 = phi i32 [ %62, %64 ], [ %62, %61 ], [ %66, %68 ], [ %66, %65 ]
  call void @talkserial(i32 noundef %.065, ptr noundef %49, ptr noundef %50)
  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: nofree
declare noundef i32 @open(ptr nocapture noundef readonly, i32 noundef, ...) local_unnamed_addr #5

declare i32 @dial(ptr noundef, i32 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 = { nofree "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nounwind }
attributes #7 = { noreturn nounwind }
attributes #8 = { 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}


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