; LLVM IR from Izaron/ACM-ICPC :: Timus Online Judge/Volume 2/1158. Censored!.ll (Z3badi)

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

%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<node *, std::allocator<node *>>::_Vector_impl" }
%"struct.std::_Vector_base<node *, std::allocator<node *>>::_Vector_impl" = type { %"struct.std::_Vector_base<node *, std::allocator<node *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<node *, std::allocator<node *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.node = type { i32, i32, i32, i8, i8, i8, %"class.std::vector.6", %"class.std::vector.6" }
%"class.std::vector.6" = type { %"struct.std::_Vector_base.7" }
%"struct.std::_Vector_base.7" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@nodes = external dso_local global %"class.std::vector", align 8

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIP4nodeSaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #1 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z8get_linki(i32 noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z3badi(i32 noundef %0) #2 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  store i32 %0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %4 = load i32, ptr %2, align 4, !tbaa !5
  %5 = sext i32 %4 to i64
  %6 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIP4nodeSaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @nodes, i64 noundef %5) #3
  %7 = load ptr, ptr %6, align 8, !tbaa !9
  store ptr %7, ptr %3, align 8, !tbaa !9
  %8 = load ptr, ptr %3, align 8, !tbaa !9
  %9 = getelementptr inbounds %struct.node, ptr %8, i32 0, i32 4
  %10 = load i8, ptr %9, align 1, !tbaa !11, !range !18, !noundef !19
  %11 = trunc i8 %10 to i1
  br i1 %11, label %37, label %12

12:                                               ; preds = %1
  %13 = load ptr, ptr %3, align 8, !tbaa !9
  %14 = getelementptr inbounds %struct.node, ptr %13, i32 0, i32 4
  store i8 1, ptr %14, align 1, !tbaa !11
  %15 = load ptr, ptr %3, align 8, !tbaa !9
  %16 = getelementptr inbounds %struct.node, ptr %15, i32 0, i32 3
  %17 = load i8, ptr %16, align 4, !tbaa !20, !range !18, !noundef !19
  %18 = trunc i8 %17 to i1
  br i1 %18, label %19, label %22

19:                                               ; preds = %12
  %20 = load ptr, ptr %3, align 8, !tbaa !9
  %21 = getelementptr inbounds %struct.node, ptr %20, i32 0, i32 5
  store i8 1, ptr %21, align 2, !tbaa !21
  br label %36

22:                                               ; preds = %12
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = icmp eq i32 %23, 0
  br i1 %24, label %25, label %28

25:                                               ; preds = %22
  %26 = load ptr, ptr %3, align 8, !tbaa !9
  %27 = getelementptr inbounds %struct.node, ptr %26, i32 0, i32 5
  store i8 0, ptr %27, align 2, !tbaa !21
  br label %35

28:                                               ; preds = %22
  %29 = load i32, ptr %2, align 4, !tbaa !5
  %30 = call noundef i32 @_Z8get_linki(i32 noundef %29)
  %31 = call noundef zeroext i1 @_Z3badi(i32 noundef %30)
  %32 = load ptr, ptr %3, align 8, !tbaa !9
  %33 = getelementptr inbounds %struct.node, ptr %32, i32 0, i32 5
  %34 = zext i1 %31 to i8
  store i8 %34, ptr %33, align 2, !tbaa !21
  br label %35

35:                                               ; preds = %28, %25
  br label %36

36:                                               ; preds = %35, %19
  br label %37

37:                                               ; preds = %36, %1
  %38 = load ptr, ptr %3, align 8, !tbaa !9
  %39 = getelementptr inbounds %struct.node, ptr %38, i32 0, i32 5
  %40 = load i8, ptr %39, align 2, !tbaa !21, !range !18, !noundef !19
  %41 = trunc i8 %40 to i1
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret i1 %41
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { mustprogress 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 #3 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !13, i64 13}
!12 = !{!"_ZTS4node", !6, i64 0, !6, i64 4, !6, i64 8, !13, i64 12, !13, i64 13, !13, i64 14, !14, i64 16, !14, i64 40}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"_ZTSSt6vectorIiSaIiEE", !15, i64 0}
!15 = !{!"_ZTSSt12_Vector_baseIiSaIiEE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE12_Vector_implE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataE", !10, i64 0, !10, i64 8, !10, i64 16}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = !{!12, !13, i64 12}
!21 = !{!12, !13, i64 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"

%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<node *, std::allocator<node *>>::_Vector_impl" }
%"struct.std::_Vector_base<node *, std::allocator<node *>>::_Vector_impl" = type { %"struct.std::_Vector_base<node *, std::allocator<node *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<node *, std::allocator<node *>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@nodes = external dso_local global %"class.std::vector", align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIP4nodeSaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z8get_linki(i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z3badi(i32 noundef %0) local_unnamed_addr #1 {
  %2 = sext i32 %0 to i64
  %3 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIP4nodeSaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @nodes, i64 noundef %2) #2
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %4, i64 13
  %6 = load i8, ptr %5, align 1, !tbaa !9, !range !17, !noundef !18
  %7 = trunc nuw i8 %6 to i1
  br i1 %7, label %._crit_edge, label %9

._crit_edge:                                      ; preds = %1
  %.phi.trans.insert = getelementptr inbounds i8, ptr %4, i64 14
  %.pre = load i8, ptr %.phi.trans.insert, align 2, !tbaa !19, !range !17
  %8 = trunc nuw i8 %.pre to i1
  br label %common.ret

9:                                                ; preds = %1
  store i8 1, ptr %5, align 1, !tbaa !9
  %10 = getelementptr inbounds i8, ptr %4, i64 12
  %11 = load i8, ptr %10, align 4, !tbaa !20, !range !17, !noundef !18
  %12 = trunc nuw i8 %11 to i1
  br i1 %12, label %13, label %15

13:                                               ; preds = %9
  %14 = getelementptr inbounds i8, ptr %4, i64 14
  store i8 1, ptr %14, align 2, !tbaa !19
  br label %common.ret

15:                                               ; preds = %9
  %16 = icmp eq i32 %0, 0
  br i1 %16, label %17, label %19

17:                                               ; preds = %15
  %18 = getelementptr inbounds i8, ptr %4, i64 14
  store i8 0, ptr %18, align 2, !tbaa !19
  br label %common.ret

common.ret:                                       ; preds = %17, %13, %._crit_edge, %19
  %common.ret.op = phi i1 [ %21, %19 ], [ %8, %._crit_edge ], [ true, %13 ], [ false, %17 ]
  ret i1 %common.ret.op

19:                                               ; preds = %15
  %20 = tail call noundef i32 @_Z8get_linki(i32 noundef %0)
  %21 = tail call noundef zeroext i1 @_Z3badi(i32 noundef %20)
  %22 = getelementptr inbounds i8, ptr %4, i64 14
  %23 = zext i1 %21 to i8
  store i8 %23, ptr %22, align 2, !tbaa !19
  br label %common.ret
}

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 = { mustprogress 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 = { 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++ TBAA"}
!9 = !{!10, !12, i64 13}
!10 = !{!"_ZTS4node", !11, i64 0, !11, i64 4, !11, i64 8, !12, i64 12, !12, i64 13, !12, i64 14, !13, i64 16, !13, i64 40}
!11 = !{!"int", !7, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!"_ZTSSt6vectorIiSaIiEE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseIiSaIiEE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = !{!10, !12, i64 14}
!20 = !{!10, !12, i64 12}


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