; LLVM IR from martanne/dvtm :: dvtm-editor (main)

; 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.stat = type { i64, i64, i64, i32, i32, i32, i32, i64, i64, i64, i64, %struct.timespec, %struct.timespec, %struct.timespec, [3 x i64] }
%struct.timespec = type { i64, i64 }

@.str = external hidden unnamed_addr constant [12 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@__const.main.tempname = external hidden unnamed_addr constant [24 x i8], align 16
@.str.4 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [44 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [31 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca [24 x i8], align 16
  %10 = alloca [2048 x i8], align 16
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i32, align 4
  %14 = alloca %struct.stat, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca ptr, align 8
  %18 = alloca i64, align 8
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca %struct.stat, align 8
  %23 = alloca i64, align 8
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  store i32 1, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  store i32 -1, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  %24 = call ptr @getenv(ptr noundef @.str) #7
  store ptr %24, ptr %8, align 8, !tbaa !9
  %25 = load ptr, ptr %8, align 8, !tbaa !9
  %26 = icmp ne ptr %25, null
  br i1 %26, label %29, label %27

27:                                               ; preds = %2
  %28 = call ptr @getenv(ptr noundef @.str.1) #7
  store ptr %28, ptr %8, align 8, !tbaa !9
  br label %29

29:                                               ; preds = %27, %2
  %30 = load ptr, ptr %8, align 8, !tbaa !9
  %31 = icmp ne ptr %30, null
  br i1 %31, label %34, label %32

32:                                               ; preds = %29
  %33 = call ptr @getenv(ptr noundef @.str.2) #7
  store ptr %33, ptr %8, align 8, !tbaa !9
  br label %34

34:                                               ; preds = %32, %29
  %35 = load ptr, ptr %8, align 8, !tbaa !9
  %36 = icmp ne ptr %35, null
  br i1 %36, label %38, label %37

37:                                               ; preds = %34
  store ptr @.str.3, ptr %8, align 8, !tbaa !9
  br label %38

38:                                               ; preds = %37, %34
  call void @llvm.lifetime.start.p0(i64 24, ptr %9) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %9, ptr align 16 @__const.main.tempname, i64 24, i1 false)
  %39 = getelementptr inbounds [24 x i8], ptr %9, i64 0, i64 0
  %40 = call i32 @mkstemp(ptr noundef %39)
  store i32 %40, ptr %7, align 4, !tbaa !5
  %41 = icmp eq i32 %40, -1
  br i1 %41, label %42, label %44

42:                                               ; preds = %38
  %43 = getelementptr inbounds [24 x i8], ptr %9, i64 0, i64 0
  call void (ptr, ...) @error(ptr noundef @.str.4, ptr noundef %43)
  br label %228

44:                                               ; preds = %38
  %45 = load i32, ptr %7, align 4, !tbaa !5
  %46 = call i32 @fchmod(i32 noundef %45, i32 noundef 384) #7
  %47 = icmp eq i32 %46, -1
  br i1 %47, label %48, label %50

48:                                               ; preds = %44
  %49 = getelementptr inbounds [24 x i8], ptr %9, i64 0, i64 0
  call void (ptr, ...) @error(ptr noundef @.str.5, ptr noundef %49)
  br label %228

50:                                               ; preds = %44
  br label %51

51:                                               ; preds = %75, %50
  %52 = getelementptr inbounds [2048 x i8], ptr %10, i64 0, i64 0
  %53 = call i64 @read(i32 noundef 0, ptr noundef %52, i64 noundef 2048)
  store i64 %53, ptr %11, align 8, !tbaa !11
  %54 = icmp sgt i64 %53, 0
  br i1 %54, label %55, label %76

55:                                               ; preds = %51
  br label %56

56:                                               ; preds = %72, %55
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  %57 = load i32, ptr %7, align 4, !tbaa !5
  %58 = getelementptr inbounds [2048 x i8], ptr %10, i64 0, i64 0
  %59 = load i64, ptr %11, align 8, !tbaa !11
  %60 = call i64 @write(i32 noundef %57, ptr noundef %58, i64 noundef %59)
  store i64 %60, ptr %12, align 8, !tbaa !11
  %61 = load i64, ptr %12, align 8, !tbaa !11
  %62 = icmp eq i64 %61, -1
  br i1 %62, label %63, label %65

63:                                               ; preds = %56
  %64 = getelementptr inbounds [24 x i8], ptr %9, i64 0, i64 0
  call void (ptr, ...) @error(ptr noundef @.str.6, ptr noundef %64)
  store i32 2, ptr %13, align 4
  br label %69

65:                                               ; preds = %56
  %66 = load i64, ptr %12, align 8, !tbaa !11
  %67 = load i64, ptr %11, align 8, !tbaa !11
  %68 = sub nsw i64 %67, %66
  store i64 %68, ptr %11, align 8, !tbaa !11
  store i32 0, ptr %13, align 4
  br label %69

69:                                               ; preds = %65, %63
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  %70 = load i32, ptr %13, align 4
  switch i32 %70, label %236 [
    i32 0, label %71
    i32 2, label %228
  ]

71:                                               ; preds = %69
  br label %72

72:                                               ; preds = %71
  %73 = load i64, ptr %11, align 8, !tbaa !11
  %74 = icmp sgt i64 %73, 0
  br i1 %74, label %56, label %75, !llvm.loop !13

75:                                               ; preds = %72
  br label %51, !llvm.loop !15

76:                                               ; preds = %51
  %77 = load i32, ptr %7, align 4, !tbaa !5
  %78 = call i32 @fsync(i32 noundef %77)
  %79 = icmp eq i32 %78, -1
  br i1 %79, label %80, label %82

80:                                               ; preds = %76
  %81 = getelementptr inbounds [24 x i8], ptr %9, i64 0, i64 0
  call void (ptr, ...) @error(ptr noundef @.str.7, ptr noundef %81)
  br label %228

82:                                               ; preds = %76
  %83 = load i32, ptr %7, align 4, !tbaa !5
  %84 = call i32 @fstat(i32 noundef %83, ptr noundef %14) #7
  %85 = icmp eq i32 %84, -1
  br i1 %85, label %86, label %88

86:                                               ; preds = %82
  %87 = getelementptr inbounds [24 x i8], ptr %9, i64 0, i64 0
  call void (ptr, ...) @error(ptr noundef @.str.8, ptr noundef %87)
  br label %228

88:                                               ; preds = %82
  %89 = load i32, ptr %7, align 4, !tbaa !5
  %90 = call i32 @close(i32 noundef %89)
  %91 = icmp eq i32 %90, -1
  br i1 %91, label %92, label %94

92:                                               ; preds = %88
  %93 = getelementptr inbounds [24 x i8], ptr %9, i64 0, i64 0
  call void (ptr, ...) @error(ptr noundef @.str.9, ptr noundef %93)
  br label %228

94:                                               ; preds = %88
  %95 = call i32 @fork() #7
  store i32 %95, ptr %15, align 4, !tbaa !5
  %96 = load i32, ptr %15, align 4, !tbaa !5
  %97 = icmp eq i32 %96, -1
  br i1 %97, label %98, label %99

98:                                               ; preds = %94
  call void (ptr, ...) @error(ptr noundef @.str.10)
  br label %228

99:                                               ; preds = %94
  %100 = load i32, ptr %15, align 4, !tbaa !5
  %101 = icmp eq i32 %100, 0
  br i1 %101, label %102, label %161

102:                                              ; preds = %99
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #7
  %103 = call i32 (ptr, i32, ...) @open(ptr noundef @.str.11, i32 noundef 2)
  store i32 %103, ptr %16, align 4, !tbaa !5
  %104 = load i32, ptr %16, align 4, !tbaa !5
  %105 = icmp eq i32 %104, -1
  br i1 %105, label %106, label %107

106:                                              ; preds = %102
  call void (ptr, ...) @error(ptr noundef @.str.12)
  call void @_exit(i32 noundef 1) #8
  unreachable

107:                                              ; preds = %102
  %108 = load i32, ptr %16, align 4, !tbaa !5
  %109 = call i32 @dup2(i32 noundef %108, i32 noundef 0) #7
  %110 = icmp eq i32 %109, -1
  br i1 %110, label %111, label %112

111:                                              ; preds = %107
  call void (ptr, ...) @error(ptr noundef @.str.13)
  call void @_exit(i32 noundef 1) #8
  unreachable

112:                                              ; preds = %107
  %113 = load i32, ptr %16, align 4, !tbaa !5
  %114 = call i32 @dup2(i32 noundef %113, i32 noundef 1) #7
  %115 = icmp eq i32 %114, -1
  br i1 %115, label %116, label %117

116:                                              ; preds = %112
  call void (ptr, ...) @error(ptr noundef @.str.14)
  call void @_exit(i32 noundef 1) #8
  unreachable

117:                                              ; preds = %112
  %118 = load i32, ptr %16, align 4, !tbaa !5
  %119 = call i32 @dup2(i32 noundef %118, i32 noundef 2) #7
  %120 = icmp eq i32 %119, -1
  br i1 %120, label %121, label %122

121:                                              ; preds = %117
  call void (ptr, ...) @error(ptr noundef @.str.15)
  call void @_exit(i32 noundef 1) #8
  unreachable

122:                                              ; preds = %117
  %123 = load i32, ptr %16, align 4, !tbaa !5
  %124 = call i32 @close(i32 noundef %123)
  %125 = load i32, ptr %4, align 4, !tbaa !5
  %126 = add nsw i32 %125, 2
  %127 = zext i32 %126 to i64
  %128 = call ptr @llvm.stacksave.p0()
  store ptr %128, ptr %17, align 8
  %129 = alloca ptr, i64 %127, align 16
  store i64 %127, ptr %18, align 8
  %130 = load ptr, ptr %8, align 8, !tbaa !9
  %131 = getelementptr inbounds ptr, ptr %129, i64 0
  store ptr %130, ptr %131, align 16, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #7
  store i32 1, ptr %19, align 4, !tbaa !5
  br label %132

132:                                              ; preds = %146, %122
  %133 = load i32, ptr %19, align 4, !tbaa !5
  %134 = load i32, ptr %4, align 4, !tbaa !5
  %135 = icmp slt i32 %133, %134
  br i1 %135, label %137, label %136

136:                                              ; preds = %132
  store i32 7, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #7
  br label %149

137:                                              ; preds = %132
  %138 = load ptr, ptr %5, align 8, !tbaa !9
  %139 = load i32, ptr %19, align 4, !tbaa !5
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds ptr, ptr %138, i64 %140
  %142 = load ptr, ptr %141, align 8, !tbaa !9
  %143 = load i32, ptr %19, align 4, !tbaa !5
  %144 = sext i32 %143 to i64
  %145 = getelementptr inbounds ptr, ptr %129, i64 %144
  store ptr %142, ptr %145, align 8, !tbaa !9
  br label %146

146:                                              ; preds = %137
  %147 = load i32, ptr %19, align 4, !tbaa !5
  %148 = add nsw i32 %147, 1
  store i32 %148, ptr %19, align 4, !tbaa !5
  br label %132, !llvm.loop !16

149:                                              ; preds = %136
  %150 = getelementptr inbounds [24 x i8], ptr %9, i64 0, i64 0
  %151 = load i32, ptr %4, align 4, !tbaa !5
  %152 = sext i32 %151 to i64
  %153 = getelementptr inbounds ptr, ptr %129, i64 %152
  store ptr %150, ptr %153, align 8, !tbaa !9
  %154 = load i32, ptr %4, align 4, !tbaa !5
  %155 = add nsw i32 %154, 1
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds ptr, ptr %129, i64 %156
  store ptr null, ptr %157, align 8, !tbaa !9
  %158 = load ptr, ptr %8, align 8, !tbaa !9
  %159 = call i32 @execvp(ptr noundef %158, ptr noundef %129) #7
  %160 = load ptr, ptr %8, align 8, !tbaa !9
  call void (ptr, ...) @error(ptr noundef @.str.16, ptr noundef %160)
  call void @_exit(i32 noundef 127) #8
  unreachable

161:                                              ; preds = %99
  br label %162

162:                                              ; preds = %161
  %163 = load i32, ptr %15, align 4, !tbaa !5
  %164 = call i32 @waitpid(i32 noundef %163, ptr noundef %20, i32 noundef 0)
  %165 = icmp eq i32 %164, -1
  br i1 %165, label %166, label %167

166:                                              ; preds = %162
  call void (ptr, ...) @error(ptr noundef @.str.17)
  br label %228

167:                                              ; preds = %162
  %168 = load i32, ptr %20, align 4, !tbaa !5
  %169 = and i32 %168, 127
  %170 = icmp eq i32 %169, 0
  br i1 %170, label %172, label %171

171:                                              ; preds = %167
  call void (ptr, ...) @error(ptr noundef @.str.18)
  br label %228

172:                                              ; preds = %167
  %173 = load i32, ptr %20, align 4, !tbaa !5
  %174 = and i32 %173, 65280
  %175 = ashr i32 %174, 8
  store i32 %175, ptr %20, align 4, !tbaa !5
  %176 = icmp ne i32 %175, 0
  br i1 %176, label %177, label %179

177:                                              ; preds = %172
  %178 = load i32, ptr %20, align 4, !tbaa !5
  call void (ptr, ...) @error(ptr noundef @.str.19, i32 noundef %178)
  br label %228

179:                                              ; preds = %172
  %180 = getelementptr inbounds [24 x i8], ptr %9, i64 0, i64 0
  %181 = call i32 (ptr, i32, ...) @open(ptr noundef %180, i32 noundef 0)
  store i32 %181, ptr %21, align 4, !tbaa !5
  %182 = load i32, ptr %21, align 4, !tbaa !5
  %183 = icmp eq i32 %182, -1
  br i1 %183, label %184, label %186

184:                                              ; preds = %179
  %185 = getelementptr inbounds [24 x i8], ptr %9, i64 0, i64 0
  call void (ptr, ...) @error(ptr noundef @.str.20, ptr noundef %185)
  br label %228

186:                                              ; preds = %179
  %187 = load i32, ptr %21, align 4, !tbaa !5
  %188 = call i32 @fstat(i32 noundef %187, ptr noundef %22) #7
  %189 = icmp eq i32 %188, -1
  br i1 %189, label %190, label %192

190:                                              ; preds = %186
  %191 = getelementptr inbounds [24 x i8], ptr %9, i64 0, i64 0
  call void (ptr, ...) @error(ptr noundef @.str.21, ptr noundef %191)
  br label %228

192:                                              ; preds = %186
  %193 = getelementptr inbounds %struct.stat, ptr %14, i32 0, i32 12
  %194 = getelementptr inbounds %struct.timespec, ptr %193, i32 0, i32 0
  %195 = load i64, ptr %194, align 8, !tbaa !17
  %196 = getelementptr inbounds %struct.stat, ptr %22, i32 0, i32 12
  %197 = getelementptr inbounds %struct.timespec, ptr %196, i32 0, i32 0
  %198 = load i64, ptr %197, align 8, !tbaa !17
  %199 = icmp eq i64 %195, %198
  br i1 %199, label %200, label %201

200:                                              ; preds = %192
  br label %227

201:                                              ; preds = %192
  br label %202

202:                                              ; preds = %225, %201
  %203 = load i32, ptr %21, align 4, !tbaa !5
  %204 = getelementptr inbounds [2048 x i8], ptr %10, i64 0, i64 0
  %205 = call i64 @read(i32 noundef %203, ptr noundef %204, i64 noundef 2048)
  store i64 %205, ptr %11, align 8, !tbaa !11
  %206 = icmp sgt i64 %205, 0
  br i1 %206, label %207, label %226

207:                                              ; preds = %202
  br label %208

208:                                              ; preds = %222, %207
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #7
  %209 = getelementptr inbounds [2048 x i8], ptr %10, i64 0, i64 0
  %210 = load i64, ptr %11, align 8, !tbaa !11
  %211 = call i64 @write(i32 noundef 1, ptr noundef %209, i64 noundef %210)
  store i64 %211, ptr %23, align 8, !tbaa !11
  %212 = load i64, ptr %23, align 8, !tbaa !11
  %213 = icmp eq i64 %212, -1
  br i1 %213, label %214, label %215

214:                                              ; preds = %208
  call void (ptr, ...) @error(ptr noundef @.str.22)
  store i32 2, ptr %13, align 4
  br label %219

215:                                              ; preds = %208
  %216 = load i64, ptr %23, align 8, !tbaa !11
  %217 = load i64, ptr %11, align 8, !tbaa !11
  %218 = sub nsw i64 %217, %216
  store i64 %218, ptr %11, align 8, !tbaa !11
  store i32 0, ptr %13, align 4
  br label %219

219:                                              ; preds = %215, %214
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #7
  %220 = load i32, ptr %13, align 4
  switch i32 %220, label %236 [
    i32 0, label %221
    i32 2, label %228
  ]

221:                                              ; preds = %219
  br label %222

222:                                              ; preds = %221
  %223 = load i64, ptr %11, align 8, !tbaa !11
  %224 = icmp sgt i64 %223, 0
  br i1 %224, label %208, label %225, !llvm.loop !20

225:                                              ; preds = %222
  br label %202, !llvm.loop !21

226:                                              ; preds = %202
  br label %227

227:                                              ; preds = %226, %200
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %228

228:                                              ; preds = %227, %219, %190, %184, %177, %171, %166, %98, %92, %86, %80, %69, %48, %42
  %229 = load i32, ptr %7, align 4, !tbaa !5
  %230 = icmp ne i32 %229, -1
  br i1 %230, label %231, label %234

231:                                              ; preds = %228
  %232 = getelementptr inbounds [24 x i8], ptr %9, i64 0, i64 0
  %233 = call i32 @unlink(ptr noundef %232) #7
  br label %234

234:                                              ; preds = %231, %228
  %235 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %235, ptr %3, align 4
  store i32 1, ptr %13, align 4
  br label %236

236:                                              ; preds = %234, %219, %69
  call void @llvm.lifetime.end.p0(i64 24, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  %237 = load i32, ptr %3, align 4
  ret i32 %237
}

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

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

; 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) #3

declare i32 @mkstemp(ptr noundef) #4

; Function Attrs: nounwind uwtable
declare hidden void @error(ptr noundef, ...) #0

; Function Attrs: nounwind
declare i32 @fchmod(i32 noundef, i32 noundef) #2

declare i64 @read(i32 noundef, ptr noundef, i64 noundef) #4

declare i64 @write(i32 noundef, ptr noundef, i64 noundef) #4

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

declare i32 @fsync(i32 noundef) #4

; Function Attrs: nounwind
declare i32 @fstat(i32 noundef, ptr noundef) #2

declare i32 @close(i32 noundef) #4

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

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

; Function Attrs: noreturn
declare void @_exit(i32 noundef) #5

; Function Attrs: nounwind
declare i32 @dup2(i32 noundef, i32 noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #6

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

declare i32 @waitpid(i32 noundef, ptr noundef, i32 noundef) #4

; Function Attrs: nounwind
declare i32 @unlink(ptr noundef) #2

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 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { noreturn "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 nosync nounwind willreturn }
attributes #7 = { nounwind }
attributes #8 = { noreturn }

!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 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}
!17 = !{!18, !12, i64 88}
!18 = !{!"stat", !12, i64 0, !12, i64 8, !12, i64 16, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36, !12, i64 40, !12, i64 48, !12, i64 56, !12, i64 64, !19, i64 72, !19, i64 88, !19, i64 104, !7, i64 120}
!19 = !{!"timespec", !12, i64 0, !12, i64 8}
!20 = distinct !{!20, !14}
!21 = distinct !{!21, !14}


; 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.stat = type { i64, i64, i64, i32, i32, i32, i32, i64, i64, i64, i64, %struct.timespec, %struct.timespec, %struct.timespec, [3 x i64] }
%struct.timespec = type { i64, i64 }

@.str = external hidden unnamed_addr constant [12 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@__const.main.tempname = external hidden unnamed_addr constant [24 x i8], align 16
@.str.4 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [44 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [31 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @main(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = alloca [24 x i8], align 16
  %4 = alloca [2048 x i8], align 16
  %5 = alloca %struct.stat, align 8
  %6 = alloca i32, align 4
  %7 = alloca %struct.stat, align 8
  %8 = tail call ptr @getenv(ptr noundef nonnull @.str) #9
  %.not = icmp eq ptr %8, null
  br i1 %.not, label %9, label %.thread

9:                                                ; preds = %2
  %10 = tail call ptr @getenv(ptr noundef nonnull @.str.1) #9
  %.not63 = icmp eq ptr %10, null
  br i1 %.not63, label %11, label %.thread

11:                                               ; preds = %9
  %12 = tail call ptr @getenv(ptr noundef nonnull @.str.2) #9
  br label %.thread

.thread:                                          ; preds = %2, %11, %9
  %.1 = phi ptr [ %10, %9 ], [ %12, %11 ], [ %8, %2 ]
  %.not64 = icmp eq ptr %.1, null
  %spec.store.select = select i1 %.not64, ptr @.str.3, ptr %.1
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %3) #9
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(24) %3, ptr noundef nonnull align 16 dereferenceable(24) @__const.main.tempname, i64 24, i1 false)
  %13 = call i32 @mkstemp(ptr noundef nonnull %3) #9
  %14 = icmp eq i32 %13, -1
  br i1 %14, label %.thread83, label %15

.thread83:                                        ; preds = %.thread
  call void (ptr, ...) @error(ptr noundef nonnull @.str.4, ptr noundef nonnull %3)
  br label %111

15:                                               ; preds = %.thread
  %16 = call i32 @fchmod(i32 noundef %13, i32 noundef 384) #9
  %17 = icmp eq i32 %16, -1
  br i1 %17, label %.thread86, label %.preheader91

.preheader91:                                     ; preds = %15
  %18 = call i64 @read(i32 noundef 0, ptr noundef nonnull %4, i64 noundef 2048) #9
  %19 = icmp sgt i64 %18, 0
  br i1 %19, label %.preheader90, label %._crit_edge

.thread86:                                        ; preds = %15
  call void (ptr, ...) @error(ptr noundef nonnull @.str.5, ptr noundef nonnull %3)
  br label %.loopexit

.preheader90:                                     ; preds = %.preheader91, %.preheader90.backedge
  %.048 = phi i64 [ %.048.be, %.preheader90.backedge ], [ %18, %.preheader91 ]
  %20 = call i64 @write(i32 noundef %13, ptr noundef nonnull %4, i64 noundef %.048) #9
  %21 = icmp eq i64 %20, -1
  br i1 %21, label %22, label %23

22:                                               ; preds = %.preheader90
  call void (ptr, ...) @error(ptr noundef nonnull @.str.6, ptr noundef nonnull %3)
  br label %.loopexit

23:                                               ; preds = %.preheader90
  %24 = sub nsw i64 %.048, %20
  %25 = icmp sgt i64 %24, 0
  br i1 %25, label %.preheader90.backedge, label %26

.preheader90.backedge:                            ; preds = %23, %26
  %.048.be = phi i64 [ %24, %23 ], [ %27, %26 ]
  br label %.preheader90, !llvm.loop !5

26:                                               ; preds = %23
  %27 = call i64 @read(i32 noundef 0, ptr noundef nonnull %4, i64 noundef 2048) #9
  %28 = icmp sgt i64 %27, 0
  br i1 %28, label %.preheader90.backedge, label %._crit_edge

._crit_edge:                                      ; preds = %26, %.preheader91
  %29 = call i32 @fsync(i32 noundef %13) #9
  %30 = icmp eq i32 %29, -1
  br i1 %30, label %31, label %32

31:                                               ; preds = %._crit_edge
  call void (ptr, ...) @error(ptr noundef nonnull @.str.7, ptr noundef nonnull %3)
  br label %.loopexit

32:                                               ; preds = %._crit_edge
  %33 = call i32 @fstat(i32 noundef %13, ptr noundef nonnull %5) #9
  %34 = icmp eq i32 %33, -1
  br i1 %34, label %35, label %36

35:                                               ; preds = %32
  call void (ptr, ...) @error(ptr noundef nonnull @.str.8, ptr noundef nonnull %3)
  br label %.loopexit

36:                                               ; preds = %32
  %37 = call i32 @close(i32 noundef %13) #9
  %38 = icmp eq i32 %37, -1
  br i1 %38, label %39, label %40

39:                                               ; preds = %36
  call void (ptr, ...) @error(ptr noundef nonnull @.str.9, ptr noundef nonnull %3)
  br label %.loopexit

40:                                               ; preds = %36
  %41 = call i32 @fork() #9
  switch i32 %41, label %72 [
    i32 -1, label %42
    i32 0, label %43
  ]

42:                                               ; preds = %40
  call void (ptr, ...) @error(ptr noundef nonnull @.str.10)
  br label %.loopexit

43:                                               ; preds = %40
  %44 = call i32 (ptr, i32, ...) @open(ptr noundef nonnull @.str.11, i32 noundef 2) #9
  %45 = icmp eq i32 %44, -1
  br i1 %45, label %46, label %47

46:                                               ; preds = %43
  call void (ptr, ...) @error(ptr noundef nonnull @.str.12)
  call void @_exit(i32 noundef 1) #10
  unreachable

47:                                               ; preds = %43
  %48 = call i32 @dup2(i32 noundef %44, i32 noundef 0) #9
  %49 = icmp eq i32 %48, -1
  br i1 %49, label %50, label %51

50:                                               ; preds = %47
  call void (ptr, ...) @error(ptr noundef nonnull @.str.13)
  call void @_exit(i32 noundef 1) #10
  unreachable

51:                                               ; preds = %47
  %52 = call i32 @dup2(i32 noundef %44, i32 noundef 1) #9
  %53 = icmp eq i32 %52, -1
  br i1 %53, label %54, label %55

54:                                               ; preds = %51
  call void (ptr, ...) @error(ptr noundef nonnull @.str.14)
  call void @_exit(i32 noundef 1) #10
  unreachable

55:                                               ; preds = %51
  %56 = call i32 @dup2(i32 noundef %44, i32 noundef 2) #9
  %57 = icmp eq i32 %56, -1
  br i1 %57, label %58, label %59

58:                                               ; preds = %55
  call void (ptr, ...) @error(ptr noundef nonnull @.str.15)
  call void @_exit(i32 noundef 1) #10
  unreachable

59:                                               ; preds = %55
  %60 = call i32 @close(i32 noundef %44) #9
  %61 = add nsw i32 %0, 2
  %62 = zext i32 %61 to i64
  %63 = alloca ptr, i64 %62, align 16
  store ptr %spec.store.select, ptr %63, align 16, !tbaa !7
  %64 = icmp sgt i32 %0, 1
  br i1 %64, label %.lr.ph.preheader, label %._crit_edge94

.lr.ph.preheader:                                 ; preds = %59
  %scevgep = getelementptr i8, ptr %63, i64 8
  %scevgep95 = getelementptr i8, ptr %1, i64 8
  %65 = add nsw i32 %0, -1
  %66 = zext nneg i32 %65 to i64
  %67 = shl nuw nsw i64 %66, 3
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %scevgep, ptr align 8 %scevgep95, i64 %67, i1 false), !tbaa !7
  br label %._crit_edge94

._crit_edge94:                                    ; preds = %.lr.ph.preheader, %59
  %68 = sext i32 %0 to i64
  %69 = getelementptr inbounds ptr, ptr %63, i64 %68
  store ptr %3, ptr %69, align 8, !tbaa !7
  %70 = getelementptr i8, ptr %69, i64 8
  store ptr null, ptr %70, align 8, !tbaa !7
  %71 = call i32 @execvp(ptr noundef nonnull %spec.store.select, ptr noundef nonnull %63) #9
  call void (ptr, ...) @error(ptr noundef nonnull @.str.16, ptr noundef nonnull %spec.store.select)
  call void @_exit(i32 noundef 127) #10
  unreachable

72:                                               ; preds = %40
  %73 = call i32 @waitpid(i32 noundef %41, ptr noundef nonnull %6, i32 noundef 0) #9
  %74 = icmp eq i32 %73, -1
  br i1 %74, label %75, label %76

75:                                               ; preds = %72
  call void (ptr, ...) @error(ptr noundef nonnull @.str.17)
  br label %.loopexit

76:                                               ; preds = %72
  %77 = load i32, ptr %6, align 4, !tbaa !11
  %78 = and i32 %77, 127
  %79 = icmp eq i32 %78, 0
  br i1 %79, label %81, label %80

80:                                               ; preds = %76
  call void (ptr, ...) @error(ptr noundef nonnull @.str.18)
  br label %.loopexit

81:                                               ; preds = %76
  %82 = lshr i32 %77, 8
  %83 = and i32 %82, 255
  store i32 %83, ptr %6, align 4, !tbaa !11
  %.not65 = icmp eq i32 %83, 0
  br i1 %.not65, label %85, label %84

84:                                               ; preds = %81
  call void (ptr, ...) @error(ptr noundef nonnull @.str.19, i32 noundef %83)
  br label %.loopexit

85:                                               ; preds = %81
  %86 = call i32 (ptr, i32, ...) @open(ptr noundef nonnull %3, i32 noundef 0) #9
  %87 = icmp eq i32 %86, -1
  br i1 %87, label %88, label %89

88:                                               ; preds = %85
  call void (ptr, ...) @error(ptr noundef nonnull @.str.20, ptr noundef nonnull %3)
  br label %.loopexit

89:                                               ; preds = %85
  %90 = call i32 @fstat(i32 noundef %86, ptr noundef nonnull %7) #9
  %91 = icmp eq i32 %90, -1
  br i1 %91, label %92, label %93

92:                                               ; preds = %89
  call void (ptr, ...) @error(ptr noundef nonnull @.str.21, ptr noundef nonnull %3)
  br label %.loopexit

93:                                               ; preds = %89
  %94 = getelementptr inbounds i8, ptr %5, i64 88
  %95 = load i64, ptr %94, align 8, !tbaa !13
  %96 = getelementptr inbounds i8, ptr %7, i64 88
  %97 = load i64, ptr %96, align 8, !tbaa !13
  %98 = icmp eq i64 %95, %97
  br i1 %98, label %.loopexit, label %.preheader89

.preheader89:                                     ; preds = %93
  %99 = call i64 @read(i32 noundef %86, ptr noundef nonnull %4, i64 noundef 2048) #9
  %100 = icmp sgt i64 %99, 0
  br i1 %100, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %.preheader89, %.preheader.backedge
  %.2 = phi i64 [ %.2.be, %.preheader.backedge ], [ %99, %.preheader89 ]
  %101 = call i64 @write(i32 noundef 1, ptr noundef nonnull %4, i64 noundef %.2) #9
  %102 = icmp eq i64 %101, -1
  br i1 %102, label %103, label %104

103:                                              ; preds = %.preheader
  call void (ptr, ...) @error(ptr noundef nonnull @.str.22)
  br label %.loopexit

104:                                              ; preds = %.preheader
  %105 = sub nsw i64 %.2, %101
  %106 = icmp sgt i64 %105, 0
  br i1 %106, label %.preheader.backedge, label %107

.preheader.backedge:                              ; preds = %104, %107
  %.2.be = phi i64 [ %105, %104 ], [ %108, %107 ]
  br label %.preheader, !llvm.loop !17

107:                                              ; preds = %104
  %108 = call i64 @read(i32 noundef %86, ptr noundef nonnull %4, i64 noundef 2048) #9
  %109 = icmp sgt i64 %108, 0
  br i1 %109, label %.preheader.backedge, label %.loopexit

.loopexit:                                        ; preds = %107, %31, %35, %39, %42, %75, %80, %84, %88, %92, %93, %22, %103, %.preheader89, %.thread86
  %.04588 = phi i32 [ 1, %.thread86 ], [ 1, %22 ], [ 1, %31 ], [ 1, %35 ], [ 1, %39 ], [ 1, %42 ], [ 1, %75 ], [ 1, %84 ], [ 1, %88 ], [ 1, %92 ], [ 1, %103 ], [ 1, %80 ], [ 0, %93 ], [ 0, %.preheader89 ], [ 0, %107 ]
  %110 = call i32 @unlink(ptr noundef nonnull %3) #9
  br label %111

111:                                              ; preds = %.thread83, %.loopexit
  %.04585 = phi i32 [ 1, %.thread83 ], [ %.04588, %.loopexit ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #9
  ret i32 %.04585
}

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

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

; Function Attrs: mustprogress 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) #3

declare i32 @mkstemp(ptr noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
declare hidden void @error(ptr noundef, ...) local_unnamed_addr #0

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

; Function Attrs: nofree
declare noundef i64 @read(i32 noundef, ptr nocapture noundef, i64 noundef) local_unnamed_addr #6

; Function Attrs: nofree
declare noundef i64 @write(i32 noundef, ptr nocapture noundef readonly, i64 noundef) local_unnamed_addr #6

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

declare i32 @fsync(i32 noundef) local_unnamed_addr #4

; Function Attrs: nofree nounwind
declare noundef i32 @fstat(i32 noundef, ptr nocapture noundef) local_unnamed_addr #7

declare i32 @close(i32 noundef) local_unnamed_addr #4

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

; Function Attrs: nofree
declare noundef i32 @open(ptr nocapture noundef readonly, i32 noundef, ...) local_unnamed_addr #6

; Function Attrs: noreturn
declare void @_exit(i32 noundef) local_unnamed_addr #8

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

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @unlink(ptr nocapture noundef readonly) local_unnamed_addr #7

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 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 #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { 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 #7 = { 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 #8 = { noreturn "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 = { nounwind }
attributes #10 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !9, i64 0}
!13 = !{!14, !15, i64 88}
!14 = !{!"stat", !15, i64 0, !15, i64 8, !15, i64 16, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !15, i64 40, !15, i64 48, !15, i64 56, !15, i64 64, !16, i64 72, !16, i64 88, !16, i64 104, !9, i64 120}
!15 = !{!"long", !9, i64 0}
!16 = !{!"timespec", !15, i64 0, !15, i64 8}
!17 = distinct !{!17, !6}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass