; LLVM IR from freakout42/macrocalc :: arx/src (lib_twpo)

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

@__const.lib_twpo.ws = external hidden unnamed_addr constant [3 x i8], align 1
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@stderr = external global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @lib_twpo(ptr noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca [2 x i32], align 4
  %9 = alloca [2 x i32], align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca [256 x ptr], align 16
  %13 = alloca [3 x i8], align 1
  %14 = alloca [1024 x i8], align 16
  %15 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  store i32 0, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 2048, ptr %12) #7
  call void @llvm.lifetime.start.p0(i64 3, ptr %13) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %13, ptr align 1 @__const.lib_twpo.ws, i64 3, i1 false)
  call void @llvm.lifetime.start.p0(i64 1024, ptr %14) #7
  %16 = getelementptr inbounds [1024 x i8], ptr %14, i64 0, i64 0
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  %18 = call ptr @strcpy(ptr noundef %16, ptr noundef %17) #7
  %19 = getelementptr inbounds [1024 x i8], ptr %14, i64 0, i64 0
  %20 = getelementptr inbounds [3 x i8], ptr %13, i64 0, i64 0
  %21 = call ptr @strtok(ptr noundef %19, ptr noundef %20) #7
  %22 = getelementptr inbounds [256 x ptr], ptr %12, i64 0, i64 0
  store ptr %21, ptr %22, align 16, !tbaa !5
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = call ptr @strchr(ptr noundef %23, i32 noundef 47) #8
  %25 = icmp ne ptr %24, null
  br i1 %25, label %26, label %27

26:                                               ; preds = %3
  store i32 1, ptr %11, align 4, !tbaa !9
  br label %35

27:                                               ; preds = %3
  %28 = call ptr @getenv(ptr noundef @.str) #7
  %29 = getelementptr inbounds [256 x ptr], ptr %12, i64 0, i64 0
  %30 = load ptr, ptr %29, align 16, !tbaa !5
  %31 = call ptr @lib_path(ptr noundef %28, ptr noundef %30, i32 noundef 1)
  %32 = icmp eq ptr %31, null
  br i1 %32, label %33, label %34

33:                                               ; preds = %27
  store i32 3, ptr %4, align 4
  store i32 1, ptr %15, align 4
  br label %171

34:                                               ; preds = %27
  br label %35

35:                                               ; preds = %34, %26
  store i32 1, ptr %10, align 4, !tbaa !9
  br label %36

36:                                               ; preds = %48, %35
  %37 = load i32, ptr %10, align 4, !tbaa !9
  %38 = icmp slt i32 %37, 256
  br i1 %38, label %39, label %51

39:                                               ; preds = %36
  %40 = getelementptr inbounds [3 x i8], ptr %13, i64 0, i64 0
  %41 = call ptr @strtok(ptr noundef null, ptr noundef %40) #7
  %42 = load i32, ptr %10, align 4, !tbaa !9
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [256 x ptr], ptr %12, i64 0, i64 %43
  store ptr %41, ptr %44, align 8, !tbaa !5
  %45 = icmp eq ptr %41, null
  br i1 %45, label %46, label %47

46:                                               ; preds = %39
  br label %51

47:                                               ; preds = %39
  br label %48

48:                                               ; preds = %47
  %49 = load i32, ptr %10, align 4, !tbaa !9
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr %10, align 4, !tbaa !9
  br label %36, !llvm.loop !11

51:                                               ; preds = %46, %36
  %52 = getelementptr inbounds [2 x i32], ptr %8, i64 0, i64 0
  %53 = call i32 @pipe(ptr noundef %52) #7
  %54 = icmp ne i32 %53, 0
  br i1 %54, label %59, label %55

55:                                               ; preds = %51
  %56 = getelementptr inbounds [2 x i32], ptr %9, i64 0, i64 0
  %57 = call i32 @pipe(ptr noundef %56) #7
  %58 = icmp ne i32 %57, 0
  br i1 %58, label %59, label %60

59:                                               ; preds = %55, %51
  store i32 3, ptr %4, align 4
  store i32 1, ptr %15, align 4
  br label %171

