; LLVM IR from kazunetakahashi/atcoder :: 201610_12/1106_ARC063/E.ll (Z7ok_condi9condition)

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z7ok_condi9condition(i32 noundef %0, i64 %1, i8 %2) #0 {
  %4 = alloca i1, align 1
  %5 = alloca %struct.condition, align 4
  %6 = alloca { i64, i8 }, align 4
  %7 = alloca i32, align 4
  %8 = alloca i8, align 1
  %9 = alloca i32, align 4
  %10 = getelementptr inbounds { i64, i8 }, ptr %6, i32 0, i32 0
  store i64 %1, ptr %10, align 4
  %11 = getelementptr inbounds { i64, i8 }, ptr %6, i32 0, i32 1
  store i8 %2, ptr %11, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %5, ptr align 4 %6, i64 12, i1 false)
  store i32 %0, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #3
  %12 = load i32, ptr %7, align 4, !tbaa !5
  %13 = srem i32 %12, 2
  %14 = icmp eq i32 %13, 1
  %15 = zext i1 %14 to i8
  store i8 %15, ptr %8, align 1, !tbaa !9
  %16 = getelementptr inbounds %struct.condition, ptr %5, i32 0, i32 2
  %17 = load i8, ptr %16, align 4, !tbaa !11, !range !13, !noundef !14
  %18 = trunc i8 %17 to i1
  %19 = zext i1 %18 to i32
  %20 = load i8, ptr %8, align 1, !tbaa !9, !range !13, !noundef !14
  %21 = trunc i8 %20 to i1
  %22 = zext i1 %21 to i32
  %23 = icmp ne i32 %19, %22
  br i1 %23, label %24, label %25

24:                                               ; preds = %3
  store i1 false, ptr %4, align 1
  store i32 1, ptr %9, align 4
  br label %37

25:                                               ; preds = %3
  %26 = getelementptr inbounds %struct.condition, ptr %5, i32 0, i32 0
  %27 = load i32, ptr %26, align 4, !tbaa !15
  %28 = load i32, ptr %7, align 4, !tbaa !5
  %29 = icmp sge i32 %27, %28
  br i1 %29, label %30, label %35

30:                                               ; preds = %25
  %31 = load i32, ptr %7, align 4, !tbaa !5
  %32 = getelementptr inbounds %struct.condition, ptr %5, i32 0, i32 1
  %33 = load i32, ptr %32, align 4, !tbaa !16
  %34 = icmp sge i32 %31, %33
  br label %35

35:                                               ; preds = %30, %25
  %36 = phi i1 [ false, %25 ], [ %34, %30 ]
  store i1 %36, ptr %4, align 1
  store i32 1, ptr %9, align 4
  br label %37

37:                                               ; preds = %35, %24
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #3
  %38 = load i1, ptr %4, align 1
  ret i1 %38
}

; 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

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

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

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) }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"bool", !7, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"_ZTS9condition", !6, i64 0, !6, i64 4, !10, i64 8}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!12, !6, i64 0}
!16 = !{!12, !6, i64 4}


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

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local noundef zeroext i1 @_Z7ok_condi9condition(i32 noundef %0, i64 %1, i8 %2) local_unnamed_addr #0 {
  %4 = and i32 %0, -2147483647
  %5 = trunc i8 %2 to i1
  %6 = icmp ne i32 %4, 1
  %.not = xor i1 %6, %5
  br i1 %.not, label %7, label %11

7:                                                ; preds = %3
  %.sroa.25.0.extract.shift = lshr i64 %1, 32
  %.sroa.25.0.extract.trunc = trunc nuw i64 %.sroa.25.0.extract.shift to i32
  %.sroa.04.0.extract.trunc = trunc i64 %1 to i32
  %8 = icmp sge i32 %.sroa.04.0.extract.trunc, %0
  %9 = icmp sle i32 %.sroa.25.0.extract.trunc, %0
  %10 = select i1 %8, i1 %9, i1 false
  br label %11

11:                                               ; preds = %3, %7
  %.0 = phi i1 [ %10, %7 ], [ false, %3 ]
  ret i1 %.0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) 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)"}


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