; LLVM IR from omonimus1/competitive-programming :: codechef (EXAMTIME)

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

@.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 [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [5 x i8], align 1

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

9:                                                ; preds = %109, %0
  %10 = load i32, ptr %3, align 4, !tbaa !5
  %11 = load i32, ptr %2, align 4, !tbaa !5
  %12 = icmp slt i32 %10, %11
  br i1 %12, label %14, label %13

13:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  br label %112

14:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 12, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 12, ptr %5) #3
  %15 = getelementptr inbounds %struct.stu, ptr %4, i32 0, i32 0
  %16 = getelementptr inbounds %struct.stu, ptr %4, i32 0, i32 1
  %17 = getelementptr inbounds %struct.stu, ptr %4, i32 0, i32 2
  %18 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %15, ptr noundef %16, ptr noundef %17)
  %19 = getelementptr inbounds %struct.stu, ptr %5, i32 0, i32 0
  %20 = getelementptr inbounds %struct.stu, ptr %5, i32 0, i32 1
  %21 = getelementptr inbounds %struct.stu, ptr %5, i32 0, i32 2
  %22 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %19, ptr noundef %20, ptr noundef %21)
  %23 = getelementptr inbounds %struct.stu, ptr %4, i32 0, i32 0
  %24 = load i32, ptr %23, align 4, !tbaa !9
  %25 = icmp sle i32 %24, 100
  br i1 %25, label %26, label %108

26:                                               ; preds = %14
  %27 = getelementptr inbounds %struct.stu, ptr %4, i32 0, i32 1
  %28 = load i32, ptr %27, align 4, !tbaa !11
  %29 = icmp sle i32 %28, 100
  br i1 %29, label %30, label %108

30:                                               ; preds = %26
  %31 = getelementptr inbounds %struct.stu, ptr %4, i32 0, i32 2
  %32 = load i32, ptr %31, align 4, !tbaa !12
  %33 = icmp sle i32 %32, 100
  br i1 %33, label %34, label %108

34:                                               ; preds = %30
  %35 = getelementptr inbounds %struct.stu, ptr %5, i32 0, i32 0
  %36 = load i32, ptr %35, align 4, !tbaa !9
  %37 = icmp sle i32 %36, 100
  br i1 %37, label %38, label %108

38:                                               ; preds = %34
  %39 = getelementptr inbounds %struct.stu, ptr %5, i32 0, i32 1
  %40 = load i32, ptr %39, align 4, !tbaa !11
  %41 = icmp sle i32 %40, 100
  br i1 %41, label %42, label %108

42:                                               ; preds = %38
  %43 = getelementptr inbounds %struct.stu, ptr %5, i32 0, i32 2
  %44 = load i32, ptr %43, align 4, !tbaa !12
  %45 = icmp sle i32 %44, 100
  br i1 %45, label %46, label %108

46:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %47 = getelementptr inbounds %struct.stu, ptr %4, i32 0, i32 0
  %48 = load i32, ptr %47, align 4, !tbaa !9
  %49 = getelementptr inbounds %struct.stu, ptr %4, i32 0, i32 1
  %50 = load i32, ptr %49, align 4, !tbaa !11
  %51 = add nsw i32 %48, %50
  %52 = getelementptr inbounds %struct.stu, ptr %4, i32 0, i32 2
  %53 = load i32, ptr %52, align 4, !tbaa !12
  %54 = add nsw i32 %51, %53
  store i32 %54, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %55 = getelementptr inbounds %struct.stu, ptr %5, i32 0, i32 2
  %56 = load i32, ptr %55, align 4, !tbaa !12
  %57 = getelementptr inbounds %struct.stu, ptr %5, i32 0, i32 0
  %58 = load i32, ptr %57, align 4, !tbaa !9
  %59 = add nsw i32 %56, %58
  %60 = getelementptr inbounds %struct.stu, ptr %5, i32 0, i32 1
  %61 = load i32, ptr %60, align 4, !tbaa !11
  %62 = add nsw i32 %59, %61
  store i32 %62, ptr %7, align 4, !tbaa !5
  %63 = load i32, ptr %6, align 4, !tbaa !5
  %64 = load i32, ptr %7, align 4, !tbaa !5
  %65 = icmp ne i32 %63, %64
  br i1 %65, label %66, label %73

66:                                               ; preds = %46
  %67 = load i32, ptr %6, align 4, !tbaa !5
  %68 = load i32, ptr %7, align 4, !tbaa !5
  %69 = icmp sgt i32 %67, %68
  %70 = zext i1 %69 to i64
  %71 = select i1 %69, ptr @.str.3, ptr @.str.4
  %72 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, ptr noundef %71)
  br label %107

73:                                               ; preds = %46
  %74 = getelementptr inbounds %struct.stu, ptr %4, i32 0, i32 0
  %75 = load i32, ptr %74, align 4, !tbaa !9
  %76 = getelementptr inbounds %struct.stu, ptr %5, i32 0, i32 0
  %77 = load i32, ptr %76, align 4, !tbaa !9
  %78 = icmp ne i32 %75, %77
  br i1 %78, label %79, label %88

79:                                               ; preds = %73
  %80 = getelementptr inbounds %struct.stu, ptr %4, i32 0, i32 0
  %81 = load i32, ptr %80, align 4, !tbaa !9
  %82 = getelementptr inbounds %struct.stu, ptr %5, i32 0, i32 0
  %83 = load i32, ptr %82, align 4, !tbaa !9
  %84 = icmp sgt i32 %81, %83
  %85 = zext i1 %84 to i64
  %86 = select i1 %84, ptr @.str.3, ptr @.str.4
  %87 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, ptr noundef %86)
  br label %106

88:                                               ; preds = %73
  %89 = getelementptr inbounds %struct.stu, ptr %4, i32 0, i32 1
  %90 = load i32, ptr %89, align 4, !tbaa !11
  %91 = getelementptr inbounds %struct.stu, ptr %5, i32 0, i32 1
  %92 = load i32, ptr %91, align 4, !tbaa !11
  %93 = icmp ne i32 %90, %92
  br i1 %93, label %94, label %103

94:                                               ; preds = %88
  %95 = getelementptr inbounds %struct.stu, ptr %4, i32 0, i32 1
  %96 = load i32, ptr %95, align 4, !tbaa !11
  %97 = getelementptr inbounds %struct.stu, ptr %5, i32 0, i32 1
  %98 = load i32, ptr %97, align 4, !tbaa !11
  %99 = icmp sgt i32 %96, %98
  %100 = zext i1 %99 to i64
  %101 = select i1 %99, ptr @.str.3, ptr @.str.4
  %102 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, ptr noundef %101)
  br label %105

103:                                              ; preds = %88
  %104 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  br label %105

105:                                              ; preds = %103, %94
  br label %106

106:                                              ; preds = %105, %79
  br label %107

107:                                              ; preds = %106, %66
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %108

108:                                              ; preds = %107, %42, %38, %34, %30, %26, %14
  call void @llvm.lifetime.end.p0(i64 12, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 12, ptr %4) #3
  br label %109

109:                                              ; preds = %108
  %110 = load i32, ptr %3, align 4, !tbaa !5
  %111 = add nsw i32 %110, 1
  store i32 %111, ptr %3, align 4, !tbaa !5
  br label %9, !llvm.loop !13

112:                                              ; preds = %13
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  ret i32 0
}

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

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

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

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

attributes #0 = { 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 nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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/C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"stu", !6, i64 0, !6, i64 4, !6, i64 8}
!11 = !{!10, !6, i64 4}
!12 = !{!10, !6, i64 8}
!13 = distinct !{!13, !14}
!14 = !{!"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"

%struct.stu = type { i32, i32, i32 }

@.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 [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: nofree nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca %struct.stu, align 4
  %3 = alloca %struct.stu, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #3
  %4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %5 = load i32, ptr %1, align 4, !tbaa !5
  %6 = icmp sgt i32 %5, 0
  br i1 %6, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0
  %7 = getelementptr inbounds i8, ptr %2, i64 4
  %8 = getelementptr inbounds i8, ptr %2, i64 8
  %9 = getelementptr inbounds i8, ptr %3, i64 4
  %10 = getelementptr inbounds i8, ptr %3, i64 8
  br label %11

._crit_edge:                                      ; preds = %49, %0
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #3
  ret i32 0

11:                                               ; preds = %.lr.ph, %49
  %.029 = phi i32 [ 0, %.lr.ph ], [ %50, %49 ]
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %2) #3
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %3) #3
  %12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %2, ptr noundef nonnull %7, ptr noundef nonnull %8)
  %13 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %3, ptr noundef nonnull %9, ptr noundef nonnull %10)
  %14 = load i32, ptr %2, align 4, !tbaa !9
  %.fr32 = freeze i32 %14
  %15 = icmp slt i32 %.fr32, 101
  %16 = load <2 x i32>, ptr %7, align 4
  %17 = load <2 x i32>, ptr %3, align 8
  %18 = shufflevector <2 x i32> %16, <2 x i32> %17, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
  %.fr = freeze <4 x i32> %18
  %19 = load i32, ptr %10, align 8
  %20 = icmp slt i32 %19, 101
  %21 = icmp sgt <4 x i32> %.fr, <i32 100, i32 100, i32 100, i32 100>
  %22 = bitcast <4 x i1> %21 to i4
  %23 = icmp eq i4 %22, 0
  %op.rdx = and i1 %15, %23
  %op.rdx30 = select i1 %op.rdx, i1 %20, i1 false
  br i1 %op.rdx30, label %24, label %49

24:                                               ; preds = %11
  %25 = extractelement <2 x i32> %16, i64 0
  %26 = add nsw i32 %25, %.fr32
  %27 = extractelement <2 x i32> %16, i64 1
  %28 = add nsw i32 %26, %27
  %29 = extractelement <2 x i32> %17, i64 0
  %30 = extractelement <2 x i32> %17, i64 1
  %31 = add i32 %30, %29
  %32 = add i32 %31, %19
  %.not = icmp eq i32 %28, %32
  br i1 %.not, label %37, label %33

33:                                               ; preds = %24
  %34 = icmp sgt i32 %28, %32
  %35 = select i1 %34, ptr @.str.3, ptr @.str.4
  %36 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef nonnull %35)
  br label %49

37:                                               ; preds = %24
  %.not27 = icmp eq i32 %.fr32, %29
  br i1 %.not27, label %42, label %38

38:                                               ; preds = %37
  %39 = icmp sgt i32 %.fr32, %29
  %40 = select i1 %39, ptr @.str.3, ptr @.str.4
  %41 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef nonnull %40)
  br label %49

42:                                               ; preds = %37
  %.not28 = icmp eq i32 %25, %30
  br i1 %.not28, label %47, label %43

43:                                               ; preds = %42
  %44 = icmp sgt i32 %25, %30
  %45 = select i1 %44, ptr @.str.3, ptr @.str.4
  %46 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef nonnull %45)
  br label %49

47:                                               ; preds = %42
  %48 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  br label %49

49:                                               ; preds = %33, %43, %47, %38, %11
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %3) #3
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %2) #3
  %50 = add nuw nsw i32 %.029, 1
  %51 = load i32, ptr %1, align 4, !tbaa !5
  %52 = icmp slt i32 %50, %51
  br i1 %52, label %11, label %._crit_edge, !llvm.loop !11
}

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

; 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

attributes #0 = { 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" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
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/C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"stu", !6, i64 0, !6, i64 4, !6, i64 8}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalDCEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,VectorCombinePass