60:                                               ; preds = %55
  %61 = call i32 @fork() #7
  switch i32 %61, label %125 [
    i32 -1, label %62
    i32 0, label %63
  ]

62:                                               ; preds = %60
  store i32 1, ptr %4, align 4
  store i32 1, ptr %15, align 4
  br label %171

63:                                               ; preds = %60
  %64 = call i32 @close(i32 noundef 0)
  %65 = icmp ne i32 %64, 0
  br i1 %65, label %72, label %66

66:                                               ; preds = %63
  %67 = call i32 @close(i32 noundef 1)
  %68 = icmp ne i32 %67, 0
  br i1 %68, label %72, label %69

69:                                               ; preds = %66
  %70 = call i32 @close(i32 noundef 2)
  %71 = icmp ne i32 %70, 0
  br i1 %71, label %72, label %73

72:                                               ; preds = %69, %66, %63
  call void @exit(i32 noundef 3) #9
  unreachable

73:                                               ; preds = %69
  %74 = getelementptr inbounds [2 x i32], ptr %9, i64 0, i64 0
  %75 = load i32, ptr %74, align 4, !tbaa !9
  %76 = call i32 @dup(i32 noundef %75) #7
  %77 = icmp ne i32 %76, 0
  br i1 %77, label %88, label %78

78:                                               ; preds = %73
  %79 = getelementptr inbounds [2 x i32], ptr %8, i64 0, i64 1
  %80 = load i32, ptr %79, align 4, !tbaa !9
  %81 = call i32 @dup(i32 noundef %80) #7
  %82 = icmp ne i32 %81, 1
  br i1 %82, label %88, label %83

83:                                               ; preds = %78
  %84 = getelementptr inbounds [2 x i32], ptr %8, i64 0, i64 1
  %85 = load i32, ptr %84, align 4, !tbaa !9
  %86 = call i32 @dup(i32 noundef %85) #7
  %87 = icmp ne i32 %86, 2
  br i1 %87, label %88, label %89

88:                                               ; preds = %83, %78, %73
  call void @exit(i32 noundef 1) #9
  unreachable

89:                                               ; preds = %83
  %90 = getelementptr inbounds [2 x i32], ptr %9, i64 0, i64 0
  %91 = load i32, ptr %90, align 4, !tbaa !9
  %92 = call i32 @close(i32 noundef %91)
  %93 = icmp ne i32 %92, 0
  br i1 %93, label %109, label %94

94:                                               ; preds = %89
  %95 = getelementptr inbounds [2 x i32], ptr %9, i64 0, i64 1
  %96 = load i32, ptr %95, align 4, !tbaa !9
  %97 = call i32 @close(i32 noundef %96)
  %98 = icmp ne i32 %97, 0
  br i1 %98, label %109, label %99

99:                                               ; preds = %94
  %100 = getelementptr inbounds [2 x i32], ptr %8, i64 0, i64 0
  %101 = load i32, ptr %100, align 4, !tbaa !9
  %102 = call i32 @close(i32 noundef %101)
  %103 = icmp ne i32 %102, 0
  br i1 %103, label %109, label %104

104:                                              ; preds = %99
  %105 = getelementptr inbounds [2 x i32], ptr %8, i64 0, i64 1
  %106 = load i32, ptr %105, align 4, !tbaa !9
  %107 = call i32 @close(i32 noundef %106)
  %108 = icmp ne i32 %107, 0
  br i1 %108, label %109, label %110

109:                                              ; preds = %104, %99, %94, %89
  call void @exit(i32 noundef 1) #9
  unreachable

110:                                              ; preds = %104
  %111 = load i32, ptr %11, align 4, !tbaa !9
  %112 = icmp ne i32 %111, 0
  br i1 %112, label %113, label %117

113:                                              ; preds = %110
  %114 = getelementptr inbounds [1024 x i8], ptr %14, i64 0, i64 0
  %115 = getelementptr inbounds [256 x ptr], ptr %12, i64 0, i64 0
  %116 = call i32 @execv(ptr noundef %114, ptr noundef %115) #7
  br label %121

117:                                              ; preds = %110
  %118 = getelementptr inbounds [1024 x i8], ptr %14, i64 0, i64 0
  %119 = getelementptr inbounds [256 x ptr], ptr %12, i64 0, i64 0
  %120 = call i32 @execvp(ptr noundef %118, ptr noundef %119) #7
  br label %121

121:                                              ; preds = %117, %113
  %122 = load ptr, ptr @stderr, align 8, !tbaa !5
  %123 = load ptr, ptr %7, align 8, !tbaa !5
  %124 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %122, ptr noundef @.str.1, ptr noundef %123) #7
  call void @exit(i32 noundef 3) #9
  unreachable

125:                                              ; preds = %60
  %126 = getelementptr inbounds [2 x i32], ptr %9, i64 0, i64 0
  %127 = load i32, ptr %126, align 4, !tbaa !9
  %128 = call i32 @close(i32 noundef %127)
  %129 = icmp ne i32 %128, 0
  br i1 %129, label %135, label %130

130:                                              ; preds = %125
  %131 = getelementptr inbounds [2 x i32], ptr %8, i64 0, i64 1
  %132 = load i32, ptr %131, align 4, !tbaa !9
  %133 = call i32 @close(i32 noundef %132)
  %134 = icmp ne i32 %133, 0
  br i1 %134, label %135, label %136

135:                                              ; preds = %130, %125
  store i32 1, ptr %4, align 4
  store i32 1, ptr %15, align 4
  br label %171

136:                                              ; preds = %130
  %137 = load ptr, ptr %5, align 8, !tbaa !5
  %138 = load ptr, ptr %137, align 8, !tbaa !5
  %139 = icmp eq ptr %138, null
  br i1 %139, label %140, label %144

140:                                              ; preds = %136
  %141 = getelementptr inbounds [2 x i32], ptr %8, i64 0, i64 0
  %142 = load i32, ptr %141, align 4, !tbaa !9
  %143 = call i32 (i32, i32, ...) @fcntl(i32 noundef %142, i32 noundef 4, i32 noundef 2048)
  br label %144

144:                                              ; preds = %140, %136
  %145 = getelementptr inbounds [2 x i32], ptr %8, i64 0, i64 0
  %146 = load i32, ptr %145, align 4, !tbaa !9
  %147 = call i32 (i32, i32, ...) @fcntl(i32 noundef %146, i32 noundef 2, i32 noundef 1)
  %148 = getelementptr inbounds [2 x i32], ptr %9, i64 0, i64 1
  %149 = load i32, ptr %148, align 4, !tbaa !9
  %150 = call i32 (i32, i32, ...) @fcntl(i32 noundef %149, i32 noundef 2, i32 noundef 1)
  %151 = getelementptr inbounds [2 x i32], ptr %8, i64 0, i64 0
  %152 = load i32, ptr %151, align 4, !tbaa !9
  %153 = call noalias ptr @fdopen(i32 noundef %152, ptr noundef @.str.2) #7
  %154 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %153, ptr %154, align 8, !tbaa !5
  %155 = getelementptr inbounds [2 x i32], ptr %9, i64 0, i64 1
  %156 = load i32, ptr %155, align 4, !tbaa !9
  %157 = call noalias ptr @fdopen(i32 noundef %156, ptr noundef @.str.3) #7
  %158 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %157, ptr %158, align 8, !tbaa !5
  %159 = load ptr, ptr %6, align 8, !tbaa !5
  %160 = load ptr, ptr %159, align 8, !tbaa !5
  call void @setbuf(ptr noundef %160, ptr noundef null) #7
  %161 = load ptr, ptr %5, align 8, !tbaa !5
  %162 = load ptr, ptr %161, align 8, !tbaa !5
  %163 = icmp eq ptr %162, null
  br i1 %163, label %168, label %164

164:                                              ; preds = %144
  %165 = load ptr, ptr %6, align 8, !tbaa !5
  %166 = load ptr, ptr %165, align 8, !tbaa !5
  %167 = icmp eq ptr %166, null
  br i1 %167, label %168, label %169

168:                                              ; preds = %164, %144
  store i32 1, ptr %4, align 4
  store i32 1, ptr %15, align 4
  br label %171

169:                                              ; preds = %164
  br label %170

170:                                              ; preds = %169
  store i32 0, ptr %4, align 4
  store i32 1, ptr %15, align 4
  br label %171

171:                                              ; preds = %170, %168, %135, %62, %59, %33
  call void @llvm.lifetime.end.p0(i64 1024, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 3, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 2048, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  %172 = load i32, ptr %4, align 4
  ret i32 %172
}

; 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: nounwind
declare ptr @strcpy(ptr noundef, ptr noundef) #3

; Function Attrs: nounwind
declare ptr @strtok(ptr noundef, ptr noundef) #3

; Function Attrs: nounwind willreturn memory(read)
declare ptr @strchr(ptr noundef, i32 noundef) #4

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

; Function Attrs: nounwind
declare ptr @getenv(ptr noundef) #3

; Function Attrs: nounwind
declare i32 @pipe(ptr noundef) #3

; Function Attrs: nounwind
declare i32 @fork() #3

declare i32 @close(i32 noundef) #5

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

; Function Attrs: nounwind
declare i32 @dup(i32 noundef) #3

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

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

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

declare i32 @fcntl(i32 noundef, i32 noundef, ...) #5

; Function Attrs: nounwind
declare noalias ptr @fdopen(i32 noundef, ptr noundef) #3

; Function Attrs: nounwind
declare void @setbuf(ptr noundef, ptr noundef) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { 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 = { nounwind willreturn memory(read) "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 = { 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 #7 = { nounwind }
attributes #8 = { nounwind willreturn memory(read) }
attributes #9 = { noreturn nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@__const.lib_twpo.ws = external hidden unnamed_addr constant [3 x i8], align 1
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@stderr = external local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 4) i32 @lib_twpo(ptr nocapture noundef %0, ptr nocapture noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = alloca [2 x i32], align 4
  %5 = alloca [2 x i32], align 4
  %6 = alloca [256 x ptr], align 16
  %7 = alloca [1024 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #10
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #10
  call void @llvm.lifetime.start.p0(i64 2048, ptr nonnull %6) #10
  call void @llvm.lifetime.start.p0(i64 1024, ptr nonnull %7) #10
  %8 = call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %7, ptr noundef nonnull dereferenceable(1) %2) #10
  %9 = call ptr @strtok(ptr noundef nonnull %7, ptr noundef nonnull @__const.lib_twpo.ws) #10
  store ptr %9, ptr %6, align 16, !tbaa !5
  %10 = call ptr @strchr(ptr noundef nonnull dereferenceable(1) %2, i32 noundef 47) #11
  %.not = icmp eq ptr %10, null
  br i1 %.not, label %11, label %.preheader

11:                                               ; preds = %3
  %12 = call ptr @getenv(ptr noundef nonnull @.str) #10
  %13 = call ptr @lib_path(ptr noundef %12, ptr noundef %9, i32 noundef 1) #10
  %14 = icmp eq ptr %13, null
  br i1 %14, label %93, label %.preheader

.preheader:                                       ; preds = %3, %11
  br label %15

15:                                               ; preds = %.preheader, %15
  %indvars.iv = phi i64 [ %indvars.iv.next, %15 ], [ 1, %.preheader ]
  %16 = call ptr @strtok(ptr noundef null, ptr noundef nonnull @__const.lib_twpo.ws) #10
  %17 = getelementptr inbounds [256 x ptr], ptr %6, i64 0, i64 %indvars.iv
  store ptr %16, ptr %17, align 8, !tbaa !5
  %18 = icmp eq ptr %16, null
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 256
  %or.cond = select i1 %18, i1 true, i1 %exitcond.not
  br i1 %or.cond, label %19, label %15, !llvm.loop !9

19:                                               ; preds = %15
  %20 = call i32 @pipe(ptr noundef nonnull %4) #10
  %.not15 = icmp eq i32 %20, 0
  br i1 %.not15, label %21, label %93

21:                                               ; preds = %19
  %22 = call i32 @pipe(ptr noundef nonnull %5) #10
  %.not16 = icmp eq i32 %22, 0
  br i1 %.not16, label %23, label %93

23:                                               ; preds = %21
  %24 = call i32 @fork() #10
  switch i32 %24, label %65 [
    i32 -1, label %93
    i32 0, label %25
  ]

25:                                               ; preds = %23
  %26 = call i32 @close(i32 noundef 0) #10
  %.not17 = icmp eq i32 %26, 0
  br i1 %.not17, label %27, label %31

27:                                               ; preds = %25
  %28 = call i32 @close(i32 noundef 1) #10
  %.not18 = icmp eq i32 %28, 0
  br i1 %.not18, label %29, label %31

29:                                               ; preds = %27
  %30 = call i32 @close(i32 noundef 2) #10
  %.not19 = icmp eq i32 %30, 0
  br i1 %.not19, label %32, label %31

31:                                               ; preds = %29, %27, %25
  call void @exit(i32 noundef 3) #12
  unreachable

32:                                               ; preds = %29
  %33 = load i32, ptr %5, align 4, !tbaa !11
  %34 = call i32 @dup(i32 noundef %33) #10
  %.not20 = icmp eq i32 %34, 0
  br i1 %.not20, label %35, label %42

35:                                               ; preds = %32
  %36 = getelementptr inbounds i8, ptr %4, i64 4
  %37 = load i32, ptr %36, align 4, !tbaa !11
  %38 = call i32 @dup(i32 noundef %37) #10
  %.not21 = icmp eq i32 %38, 1
  br i1 %.not21, label %39, label %42

39:                                               ; preds = %35
  %40 = load i32, ptr %36, align 4, !tbaa !11
  %41 = call i32 @dup(i32 noundef %40) #10
  %.not22 = icmp eq i32 %41, 2
  br i1 %.not22, label %43, label %42

42:                                               ; preds = %39, %35, %32
  call void @exit(i32 noundef 1) #12
  unreachable

43:                                               ; preds = %39
  %44 = load i32, ptr %5, align 4, !tbaa !11
  %45 = call i32 @close(i32 noundef %44) #10
  %.not23 = icmp eq i32 %45, 0
  br i1 %.not23, label %46, label %56

46:                                               ; preds = %43
  %47 = getelementptr inbounds i8, ptr %5, i64 4
  %48 = load i32, ptr %47, align 4, !tbaa !11
  %49 = call i32 @close(i32 noundef %48) #10
  %.not24 = icmp eq i32 %49, 0
  br i1 %.not24, label %50, label %56

50:                                               ; preds = %46
  %51 = load i32, ptr %4, align 4, !tbaa !11
  %52 = call i32 @close(i32 noundef %51) #10
  %.not25 = icmp eq i32 %52, 0
  br i1 %.not25, label %53, label %56

53:                                               ; preds = %50
  %54 = load i32, ptr %36, align 4, !tbaa !11
  %55 = call i32 @close(i32 noundef %54) #10
  %.not26 = icmp eq i32 %55, 0
  br i1 %.not26, label %57, label %56

56:                                               ; preds = %53, %50, %46, %43
  call void @exit(i32 noundef 1) #12
  unreachable

57:                                               ; preds = %53
  br i1 %.not, label %60, label %58

58:                                               ; preds = %57
  %59 = call i32 @execv(ptr noundef nonnull %7, ptr noundef nonnull %6) #10
  br label %62

60:                                               ; preds = %57
  %61 = call i32 @execvp(ptr noundef nonnull %7, ptr noundef nonnull %6) #10
  br label %62

62:                                               ; preds = %60, %58
  %63 = load ptr, ptr @stderr, align 8, !tbaa !5
  %64 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %63, ptr noundef nonnull @.str.1, ptr noundef %2) #13
  call void @exit(i32 noundef 3) #12
  unreachable

65:                                               ; preds = %23
  %66 = load i32, ptr %5, align 4, !tbaa !11
  %67 = call i32 @close(i32 noundef %66) #10
  %.not28 = icmp eq i32 %67, 0
  br i1 %.not28, label %68, label %93

68:                                               ; preds = %65
  %69 = getelementptr inbounds i8, ptr %4, i64 4
  %70 = load i32, ptr %69, align 4, !tbaa !11
  %71 = call i32 @close(i32 noundef %70) #10
  %.not29 = icmp eq i32 %71, 0
  br i1 %.not29, label %72, label %93

72:                                               ; preds = %68
  %73 = load ptr, ptr %0, align 8, !tbaa !5
  %74 = icmp eq ptr %73, null
  br i1 %74, label %75, label %78

75:                                               ; preds = %72
  %76 = load i32, ptr %4, align 4, !tbaa !11
  %77 = call i32 (i32, i32, ...) @fcntl(i32 noundef %76, i32 noundef 4, i32 noundef 2048) #10
  br label %78

78:                                               ; preds = %75, %72
  %79 = load i32, ptr %4, align 4, !tbaa !11
  %80 = call i32 (i32, i32, ...) @fcntl(i32 noundef %79, i32 noundef 2, i32 noundef 1) #10
  %81 = getelementptr inbounds i8, ptr %5, i64 4
  %82 = load i32, ptr %81, align 4, !tbaa !11
  %83 = call i32 (i32, i32, ...) @fcntl(i32 noundef %82, i32 noundef 2, i32 noundef 1) #10
  %84 = load i32, ptr %4, align 4, !tbaa !11
  %85 = call noalias ptr @fdopen(i32 noundef %84, ptr noundef nonnull @.str.2) #10
  store ptr %85, ptr %0, align 8, !tbaa !5
  %86 = load i32, ptr %81, align 4, !tbaa !11
  %87 = call noalias ptr @fdopen(i32 noundef %86, ptr noundef nonnull @.str.3) #10
  store ptr %87, ptr %1, align 8, !tbaa !5
  call void @setbuf(ptr noundef %87, ptr noundef null) #10
  %88 = load ptr, ptr %0, align 8, !tbaa !5
  %89 = icmp eq ptr %88, null
  br i1 %89, label %93, label %90

90:                                               ; preds = %78
  %91 = load ptr, ptr %1, align 8, !tbaa !5
  %92 = icmp eq ptr %91, null
  %spec.select = zext i1 %92 to i32
  br label %93

93:                                               ; preds = %90, %78, %65, %68, %23, %19, %21, %11
  %.014 = phi i32 [ 3, %11 ], [ 3, %21 ], [ 3, %19 ], [ 1, %23 ], [ 1, %68 ], [ 1, %65 ], [ 1, %78 ], [ %spec.select, %90 ]
  call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %7) #10
  call void @llvm.lifetime.end.p0(i64 2048, ptr nonnull %6) #10
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #10
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #10
  ret i32 %.014
}

