#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*/ assert_equal_str(char *, char *, char *, char *);
int /*<<< orphan*/ free(char *);
char *pl_slice(char *, int, int);
void test_slice_both_negative() {
  char the_string[] = "spam, eggs, and ham";
  char *ret_val;
  ret_val = pl_slice(the_string, -13, -4);
  assert_equal_str(
      "eggs, and", ret_val, "test_slice_both_negative",
      "Test 1: The function did not return the correct substring.");
  free(ret_val);
  ret_val = pl_slice(the_string, -5, -5);
  assert_equal_str(
      NULL, ret_val, "test_slice_both_negative",
      "Test 2: The function did not return the correct substring.");
  ret_val = pl_slice(the_string, -5, -10);
  assert_equal_str(
      NULL, ret_val, "test_slice_both_negative",
      "Test 3: The function did not return the correct substring.");
}


x86 assembly (clang, -O0):
<test_slice_both_negative>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0xec1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xebe(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xebc(%rip),%eax
mov    %eax,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0xfffffff3,%esi
mov    $0xfffffffc,%edx
call   1050 <pl_slice@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
lea    0xe9b(%rip),%rdi
lea    0xe9e(%rip),%rdx
lea    0xeb0(%rip),%rcx
call   1040 <assert_equal_str@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
lea    -0x20(%rbp),%rdi
mov    $0xfffffffb,%edx
mov    %edx,%esi
call   1050 <pl_slice@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
lea    0xe66(%rip),%rdx
lea    0xeb3(%rip),%rcx
call   1040 <assert_equal_str@plt>
lea    -0x20(%rbp),%rdi
mov    $0xfffffffb,%esi
mov    $0xfffffff6,%edx
call   1050 <pl_slice@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
lea    0xe34(%rip),%rdx
lea    0xebc(%rip),%rcx
call   1040 <assert_equal_str@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_slice_both_negative>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
movaps 0xec0(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0x6d6168,0x10(%rsp)
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0xfffffff3,%esi
mov    $0xfffffffc,%edx
call   1050 <pl_slice@plt>
mov    %rax,%rbx
lea    0xea9(%rip),%rdi
lea    0xeac(%rip),%r15
lea    0xebe(%rip),%rcx
mov    %rax,%rsi
mov    %r15,%rdx
call   1040 <assert_equal_str@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
mov    $0xfffffffb,%esi
mov    $0xfffffffb,%edx
call   1050 <pl_slice@plt>
lea    0xecd(%rip),%rcx
xor    %edi,%edi
mov    %rax,%rsi
mov    %r15,%rdx
call   1040 <assert_equal_str@plt>
mov    %r14,%rdi
mov    $0xfffffffb,%esi
mov    $0xfffffff6,%edx
call   1050 <pl_slice@plt>
lea    0xee2(%rip),%rcx
xor    %edi,%edi
mov    %rax,%rsi
mov    %r15,%rdx
call   1040 <assert_equal_str@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.test_slice_both_negative.the_string = [20 x i8] c"spam, eggs, and ham\00"
@.str = [10 x i8] c"eggs, and\00"
@.str.1 = [25 x i8] c"test_slice_both_negative\00"
@.str.2 = [59 x i8] c"Test 1: The function did not return the correct substring.\00"
@.str.3 = [59 x i8] c"Test 2: The function did not return the correct substring.\00"
@.str.4 = [59 x i8] c"Test 3: The function did not return the correct substring.\00"
define void @test_slice_both_negative() {
%1 = alloca [20 x i8]
%2 = alloca i8*
%3 = bitcast [20 x i8]* %1 to i8*
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%5 = call i8* @pl_slice(i8* %4, i32 -13, i32 -4)
store i8* %5, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 @assert_equal_str(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %6, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.2, i64 0, i64 0))
%8 = load i8*, i8** %2
%9 = call i32 @free(i8* %8)
%10 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%11 = call i8* @pl_slice(i8* %10, i32 -5, i32 -5)
store i8* %11, i8** %2
%12 = load i8*, i8** %2
%13 = call i32 @assert_equal_str(i8* null, i8* %12, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.3, i64 0, i64 0))
%14 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%15 = call i8* @pl_slice(i8* %14, i32 -5, i32 -10)
store i8* %15, i8** %2
%16 = load i8*, i8** %2
%17 = call i32 @assert_equal_str(i8* null, i8* %16, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@__const.test_slice_both_negative.the_string = [20 x i8] c"spam, eggs, and ham\00"
@.str = [10 x i8] c"eggs, and\00"
@.str.1 = [25 x i8] c"test_slice_both_negative\00"
@.str.2 = [59 x i8] c"Test 1: The function did not return the correct substring.\00"
@.str.3 = [59 x i8] c"Test 2: The function did not return the correct substring.\00"
@.str.4 = [59 x i8] c"Test 3: The function did not return the correct substring.\00"
define void @test_slice_both_negative() {
%1 = alloca [20 x i8]
%2 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%3 = call i8* @pl_slice(i8* %2, i32 -13, i32 -4)
%4 = call i32 @assert_equal_str(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %3, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.2, i64 0, i64 0))
%5 = call i32 @free(i8* %3)
%6 = call i8* @pl_slice(i8* %2, i32 -5, i32 -5)
%7 = call i32 @assert_equal_str(i8* null, i8* %6, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.3, i64 0, i64 0))
%8 = call i8* @pl_slice(i8* %2, i32 -5, i32 -10)
%9 = call i32 @assert_equal_str(i8* null, i8* %8, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.4, i64 0, i64 0))
ret void
}