#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ arrayFill(int /*<<< orphan*/ *, unsigned long long *,
                             unsigned long long);
int /*<<< orphan*/ arrayNull(unsigned long long *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
unsigned long long getValue(int /*<<< orphan*/ *);
int /*<<< orphan*/ minPrice(unsigned long long *, unsigned long long);
int main() {
  FILE *in = fopen("task.in", "r");
  FILE *out = fopen("task.out", "w");
  long long unsigned array[1001];
  long long unsigned farmerQuantity = getValue(in);
  long long unsigned amountNeeded = getValue(in);
  if (amountNeeded <= 0 || amountNeeded <= 0) {
    fprintf(out, "0\n");
  } else {
    arrayNull(array);
    arrayFill(in, array, farmerQuantity);
    fprintf(out, "%llu\n", minPrice(array, amountNeeded));
  }
  fclose(in);
  fclose(out);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1f80,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe77(%rip),%rdi
lea    0xe78(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    0xe6a(%rip),%rdi
lea    0xe6c(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <getValue@plt>
mov    %rax,-0x1f68(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <getValue@plt>
mov    %rax,-0x1f70(%rbp)
cmpq   $0x0,-0x1f70(%rbp)
jbe    11ec <main+0x7c>
cmpq   $0x0,-0x1f70(%rbp)
ja     1203 <main+0x93>
mov    -0x18(%rbp),%rdi
lea    0xe1e(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    125b <main+0xeb>
lea    -0x1f60(%rbp),%rdi
call   1070 <arrayNull@plt>
mov    -0x10(%rbp),%rdi
lea    -0x1f60(%rbp),%rsi
mov    -0x1f68(%rbp),%rdx
call   1030 <arrayFill@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x1f78(%rbp)
lea    -0x1f60(%rbp),%rdi
mov    -0x1f70(%rbp),%rsi
call   1090 <minPrice@plt>
mov    -0x1f78(%rbp),%rdi
mov    %eax,%edx
lea    0xdc4(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x1f80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1f50,%rsp
lea    0xe69(%rip),%rdi
lea    0xe6a(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r12
lea    0xe5d(%rip),%rdi
lea    0xe5f(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
mov    %r12,%rdi
call   1050 <getValue@plt>
mov    %rax,%r15
mov    %r12,%rdi
call   1050 <getValue@plt>
test   %rax,%rax
je     1210 <main+0x90>
mov    %rax,%rbx
mov    %rsp,%r13
mov    %r13,%rdi
call   1070 <arrayNull@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
call   1030 <arrayFill@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1090 <minPrice@plt>
lea    0xe16(%rip),%rsi
mov    %r14,%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    1229 <main+0xa9>
lea    0xdfe(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10a0 <fwrite@plt>
mov    %r12,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x1f50,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [8 x i8] c"task.in\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [9 x i8] c"task.out\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [3 x i8] c"0\0A\00"
@.str.5 = [6 x i8] c"%llu\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca [1001 x i64]
%5 = alloca i64
%6 = alloca i64
store i32 0, i32* %1
%7 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %2
%8 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %8, i32** %3
%9 = load i32*, i32** %2
%10 = call i64 @getValue(i32* %9)
store i64 %10, i64* %5
%11 = load i32*, i32** %2
%12 = call i64 @getValue(i32* %11)
store i64 %12, i64* %6
%13 = load i64, i64* %6
%14 = icmp ule i64 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %0
%16 = load i64, i64* %6
%17 = icmp ule i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %15, %0
%19 = load i32*, i32** %3
%20 = call i32 (i32*, i8*, ...) @fprintf(i32* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %33
21: ; preds = %15
%22 = getelementptr inbounds [1001 x i64], [1001 x i64]* %4, i64 0, i64 0
%23 = call i32 @arrayNull(i64* %22)
%24 = load i32*, i32** %2
%25 = getelementptr inbounds [1001 x i64], [1001 x i64]* %4, i64 0, i64 0
%26 = load i64, i64* %5
%27 = call i32 @arrayFill(i32* %24, i64* %25, i64 %26)
%28 = load i32*, i32** %3
%29 = getelementptr inbounds [1001 x i64], [1001 x i64]* %4, i64 0, i64 0
%30 = load i64, i64* %6
%31 = call i32 @minPrice(i64* %29, i64 %30)
%32 = call i32 (i32*, i8*, ...) @fprintf(i32* %28, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %21, %18
%34 = load i32*, i32** %2
%35 = call i32 @fclose(i32* %34)
%36 = load i32*, i32** %3
%37 = call i32 @fclose(i32* %36)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"task.in\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [9 x i8] c"task.out\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [3 x i8] c"0\0A\00"
@.str.5 = [6 x i8] c"%llu\0A\00"
define i32 @main() {
%1 = alloca [1001 x i64]
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%4 = bitcast [1001 x i64]* %1 to i8*
%5 = tail call i64 @getValue(i32* %2)
%6 = tail call i64 @getValue(i32* %2)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i64 2, i64 1, i32* %3)
br label %16
10: ; preds = %0
%11 = getelementptr inbounds [1001 x i64], [1001 x i64]* %1, i64 0, i64 0
%12 = call i32 @arrayNull(i64* %11)
%13 = call i32 @arrayFill(i32* %2, i64* %11, i64 %5)
%14 = call i32 @minPrice(i64* %11, i64 %6)
%15 = call i32 (i32*, i8*, ...) @fprintf(i32* %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %10, %8
%17 = call i32 @fclose(i32* %2)
%18 = call i32 @fclose(i32* %3)
ret i32 0
}