; 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 nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strcpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn
declare ptr @strtok(ptr noundef, ptr nocapture noundef readonly) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare ptr @strchr(ptr noundef, i32 noundef) local_unnamed_addr #4

declare ptr @lib_path(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #5

; Function Attrs: nofree nounwind memory(read)
declare noundef ptr @getenv(ptr nocapture noundef) local_unnamed_addr #6

; Function Attrs: nounwind
declare i32 @pipe(ptr noundef) local_unnamed_addr #7

; Function Attrs: nofree nounwind
declare i32 @fork() local_unnamed_addr #8

declare i32 @close(i32 noundef) local_unnamed_addr #5

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

; Function Attrs: nounwind
declare i32 @dup(i32 noundef) local_unnamed_addr #7

; Function Attrs: nofree nounwind
declare i32 @execv(ptr noundef, ptr noundef) local_unnamed_addr #8

; Function Attrs: nofree nounwind
declare i32 @execvp(ptr noundef, ptr noundef) local_unnamed_addr #8

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

declare i32 @fcntl(i32 noundef, i32 noundef, ...) local_unnamed_addr #5

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fdopen(i32 noundef, ptr nocapture noundef readonly) local_unnamed_addr #8

; Function Attrs: nofree nounwind
declare void @setbuf(ptr nocapture noundef, ptr noundef) local_unnamed_addr #8

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nofree nounwind willreturn memory(argmem: readwrite) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nofree nounwind willreturn "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 = { nofree nounwind memory(read) "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 "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 = { 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 #9 = { 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 #10 = { nounwind }
attributes #11 = { nounwind willreturn memory(read) }
attributes #12 = { noreturn nounwind }
attributes #13 = { 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 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}


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