; LLVM IR from totte174/minesolve :: src (commands)

; 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.Board = type { i32, i32, i32, i32, [1024 x i32], [1024 x i8], [1024 x i8], i8 }
%struct.SearchResult = type { double, double, i32, i32 }
%struct.timespec = type { i64, i64 }
%struct.Arguments = type { [2048 x i8], i32, i32, i32, i32, i32, i32, i8, i8, i8, i8 }

@simulate.board = external hidden global %struct.Board, align 4
@simulate.solver_result = external hidden global %struct.SearchResult, align 8
@simulate.p_a = external hidden global [1024 x double], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [20 x i8], align 1
@__const.simulate.ts = external hidden unnamed_addr constant %struct.timespec, align 8
@stderr = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [4 x i8], align 1

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @move(ptr noundef, i32 noundef, i1 noundef zeroext) #1

; Function Attrs: nounwind uwtable
define dso_local void @simulate(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i8, align 1
  %7 = alloca i8, align 1
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca %struct.timespec, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.Arguments, ptr %19, i32 0, i32 3
  %21 = load i32, ptr %20, align 4, !tbaa !9
  store i32 %21, ptr getelementptr inbounds (%struct.Board, ptr @simulate.board, i32 0, i32 1), align 4, !tbaa !13
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.Arguments, ptr %22, i32 0, i32 2
  %24 = load i32, ptr %23, align 4, !tbaa !15
  store i32 %24, ptr @simulate.board, align 4, !tbaa !16
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.Arguments, ptr %25, i32 0, i32 7
  %27 = load i8, ptr %26, align 4, !tbaa !17, !range !18, !noundef !19
  %28 = trunc i8 %27 to i1
  %29 = zext i1 %28 to i8
  store i8 %29, ptr getelementptr inbounds (%struct.Board, ptr @simulate.board, i32 0, i32 7), align 4, !tbaa !20
  %30 = load ptr, ptr %2, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.Arguments, ptr %30, i32 0, i32 9
  %32 = load i8, ptr %31, align 2, !tbaa !21, !range !18, !noundef !19
  %33 = trunc i8 %32 to i1
  br i1 %33, label %34, label %41

34:                                               ; preds = %1
  %35 = load ptr, ptr %2, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.Arguments, ptr %35, i32 0, i32 8
  %37 = load i8, ptr %36, align 1, !tbaa !22, !range !18, !noundef !19
  %38 = trunc i8 %37 to i1
  br i1 %38, label %41, label %39

39:                                               ; preds = %34
  %40 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  br label %41

41:                                               ; preds = %39, %34, %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 0, ptr %3, align 4, !tbaa !23
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 0, ptr %4, align 4, !tbaa !23
  br label %42

42:                                               ; preds = %227, %41
  %43 = load i32, ptr %4, align 4, !tbaa !23
  %44 = load ptr, ptr %2, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.Arguments, ptr %44, i32 0, i32 5
  %46 = load i32, ptr %45, align 4, !tbaa !24
  %47 = icmp slt i32 %43, %46
  br i1 %47, label %49, label %48

48:                                               ; preds = %42
  store i32 2, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %230

49:                                               ; preds = %42
  %50 = load ptr, ptr %2, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.Arguments, ptr %50, i32 0, i32 4
  %52 = load i32, ptr %51, align 4, !tbaa !25
  call void @generate_board(i32 noundef %52, ptr noundef @simulate.board)
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #6
  store i8 1, ptr %6, align 1, !tbaa !26
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #6
  store i8 1, ptr %7, align 1, !tbaa !26
  br label %53

53:                                               ; preds = %188, %49
  %54 = load i32, ptr getelementptr inbounds (%struct.Board, ptr @simulate.board, i32 0, i32 3), align 4, !tbaa !27
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.Arguments, ptr %55, i32 0, i32 4
  %57 = load i32, ptr %56, align 4, !tbaa !25
  %58 = icmp sgt i32 %54, %57
  br i1 %58, label %59, label %62

59:                                               ; preds = %53
  %60 = load i8, ptr %7, align 1, !tbaa !26, !range !18, !noundef !19
  %61 = trunc i8 %60 to i1
  br label %62

62:                                               ; preds = %59, %53
  %63 = phi i1 [ false, %53 ], [ %61, %59 ]
  br i1 %63, label %64, label %189

64:                                               ; preds = %62
  %65 = load ptr, ptr %2, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.Arguments, ptr %65, i32 0, i32 9
  %67 = load i8, ptr %66, align 2, !tbaa !21, !range !18, !noundef !19
  %68 = trunc i8 %67 to i1
  br i1 %68, label %69, label %114

69:                                               ; preds = %64
  %70 = load ptr, ptr %2, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.Arguments, ptr %70, i32 0, i32 8
  %72 = load i8, ptr %71, align 1, !tbaa !22, !range !18, !noundef !19
  %73 = trunc i8 %72 to i1
  br i1 %73, label %74, label %93

74:                                               ; preds = %69
  call void @print_board(ptr noundef @simulate.board)
  %75 = load i32, ptr %3, align 4, !tbaa !23
  %76 = load i32, ptr %4, align 4, !tbaa !23
  %77 = load i32, ptr %3, align 4, !tbaa !23
  %78 = sitofp i32 %77 to double
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  store i32 1, ptr %8, align 4, !tbaa !23
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  %79 = load i32, ptr %4, align 4, !tbaa !23
  store i32 %79, ptr %9, align 4, !tbaa !23
  %80 = load i32, ptr %8, align 4, !tbaa !23
  %81 = load i32, ptr %9, align 4, !tbaa !23
  %82 = icmp sgt i32 %80, %81
  br i1 %82, label %83, label %85

83:                                               ; preds = %74
  %84 = load i32, ptr %8, align 4, !tbaa !23
  br label %87

85:                                               ; preds = %74
  %86 = load i32, ptr %9, align 4, !tbaa !23
  br label %87

87:                                               ; preds = %85, %83
  %88 = phi i32 [ %84, %83 ], [ %86, %85 ]
  store i32 %88, ptr %10, align 4, !tbaa !23
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  %89 = load i32, ptr %10, align 4, !tbaa !23
  %90 = sitofp i32 %89 to double
  %91 = fdiv double %78, %90
  %92 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %75, i32 noundef %76, double noundef %91)
  br label %113

93:                                               ; preds = %69
  call void @print_board_pretty(ptr noundef @simulate.board, i1 noundef zeroext true)
  %94 = load i32, ptr %3, align 4, !tbaa !23
  %95 = load i32, ptr %4, align 4, !tbaa !23
  %96 = load i32, ptr %3, align 4, !tbaa !23
  %97 = sitofp i32 %96 to double
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  store i32 1, ptr %11, align 4, !tbaa !23
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  %98 = load i32, ptr %4, align 4, !tbaa !23
  store i32 %98, ptr %12, align 4, !tbaa !23
  %99 = load i32, ptr %11, align 4, !tbaa !23
  %100 = load i32, ptr %12, align 4, !tbaa !23
  %101 = icmp sgt i32 %99, %100
  br i1 %101, label %102, label %104

102:                                              ; preds = %93
  %103 = load i32, ptr %11, align 4, !tbaa !23
  br label %106

104:                                              ; preds = %93
  %105 = load i32, ptr %12, align 4, !tbaa !23
  br label %106

106:                                              ; preds = %104, %102
  %107 = phi i32 [ %103, %102 ], [ %105, %104 ]
  store i32 %107, ptr %13, align 4, !tbaa !23
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  %108 = load i32, ptr %13, align 4, !tbaa !23
  %109 = sitofp i32 %108 to double
  %110 = fdiv double %97, %109
  %111 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %94, i32 noundef %95, double noundef %110)
  call void @llvm.lifetime.start.p0(i64 16, ptr %14) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %14, ptr align 8 @__const.simulate.ts, i64 16, i1 false)
  %112 = call i32 @nanosleep(ptr noundef %14, ptr noundef null)
  call void @llvm.lifetime.end.p0(i64 16, ptr %14) #6
  br label %113

113:                                              ; preds = %106, %87
  br label %114

114:                                              ; preds = %113, %64
  %115 = load ptr, ptr %2, align 8, !tbaa !5
  call void @get_solver_result(ptr noundef @simulate.board, ptr noundef %115, ptr noundef @simulate.solver_result, ptr noundef @simulate.p_a)
  %116 = load i32, ptr getelementptr inbounds (%struct.SearchResult, ptr @simulate.solver_result, i32 0, i32 3), align 4, !tbaa !28
  %117 = icmp eq i32 %116, 1
  br i1 %117, label %118, label %120

118:                                              ; preds = %114
  %119 = load ptr, ptr %2, align 8, !tbaa !5
  call void @get_solver_result_basic(ptr noundef @simulate.board, ptr noundef %119, ptr noundef @simulate.solver_result, ptr noundef @simulate.p_a)
  br label %120

