; LLVM IR from tangjz/acm-icpc :: hackerrank (prng-sequence-guessing)

; 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.Random = type { i64 }

@Rand = external dso_local global %class.Random, align 8
@t = external dso_local global i32, align 4
@seq = external dso_local global [10 x i32], align 16
@L = external dso_local global i64, align 8
@R = external dso_local global i64, align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i8, align 1
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  br label %8

8:                                                ; preds = %83, %0
  %9 = load i32, ptr @t, align 4, !tbaa !5
  %10 = add nsw i32 %9, -1
  store i32 %10, ptr @t, align 4, !tbaa !5
  %11 = icmp ne i32 %9, 0
  br i1 %11, label %12, label %85

12:                                               ; preds = %8
  %13 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @L, ptr noundef @R)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %23, %12
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = icmp slt i32 %15, 10
  br i1 %16, label %18, label %17

17:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  br label %26

18:                                               ; preds = %14
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds i32, ptr @seq, i64 %20
  %22 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %21)
  br label %23

23:                                               ; preds = %18
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = add nsw i32 %24, 1
  store i32 %25, ptr %2, align 4, !tbaa !5
  br label %14, !llvm.loop !9

26:                                               ; preds = %17
  br label %27

27:                                               ; preds = %67, %26
  %28 = load i64, ptr @L, align 8, !tbaa !11
  %29 = load i64, ptr @R, align 8, !tbaa !11
  %30 = icmp sle i64 %28, %29
  br i1 %30, label %31, label %70

31:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #5
  store i8 1, ptr %3, align 1, !tbaa !13
  %32 = load i64, ptr @L, align 8, !tbaa !11
  call void @_ZN6Random7setSeedEx(ptr noundef nonnull align 8 dereferenceable(8) @Rand, i64 noundef %32)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %33

33:                                               ; preds = %56, %31
  %34 = load i32, ptr %4, align 4, !tbaa !5
  %35 = icmp slt i32 %34, 10
  br i1 %35, label %36, label %39

36:                                               ; preds = %33
  %37 = load i8, ptr %3, align 1, !tbaa !13, !range !15, !noundef !16
  %38 = trunc i8 %37 to i1
  br label %39

39:                                               ; preds = %36, %33
  %40 = phi i1 [ false, %33 ], [ %38, %36 ]
  br i1 %40, label %42, label %41

41:                                               ; preds = %39
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %59

42:                                               ; preds = %39
  %43 = call noundef i32 @_ZN6Random7nextIntEi(ptr noundef nonnull align 8 dereferenceable(8) @Rand, i32 noundef 1000)
  %44 = load i32, ptr %4, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [10 x i32], ptr @seq, i64 0, i64 %45
  %47 = load i32, ptr %46, align 4, !tbaa !5
  %48 = icmp eq i32 %43, %47
  %49 = zext i1 %48 to i32
  %50 = load i8, ptr %3, align 1, !tbaa !13, !range !15, !noundef !16
  %51 = trunc i8 %50 to i1
  %52 = zext i1 %51 to i32
  %53 = and i32 %52, %49
  %54 = icmp ne i32 %53, 0
  %55 = zext i1 %54 to i8
  store i8 %55, ptr %3, align 1, !tbaa !13
  br label %56

56:                                               ; preds = %42
  %57 = load i32, ptr %4, align 4, !tbaa !5
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %4, align 4, !tbaa !5
  br label %33, !llvm.loop !17

59:                                               ; preds = %41
  %60 = load i8, ptr %3, align 1, !tbaa !13, !range !15, !noundef !16
  %61 = trunc i8 %60 to i1
  br i1 %61, label %62, label %63

62:                                               ; preds = %59
  store i32 7, ptr %5, align 4
  br label %64

63:                                               ; preds = %59
  store i32 0, ptr %5, align 4
  br label %64

64:                                               ; preds = %63, %62
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #5
  %65 = load i32, ptr %5, align 4
  switch i32 %65, label %86 [
    i32 0, label %66
    i32 7, label %70
  ]

