; LLVM IR from xirc/cp-algorithm :: atcoder/abc119/C/main.ll (Z5solveiiii)

; 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.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::initializer_list" = type { ptr, i64 }

@N = external dso_local global i32, align 4
@A = external dso_local global i32, align 4
@B = external dso_local global i32, align 4
@C = external dso_local global i32, align 4
@L = external dso_local global %"class.std::vector", align 8

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z5solveiiii(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) #0 {
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca %"class.std::initializer_list", align 8
  %11 = alloca [3 x i32], align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca %"class.std::initializer_list", align 8
  %17 = alloca [4 x i32], align 4
  store i32 %0, ptr %6, align 4, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !5
  %18 = load i32, ptr %6, align 4, !tbaa !5
  %19 = load i32, ptr @N, align 4, !tbaa !5
  %20 = icmp eq i32 %18, %19
  br i1 %20, label %21, label %52

21:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 12, ptr %11) #5
  %22 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %22, ptr %11, align 4, !tbaa !5
  %23 = getelementptr inbounds i32, ptr %11, i64 1
  %24 = load i32, ptr %8, align 4, !tbaa !5
  store i32 %24, ptr %23, align 4, !tbaa !5
  %25 = getelementptr inbounds i32, ptr %11, i64 2
  %26 = load i32, ptr %9, align 4, !tbaa !5
  store i32 %26, ptr %25, align 4, !tbaa !5
  %27 = getelementptr inbounds %"class.std::initializer_list", ptr %10, i32 0, i32 0
  store ptr %11, ptr %27, align 8, !tbaa !9
  %28 = getelementptr inbounds %"class.std::initializer_list", ptr %10, i32 0, i32 1
  store i64 3, ptr %28, align 8, !tbaa !13
  %29 = getelementptr inbounds { ptr, i64 }, ptr %10, i32 0, i32 0
  %30 = load ptr, ptr %29, align 8
  %31 = getelementptr inbounds { ptr, i64 }, ptr %10, i32 0, i32 1
  %32 = load i64, ptr %31, align 8
  %33 = call noundef i32 @_ZSt3minIiET_St16initializer_listIS0_E(ptr %30, i64 %32)
  %34 = icmp eq i32 %33, 0
  call void @llvm.lifetime.end.p0(i64 12, ptr %11) #5
  br i1 %34, label %35, label %36

35:                                               ; preds = %21
  store i32 100000000, ptr %5, align 4
  br label %109

36:                                               ; preds = %21
  %37 = load i32, ptr @A, align 4, !tbaa !5
  %38 = load i32, ptr %7, align 4, !tbaa !5
  %39 = sub nsw i32 %37, %38
  %40 = call i32 @llvm.abs.i32(i32 %39, i1 true)
  %41 = load i32, ptr @B, align 4, !tbaa !5
  %42 = load i32, ptr %8, align 4, !tbaa !5
  %43 = sub nsw i32 %41, %42
  %44 = call i32 @llvm.abs.i32(i32 %43, i1 true)
  %45 = add nsw i32 %40, %44
  %46 = load i32, ptr @C, align 4, !tbaa !5
  %47 = load i32, ptr %9, align 4, !tbaa !5
  %48 = sub nsw i32 %46, %47
  %49 = call i32 @llvm.abs.i32(i32 %48, i1 true)
  %50 = add nsw i32 %45, %49
  %51 = sub nsw i32 %50, 30
  store i32 %51, ptr %5, align 4
  br label %109

52:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %53 = load i32, ptr %6, align 4, !tbaa !5
  %54 = add nsw i32 %53, 1
  %55 = load i32, ptr %7, align 4, !tbaa !5
  %56 = load i32, ptr %8, align 4, !tbaa !5
  %57 = load i32, ptr %9, align 4, !tbaa !5
  %58 = call noundef i32 @_Z5solveiiii(i32 noundef %54, i32 noundef %55, i32 noundef %56, i32 noundef %57)
  store i32 %58, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %59 = load i32, ptr %6, align 4, !tbaa !5
  %60 = add nsw i32 %59, 1
  %61 = load i32, ptr %7, align 4, !tbaa !5
  %62 = load i32, ptr %6, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @L, i64 noundef %63) #5
  %65 = load i32, ptr %64, align 4, !tbaa !5
  %66 = add nsw i32 %61, %65
  %67 = load i32, ptr %8, align 4, !tbaa !5
  %68 = load i32, ptr %9, align 4, !tbaa !5
  %69 = call noundef i32 @_Z5solveiiii(i32 noundef %60, i32 noundef %66, i32 noundef %67, i32 noundef %68)
  %70 = add nsw i32 %69, 10
  store i32 %70, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  %71 = load i32, ptr %6, align 4, !tbaa !5
  %72 = add nsw i32 %71, 1
  %73 = load i32, ptr %7, align 4, !tbaa !5
  %74 = load i32, ptr %8, align 4, !tbaa !5
  %75 = load i32, ptr %6, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @L, i64 noundef %76) #5
  %78 = load i32, ptr %77, align 4, !tbaa !5
  %79 = add nsw i32 %74, %78
  %80 = load i32, ptr %9, align 4, !tbaa !5
  %81 = call noundef i32 @_Z5solveiiii(i32 noundef %72, i32 noundef %73, i32 noundef %79, i32 noundef %80)
  %82 = add nsw i32 %81, 10
  store i32 %82, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  %83 = load i32, ptr %6, align 4, !tbaa !5
  %84 = add nsw i32 %83, 1
  %85 = load i32, ptr %7, align 4, !tbaa !5
  %86 = load i32, ptr %8, align 4, !tbaa !5
  %87 = load i32, ptr %9, align 4, !tbaa !5
  %88 = load i32, ptr %6, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @L, i64 noundef %89) #5
  %91 = load i32, ptr %90, align 4, !tbaa !5
  %92 = add nsw i32 %87, %91
  %93 = call noundef i32 @_Z5solveiiii(i32 noundef %84, i32 noundef %85, i32 noundef %86, i32 noundef %92)
  %94 = add nsw i32 %93, 10
  store i32 %94, ptr %15, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %17) #5
  %95 = load i32, ptr %12, align 4, !tbaa !5
  store i32 %95, ptr %17, align 4, !tbaa !5
  %96 = getelementptr inbounds i32, ptr %17, i64 1
  %97 = load i32, ptr %13, align 4, !tbaa !5
  store i32 %97, ptr %96, align 4, !tbaa !5
  %98 = getelementptr inbounds i32, ptr %17, i64 2
  %99 = load i32, ptr %14, align 4, !tbaa !5
  store i32 %99, ptr %98, align 4, !tbaa !5
  %100 = getelementptr inbounds i32, ptr %17, i64 3
  %101 = load i32, ptr %15, align 4, !tbaa !5
  store i32 %101, ptr %100, align 4, !tbaa !5
  %102 = getelementptr inbounds %"class.std::initializer_list", ptr %16, i32 0, i32 0
  store ptr %17, ptr %102, align 8, !tbaa !9
  %103 = getelementptr inbounds %"class.std::initializer_list", ptr %16, i32 0, i32 1
  store i64 4, ptr %103, align 8, !tbaa !13
  %104 = getelementptr inbounds { ptr, i64 }, ptr %16, i32 0, i32 0
  %105 = load ptr, ptr %104, align 8
  %106 = getelementptr inbounds { ptr, i64 }, ptr %16, i32 0, i32 1
  %107 = load i64, ptr %106, align 8
  %108 = call noundef i32 @_ZSt3minIiET_St16initializer_listIS0_E(ptr %105, i64 %107)
  store i32 %108, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  br label %109

109:                                              ; preds = %52, %36, %35
  %110 = load i32, ptr %5, align 4
  ret i32 %110
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZSt3minIiET_St16initializer_listIS0_E(ptr, i64) #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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #4 align 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 = { 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 #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 = !{!10, !11, i64 0}
!10 = !{!"_ZTSSt16initializer_listIiE", !11, i64 0, !12, i64 8}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!10, !12, i64 8}


; 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.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@N = external dso_local local_unnamed_addr global i32, align 4
@A = external dso_local local_unnamed_addr global i32, align 4
@B = external dso_local local_unnamed_addr global i32, align 4
@C = external dso_local local_unnamed_addr global i32, align 4
@L = external dso_local global %"class.std::vector", align 8

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z5solveiiii(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = alloca [3 x i32], align 4
  %6 = alloca [4 x i32], align 4
  %7 = load i32, ptr @N, align 4, !tbaa !5
  %8 = icmp eq i32 %7, %0
  br i1 %8, label %9, label %27

9:                                                ; preds = %4
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %5) #5
  store i32 %1, ptr %5, align 4, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %5, i64 4
  store i32 %2, ptr %10, align 4, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %5, i64 8
  store i32 %3, ptr %11, align 4, !tbaa !5
  %12 = call noundef i32 @_ZSt3minIiET_St16initializer_listIS0_E(ptr nonnull %5, i64 3)
  %13 = icmp eq i32 %12, 0
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %5) #5
  br i1 %13, label %common.ret34, label %14

14:                                               ; preds = %9
  %15 = load i32, ptr @A, align 4, !tbaa !5
  %16 = sub nsw i32 %15, %1
  %17 = call i32 @llvm.abs.i32(i32 %16, i1 true)
  %18 = load i32, ptr @B, align 4, !tbaa !5
  %19 = sub nsw i32 %18, %2
  %20 = call i32 @llvm.abs.i32(i32 %19, i1 true)
  %21 = load i32, ptr @C, align 4, !tbaa !5
  %22 = sub nsw i32 %21, %3
  %23 = call i32 @llvm.abs.i32(i32 %22, i1 true)
  %24 = add nsw i32 %17, -30
  %25 = add i32 %24, %20
  %26 = add i32 %25, %23
  br label %common.ret34

common.ret34:                                     ; preds = %9, %14, %27
  %common.ret34.op = phi i32 [ %49, %27 ], [ %26, %14 ], [ 100000000, %9 ]
  ret i32 %common.ret34.op

27:                                               ; preds = %4
  %28 = add nsw i32 %0, 1
  %29 = tail call noundef i32 @_Z5solveiiii(i32 noundef %28, i32 noundef %1, i32 noundef %2, i32 noundef %3)
  %30 = sext i32 %0 to i64
  %31 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @L, i64 noundef %30) #5
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %33 = add nsw i32 %32, %1
  %34 = tail call noundef i32 @_Z5solveiiii(i32 noundef %28, i32 noundef %33, i32 noundef %2, i32 noundef %3)
  %35 = add nsw i32 %34, 10
  %36 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @L, i64 noundef %30) #5
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %38 = add nsw i32 %37, %2
  %39 = tail call noundef i32 @_Z5solveiiii(i32 noundef %28, i32 noundef %1, i32 noundef %38, i32 noundef %3)
  %40 = add nsw i32 %39, 10
  %41 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @L, i64 noundef %30) #5
  %42 = load i32, ptr %41, align 4, !tbaa !5
  %43 = add nsw i32 %42, %3
  %44 = tail call noundef i32 @_Z5solveiiii(i32 noundef %28, i32 noundef %1, i32 noundef %2, i32 noundef %43)
  %45 = add nsw i32 %44, 10
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #5
  store i32 %29, ptr %6, align 4, !tbaa !5
  %46 = getelementptr inbounds i8, ptr %6, i64 4
  store i32 %35, ptr %46, align 4, !tbaa !5
  %47 = getelementptr inbounds i8, ptr %6, i64 8
  store i32 %40, ptr %47, align 4, !tbaa !5
  %48 = getelementptr inbounds i8, ptr %6, i64 12
  store i32 %45, ptr %48, align 4, !tbaa !5
  %49 = call noundef i32 @_ZSt3minIiET_St16initializer_listIS0_E(ptr nonnull %6, i64 4)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #5
  br label %common.ret34
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZSt3minIiET_St16initializer_listIS0_E(ptr, i64) local_unnamed_addr #1

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

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #4 align 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 = { 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 #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"}


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