120:                                              ; preds = %118, %114
  %121 = load i32, ptr getelementptr inbounds (%struct.SearchResult, ptr @simulate.solver_result, i32 0, i32 3), align 4, !tbaa !28
  %122 = icmp eq i32 %121, 3
  br i1 %122, label %123, label %126

123:                                              ; preds = %120
  call void @print_board(ptr noundef @simulate.board)
  %124 = load ptr, ptr @stderr, align 8, !tbaa !5
  %125 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %124, ptr noundef @.str.2) #6
  call void @exit(i32 noundef 1) #7
  unreachable

126:                                              ; preds = %120
  %127 = load i32, ptr getelementptr inbounds (%struct.SearchResult, ptr @simulate.solver_result, i32 0, i32 3), align 4, !tbaa !28
  %128 = icmp eq i32 %127, 2
  br i1 %128, label %129, label %132

129:                                              ; preds = %126
  call void @print_board(ptr noundef @simulate.board)
  %130 = load ptr, ptr @stderr, align 8, !tbaa !5
  %131 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %130, ptr noundef @.str.3) #6
  call void @exit(i32 noundef 1) #7
  unreachable

132:                                              ; preds = %126
  %133 = load i32, ptr getelementptr inbounds (%struct.SearchResult, ptr @simulate.solver_result, i32 0, i32 2), align 8, !tbaa !31
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds [1024 x i8], ptr getelementptr inbounds (%struct.Board, ptr @simulate.board, i32 0, i32 5), i64 0, i64 %134
  %136 = load i8, ptr %135, align 1, !tbaa !26, !range !18, !noundef !19
  %137 = trunc i8 %136 to i1
  br i1 %137, label %138, label %141

138:                                              ; preds = %132
  call void @print_board(ptr noundef @simulate.board)
  %139 = load ptr, ptr @stderr, align 8, !tbaa !5
  %140 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %139, ptr noundef @.str.4) #6
  call void @exit(i32 noundef 1) #7
  unreachable

141:                                              ; preds = %132
  %142 = load i32, ptr getelementptr inbounds (%struct.SearchResult, ptr @simulate.solver_result, i32 0, i32 2), align 8, !tbaa !31
  %143 = sext i32 %142 to i64
  %144 = getelementptr inbounds [1024 x double], ptr @simulate.p_a, i64 0, i64 %143
  %145 = load double, ptr %144, align 8, !tbaa !32
  %146 = fcmp oeq double %145, 0.000000e+00
  br i1 %146, label %147, label %181

147:                                              ; preds = %141
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  store i32 0, ptr %15, align 4, !tbaa !23
  br label %148

148:                                              ; preds = %177, %147
  %149 = load i32, ptr %15, align 4, !tbaa !23
  %150 = load i32, ptr @simulate.board, align 4, !tbaa !16
  %151 = load i32, ptr getelementptr inbounds (%struct.Board, ptr @simulate.board, i32 0, i32 1), align 4, !tbaa !13
  %152 = mul nsw i32 %150, %151
  %153 = icmp slt i32 %149, %152
  br i1 %153, label %155, label %154

154:                                              ; preds = %148
  store i32 7, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  br label %180

155:                                              ; preds = %148
  %156 = load i32, ptr %15, align 4, !tbaa !23
  %157 = sext i32 %156 to i64
  %158 = getelementptr inbounds [1024 x double], ptr @simulate.p_a, i64 0, i64 %157
  %159 = load double, ptr %158, align 8, !tbaa !32
  %160 = fcmp oeq double %159, 0.000000e+00
  br i1 %160, label %161, label %176

161:                                              ; preds = %155
  %162 = load i32, ptr %15, align 4, !tbaa !23
  %163 = sext i32 %162 to i64
  %164 = getelementptr inbounds [1024 x i8], ptr getelementptr inbounds (%struct.Board, ptr @simulate.board, i32 0, i32 5), i64 0, i64 %163
  %165 = load i8, ptr %164, align 1, !tbaa !26, !range !18, !noundef !19
  %166 = trunc i8 %165 to i1
  br i1 %166, label %176, label %167

167:                                              ; preds = %161
  %168 = load i32, ptr %15, align 4, !tbaa !23
  %169 = load i8, ptr %6, align 1, !tbaa !26, !range !18, !noundef !19
  %170 = trunc i8 %169 to i1
  %171 = call zeroext i1 @move(ptr noundef @simulate.board, i32 noundef %168, i1 noundef zeroext %170)
  br i1 %171, label %175, label %172

