; LLVM IR from upupming/algorithm :: acwing/算法竞赛进阶指南/0x25-广度优先搜索/172. 立体推箱子.ll (Z5valid3rec)

; 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.rec = type { i32, i32, i32 }

@s = external dso_local global [510 x [510 x i8]], align 16

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z5validii(i32 noundef, i32 noundef) #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z5valid3rec(i64 %0, i32 %1) #0 {
  %3 = alloca i1, align 1
  %4 = alloca %struct.rec, align 4
  %5 = alloca { i64, i32 }, align 4
  %6 = getelementptr inbounds { i64, i32 }, ptr %5, i32 0, i32 0
  store i64 %0, ptr %6, align 4
  %7 = getelementptr inbounds { i64, i32 }, ptr %5, i32 0, i32 1
  store i32 %1, ptr %7, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %4, ptr align 4 %5, i64 12, i1 false)
  %8 = getelementptr inbounds %struct.rec, ptr %4, i32 0, i32 0
  %9 = load i32, ptr %8, align 4, !tbaa !5
  %10 = getelementptr inbounds %struct.rec, ptr %4, i32 0, i32 1
  %11 = load i32, ptr %10, align 4, !tbaa !10
  %12 = call noundef zeroext i1 @_Z5validii(i32 noundef %9, i32 noundef %11)
  br i1 %12, label %14, label %13

13:                                               ; preds = %2
  store i1 false, ptr %3, align 1
  br label %81

14:                                               ; preds = %2
  %15 = getelementptr inbounds %struct.rec, ptr %4, i32 0, i32 0
  %16 = load i32, ptr %15, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [510 x [510 x i8]], ptr @s, i64 0, i64 %17
  %19 = getelementptr inbounds %struct.rec, ptr %4, i32 0, i32 1
  %20 = load i32, ptr %19, align 4, !tbaa !10
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [510 x i8], ptr %18, i64 0, i64 %21
  %23 = load i8, ptr %22, align 1, !tbaa !11
  %24 = sext i8 %23 to i32
  %25 = icmp eq i32 %24, 35
  br i1 %25, label %26, label %27

26:                                               ; preds = %14
  store i1 false, ptr %3, align 1
  br label %81

27:                                               ; preds = %14
  %28 = getelementptr inbounds %struct.rec, ptr %4, i32 0, i32 2
  %29 = load i32, ptr %28, align 4, !tbaa !12
  %30 = icmp eq i32 %29, 0
  br i1 %30, label %31, label %44

31:                                               ; preds = %27
  %32 = getelementptr inbounds %struct.rec, ptr %4, i32 0, i32 0
  %33 = load i32, ptr %32, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [510 x [510 x i8]], ptr @s, i64 0, i64 %34
  %36 = getelementptr inbounds %struct.rec, ptr %4, i32 0, i32 1
  %37 = load i32, ptr %36, align 4, !tbaa !10
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [510 x i8], ptr %35, i64 0, i64 %38
  %40 = load i8, ptr %39, align 1, !tbaa !11
  %41 = sext i8 %40 to i32
  %42 = icmp ne i32 %41, 46
  br i1 %42, label %43, label %44

43:                                               ; preds = %31
  store i1 false, ptr %3, align 1
  br label %81

44:                                               ; preds = %31, %27
  %45 = getelementptr inbounds %struct.rec, ptr %4, i32 0, i32 2
  %46 = load i32, ptr %45, align 4, !tbaa !12
  %47 = icmp eq i32 %46, 1
  br i1 %47, label %48, label %62

48:                                               ; preds = %44
  %49 = getelementptr inbounds %struct.rec, ptr %4, i32 0, i32 0
  %50 = load i32, ptr %49, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [510 x [510 x i8]], ptr @s, i64 0, i64 %51
  %53 = getelementptr inbounds %struct.rec, ptr %4, i32 0, i32 1
  %54 = load i32, ptr %53, align 4, !tbaa !10
  %55 = add nsw i32 %54, 1
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [510 x i8], ptr %52, i64 0, i64 %56
  %58 = load i8, ptr %57, align 1, !tbaa !11
  %59 = sext i8 %58 to i32
  %60 = icmp eq i32 %59, 35
  br i1 %60, label %61, label %62

61:                                               ; preds = %48
  store i1 false, ptr %3, align 1
  br label %81

62:                                               ; preds = %48, %44
  %63 = getelementptr inbounds %struct.rec, ptr %4, i32 0, i32 2
  %64 = load i32, ptr %63, align 4, !tbaa !12
  %65 = icmp eq i32 %64, 2
  br i1 %65, label %66, label %80

66:                                               ; preds = %62
  %67 = getelementptr inbounds %struct.rec, ptr %4, i32 0, i32 0
  %68 = load i32, ptr %67, align 4, !tbaa !5
  %69 = add nsw i32 %68, 1
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [510 x [510 x i8]], ptr @s, i64 0, i64 %70
  %72 = getelementptr inbounds %struct.rec, ptr %4, i32 0, i32 1
  %73 = load i32, ptr %72, align 4, !tbaa !10
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [510 x i8], ptr %71, i64 0, i64 %74
  %76 = load i8, ptr %75, align 1, !tbaa !11
  %77 = sext i8 %76 to i32
  %78 = icmp eq i32 %77, 35
  br i1 %78, label %79, label %80

79:                                               ; preds = %66
  store i1 false, ptr %3, align 1
  br label %81

80:                                               ; preds = %66, %62
  store i1 true, ptr %3, align 1
  br label %81

81:                                               ; preds = %80, %79, %61, %43, %26, %13
  %82 = load i1, ptr %3, align 1
  ret i1 %82
}

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

attributes #0 = { mustprogress 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 nounwind willreturn memory(argmem: readwrite) }

!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, !7, i64 0}
!6 = !{!"_ZTS3rec", !7, i64 0, !7, i64 4, !7, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 4}
!11 = !{!8, !8, i64 0}
!12 = !{!6, !7, i64 8}


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

@s = external dso_local local_unnamed_addr global [510 x [510 x i8]], align 16

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z5validii(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z5valid3rec(i64 %0, i32 %1) local_unnamed_addr #0 {
  %.sroa.01.0.extract.trunc = trunc i64 %0 to i32
  %.sroa.6.0.extract.shift = lshr i64 %0, 32
  %.sroa.6.0.extract.trunc = trunc nuw i64 %.sroa.6.0.extract.shift to i32
  %3 = tail call noundef zeroext i1 @_Z5validii(i32 noundef %.sroa.01.0.extract.trunc, i32 noundef %.sroa.6.0.extract.trunc)
  br i1 %3, label %4, label %24

4:                                                ; preds = %2
  %sext = shl i64 %0, 32
  %5 = ashr exact i64 %sext, 32
  %6 = ashr i64 %0, 32
  %7 = getelementptr inbounds [510 x [510 x i8]], ptr @s, i64 0, i64 %5, i64 %6
  %8 = load i8, ptr %7, align 1, !tbaa !5
  %9 = icmp eq i8 %8, 35
  br i1 %9, label %24, label %10

10:                                               ; preds = %4
  %11 = icmp ne i32 %1, 0
  %.not = icmp eq i8 %8, 46
  %or.cond = or i1 %11, %.not
  br i1 %or.cond, label %12, label %24

12:                                               ; preds = %10
  switch i32 %1, label %23 [
    i32 1, label %13
    i32 2, label %18
  ]

13:                                               ; preds = %12
  %sext14 = add i64 %0, 4294967296
  %14 = ashr i64 %sext14, 32
  %15 = getelementptr inbounds [510 x [510 x i8]], ptr @s, i64 0, i64 %5, i64 %14
  %16 = load i8, ptr %15, align 1, !tbaa !5
  %17 = icmp eq i8 %16, 35
  br i1 %17, label %24, label %23

18:                                               ; preds = %12
  %sext15 = add i64 %sext, 4294967296
  %19 = ashr exact i64 %sext15, 32
  %20 = getelementptr inbounds [510 x [510 x i8]], ptr @s, i64 0, i64 %19, i64 %6
  %21 = load i8, ptr %20, align 1, !tbaa !5
  %22 = icmp eq i8 %21, 35
  br i1 %22, label %24, label %23

23:                                               ; preds = %13, %12, %18
  br label %24

24:                                               ; preds = %18, %13, %10, %4, %2, %23
  %.0 = phi i1 [ true, %23 ], [ false, %2 ], [ false, %4 ], [ false, %10 ], [ false, %13 ], [ false, %18 ]
  ret i1 %.0
}

attributes #0 = { mustprogress 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" }

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass,TailCallElimPass