; LLVM IR from clausecker/24puzzle :: cmd (verifypdb)

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

@.str = external hidden unnamed_addr constant [7 x i8], align 1
@optarg = external global ptr, align 8
@pdb_jobs = external global i32, align 4
@stderr = external global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [44 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [54 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [9 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 ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  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 8, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 231, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  store ptr null, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  store ptr null, ptr %10, align 8, !tbaa !9
  br label %12

12:                                               ; preds = %47, %2
  %13 = load i32, ptr %4, align 4, !tbaa !5
  %14 = load ptr, ptr %5, align 8, !tbaa !9
  %15 = call i32 @__posix_getopt(i32 noundef %13, ptr noundef %14, ptr noundef @.str) #6
  store i32 %15, ptr %8, align 4, !tbaa !5
  %16 = load i32, ptr %8, align 4, !tbaa !5
  %17 = icmp ne i32 %16, -1
  br i1 %17, label %18, label %48

18:                                               ; preds = %12
  %19 = load i32, ptr %8, align 4, !tbaa !5
  switch i32 %19, label %47 [
    i32 102, label %20
    i32 106, label %22
    i32 116, label %34
    i32 63, label %43
    i32 58, label %43
  ]

20:                                               ; preds = %18
  %21 = load ptr, ptr @optarg, align 8, !tbaa !9
  store ptr %21, ptr %9, align 8, !tbaa !9
  br label %47

22:                                               ; preds = %18
  %23 = load ptr, ptr @optarg, align 8, !tbaa !9
  %24 = call i32 @atoi(ptr noundef %23) #7
  store i32 %24, ptr @pdb_jobs, align 4, !tbaa !5
  %25 = load i32, ptr @pdb_jobs, align 4, !tbaa !5
  %26 = icmp slt i32 %25, 1
  br i1 %26, label %30, label %27

27:                                               ; preds = %22
  %28 = load i32, ptr @pdb_jobs, align 4, !tbaa !5
  %29 = icmp sgt i32 %28, 256
  br i1 %29, label %30, label %33

30:                                               ; preds = %27, %22
  %31 = load ptr, ptr @stderr, align 8, !tbaa !9
  %32 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %31, ptr noundef @.str.1, i32 noundef 256) #6
  store i32 1, ptr %3, align 4
  store i32 1, ptr %11, align 4
  br label %86

33:                                               ; preds = %27
  br label %47

34:                                               ; preds = %18
  %35 = load ptr, ptr @optarg, align 8, !tbaa !9
  %36 = call i32 @tileset_parse(ptr noundef %7, ptr noundef %35)
  %37 = icmp ne i32 %36, 0
  br i1 %37, label %38, label %42

38:                                               ; preds = %34
  %39 = load ptr, ptr @stderr, align 8, !tbaa !9
  %40 = load ptr, ptr @optarg, align 8, !tbaa !9
  %41 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %39, ptr noundef @.str.2, ptr noundef %40) #6
  store i32 1, ptr %3, align 4
  store i32 1, ptr %11, align 4
  br label %86

42:                                               ; preds = %34
  br label %47

43:                                               ; preds = %18, %18
  %44 = load ptr, ptr %5, align 8, !tbaa !9
  %45 = getelementptr inbounds ptr, ptr %44, i64 0
  %46 = load ptr, ptr %45, align 8, !tbaa !9
  call void @usage(ptr noundef %46)
  br label %47

47:                                               ; preds = %43, %42, %33, %20, %18
  br label %12, !llvm.loop !11

48:                                               ; preds = %12
  %49 = load i32, ptr %7, align 4, !tbaa !5
  %50 = call i32 @tileset_remove(i32 noundef %49, i32 noundef 0)
  %51 = call i32 @tileset_count(i32 noundef %50)
  %52 = icmp uge i32 %51, 12
  br i1 %52, label %53, label %59

53:                                               ; preds = %48
  %54 = load ptr, ptr @stderr, align 8, !tbaa !9
  %55 = load i32, ptr %7, align 4, !tbaa !5
  %56 = call i32 @tileset_remove(i32 noundef %55, i32 noundef 0)
  %57 = call i32 @tileset_count(i32 noundef %56)
  %58 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %54, ptr noundef @.str.3, i32 noundef %57, i32 noundef 12) #6
  store i32 1, ptr %3, align 4
  store i32 1, ptr %11, align 4
  br label %86

