#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 __VERIFIER_nondet_int();
scalar_t__ alloca(int);
int /*<<< orphan*/ knapsack(int *, int *, int, int *, int *, int);
int main() {
  int N = __VERIFIER_nondet_int();
  int M = __VERIFIER_nondet_int();
  if (N < 1) {
    N = 1;
  }
  if (M < 1) {
    M = 1;
  }
  int *size = (int *)alloca(N * sizeof(int));
  int *val = (int *)alloca(N * sizeof(int));
  int *cost = (int *)alloca(M * sizeof(int));
  int *best = (int *)alloca(M * sizeof(int));
  knapsack(size, val, N, cost, best, M);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <__VERIFIER_nondet_int@plt>
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1040 <__VERIFIER_nondet_int@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x1,-0x8(%rbp)
jge    1164 <main+0x34>
movl   $0x1,-0x8(%rbp)
cmpl   $0x1,-0xc(%rbp)
jge    1175 <main+0x45>
movl   $0x1,-0xc(%rbp)
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1030 <alloca@plt>
mov    %rax,-0x18(%rbp)
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1030 <alloca@plt>
mov    %rax,-0x20(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1030 <alloca@plt>
mov    %rax,-0x28(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1030 <alloca@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x8(%rbp),%edx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0xc(%rbp),%r9d
call   1050 <knapsack@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <__VERIFIER_nondet_int@plt>
mov    %eax,%r14d
xor    %eax,%eax
call   1040 <__VERIFIER_nondet_int@plt>
test   %r14d,%r14d
mov    $0x1,%ebx
cmovle %ebx,%r14d
test   %eax,%eax
cmovg  %eax,%ebx
lea    0x0(,%r14,4),%ebp
mov    %ebp,%edi
call   1030 <alloca@plt>
mov    %rax,%r15
mov    %ebp,%edi
call   1030 <alloca@plt>
mov    %rax,%r12
lea    0x0(,%rbx,4),%ebp
mov    %ebp,%edi
call   1030 <alloca@plt>
mov    %rax,%r13
mov    %ebp,%edi
call   1030 <alloca@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r14d,%edx
mov    %r13,%rcx
mov    %rax,%r8
mov    %ebx,%r9d
call   1050 <knapsack@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
store i32 0, i32* %1
%8 = call i32 (...) @__VERIFIER_nondet_int()
store i32 %8, i32* %2
%9 = call i32 (...) @__VERIFIER_nondet_int()
store i32 %9, i32* %3
%10 = load i32, i32* %2
%11 = icmp slt i32 %10, 1
br i1 %11, label %12, label %13
12: ; preds = %0
store i32 1, i32* %2
br label %13
13: ; preds = %12, %0
%14 = load i32, i32* %3
%15 = icmp slt i32 %14, 1
br i1 %15, label %16, label %17
16: ; preds = %13
store i32 1, i32* %3
br label %17
17: ; preds = %16, %13
%18 = load i32, i32* %2
%19 = sext i32 %18 to i64
%20 = mul i64 %19, 4
%21 = trunc i64 %20 to i32
%22 = call i64 @alloca(i32 %21)
%23 = inttoptr i64 %22 to i32*
store i32* %23, i32** %4
%24 = load i32, i32* %2
%25 = sext i32 %24 to i64
%26 = mul i64 %25, 4
%27 = trunc i64 %26 to i32
%28 = call i64 @alloca(i32 %27)
%29 = inttoptr i64 %28 to i32*
store i32* %29, i32** %5
%30 = load i32, i32* %3
%31 = sext i32 %30 to i64
%32 = mul i64 %31, 4
%33 = trunc i64 %32 to i32
%34 = call i64 @alloca(i32 %33)
%35 = inttoptr i64 %34 to i32*
store i32* %35, i32** %6
%36 = load i32, i32* %3
%37 = sext i32 %36 to i64
%38 = mul i64 %37, 4
%39 = trunc i64 %38 to i32
%40 = call i64 @alloca(i32 %39)
%41 = inttoptr i64 %40 to i32*
store i32* %41, i32** %7
%42 = load i32*, i32** %4
%43 = load i32*, i32** %5
%44 = load i32, i32* %2
%45 = load i32*, i32** %6
%46 = load i32*, i32** %7
%47 = load i32, i32* %3
%48 = call i32 @knapsack(i32* %42, i32* %43, i32 %44, i32* %45, i32* %46, i32 %47)
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 (...) @__VERIFIER_nondet_int()
%2 = tail call i32 (...) @__VERIFIER_nondet_int()
%3 = icmp sgt i32 %1, 1
%4 = select i1 %3, i32 %1, i32 1
%5 = icmp sgt i32 %2, 1
%6 = select i1 %5, i32 %2, i32 1
%7 = shl i32 %4, 2
%8 = tail call i64 @alloca(i32 %7)
%9 = inttoptr i64 %8 to i32*
%10 = tail call i64 @alloca(i32 %7)
%11 = inttoptr i64 %10 to i32*
%12 = shl i32 %6, 2
%13 = tail call i64 @alloca(i32 %12)
%14 = inttoptr i64 %13 to i32*
%15 = tail call i64 @alloca(i32 %12)
%16 = inttoptr i64 %15 to i32*
%17 = tail call i32 @knapsack(i32* %9, i32* %11, i32 %4, i32* %14, i32* %16, i32 %6)
ret i32 0
}