; LLVM IR from tangjz/acm-icpc :: self_training/2015-09-24 (E)

; 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.Exp = type { i32, [10 x i32], [10 x i8] }
%"struct.std::pair" = type { i32, i32 }

@val = external dso_local global [10 x %struct.Exp], align 16
@t = external dso_local global i32, align 4
@str = external dso_local global [10 x i8], align 1
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local i64 @_Z3dfsii(i32 noundef, i32 noundef) #0

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca %"struct.std::pair", align 4
  %6 = alloca %"struct.std::pair", align 4
  store i32 0, ptr %1, align 4
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %8

8:                                                ; preds = %97, %0
  %9 = load i32, ptr %2, align 4, !tbaa !5
  %10 = load i32, ptr @t, align 4, !tbaa !5
  %11 = icmp sle i32 %9, %10
  br i1 %11, label %13, label %12

12:                                               ; preds = %8
  store i32 2, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  br label %100

13:                                               ; preds = %8
  %14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @val, ptr noundef getelementptr inbounds (%struct.Exp, ptr @val, i32 0, i32 1))
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %15

15:                                               ; preds = %30, %13
  %16 = load i32, ptr %4, align 4, !tbaa !5
  %17 = load i32, ptr @val, align 16, !tbaa !9
  %18 = icmp slt i32 %16, %17
  br i1 %18, label %20, label %19

19:                                               ; preds = %15
  store i32 5, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %33

20:                                               ; preds = %15
  %21 = load i32, ptr %4, align 4, !tbaa !5
  %22 = add nsw i32 %21, 1
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [10 x i32], ptr getelementptr inbounds (%struct.Exp, ptr @val, i32 0, i32 1), i64 0, i64 %23
  %25 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef @str, ptr noundef %24)
  %26 = load i8, ptr @str, align 1, !tbaa !11
  %27 = load i32, ptr %4, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [10 x i8], ptr getelementptr inbounds (%struct.Exp, ptr @val, i32 0, i32 2), i64 0, i64 %28
  store i8 %26, ptr %29, align 1, !tbaa !11
  br label %30

30:                                               ; preds = %20
  %31 = load i32, ptr %4, align 4, !tbaa !5
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %4, align 4, !tbaa !5
  br label %15, !llvm.loop !12

33:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %34 = call i64 @_Z3dfsii(i32 noundef 0, i32 noundef 0)
  store i64 %34, ptr %5, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %35 = call i64 @_Z3dfsii(i32 noundef 0, i32 noundef 1)
  store i64 %35, ptr %6, align 4
  %36 = load i32, ptr %2, align 4, !tbaa !5
  %37 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %36)
  %38 = getelementptr inbounds %"struct.std::pair", ptr %5, i32 0, i32 1
  %39 = load i32, ptr %38, align 4, !tbaa !14
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [10 x i32], ptr getelementptr inbounds (%struct.Exp, ptr @val, i32 0, i32 1), i64 0, i64 %40
  %42 = load i32, ptr %41, align 4, !tbaa !5
  %43 = getelementptr inbounds %"struct.std::pair", ptr %5, i32 0, i32 1
  %44 = load i32, ptr %43, align 4, !tbaa !14
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [10 x i8], ptr getelementptr inbounds (%struct.Exp, ptr @val, i32 0, i32 2), i64 0, i64 %45
  %47 = load i8, ptr %46, align 1, !tbaa !11
  %48 = sext i8 %47 to i32
  %49 = getelementptr inbounds %"struct.std::pair", ptr %5, i32 0, i32 1
  %50 = load i32, ptr %49, align 4, !tbaa !14
  %51 = add nsw i32 %50, 1
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [10 x i32], ptr getelementptr inbounds (%struct.Exp, ptr @val, i32 0, i32 1), i64 0, i64 %52
  %54 = load i32, ptr %53, align 4, !tbaa !5
  %55 = getelementptr inbounds %"struct.std::pair", ptr %5, i32 0, i32 0
  %56 = load i32, ptr %55, align 4, !tbaa !16
  %57 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i32 noundef %42, i32 noundef %48, i32 noundef %54, i32 noundef %56)
  %58 = getelementptr inbounds %"struct.std::pair", ptr %6, i32 0, i32 1
  %59 = load i32, ptr %58, align 4, !tbaa !14
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [10 x i32], ptr getelementptr inbounds (%struct.Exp, ptr @val, i32 0, i32 1), i64 0, i64 %60
  %62 = load i32, ptr %61, align 4, !tbaa !5
  %63 = getelementptr inbounds %"struct.std::pair", ptr %6, i32 0, i32 1
  %64 = load i32, ptr %63, align 4, !tbaa !14
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [10 x i8], ptr getelementptr inbounds (%struct.Exp, ptr @val, i32 0, i32 2), i64 0, i64 %65
  %67 = load i8, ptr %66, align 1, !tbaa !11
  %68 = sext i8 %67 to i32
  %69 = getelementptr inbounds %"struct.std::pair", ptr %6, i32 0, i32 1
  %70 = load i32, ptr %69, align 4, !tbaa !14
  %71 = add nsw i32 %70, 1
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [10 x i32], ptr getelementptr inbounds (%struct.Exp, ptr @val, i32 0, i32 1), i64 0, i64 %72
  %74 = load i32, ptr %73, align 4, !tbaa !5
  %75 = getelementptr inbounds %"struct.std::pair", ptr %6, i32 0, i32 0
  %76 = load i32, ptr %75, align 4, !tbaa !16
  %77 = call i32 (ptr, ...) @printf(ptr noundef @.str.5, i32 noundef %62, i32 noundef %68, i32 noundef %74, i32 noundef %76)
  %78 = getelementptr inbounds %"struct.std::pair", ptr %5, i32 0, i32 0
  %79 = load i32, ptr %78, align 4, !tbaa !16
  %80 = getelementptr inbounds %"struct.std::pair", ptr %6, i32 0, i32 0
  %81 = load i32, ptr %80, align 4, !tbaa !16
  %82 = add nsw i32 %79, %81
  %83 = icmp ne i32 %82, 0
  br i1 %83, label %84, label %94

84:                                               ; preds = %33
  %85 = getelementptr inbounds %"struct.std::pair", ptr %5, i32 0, i32 0
  %86 = load i32, ptr %85, align 4, !tbaa !16
  %87 = getelementptr inbounds %"struct.std::pair", ptr %6, i32 0, i32 0
  %88 = load i32, ptr %87, align 4, !tbaa !16
  %89 = add nsw i32 %86, %88
  %90 = icmp sgt i32 %89, 0
  %91 = zext i1 %90 to i64
  %92 = select i1 %90, i32 1, i32 2
  %93 = call i32 (ptr, ...) @printf(ptr noundef @.str.6, i32 noundef %92)
  br label %96

94:                                               ; preds = %33
  %95 = call i32 @puts(ptr noundef @.str.7)
  br label %96

96:                                               ; preds = %94, %84
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  br label %97

97:                                               ; preds = %96
  %98 = load i32, ptr %2, align 4, !tbaa !5
  %99 = add nsw i32 %98, 1
  store i32 %99, ptr %2, align 4, !tbaa !5
  br label %8, !llvm.loop !17

100:                                              ; preds = %12
  ret i32 0
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #3

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

declare i32 @puts(ptr noundef) #3

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { "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 = { 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, !6, i64 0}
!10 = !{!"_ZTS3Exp", !6, i64 0, !7, i64 4, !7, i64 44}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!15, !6, i64 4}
!15 = !{!"_ZTSSt4pairIiiE", !6, i64 0, !6, i64 4}
!16 = !{!15, !6, i64 0}
!17 = distinct !{!17, !13}


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

%struct.Exp = type { i32, [10 x i32], [10 x i8] }

@val = external dso_local global [10 x %struct.Exp], align 16
@t = external dso_local global i32, align 4
@str = external dso_local global [10 x i8], align 1
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local i64 @_Z3dfsii(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @t)
  %2 = load i32, ptr @t, align 4, !tbaa !5
  %.not23 = icmp slt i32 %2, 1
  br i1 %.not23, label %._crit_edge27, label %.lr.ph26

._crit_edge27:                                    ; preds = %42, %0
  ret i32 0

.lr.ph26:                                         ; preds = %0, %42
  %.024 = phi i32 [ %43, %42 ], [ 1, %0 ]
  %3 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @val, ptr noundef nonnull getelementptr inbounds (i8, ptr @val, i64 4))
  %4 = load i32, ptr @val, align 16, !tbaa !9
  %5 = icmp sgt i32 %4, 0
  br i1 %5, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph26
  %6 = tail call i64 @_Z3dfsii(i32 noundef 0, i32 noundef 0)
  %.sroa.05.0.extract.trunc = trunc i64 %6 to i32
  %7 = tail call i64 @_Z3dfsii(i32 noundef 0, i32 noundef 1)
  %.sroa.0.0.extract.trunc = trunc i64 %7 to i32
  %8 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %.024)
  %9 = ashr i64 %6, 32
  %10 = getelementptr inbounds [10 x i32], ptr getelementptr inbounds (i8, ptr @val, i64 4), i64 0, i64 %9
  %11 = load i32, ptr %10, align 4, !tbaa !5
  %12 = getelementptr inbounds [10 x i8], ptr getelementptr inbounds (i8, ptr @val, i64 44), i64 0, i64 %9
  %13 = load i8, ptr %12, align 1, !tbaa !11
  %14 = sext i8 %13 to i32
  %sext = add i64 %6, 4294967296
  %15 = ashr i64 %sext, 32
  %16 = getelementptr inbounds [10 x i32], ptr getelementptr inbounds (i8, ptr @val, i64 4), i64 0, i64 %15
  %17 = load i32, ptr %16, align 4, !tbaa !5
  %18 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %11, i32 noundef %14, i32 noundef %17, i32 noundef %.sroa.05.0.extract.trunc)
  %19 = ashr i64 %7, 32
  %20 = getelementptr inbounds [10 x i32], ptr getelementptr inbounds (i8, ptr @val, i64 4), i64 0, i64 %19
  %21 = load i32, ptr %20, align 4, !tbaa !5
  %22 = getelementptr inbounds [10 x i8], ptr getelementptr inbounds (i8, ptr @val, i64 44), i64 0, i64 %19
  %23 = load i8, ptr %22, align 1, !tbaa !11
  %24 = sext i8 %23 to i32
  %sext20 = add i64 %7, 4294967296
  %25 = ashr i64 %sext20, 32
  %26 = getelementptr inbounds [10 x i32], ptr getelementptr inbounds (i8, ptr @val, i64 4), i64 0, i64 %25
  %27 = load i32, ptr %26, align 4, !tbaa !5
  %28 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, i32 noundef %21, i32 noundef %24, i32 noundef %27, i32 noundef %.sroa.0.0.extract.trunc)
  %29 = add nsw i32 %.sroa.0.0.extract.trunc, %.sroa.05.0.extract.trunc
  %.not21 = icmp eq i32 %29, 0
  br i1 %.not21, label %40, label %37

.lr.ph:                                           ; preds = %.lr.ph26, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.lr.ph26 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %30 = getelementptr inbounds [10 x i32], ptr getelementptr inbounds (i8, ptr @val, i64 4), i64 0, i64 %indvars.iv.next
  %31 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull @str, ptr noundef nonnull %30)
  %32 = load i8, ptr @str, align 1, !tbaa !11
  %33 = getelementptr inbounds [10 x i8], ptr getelementptr inbounds (i8, ptr @val, i64 44), i64 0, i64 %indvars.iv
  store i8 %32, ptr %33, align 1, !tbaa !11
  %34 = load i32, ptr @val, align 16, !tbaa !9
  %35 = sext i32 %34 to i64
  %36 = icmp slt i64 %indvars.iv.next, %35
  br i1 %36, label %.lr.ph, label %._crit_edge, !llvm.loop !12

37:                                               ; preds = %._crit_edge
  %.inv = icmp slt i32 %29, 1
  %38 = select i1 %.inv, i32 2, i32 1
  %39 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, i32 noundef %38)
  br label %42

40:                                               ; preds = %._crit_edge
  %41 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.7)
  br label %42

42:                                               ; preds = %40, %37
  %43 = add nuw nsw i32 %.024, 1
  %44 = load i32, ptr @t, align 4, !tbaa !5
  %.not.not = icmp slt i32 %.024, %44
  br i1 %.not.not, label %.lr.ph26, label %._crit_edge27, !llvm.loop !14
}

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #2

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

!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, !6, i64 0}
!10 = !{!"_ZTS3Exp", !6, i64 0, !7, i64 4, !7, i64 44}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


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