172:                                              ; preds = %167
  %173 = load ptr, ptr @stderr, align 8, !tbaa !5
  %174 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %173, ptr noundef @.str.5) #6
  call void @exit(i32 noundef 1) #7
  unreachable

175:                                              ; preds = %167
  br label %176

176:                                              ; preds = %175, %161, %155
  br label %177

177:                                              ; preds = %176
  %178 = load i32, ptr %15, align 4, !tbaa !23
  %179 = add nsw i32 %178, 1
  store i32 %179, ptr %15, align 4, !tbaa !23
  br label %148, !llvm.loop !33

180:                                              ; preds = %154
  br label %188

181:                                              ; preds = %141
  %182 = load i32, ptr getelementptr inbounds (%struct.SearchResult, ptr @simulate.solver_result, i32 0, i32 2), align 8, !tbaa !31
  %183 = load i8, ptr %6, align 1, !tbaa !26, !range !18, !noundef !19
  %184 = trunc i8 %183 to i1
  %185 = call zeroext i1 @move(ptr noundef @simulate.board, i32 noundef %182, i1 noundef zeroext %184)
  br i1 %185, label %187, label %186

186:                                              ; preds = %181
  store i8 0, ptr %7, align 1, !tbaa !26
  br label %187

187:                                              ; preds = %186, %181
  br label %188

188:                                              ; preds = %187, %180
  store i8 0, ptr %6, align 1, !tbaa !26
  br label %53, !llvm.loop !35

189:                                              ; preds = %62
  %190 = load ptr, ptr %2, align 8, !tbaa !5
  %191 = getelementptr inbounds %struct.Arguments, ptr %190, i32 0, i32 9
  %192 = load i8, ptr %191, align 2, !tbaa !21, !range !18, !noundef !19
  %193 = trunc i8 %192 to i1
  br i1 %193, label %194, label %220

194:                                              ; preds = %189
  %195 = load ptr, ptr %2, align 8, !tbaa !5
  %196 = getelementptr inbounds %struct.Arguments, ptr %195, i32 0, i32 8
  %197 = load i8, ptr %196, align 1, !tbaa !22, !range !18, !noundef !19
  %198 = trunc i8 %197 to i1
  br i1 %198, label %199, label %200

199:                                              ; preds = %194
  call void @print_board(ptr noundef @simulate.board)
  br label %201

200:                                              ; preds = %194
  call void @print_board_pretty(ptr noundef @simulate.board, i1 noundef zeroext true)
  br label %201

201:                                              ; preds = %200, %199
  %202 = load i32, ptr %3, align 4, !tbaa !23
  %203 = load i32, ptr %4, align 4, !tbaa !23
  %204 = load i32, ptr %3, align 4, !tbaa !23
  %205 = sitofp i32 %204 to double
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  store i32 1, ptr %16, align 4, !tbaa !23
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  %206 = load i32, ptr %4, align 4, !tbaa !23
  store i32 %206, ptr %17, align 4, !tbaa !23
  %207 = load i32, ptr %16, align 4, !tbaa !23
  %208 = load i32, ptr %17, align 4, !tbaa !23
  %209 = icmp sgt i32 %207, %208
  br i1 %209, label %210, label %212

210:                                              ; preds = %201
  %211 = load i32, ptr %16, align 4, !tbaa !23
  br label %214

212:                                              ; preds = %201
  %213 = load i32, ptr %17, align 4, !tbaa !23
  br label %214

214:                                              ; preds = %212, %210
  %215 = phi i32 [ %211, %210 ], [ %213, %212 ]
  store i32 %215, ptr %18, align 4, !tbaa !23
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  %216 = load i32, ptr %18, align 4, !tbaa !23
  %217 = sitofp i32 %216 to double
  %218 = fdiv double %205, %217
  %219 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %202, i32 noundef %203, double noundef %218)
  br label %220

220:                                              ; preds = %214, %189
  %221 = load i8, ptr %7, align 1, !tbaa !26, !range !18, !noundef !19
  %222 = trunc i8 %221 to i1
  br i1 %222, label %223, label %226

223:                                              ; preds = %220
  %224 = load i32, ptr %3, align 4, !tbaa !23
  %225 = add nsw i32 %224, 1
  store i32 %225, ptr %3, align 4, !tbaa !23
  br label %226

226:                                              ; preds = %223, %220
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #6
  br label %227

227:                                              ; preds = %226
  %228 = load i32, ptr %4, align 4, !tbaa !23
  %229 = add nsw i32 %228, 1
  store i32 %229, ptr %4, align 4, !tbaa !23
  br label %42, !llvm.loop !36

230:                                              ; preds = %48
  %231 = load ptr, ptr %2, align 8, !tbaa !5
  %232 = getelementptr inbounds %struct.Arguments, ptr %231, i32 0, i32 9
  %233 = load i8, ptr %232, align 2, !tbaa !21, !range !18, !noundef !19
  %234 = trunc i8 %233 to i1
  br i1 %234, label %238, label %235

235:                                              ; preds = %230
  %236 = load i32, ptr %3, align 4, !tbaa !23
  %237 = call i32 (ptr, ...) @printf(ptr noundef @.str.6, i32 noundef %236)
  br label %238

238:                                              ; preds = %235, %230
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  ret void
}

declare i32 @printf(ptr noundef, ...) #2

declare void @print_board(ptr noundef) #2

declare void @print_board_pretty(ptr noundef, i1 noundef zeroext) #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 @nanosleep(ptr noundef, ptr noundef) #2

declare void @get_solver_result(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #2

declare void @get_solver_result_basic(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #2

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { "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 = { 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 = { 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 2056}
!10 = !{!"Arguments", !7, i64 0, !11, i64 2048, !11, i64 2052, !11, i64 2056, !11, i64 2060, !11, i64 2064, !11, i64 2068, !12, i64 2072, !12, i64 2073, !12, i64 2074, !12, i64 2075}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!14, !11, i64 4}
!14 = !{!"Board", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !7, i64 16, !7, i64 4112, !7, i64 5136, !12, i64 6160}
!15 = !{!10, !11, i64 2052}
!16 = !{!14, !11, i64 0}
!17 = !{!10, !12, i64 2072}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = !{!14, !12, i64 6160}
!21 = !{!10, !12, i64 2074}
!22 = !{!10, !12, i64 2073}
!23 = !{!11, !11, i64 0}
!24 = !{!10, !11, i64 2064}
!25 = !{!10, !11, i64 2060}
!26 = !{!12, !12, i64 0}
!27 = !{!14, !11, i64 12}
!28 = !{!29, !11, i64 20}
!29 = !{!"SearchResult", !30, i64 0, !30, i64 8, !11, i64 16, !11, i64 20}
!30 = !{!"double", !7, i64 0}
!31 = !{!29, !11, i64 16}
!32 = !{!30, !30, i64 0}
!33 = distinct !{!33, !34}
!34 = !{!"llvm.loop.mustprogress"}
!35 = distinct !{!35, !34}
!36 = distinct !{!36, !34}


; 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.Board = type { i32, i32, i32, i32, [1024 x i32], [1024 x i8], [1024 x i8], i8 }
%struct.SearchResult = type { double, double, i32, i32 }
%struct.timespec = type { i64, i64 }

@simulate.board = external hidden global %struct.Board, align 4
@simulate.solver_result = external hidden global %struct.SearchResult, align 8
@simulate.p_a = external hidden global [1024 x double], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [20 x i8], align 1
@__const.simulate.ts = external hidden unnamed_addr constant %struct.timespec, align 8
@stderr = external local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [4 x i8], align 1

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @generate_board(i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @move(ptr noundef, i32 noundef, i1 noundef zeroext) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @simulate(ptr noundef %0) local_unnamed_addr #1 {
  %2 = alloca %struct.timespec, align 8
  %3 = getelementptr inbounds i8, ptr %0, i64 2052
  %4 = load <2 x i32>, ptr %3, align 4, !tbaa !5
  store <2 x i32> %4, ptr @simulate.board, align 4, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 2072
  %6 = load i8, ptr %5, align 4, !tbaa !9, !range !12, !noundef !13
  store i8 %6, ptr getelementptr inbounds (i8, ptr @simulate.board, i64 6160), align 4, !tbaa !14
  %7 = getelementptr inbounds i8, ptr %0, i64 2074
  %8 = load i8, ptr %7, align 2, !tbaa !16, !range !12, !noundef !13
  %9 = trunc nuw i8 %8 to i1
  br i1 %9, label %10, label %16

10:                                               ; preds = %1
  %11 = getelementptr inbounds i8, ptr %0, i64 2073
  %12 = load i8, ptr %11, align 1, !tbaa !17, !range !12, !noundef !13
  %13 = trunc nuw i8 %12 to i1
  br i1 %13, label %16, label %14

14:                                               ; preds = %10
  %15 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  br label %16

16:                                               ; preds = %14, %10, %1
  %17 = getelementptr inbounds i8, ptr %0, i64 2064
  %18 = load i32, ptr %17, align 4, !tbaa !18
  %19 = icmp sgt i32 %18, 0
  br i1 %19, label %.lr.ph76, label %._crit_edge77

.lr.ph76:                                         ; preds = %16
  %20 = getelementptr inbounds i8, ptr %0, i64 2060
  %21 = getelementptr inbounds i8, ptr %0, i64 2073
  br label %24

._crit_edge77:                                    ; preds = %114, %16
  %.0.lcssa = phi i32 [ 0, %16 ], [ %spec.select60, %114 ]
  %22 = load i8, ptr %7, align 2, !tbaa !16, !range !12, !noundef !13
  %23 = trunc nuw i8 %22 to i1
  br i1 %23, label %121, label %119

24:                                               ; preds = %.lr.ph76, %114
  %.074 = phi i32 [ 0, %.lr.ph76 ], [ %spec.select60, %114 ]
  %.05473 = phi i32 [ 0, %.lr.ph76 ], [ %116, %114 ]
  %25 = load i32, ptr %20, align 4, !tbaa !19
  call void @generate_board(i32 noundef %25, ptr noundef nonnull @simulate.board)
  %26 = load i32, ptr getelementptr inbounds (i8, ptr @simulate.board, i64 12), align 4, !tbaa !20
  %27 = load i32, ptr %20, align 4, !tbaa !19
  %28 = icmp sgt i32 %26, %27
  br i1 %28, label %.lr.ph72, label %._crit_edge

.lr.ph72:                                         ; preds = %24
  %29 = uitofp nneg i32 %.074 to double
  %30 = call i32 @llvm.umax.i32(i32 %.05473, i32 1)
  %31 = uitofp nneg i32 %30 to double
  %32 = fdiv double %29, %31
  br label %33

33:                                               ; preds = %.lr.ph72, %.loopexit
  %.05671 = phi i1 [ true, %.lr.ph72 ], [ false, %.loopexit ]
  %.05770 = phi i8 [ 1, %.lr.ph72 ], [ %.158, %.loopexit ]
  %34 = load i8, ptr %7, align 2, !tbaa !16, !range !12, !noundef !13
  %35 = trunc nuw i8 %34 to i1
  br i1 %35, label %36, label %44

36:                                               ; preds = %33
  %37 = load i8, ptr %21, align 1, !tbaa !17, !range !12, !noundef !13
  %38 = trunc nuw i8 %37 to i1
  br i1 %38, label %39, label %41

39:                                               ; preds = %36
  call void @print_board(ptr noundef nonnull @simulate.board) #7
  %40 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %.074, i32 noundef %.05473, double noundef %32)
  br label %44

41:                                               ; preds = %36
  call void @print_board_pretty(ptr noundef nonnull @simulate.board, i1 noundef zeroext true) #7
  %42 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %.074, i32 noundef %.05473, double noundef %32)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #7
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 8 dereferenceable(16) @__const.simulate.ts, i64 16, i1 false)
  %43 = call i32 @nanosleep(ptr noundef nonnull %2, ptr noundef null) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #7
  br label %44