66:                                               ; preds = %64
  br label %67

67:                                               ; preds = %66
  %68 = load i64, ptr @L, align 8, !tbaa !11
  %69 = add nsw i64 %68, 1
  store i64 %69, ptr @L, align 8, !tbaa !11
  br label %27, !llvm.loop !18

70:                                               ; preds = %64, %27
  %71 = load i64, ptr @L, align 8, !tbaa !11
  %72 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i64 noundef %71)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %73

73:                                               ; preds = %80, %70
  %74 = load i32, ptr %6, align 4, !tbaa !5
  %75 = icmp slt i32 %74, 10
  br i1 %75, label %77, label %76

76:                                               ; preds = %73
  store i32 13, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %83

77:                                               ; preds = %73
  %78 = call noundef i32 @_ZN6Random7nextIntEi(ptr noundef nonnull align 8 dereferenceable(8) @Rand, i32 noundef 1000)
  %79 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %78)
  br label %80

80:                                               ; preds = %77
  %81 = load i32, ptr %6, align 4, !tbaa !5
  %82 = add nsw i32 %81, 1
  store i32 %82, ptr %6, align 4, !tbaa !5
  br label %73, !llvm.loop !19

83:                                               ; preds = %76
  %84 = call i32 @putchar(i32 noundef 10)
  br label %8, !llvm.loop !20

85:                                               ; preds = %8
  ret i32 0

86:                                               ; preds = %64
  unreachable
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN6Random7setSeedEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZN6Random7nextIntEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #4 align 2

declare i32 @printf(ptr noundef, ...) #1

; Function Attrs: inlinehint mustprogress uwtable
declare i32 @putchar(i32 noundef) #4

attributes #0 = { mustprogress norecurse 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 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { inlinehint 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 #4 = { inlinehint 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 #5 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !10}


; 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.Random = type { i64 }

@Rand = external dso_local global %class.Random, align 8
@t = external dso_local global i32, align 4
@seq = external dso_local global [10 x i32], align 16
@L = external dso_local global i64, align 8
@R = external dso_local global i64, align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @t)
  %2 = load i32, ptr @t, align 4, !tbaa !5
  %3 = add nsw i32 %2, -1
  store i32 %3, ptr @t, align 4, !tbaa !5
  %.not23 = icmp eq i32 %2, 0
  br i1 %.not23, label %._crit_edge26, label %.lr.ph25

.lr.ph25:                                         ; preds = %0, %._crit_edge
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @L, ptr noundef nonnull @R)
  %5 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @seq)
  %6 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull getelementptr inbounds (i8, ptr @seq, i64 4))
  %7 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull getelementptr inbounds (i8, ptr @seq, i64 8))
  %8 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull getelementptr inbounds (i8, ptr @seq, i64 12))
  %9 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull getelementptr inbounds (i8, ptr @seq, i64 16))
  %10 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull getelementptr inbounds (i8, ptr @seq, i64 20))
  %11 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull getelementptr inbounds (i8, ptr @seq, i64 24))
  %12 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull getelementptr inbounds (i8, ptr @seq, i64 28))
  %13 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull getelementptr inbounds (i8, ptr @seq, i64 32))
  %14 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull getelementptr inbounds (i8, ptr @seq, i64 36))
  %15 = load i64, ptr @L, align 8, !tbaa !9
  %16 = load i64, ptr @R, align 8, !tbaa !9
  %.not1720 = icmp sgt i64 %15, %16
  br i1 %.not1720, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph25, %26
  %17 = phi i64 [ %27, %26 ], [ %15, %.lr.ph25 ]
  tail call void @_ZN6Random7setSeedEx(ptr noundef nonnull align 8 dereferenceable(8) @Rand, i64 noundef %17)
  br label %19

18:                                               ; preds = %19
  %.pre.pre = load i64, ptr @L, align 8, !tbaa !9
  br i1 %23, label %._crit_edge, label %26

19:                                               ; preds = %.lr.ph, %19
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %19 ]
  %20 = tail call noundef i32 @_ZN6Random7nextIntEi(ptr noundef nonnull align 8 dereferenceable(8) @Rand, i32 noundef 1000)
  %21 = getelementptr inbounds [10 x i32], ptr @seq, i64 0, i64 %indvars.iv
  %22 = load i32, ptr %21, align 4, !tbaa !5
  %23 = icmp eq i32 %20, %22
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %24 = icmp ult i64 %indvars.iv, 9
  %25 = select i1 %24, i1 %23, i1 false
  br i1 %25, label %19, label %18, !llvm.loop !11

26:                                               ; preds = %18
  %27 = add nsw i64 %.pre.pre, 1
  store i64 %27, ptr @L, align 8, !tbaa !9
  %28 = load i64, ptr @R, align 8, !tbaa !9
  %.not17.not = icmp slt i64 %.pre.pre, %28
  br i1 %.not17.not, label %.lr.ph, label %._crit_edge, !llvm.loop !13

._crit_edge:                                      ; preds = %26, %18, %.lr.ph25
  %29 = phi i64 [ %15, %.lr.ph25 ], [ %27, %26 ], [ %.pre.pre, %18 ]
  %30 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %29)
  %31 = tail call noundef i32 @_ZN6Random7nextIntEi(ptr noundef nonnull align 8 dereferenceable(8) @Rand, i32 noundef 1000)
  %32 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %31)
  %33 = tail call noundef i32 @_ZN6Random7nextIntEi(ptr noundef nonnull align 8 dereferenceable(8) @Rand, i32 noundef 1000)
  %34 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %33)
  %35 = tail call noundef i32 @_ZN6Random7nextIntEi(ptr noundef nonnull align 8 dereferenceable(8) @Rand, i32 noundef 1000)
  %36 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %35)
  %37 = tail call noundef i32 @_ZN6Random7nextIntEi(ptr noundef nonnull align 8 dereferenceable(8) @Rand, i32 noundef 1000)
  %38 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %37)
  %39 = tail call noundef i32 @_ZN6Random7nextIntEi(ptr noundef nonnull align 8 dereferenceable(8) @Rand, i32 noundef 1000)
  %40 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %39)
  %41 = tail call noundef i32 @_ZN6Random7nextIntEi(ptr noundef nonnull align 8 dereferenceable(8) @Rand, i32 noundef 1000)
  %42 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %41)
  %43 = tail call noundef i32 @_ZN6Random7nextIntEi(ptr noundef nonnull align 8 dereferenceable(8) @Rand, i32 noundef 1000)
  %44 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %43)
  %45 = tail call noundef i32 @_ZN6Random7nextIntEi(ptr noundef nonnull align 8 dereferenceable(8) @Rand, i32 noundef 1000)
  %46 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %45)
  %47 = tail call noundef i32 @_ZN6Random7nextIntEi(ptr noundef nonnull align 8 dereferenceable(8) @Rand, i32 noundef 1000)
  %48 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %47)
  %49 = tail call noundef i32 @_ZN6Random7nextIntEi(ptr noundef nonnull align 8 dereferenceable(8) @Rand, i32 noundef 1000)
  %50 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %49)
  %51 = tail call i32 @putchar(i32 noundef 10)
  %52 = load i32, ptr @t, align 4, !tbaa !5
  %53 = add nsw i32 %52, -1
  store i32 %53, ptr @t, align 4, !tbaa !5
  %.not = icmp eq i32 %52, 0
  br i1 %.not, label %._crit_edge26, label %.lr.ph25, !llvm.loop !14

._crit_edge26:                                    ; preds = %._crit_edge, %0
  ret i32 0
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN6Random7setSeedEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZN6Random7nextIntEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #3 align 2

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

; Function Attrs: inlinehint mustprogress nofree nounwind uwtable
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #4

attributes #0 = { mustprogress norecurse 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 = { 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 #2 = { inlinehint 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 #3 = { inlinehint 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 #4 = { inlinehint mustprogress nofree 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass