#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 */

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ malloc(int);
int /*<<< orphan*/ mochila(int, int *, int *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, char **argv) {
  if (argc < 1)
    exit(EXIT_FAILURE);
  int size, bag, i;
  scanf("%d", &size);
  scanf("%d", &bag);
  int *weight = (int *)malloc(sizeof(int) * size);
  for (i = 0; i < size; i++)
    scanf("%d", &weight[i]);
  int *value = (int *)malloc(sizeof(int) * size);
  for (i = 0; i < size; i++)
    scanf("%d", &value[i]);
  mochila(bag, weight, value, size);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jge    116e <main+0x2e>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
lea    0xe8b(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xe7b(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <scanf@plt>
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11dd <main+0x9d>
mov    -0x28(%rbp),%rsi
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe36(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a8 <main+0x68>
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    122c <main+0xec>
mov    -0x30(%rbp),%rsi
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xde7(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11f7 <main+0xb7>
mov    -0x18(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x14(%rbp),%ecx
call   1040 <mochila@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
test   %edi,%edi
jle    121c <main+0xdc>
lea    0xea4(%rip),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
mov    0x8(%rsp),%edi
shl    $0x2,%edi
call   1030 <malloc@plt>
mov    %rax,%r14
mov    0x8(%rsp),%edi
test   %edi,%edi
jle    11bd <main+0x7d>
xor    %r12d,%r12d
lea    0xe69(%rip),%r15
mov    %r14,%rbx
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
add    $0x1,%r12
movslq 0x8(%rsp),%rdi
add    $0x4,%rbx
cmp    %rdi,%r12
jl     11a0 <main+0x60>
shl    $0x2,%edi
call   1030 <malloc@plt>
mov    %rax,%r15
mov    0x8(%rsp),%ecx
test   %ecx,%ecx
jle    11fd <main+0xbd>
xor    %r13d,%r13d
lea    0xe26(%rip),%r12
mov    %r15,%rbx
nopl   (%rax)
mov    %r12,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
add    $0x1,%r13
movslq 0x8(%rsp),%rcx
add    $0x4,%rbx
cmp    %rcx,%r13
jl     11e0 <main+0xa0>
mov    0xc(%rsp),%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1040 <mochila@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    0x2dbd(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@.str = [3 x i8] c"%d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 1
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load i32, i32* @EXIT_FAILURE
%15 = call i32 @exit(i32 %14)
unreachable
16: ; preds = %2
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = mul i64 4, %20
%22 = trunc i64 %21 to i32
%23 = call i64 @malloc(i32 %22)
%24 = inttoptr i64 %23 to i32*
store i32* %24, i32** %9
store i32 0, i32* %8
br label %25
25: ; preds = %35, %16
%26 = load i32, i32* %8
%27 = load i32, i32* %6
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %38
29: ; preds = %25
%30 = load i32*, i32** %9
%31 = load i32, i32* %8
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %30, i64 %32
%34 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %33)
br label %35
35: ; preds = %29
%36 = load i32, i32* %8
%37 = add nsw i32 %36, 1
store i32 %37, i32* %8
br label %25
38: ; preds = %25
%39 = load i32, i32* %6
%40 = sext i32 %39 to i64
%41 = mul i64 4, %40
%42 = trunc i64 %41 to i32
%43 = call i64 @malloc(i32 %42)
%44 = inttoptr i64 %43 to i32*
store i32* %44, i32** %10
store i32 0, i32* %8
br label %45
45: ; preds = %55, %38
%46 = load i32, i32* %8
%47 = load i32, i32* %6
%48 = icmp slt i32 %46, %47
br i1 %48, label %49, label %58
49: ; preds = %45
%50 = load i32*, i32** %10
%51 = load i32, i32* %8
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i32, i32* %50, i64 %52
%54 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %53)
br label %55
55: ; preds = %49
%56 = load i32, i32* %8
%57 = add nsw i32 %56, 1
store i32 %57, i32* %8
br label %45
58: ; preds = %45
%59 = load i32, i32* %7
%60 = load i32*, i32** %9
%61 = load i32*, i32** %10
%62 = load i32, i32* %6
%63 = call i32 @mochila(i32 %59, i32* %60, i32* %61, i32 %62)
ret i32 0
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@.str = [3 x i8] c"%d\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = icmp slt i32 %0, 1
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i32, i32* @EXIT_FAILURE
%8 = tail call i32 @exit(i32 %7)
unreachable
9: ; preds = %2
%10 = bitcast i32* %3 to i8*
%11 = bitcast i32* %4 to i8*
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%14 = load i32, i32* %3
%15 = shl i32 %14, 2
%16 = call i64 @malloc(i32 %15)
%17 = inttoptr i64 %16 to i32*
%18 = load i32, i32* %3
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %28
20: ; preds = %9, %20
%21 = phi i64 [ %24, %20 ], [ 0, %9 ]
%22 = getelementptr inbounds i32, i32* %17, i64 %21
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %22)
%24 = add nuw nsw i64 %21, 1
%25 = load i32, i32* %3
%26 = sext i32 %25 to i64
%27 = icmp slt i64 %24, %26
br i1 %27, label %20, label %28
28: ; preds = %20, %9
%29 = phi i32 [ %18, %9 ], [ %25, %20 ]
%30 = shl i32 %29, 2
%31 = call i64 @malloc(i32 %30)
%32 = inttoptr i64 %31 to i32*
%33 = load i32, i32* %3
%34 = icmp sgt i32 %33, 0
br i1 %34, label %35, label %43
35: ; preds = %28, %35
%36 = phi i64 [ %39, %35 ], [ 0, %28 ]
%37 = getelementptr inbounds i32, i32* %32, i64 %36
%38 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %37)
%39 = add nuw nsw i64 %36, 1
%40 = load i32, i32* %3
%41 = sext i32 %40 to i64
%42 = icmp slt i64 %39, %41
br i1 %42, label %35, label %43
43: ; preds = %35, %28
%44 = phi i32 [ %33, %28 ], [ %40, %35 ]
%45 = load i32, i32* %4
%46 = call i32 @mochila(i32 %45, i32* %17, i32* %32, i32 %44)
ret i32 0
}