44:                                               ; preds = %39, %41, %33
  call void @get_solver_result(ptr noundef nonnull @simulate.board, ptr noundef nonnull %0, ptr noundef nonnull @simulate.solver_result, ptr noundef nonnull @simulate.p_a) #7
  %45 = load i32, ptr getelementptr inbounds (i8, ptr @simulate.solver_result, i64 20), align 4, !tbaa !21
  %46 = icmp eq i32 %45, 1
  br i1 %46, label %47, label %48

47:                                               ; preds = %44
  call void @get_solver_result_basic(ptr noundef nonnull @simulate.board, ptr noundef nonnull %0, ptr noundef nonnull @simulate.solver_result, ptr noundef nonnull @simulate.p_a) #7
  %.pr = load i32, ptr getelementptr inbounds (i8, ptr @simulate.solver_result, i64 20), align 4, !tbaa !21
  br label %48

48:                                               ; preds = %47, %44
  %49 = phi i32 [ %.pr, %47 ], [ %45, %44 ]
  switch i32 %49, label %56 [
    i32 3, label %50
    i32 2, label %53
  ]

50:                                               ; preds = %48
  call void @print_board(ptr noundef nonnull @simulate.board) #7
  %51 = load ptr, ptr @stderr, align 8, !tbaa !24
  %52 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %51, ptr noundef nonnull @.str.2) #8
  call void @exit(i32 noundef 1) #9
  unreachable

