; LLVM IR from kazunetakahashi/atcoder :: 2017/0926_ARC081/E.ll (Z5firstPb)

; 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 [6 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [80 x i8], align 1
@__PRETTY_FUNCTION__._Z5firstPb = external hidden unnamed_addr constant [18 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: mustprogress nounwind uwtable
define dso_local noundef i32 @_Z5firstPb(ptr noundef %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %6

6:                                                ; preds = %20, %1
  %7 = load i32, ptr %4, align 4, !tbaa !9
  %8 = icmp slt i32 %7, 26
  br i1 %8, label %10, label %9

9:                                                ; preds = %6
  store i32 2, ptr %5, align 4
  br label %23

10:                                               ; preds = %6
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = load i32, ptr %4, align 4, !tbaa !9
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds i8, ptr %11, i64 %13
  %15 = load i8, ptr %14, align 1, !tbaa !11, !range !13, !noundef !14
  %16 = trunc i8 %15 to i1
  br i1 %16, label %19, label %17

17:                                               ; preds = %10
  %18 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %18, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %23

19:                                               ; preds = %10
  br label %20

20:                                               ; preds = %19
  %21 = load i32, ptr %4, align 4, !tbaa !9
  %22 = add nsw i32 %21, 1
  store i32 %22, ptr %4, align 4, !tbaa !9
  br label %6, !llvm.loop !15

23:                                               ; preds = %17, %9
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  %24 = load i32, ptr %5, align 4
  switch i32 %24, label %28 [
    i32 2, label %25
    i32 1, label %26
  ]

25:                                               ; preds = %23
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.2, i32 noundef 45, ptr noundef @__PRETTY_FUNCTION__._Z5firstPb) #4
  unreachable

26:                                               ; preds = %23
  %27 = load i32, ptr %2, align 4
  ret i32 %27

28:                                               ; preds = %23
  unreachable
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

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 = { 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 #3 = { nounwind }
attributes #4 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = distinct !{!15, !16}
!16 = !{!"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 [6 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [80 x i8], align 1
@__PRETTY_FUNCTION__._Z5firstPb = external hidden unnamed_addr constant [18 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_Z5firstPb(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = load i8, ptr %0, align 1, !tbaa !5, !range !9, !noundef !10
  %3 = trunc nuw i8 %2 to i1
  br i1 %3, label %4, label %105

4:                                                ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 1
  %6 = load i8, ptr %5, align 1, !tbaa !5, !range !9, !noundef !10
  %7 = trunc nuw i8 %6 to i1
  br i1 %7, label %8, label %105

8:                                                ; preds = %4
  %9 = getelementptr inbounds i8, ptr %0, i64 2
  %10 = load i8, ptr %9, align 1, !tbaa !5, !range !9, !noundef !10
  %11 = trunc nuw i8 %10 to i1
  br i1 %11, label %12, label %105

12:                                               ; preds = %8
  %13 = getelementptr inbounds i8, ptr %0, i64 3
  %14 = load i8, ptr %13, align 1, !tbaa !5, !range !9, !noundef !10
  %15 = trunc nuw i8 %14 to i1
  br i1 %15, label %16, label %105

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

20:                                               ; preds = %16
  %21 = getelementptr inbounds i8, ptr %0, i64 5
  %22 = load i8, ptr %21, align 1, !tbaa !5, !range !9, !noundef !10
  %23 = trunc nuw i8 %22 to i1
  br i1 %23, label %24, label %105

24:                                               ; preds = %20
  %25 = getelementptr inbounds i8, ptr %0, i64 6
  %26 = load i8, ptr %25, align 1, !tbaa !5, !range !9, !noundef !10
  %27 = trunc nuw i8 %26 to i1
  br i1 %27, label %28, label %105

28:                                               ; preds = %24
  %29 = getelementptr inbounds i8, ptr %0, i64 7
  %30 = load i8, ptr %29, align 1, !tbaa !5, !range !9, !noundef !10
  %31 = trunc nuw i8 %30 to i1
  br i1 %31, label %32, label %105

32:                                               ; preds = %28
  %33 = getelementptr inbounds i8, ptr %0, i64 8
  %34 = load i8, ptr %33, align 1, !tbaa !5, !range !9, !noundef !10
  %35 = trunc nuw i8 %34 to i1
  br i1 %35, label %36, label %105

36:                                               ; preds = %32
  %37 = getelementptr inbounds i8, ptr %0, i64 9
  %38 = load i8, ptr %37, align 1, !tbaa !5, !range !9, !noundef !10
  %39 = trunc nuw i8 %38 to i1
  br i1 %39, label %40, label %105

40:                                               ; preds = %36
  %41 = getelementptr inbounds i8, ptr %0, i64 10
  %42 = load i8, ptr %41, align 1, !tbaa !5, !range !9, !noundef !10
  %43 = trunc nuw i8 %42 to i1
  br i1 %43, label %44, label %105

44:                                               ; preds = %40
  %45 = getelementptr inbounds i8, ptr %0, i64 11
  %46 = load i8, ptr %45, align 1, !tbaa !5, !range !9, !noundef !10
  %47 = trunc nuw i8 %46 to i1
  br i1 %47, label %48, label %105

48:                                               ; preds = %44
  %49 = getelementptr inbounds i8, ptr %0, i64 12
  %50 = load i8, ptr %49, align 1, !tbaa !5, !range !9, !noundef !10
  %51 = trunc nuw i8 %50 to i1
  br i1 %51, label %52, label %105

52:                                               ; preds = %48
  %53 = getelementptr inbounds i8, ptr %0, i64 13
  %54 = load i8, ptr %53, align 1, !tbaa !5, !range !9, !noundef !10
  %55 = trunc nuw i8 %54 to i1
  br i1 %55, label %56, label %105

56:                                               ; preds = %52
  %57 = getelementptr inbounds i8, ptr %0, i64 14
  %58 = load i8, ptr %57, align 1, !tbaa !5, !range !9, !noundef !10
  %59 = trunc nuw i8 %58 to i1
  br i1 %59, label %60, label %105

60:                                               ; preds = %56
  %61 = getelementptr inbounds i8, ptr %0, i64 15
  %62 = load i8, ptr %61, align 1, !tbaa !5, !range !9, !noundef !10
  %63 = trunc nuw i8 %62 to i1
  br i1 %63, label %64, label %105

64:                                               ; preds = %60
  %65 = getelementptr inbounds i8, ptr %0, i64 16
  %66 = load i8, ptr %65, align 1, !tbaa !5, !range !9, !noundef !10
  %67 = trunc nuw i8 %66 to i1
  br i1 %67, label %68, label %105

68:                                               ; preds = %64
  %69 = getelementptr inbounds i8, ptr %0, i64 17
  %70 = load i8, ptr %69, align 1, !tbaa !5, !range !9, !noundef !10
  %71 = trunc nuw i8 %70 to i1
  br i1 %71, label %72, label %105

72:                                               ; preds = %68
  %73 = getelementptr inbounds i8, ptr %0, i64 18
  %74 = load i8, ptr %73, align 1, !tbaa !5, !range !9, !noundef !10
  %75 = trunc nuw i8 %74 to i1
  br i1 %75, label %76, label %105

76:                                               ; preds = %72
  %77 = getelementptr inbounds i8, ptr %0, i64 19
  %78 = load i8, ptr %77, align 1, !tbaa !5, !range !9, !noundef !10
  %79 = trunc nuw i8 %78 to i1
  br i1 %79, label %80, label %105

80:                                               ; preds = %76
  %81 = getelementptr inbounds i8, ptr %0, i64 20
  %82 = load i8, ptr %81, align 1, !tbaa !5, !range !9, !noundef !10
  %83 = trunc nuw i8 %82 to i1
  br i1 %83, label %84, label %105

84:                                               ; preds = %80
  %85 = getelementptr inbounds i8, ptr %0, i64 21
  %86 = load i8, ptr %85, align 1, !tbaa !5, !range !9, !noundef !10
  %87 = trunc nuw i8 %86 to i1
  br i1 %87, label %88, label %105

88:                                               ; preds = %84
  %89 = getelementptr inbounds i8, ptr %0, i64 22
  %90 = load i8, ptr %89, align 1, !tbaa !5, !range !9, !noundef !10
  %91 = trunc nuw i8 %90 to i1
  br i1 %91, label %92, label %105

92:                                               ; preds = %88
  %93 = getelementptr inbounds i8, ptr %0, i64 23
  %94 = load i8, ptr %93, align 1, !tbaa !5, !range !9, !noundef !10
  %95 = trunc nuw i8 %94 to i1
  br i1 %95, label %96, label %105

96:                                               ; preds = %92
  %97 = getelementptr inbounds i8, ptr %0, i64 24
  %98 = load i8, ptr %97, align 1, !tbaa !5, !range !9, !noundef !10
  %99 = trunc nuw i8 %98 to i1
  br i1 %99, label %100, label %105

100:                                              ; preds = %96
  %101 = getelementptr inbounds i8, ptr %0, i64 25
  %102 = load i8, ptr %101, align 1, !tbaa !5, !range !9, !noundef !10
  %103 = trunc nuw i8 %102 to i1
  br i1 %103, label %104, label %105

104:                                              ; preds = %100
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.2, i32 noundef 45, ptr noundef nonnull @__PRETTY_FUNCTION__._Z5firstPb) #2
  unreachable

105:                                              ; preds = %100, %96, %92, %88, %84, %80, %76, %72, %68, %64, %60, %56, %52, %48, %44, %40, %36, %32, %28, %24, %20, %16, %12, %8, %4, %1
  %.0612.lcssa.wide = phi i32 [ 0, %1 ], [ 1, %4 ], [ 2, %8 ], [ 3, %12 ], [ 4, %16 ], [ 5, %20 ], [ 6, %24 ], [ 7, %28 ], [ 8, %32 ], [ 9, %36 ], [ 10, %40 ], [ 11, %44 ], [ 12, %48 ], [ 13, %52 ], [ 14, %56 ], [ 15, %60 ], [ 16, %64 ], [ 17, %68 ], [ 18, %72 ], [ 19, %76 ], [ 20, %80 ], [ 21, %84 ], [ 22, %88 ], [ 23, %92 ], [ 24, %96 ], [ 25, %100 ]
  ret i32 %.0612.lcssa.wide
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #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 = { 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 #2 = { 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 = !{!"bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{i8 0, i8 2}
!10 = !{}


; Effective O3 passes: CorrelatedValuePropagationPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass