#import <stdio.h>
#define MAX(a,b) ((a)>(b)?(a):(b))
void swap(int *x, int *y){
    int tmp = *x;
    *x=*y;
    *y=tmp;
}

int main(){
    int A,B,C,X,Y;
    scanf("%d %d %d %d %d",&A,&B,&C,&X,&Y);
    if(A>B){
        swap(&A,&B);
        swap(&X,&Y);
    }
    int p,q,r;
    if(2*C<A){
        p=0;
        q=0;
        r=2*MAX(X,Y);
    } else if (A+B<2*C){
        p=X;
        q=Y;
        r=0;
    } else if (2*C<B){
        q=0;
        r=2*Y;
        if(X<=Y) {
            p=0;
        } else {
            p=X-Y;
        }
    } else {
        if(X<=Y){
            r=2*X;
            q=Y-X;
            p=0;
        } else {
            r=2*Y;
            p=X-Y;
            q=0;
        }
    }
    printf("%d", p*A+q*B+r*C);
}

; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/ObjectiveC/Source_555/source.m'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/ObjectiveC/Source_555/source.m"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"

@.str = private unnamed_addr constant [15 x i8] c"%d %d %d %d %d\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%d\00", align 1

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @swap(ptr nocapture noundef %x, ptr nocapture noundef %y) local_unnamed_addr #0 {
entry:
  %0 = load i32, ptr %x, align 4, !tbaa !5
  %1 = load i32, ptr %y, align 4, !tbaa !5
  store i32 %1, ptr %x, align 4, !tbaa !5
  store i32 %0, ptr %y, align 4, !tbaa !5
  ret void
}

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

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

; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #2 {
entry:
  %A = alloca i32, align 4
  %B = alloca i32, align 4
  %C = alloca i32, align 4
  %X = alloca i32, align 4
  %Y = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %A) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %B) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %C) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %X) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %Y) #5
  %call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %A, ptr noundef nonnull %B, ptr noundef nonnull %C, ptr noundef nonnull %X, ptr noundef nonnull %Y)
  %0 = load i32, ptr %A, align 4, !tbaa !5
  %1 = load i32, ptr %B, align 4, !tbaa !5
  %cmp = icmp sgt i32 %0, %1
  br i1 %cmp, label %if.then, label %if.end

if.then:                                          ; preds = %entry
  store i32 %1, ptr %A, align 4, !tbaa !5
  store i32 %0, ptr %B, align 4, !tbaa !5
  %2 = load i32, ptr %X, align 4, !tbaa !5
  %3 = load i32, ptr %Y, align 4, !tbaa !5
  store i32 %3, ptr %X, align 4, !tbaa !5
  store i32 %2, ptr %Y, align 4, !tbaa !5
  br label %if.end

if.end:                                           ; preds = %if.then, %entry
  %4 = phi i32 [ %0, %if.then ], [ %1, %entry ]
  %5 = phi i32 [ %1, %if.then ], [ %0, %entry ]
  %6 = load i32, ptr %C, align 4, !tbaa !5
  %mul = shl nsw i32 %6, 1
  %cmp1 = icmp slt i32 %mul, %5
  br i1 %cmp1, label %if.then2, label %if.else

if.then2:                                         ; preds = %if.end
  %7 = load i32, ptr %X, align 4
  %8 = load i32, ptr %Y, align 4
  %cond = call i32 @llvm.smax.i32(i32 %7, i32 %8)
  %mul4 = shl nsw i32 %cond, 1
  br label %if.end28

if.else:                                          ; preds = %if.end
  %add = add nsw i32 %4, %5
  %cmp6 = icmp slt i32 %add, %mul
  br i1 %cmp6, label %if.then7, label %if.else8

if.then7:                                         ; preds = %if.else
  %9 = load i32, ptr %X, align 4, !tbaa !5
  %10 = load i32, ptr %Y, align 4, !tbaa !5
  br label %if.end28

if.else8:                                         ; preds = %if.else
  %cmp10 = icmp slt i32 %mul, %4
  br i1 %cmp10, label %if.then11, label %if.else17

if.then11:                                        ; preds = %if.else8
  %11 = load i32, ptr %Y, align 4, !tbaa !5
  %mul12 = shl nsw i32 %11, 1
  %12 = load i32, ptr %X, align 4, !tbaa !5
  %cmp13.not = icmp sgt i32 %12, %11
  %sub = sub nsw i32 %12, %11
  %spec.select = select i1 %cmp13.not, i32 %sub, i32 0
  br label %if.end28

if.else17:                                        ; preds = %if.else8
  %13 = load i32, ptr %X, align 4, !tbaa !5
  %14 = load i32, ptr %Y, align 4, !tbaa !5
  %cmp18.not = icmp sgt i32 %13, %14
  br i1 %cmp18.not, label %if.else22, label %if.then19

if.then19:                                        ; preds = %if.else17
  %mul20 = shl nsw i32 %13, 1
  %sub21 = sub nsw i32 %14, %13
  br label %if.end28

if.else22:                                        ; preds = %if.else17
  %mul23 = shl nsw i32 %14, 1
  %sub24 = sub nsw i32 %13, %14
  br label %if.end28

if.end28:                                         ; preds = %if.then11, %if.then7, %if.then19, %if.else22, %if.then2
  %p.0 = phi i32 [ 0, %if.then2 ], [ %9, %if.then7 ], [ 0, %if.then19 ], [ %sub24, %if.else22 ], [ %spec.select, %if.then11 ]
  %q.0 = phi i32 [ 0, %if.then2 ], [ %10, %if.then7 ], [ %sub21, %if.then19 ], [ 0, %if.else22 ], [ 0, %if.then11 ]
  %r.0 = phi i32 [ %mul4, %if.then2 ], [ 0, %if.then7 ], [ %mul20, %if.then19 ], [ %mul23, %if.else22 ], [ %mul12, %if.then11 ]
  %mul29 = mul nsw i32 %p.0, %5
  %mul30 = mul nsw i32 %4, %q.0
  %mul32 = mul nsw i32 %r.0, %6
  %add31 = add i32 %mul32, %mul29
  %add33 = add i32 %add31, %mul30
  %call34 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %add33)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %Y) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %X) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %C) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %B) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %A) #5
  ret i32 0
}

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #4

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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 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 = { 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 #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { nounwind }

!llvm.linker.options = !{}
!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 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