53:                                               ; preds = %48
  call void @print_board(ptr noundef nonnull @simulate.board) #7
  %54 = load ptr, ptr @stderr, align 8, !tbaa !24
  %55 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %54, ptr noundef nonnull @.str.3) #8
  call void @exit(i32 noundef 1) #9
  unreachable

56:                                               ; preds = %48
  %57 = load i32, ptr getelementptr inbounds (i8, ptr @simulate.solver_result, i64 16), align 8, !tbaa !26
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [1024 x i8], ptr getelementptr inbounds (i8, ptr @simulate.board, i64 4112), i64 0, i64 %58
  %60 = load i8, ptr %59, align 1, !tbaa !27, !range !12, !noundef !13
  %61 = trunc nuw i8 %60 to i1
  br i1 %61, label %62, label %65

62:                                               ; preds = %56
  call void @print_board(ptr noundef nonnull @simulate.board) #7
  %63 = load ptr, ptr @stderr, align 8, !tbaa !24
  %64 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %63, ptr noundef nonnull @.str.4) #8
  call void @exit(i32 noundef 1) #9
  unreachable

65:                                               ; preds = %56
  %66 = getelementptr inbounds [1024 x double], ptr @simulate.p_a, i64 0, i64 %58
  %67 = load double, ptr %66, align 8, !tbaa !28
  %68 = fcmp oeq double %67, 0.000000e+00
  br i1 %68, label %.preheader, label %94

.preheader:                                       ; preds = %65
  %69 = load i32, ptr @simulate.board, align 4, !tbaa !29
  %70 = load i32, ptr getelementptr inbounds (i8, ptr @simulate.board, i64 4), align 4, !tbaa !30
  %71 = mul nsw i32 %70, %69
  %72 = icmp sgt i32 %71, 0
  br i1 %72, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %.preheader, %88
  %73 = phi i32 [ %89, %88 ], [ %70, %.preheader ]
  %74 = phi i32 [ %90, %88 ], [ %69, %.preheader ]
  %indvars.iv = phi i64 [ %indvars.iv.next, %88 ], [ 0, %.preheader ]
  %75 = getelementptr inbounds [1024 x double], ptr @simulate.p_a, i64 0, i64 %indvars.iv
  %76 = load double, ptr %75, align 8, !tbaa !28
  %77 = fcmp oeq double %76, 0.000000e+00
  br i1 %77, label %78, label %88

78:                                               ; preds = %.lr.ph
  %79 = getelementptr inbounds [1024 x i8], ptr getelementptr inbounds (i8, ptr @simulate.board, i64 4112), i64 0, i64 %indvars.iv
  %80 = load i8, ptr %79, align 1, !tbaa !27, !range !12, !noundef !13
  %81 = trunc nuw i8 %80 to i1
  br i1 %81, label %88, label %82

82:                                               ; preds = %78
  %83 = trunc nuw nsw i64 %indvars.iv to i32
  %84 = call zeroext i1 @move(ptr noundef nonnull @simulate.board, i32 noundef %83, i1 noundef zeroext %.05671)
  br i1 %84, label %._crit_edge80, label %85

._crit_edge80:                                    ; preds = %82
  %.pre = load i32, ptr @simulate.board, align 4, !tbaa !29
  %.pre81 = load i32, ptr getelementptr inbounds (i8, ptr @simulate.board, i64 4), align 4, !tbaa !30
  br label %88

85:                                               ; preds = %82
  %86 = load ptr, ptr @stderr, align 8, !tbaa !24
  %87 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %86, ptr noundef nonnull @.str.5) #8
  call void @exit(i32 noundef 1) #9
  unreachable

88:                                               ; preds = %._crit_edge80, %.lr.ph, %78
  %89 = phi i32 [ %.pre81, %._crit_edge80 ], [ %73, %.lr.ph ], [ %73, %78 ]
  %90 = phi i32 [ %.pre, %._crit_edge80 ], [ %74, %.lr.ph ], [ %74, %78 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %91 = mul nsw i32 %89, %90
  %92 = sext i32 %91 to i64
  %93 = icmp slt i64 %indvars.iv.next, %92
  br i1 %93, label %.lr.ph, label %.loopexit, !llvm.loop !31

94:                                               ; preds = %65
  %95 = call zeroext i1 @move(ptr noundef nonnull @simulate.board, i32 noundef %57, i1 noundef zeroext %.05671)
  %spec.select = select i1 %95, i8 %.05770, i8 0
  br label %.loopexit

.loopexit:                                        ; preds = %88, %.preheader, %94
  %.158 = phi i8 [ %spec.select, %94 ], [ %.05770, %.preheader ], [ %.05770, %88 ]
  %96 = load i32, ptr getelementptr inbounds (i8, ptr @simulate.board, i64 12), align 4, !tbaa !20
  %97 = load i32, ptr %20, align 4, !tbaa !19
  %98 = icmp sgt i32 %96, %97
  %99 = trunc nuw i8 %.158 to i1
  %100 = select i1 %98, i1 %99, i1 false
  br i1 %100, label %33, label %._crit_edge, !llvm.loop !33

._crit_edge:                                      ; preds = %.loopexit, %24
  %.057.lcssa = phi i8 [ 1, %24 ], [ %.158, %.loopexit ]
  %101 = load i8, ptr %7, align 2, !tbaa !16, !range !12, !noundef !13
  %102 = trunc nuw i8 %101 to i1
  br i1 %102, label %103, label %114

103:                                              ; preds = %._crit_edge
  %104 = load i8, ptr %21, align 1, !tbaa !17, !range !12, !noundef !13
  %105 = trunc nuw i8 %104 to i1
  br i1 %105, label %106, label %107

106:                                              ; preds = %103
  call void @print_board(ptr noundef nonnull @simulate.board) #7
  br label %108

107:                                              ; preds = %103
  call void @print_board_pretty(ptr noundef nonnull @simulate.board, i1 noundef zeroext true) #7
  br label %108

108:                                              ; preds = %107, %106
  %109 = uitofp nneg i32 %.074 to double
  %110 = call i32 @llvm.umax.i32(i32 %.05473, i32 1)
  %111 = uitofp nneg i32 %110 to double
  %112 = fdiv double %109, %111
  %113 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %.074, i32 noundef %.05473, double noundef %112)
  br label %114

114:                                              ; preds = %108, %._crit_edge
  %.mask = and i8 %.057.lcssa, 1
  %115 = zext nneg i8 %.mask to i32
  %spec.select60 = add nuw nsw i32 %.074, %115
  %116 = add nuw nsw i32 %.05473, 1
  %117 = load i32, ptr %17, align 4, !tbaa !18
  %118 = icmp slt i32 %116, %117
  br i1 %118, label %24, label %._crit_edge77, !llvm.loop !34

119:                                              ; preds = %._crit_edge77
  %120 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, i32 noundef %.0.lcssa)
  br label %121

121:                                              ; preds = %119, %._crit_edge77
  ret void
}

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

declare void @print_board(ptr noundef) local_unnamed_addr #3

declare void @print_board_pretty(ptr noundef, i1 noundef zeroext) local_unnamed_addr #3

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

declare i32 @nanosleep(ptr noundef, ptr noundef) local_unnamed_addr #3

declare void @get_solver_result(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

declare void @get_solver_result_basic(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

; 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 #5

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umax.i32(i32, i32) #6

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { "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 nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 #6 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #7 = { nounwind }
attributes #8 = { cold nounwind }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 2072}
!10 = !{!"Arguments", !7, i64 0, !6, i64 2048, !6, i64 2052, !6, i64 2056, !6, i64 2060, !6, i64 2064, !6, i64 2068, !11, i64 2072, !11, i64 2073, !11, i64 2074, !11, i64 2075}
!11 = !{!"_Bool", !7, i64 0}
!12 = !{i8 0, i8 2}
!13 = !{}
!14 = !{!15, !11, i64 6160}
!15 = !{!"Board", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !7, i64 16, !7, i64 4112, !7, i64 5136, !11, i64 6160}
!16 = !{!10, !11, i64 2074}
!17 = !{!10, !11, i64 2073}
!18 = !{!10, !6, i64 2064}
!19 = !{!10, !6, i64 2060}
!20 = !{!15, !6, i64 12}
!21 = !{!22, !6, i64 20}
!22 = !{!"SearchResult", !23, i64 0, !23, i64 8, !6, i64 16, !6, i64 20}
!23 = !{!"double", !7, i64 0}
!24 = !{!25, !25, i64 0}
!25 = !{!"any pointer", !7, i64 0}
!26 = !{!22, !6, i64 16}
!27 = !{!11, !11, i64 0}
!28 = !{!23, !23, i64 0}
!29 = !{!15, !6, i64 0}
!30 = !{!15, !6, i64 4}
!31 = distinct !{!31, !32}
!32 = !{!"llvm.loop.mustprogress"}
!33 = distinct !{!33, !32}
!34 = distinct !{!34, !32}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass