; LLVM IR from DionysiosB/CodeForces :: 0400-0499 (409D-BigData)

; 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 [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 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
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  store i32 0, ptr %2, align 4, !tbaa !5
  %3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2)
  %4 = load i32, ptr %2, align 4, !tbaa !5
  %5 = icmp eq i32 %4, 1
  br i1 %5, label %6, label %8

6:                                                ; preds = %0
  %7 = call i32 @puts(ptr noundef @.str.1)
  br label %106

8:                                                ; preds = %0
  %9 = load i32, ptr %2, align 4, !tbaa !5
  %10 = icmp eq i32 %9, 1
  br i1 %10, label %11, label %13

11:                                               ; preds = %8
  %12 = call i32 @puts(ptr noundef @.str.1)
  br label %105

13:                                               ; preds = %8
  %14 = load i32, ptr %2, align 4, !tbaa !5
  %15 = icmp eq i32 %14, 2
  br i1 %15, label %16, label %18

16:                                               ; preds = %13
  %17 = call i32 @puts(ptr noundef @.str.2)
  br label %104

18:                                               ; preds = %13
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = icmp eq i32 %19, 3
  br i1 %20, label %21, label %23

21:                                               ; preds = %18
  %22 = call i32 @puts(ptr noundef @.str.2)
  br label %103

23:                                               ; preds = %18
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = icmp eq i32 %24, 4
  br i1 %25, label %26, label %28

26:                                               ; preds = %23
  %27 = call i32 @puts(ptr noundef @.str.1)
  br label %102

28:                                               ; preds = %23
  %29 = load i32, ptr %2, align 4, !tbaa !5
  %30 = icmp eq i32 %29, 5
  br i1 %30, label %31, label %33

31:                                               ; preds = %28
  %32 = call i32 @puts(ptr noundef @.str.2)
  br label %101

33:                                               ; preds = %28
  %34 = load i32, ptr %2, align 4, !tbaa !5
  %35 = icmp eq i32 %34, 6
  br i1 %35, label %36, label %38

36:                                               ; preds = %33
  %37 = call i32 @puts(ptr noundef @.str.1)
  br label %100

38:                                               ; preds = %33
  %39 = load i32, ptr %2, align 4, !tbaa !5
  %40 = icmp eq i32 %39, 7
  br i1 %40, label %41, label %43

41:                                               ; preds = %38
  %42 = call i32 @puts(ptr noundef @.str.2)
  br label %99

43:                                               ; preds = %38
  %44 = load i32, ptr %2, align 4, !tbaa !5
  %45 = icmp eq i32 %44, 8
  br i1 %45, label %46, label %48

46:                                               ; preds = %43
  %47 = call i32 @puts(ptr noundef @.str.1)
  br label %98

48:                                               ; preds = %43
  %49 = load i32, ptr %2, align 4, !tbaa !5
  %50 = icmp eq i32 %49, 9
  br i1 %50, label %51, label %53

51:                                               ; preds = %48
  %52 = call i32 @puts(ptr noundef @.str.1)
  br label %97

53:                                               ; preds = %48
  %54 = load i32, ptr %2, align 4, !tbaa !5
  %55 = icmp eq i32 %54, 10
  br i1 %55, label %56, label %58

56:                                               ; preds = %53
  %57 = call i32 @puts(ptr noundef @.str.1)
  br label %96

58:                                               ; preds = %53
  %59 = load i32, ptr %2, align 4, !tbaa !5
  %60 = icmp eq i32 %59, 11
  br i1 %60, label %61, label %63

61:                                               ; preds = %58
  %62 = call i32 @puts(ptr noundef @.str.2)
  br label %95

63:                                               ; preds = %58
  %64 = load i32, ptr %2, align 4, !tbaa !5
  %65 = icmp eq i32 %64, 12
  br i1 %65, label %66, label %68

66:                                               ; preds = %63
  %67 = call i32 @puts(ptr noundef @.str.2)
  br label %94

68:                                               ; preds = %63
  %69 = load i32, ptr %2, align 4, !tbaa !5
  %70 = icmp eq i32 %69, 13
  br i1 %70, label %71, label %73

71:                                               ; preds = %68
  %72 = call i32 @puts(ptr noundef @.str.1)
  br label %93

73:                                               ; preds = %68
  %74 = load i32, ptr %2, align 4, !tbaa !5
  %75 = icmp eq i32 %74, 14
  br i1 %75, label %76, label %78

76:                                               ; preds = %73
  %77 = call i32 @puts(ptr noundef @.str.2)
  br label %92

78:                                               ; preds = %73
  %79 = load i32, ptr %2, align 4, !tbaa !5
  %80 = icmp eq i32 %79, 15
  br i1 %80, label %81, label %83

81:                                               ; preds = %78
  %82 = call i32 @puts(ptr noundef @.str.1)
  br label %91

83:                                               ; preds = %78
  %84 = load i32, ptr %2, align 4, !tbaa !5
  %85 = icmp eq i32 %84, 16
  br i1 %85, label %86, label %88

86:                                               ; preds = %83
  %87 = call i32 @puts(ptr noundef @.str.2)
  br label %90

88:                                               ; preds = %83
  %89 = call i32 @puts(ptr noundef @.str.3)
  br label %90

90:                                               ; preds = %88, %86
  br label %91

91:                                               ; preds = %90, %81
  br label %92

92:                                               ; preds = %91, %76
  br label %93

93:                                               ; preds = %92, %71
  br label %94

94:                                               ; preds = %93, %66
  br label %95

95:                                               ; preds = %94, %61
  br label %96

96:                                               ; preds = %95, %56
  br label %97

97:                                               ; preds = %96, %51
  br label %98

98:                                               ; preds = %97, %46
  br label %99

99:                                               ; preds = %98, %41
  br label %100

100:                                              ; preds = %99, %36
  br label %101

101:                                              ; preds = %100, %31
  br label %102

102:                                              ; preds = %101, %26
  br label %103

103:                                              ; preds = %102, %21
  br label %104

104:                                              ; preds = %103, %16
  br label %105

105:                                              ; preds = %104, %11
  br label %106

106:                                              ; preds = %105, %6
  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 @puts(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 = { 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 = { 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++ TBAA"}


; 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 [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1
@switch.table.main = private unnamed_addr constant [16 x ptr] [ptr @.str.1, ptr @.str.2, ptr @.str.2, ptr @.str.1, ptr @.str.2, ptr @.str.1, ptr @.str.2, ptr @.str.1, ptr @.str.1, ptr @.str.1, ptr @.str.2, ptr @.str.2, ptr @.str.1, ptr @.str.2, ptr @.str.1, ptr @.str.2], align 8

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #3
  store i32 0, ptr %1, align 4, !tbaa !5
  %2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %3 = load i32, ptr %1, align 4, !tbaa !5
  %switch.tableidx = add i32 %3, -1
  %4 = icmp ult i32 %switch.tableidx, 16
  br i1 %4, label %switch.lookup, label %6

switch.lookup:                                    ; preds = %0
  %5 = zext nneg i32 %switch.tableidx to i64
  %switch.gep = getelementptr inbounds [16 x ptr], ptr @switch.table.main, i64 0, i64 %5
  %switch.load = load ptr, ptr %switch.gep, align 8
  br label %6

6:                                                ; preds = %0, %switch.lookup
  %.str.2.sink = phi ptr [ %switch.load, %switch.lookup ], [ @.str.3, %0 ]
  %7 = call i32 @puts(ptr noundef nonnull dereferenceable(1) %.str.2.sink)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #3
  ret i32 0
}

; 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 @puts(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 = { mustprogress nofree norecurse 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++ TBAA"}


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