59:                                               ; preds = %48
  %60 = load ptr, ptr %9, align 8, !tbaa !9
  %61 = icmp ne ptr %60, null
  br i1 %61, label %62, label %69

62:                                               ; preds = %59
  %63 = load ptr, ptr %9, align 8, !tbaa !9
  %64 = call noalias ptr @fopen(ptr noundef %63, ptr noundef @.str.4)
  store ptr %64, ptr %10, align 8, !tbaa !9
  %65 = load ptr, ptr %10, align 8, !tbaa !9
  %66 = icmp eq ptr %65, null
  br i1 %66, label %67, label %68

67:                                               ; preds = %62
  call void @perror(ptr noundef @.str.5)
  store i32 1, ptr %3, align 4
  store i32 1, ptr %11, align 4
  br label %86

68:                                               ; preds = %62
  br label %73

69:                                               ; preds = %59
  %70 = load ptr, ptr %5, align 8, !tbaa !9
  %71 = getelementptr inbounds ptr, ptr %70, i64 0
  %72 = load ptr, ptr %71, align 8, !tbaa !9
  call void @usage(ptr noundef %72)
  br label %73

73:                                               ; preds = %69, %68
  %74 = load i32, ptr %7, align 4, !tbaa !5
  %75 = load ptr, ptr %10, align 8, !tbaa !9
  %76 = call ptr @pdb_load(i32 noundef %74, ptr noundef %75)
  store ptr %76, ptr %6, align 8, !tbaa !9
  %77 = load ptr, ptr %6, align 8, !tbaa !9
  %78 = icmp eq ptr %77, null
  br i1 %78, label %79, label %80

79:                                               ; preds = %73
  call void @perror(ptr noundef @.str.6)
  store i32 1, ptr %3, align 4
  store i32 1, ptr %11, align 4
  br label %86

80:                                               ; preds = %73
  %81 = load ptr, ptr %10, align 8, !tbaa !9
  %82 = call i32 @fclose(ptr noundef %81)
  %83 = load ptr, ptr %6, align 8, !tbaa !9
  %84 = load ptr, ptr @stderr, align 8, !tbaa !9
  %85 = call i32 @pdb_verify(ptr noundef %83, ptr noundef %84)
  store i32 %85, ptr %3, align 4
  store i32 1, ptr %11, align 4
  br label %86

86:                                               ; preds = %80, %79, %67, %53, %38, %30
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  %87 = load i32, ptr %3, align 4
  ret i32 %87
}

; 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 i32 @__posix_getopt(i32 noundef, ptr noundef, ptr noundef) #2

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare i32 @atoi(ptr noundef nonnull) #3

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

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @tileset_count(i32 noundef) #5

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @tileset_remove(i32 noundef, i32 noundef) #5

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

declare void @perror(ptr noundef) #4

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

declare i32 @fclose(ptr noundef) #4

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

; 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 = { 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 = { inlinehint nounwind willreturn memory(read) 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 #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 = { inlinehint 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 #6 = { nounwind }
attributes #7 = { nounwind willreturn memory(read) }

!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 = 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"

@.str = external hidden unnamed_addr constant [7 x i8], align 1
@optarg = external local_unnamed_addr global ptr, align 8
@pdb_jobs = external local_unnamed_addr global i32, align 4
@stderr = external local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [44 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [54 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [9 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #7
  store i32 231, ptr %3, align 4, !tbaa !5
  br label %.outer

.outer:                                           ; preds = %6, %2
  %.014.ph = phi ptr [ %7, %6 ], [ null, %2 ]
  br label %4

4:                                                ; preds = %.backedge, %.outer
  %5 = call i32 @__posix_getopt(i32 noundef %0, ptr noundef %1, ptr noundef nonnull @.str) #7
  switch i32 %5, label %.backedge [
    i32 -1, label %24
    i32 102, label %6
    i32 106, label %8
    i32 116, label %15
    i32 63, label %22
    i32 58, label %22
  ]

.backedge:                                        ; preds = %4, %15, %8, %22
  br label %4, !llvm.loop !9

6:                                                ; preds = %4
  %7 = load ptr, ptr @optarg, align 8, !tbaa !11
  br label %.outer, !llvm.loop !9

8:                                                ; preds = %4
  %9 = load ptr, ptr @optarg, align 8, !tbaa !11
  %10 = call i32 @atoi(ptr nocapture noundef %9) #8
  store i32 %10, ptr @pdb_jobs, align 4, !tbaa !5
  %11 = add i32 %10, -257
  %or.cond = icmp ult i32 %11, -256
  br i1 %or.cond, label %12, label %.backedge

12:                                               ; preds = %8
  %13 = load ptr, ptr @stderr, align 8, !tbaa !11
  %14 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %13, ptr noundef nonnull @.str.1, i32 noundef 256) #9
  br label %51

15:                                               ; preds = %4
  %16 = load ptr, ptr @optarg, align 8, !tbaa !11
  %17 = call i32 @tileset_parse(ptr noundef nonnull %3, ptr noundef %16) #7
  %.not20 = icmp eq i32 %17, 0
  br i1 %.not20, label %.backedge, label %18

18:                                               ; preds = %15
  %19 = load ptr, ptr @stderr, align 8, !tbaa !11
  %20 = load ptr, ptr @optarg, align 8, !tbaa !11
  %21 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %19, ptr noundef nonnull @.str.2, ptr noundef %20) #9
  br label %51

22:                                               ; preds = %4, %4
  %23 = load ptr, ptr %1, align 8, !tbaa !11
  call void @usage(ptr noundef %23)
  br label %.backedge

24:                                               ; preds = %4
  %25 = load i32, ptr %3, align 4, !tbaa !5
  %26 = call i32 @tileset_remove(i32 noundef %25, i32 noundef 0)
  %27 = call i32 @tileset_count(i32 noundef %26)
  %28 = icmp ugt i32 %27, 11
  br i1 %28, label %29, label %35

29:                                               ; preds = %24
  %30 = load ptr, ptr @stderr, align 8, !tbaa !11
  %31 = load i32, ptr %3, align 4, !tbaa !5
  %32 = call i32 @tileset_remove(i32 noundef %31, i32 noundef 0)
  %33 = call i32 @tileset_count(i32 noundef %32)
  %34 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %30, ptr noundef nonnull @.str.3, i32 noundef %33, i32 noundef 12) #9
  br label %51

35:                                               ; preds = %24
  %.not19 = icmp eq ptr %.014.ph, null
  br i1 %.not19, label %40, label %36

36:                                               ; preds = %35
  %37 = call noalias ptr @fopen(ptr noundef nonnull %.014.ph, ptr noundef nonnull @.str.4)
  %38 = icmp eq ptr %37, null
  br i1 %38, label %39, label %42

39:                                               ; preds = %36
  call void @perror(ptr noundef nonnull @.str.5) #10
  br label %51

40:                                               ; preds = %35
  %41 = load ptr, ptr %1, align 8, !tbaa !11
  call void @usage(ptr noundef %41)
  br label %42

42:                                               ; preds = %36, %40
  %.0 = phi ptr [ %37, %36 ], [ null, %40 ]
  %43 = load i32, ptr %3, align 4, !tbaa !5
  %44 = call ptr @pdb_load(i32 noundef %43, ptr noundef %.0) #7
  %45 = icmp eq ptr %44, null
  br i1 %45, label %46, label %47

46:                                               ; preds = %42
  call void @perror(ptr noundef nonnull @.str.6) #10
  br label %51

47:                                               ; preds = %42
  %48 = call i32 @fclose(ptr noundef %.0)
  %49 = load ptr, ptr @stderr, align 8, !tbaa !11
  %50 = call i32 @pdb_verify(ptr noundef nonnull %44, ptr noundef %49) #7
  br label %51

51:                                               ; preds = %47, %46, %39, %29, %18, %12
  %.015 = phi i32 [ 1, %18 ], [ 1, %12 ], [ 1, %29 ], [ 1, %39 ], [ 1, %46 ], [ %50, %47 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #7
  ret i32 %.015
}

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

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

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare i32 @atoi(ptr nocapture noundef nonnull) local_unnamed_addr #3

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

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @tileset_count(i32 noundef) local_unnamed_addr #6

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @tileset_remove(i32 noundef, i32 noundef) local_unnamed_addr #6

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

; Function Attrs: nofree nounwind
declare void @perror(ptr nocapture noundef readonly) local_unnamed_addr #4

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

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #4

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

; 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 = { 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 = { inlinehint mustprogress nofree nounwind willreturn memory(read) 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 #4 = { 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 #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 = { inlinehint 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 #7 = { nounwind }
attributes #8 = { nounwind willreturn memory(read) }
attributes #9 = { cold nounwind }
attributes #10 = { cold }

!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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopUnrollPass,SROAPass,SimplifyCFGPass