#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 */
scalar_t__ cut_dyn(int *, int, int);
scalar_t__ cut_rec(int *, int, int);
int test_cut_both() {
  int prices[] = {0, 1, 5, 8, 9, 10, 17, 17, 20};
  for (int i = 0; i < 20; i++) {
    if (cut_rec(prices, 9, i) != cut_dyn(prices, 9, i))
      return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<test_cut_both>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    -0x30(%rbp),%rdi
lea    0xebd(%rip),%rsi
mov    $0x24,%edx
call   1030 <memcpy@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0x14,-0x34(%rbp)
jge    11b3 <test_cut_both+0x83>
lea    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%edx
mov    $0x9,%esi
call   1040 <cut_rec@plt>
mov    %rax,-0x40(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%edx
mov    $0x9,%esi
call   1050 <cut_dyn@plt>
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
cmp    %rcx,%rax
je     11a0 <test_cut_both+0x70>
movl   $0x0,-0x4(%rbp)
jmp    11ba <test_cut_both+0x8a>
jmp    11a5 <test_cut_both+0x75>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1154 <test_cut_both+0x24>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_cut_both>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    0xef0(%rip),%eax
mov    %eax,0x20(%rsp)
movaps 0xed5(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xeb9(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%r14
xor    %ebp,%ebp
mov    %r14,%rdi
mov    $0x9,%esi
xor    %edx,%edx
call   1030 <cut_rec@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    $0x9,%esi
xor    %edx,%edx
call   1040 <cut_dyn@plt>
cmp    %rax,%rbx
jne    11b9 <test_cut_both+0x99>
xor    %ebp,%ebp
mov    %rsp,%r14
nopl   0x0(%rax,%rax,1)
mov    %ebp,%ebx
cmp    $0x13,%ebp
je     11b0 <test_cut_both+0x90>
lea    0x1(%rbx),%ebp
mov    %r14,%rdi
mov    $0x9,%esi
mov    %ebp,%edx
call   1030 <cut_rec@plt>
mov    %rax,%r15
mov    %r14,%rdi
mov    $0x9,%esi
mov    %ebp,%edx
call   1040 <cut_dyn@plt>
cmp    %rax,%r15
je     1180 <test_cut_both+0x60>
xor    %ebp,%ebp
cmp    $0x13,%ebx
setae  %bpl
mov    %ebp,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.test_cut_both.prices = [9 x i32] [i32 0, i32 1, i32 5, i32 8, i32 9, i32 10, i32 17, i32 17, i32 20]
define i32 @test_cut_both() {
%1 = alloca i32
%2 = alloca [9 x i32]
%3 = alloca i32
%4 = bitcast [9 x i32]* %2 to i8*
store i32 0, i32* %3
br label %5
5: ; preds = %18, %0
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 20
br i1 %7, label %8, label %21
8: ; preds = %5
%9 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 0
%10 = load i32, i32* %3
%11 = call i64 @cut_rec(i32* %9, i32 9, i32 %10)
%12 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 0
%13 = load i32, i32* %3
%14 = call i64 @cut_dyn(i32* %12, i32 9, i32 %13)
%15 = icmp ne i64 %11, %14
br i1 %15, label %16, label %17
16: ; preds = %8
store i32 0, i32* %1
br label %22
17: ; preds = %8
br label %18
18: ; preds = %17
%19 = load i32, i32* %3
%20 = add nsw i32 %19, 1
store i32 %20, i32* %3
br label %5
21: ; preds = %5
store i32 1, i32* %1
br label %22
22: ; preds = %21, %16
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
@__const.test_cut_both.prices = [9 x i32] [i32 0, i32 1, i32 5, i32 8, i32 9, i32 10, i32 17, i32 17, i32 20]
define i32 @test_cut_both() {
%1 = alloca [9 x i32]
%2 = bitcast [9 x i32]* %1 to i8*
%3 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 0, i64 0
%4 = call i64 @cut_rec(i32* %3, i32 9, i32 0)
%5 = call i64 @cut_dyn(i32* %3, i32 9, i32 0)
%6 = icmp eq i64 %4, %5
br i1 %6, label %7, label %18
7: ; preds = %0, %11
%8 = phi i32 [ %9, %11 ], [ 0, %0 ]
%9 = add nuw nsw i32 %8, 1
%10 = icmp eq i32 %9, 20
br i1 %10, label %15, label %11
11: ; preds = %7
%12 = call i64 @cut_rec(i32* %3, i32 9, i32 %9)
%13 = call i64 @cut_dyn(i32* %3, i32 9, i32 %9)
%14 = icmp eq i64 %12, %13
br i1 %14, label %7, label %15
15: ; preds = %11, %7
%16 = icmp ugt i32 %8, 18
%17 = zext i1 %16 to i32
br label %18
18: ; preds = %15, %0
%19 = phi i32 [ 0, %0 ], [ %17, %15 ]
ret i32 %19
}