#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_log(int, int, char *, int *);
int /*<<< orphan*/ slice_str(int, int, char *);
int /*<<< orphan*/ strcmp(char *, int /*<<< orphan*/);
int test_slice_str(int verbose) {
  int ok = 1;
  char *tmp = "0123456789";
  assert_log(!strcmp("01", slice_str(0, 2, tmp)), verbose, "slice ! '01'", &ok);
  assert_log(!strcmp("23", slice_str(2, 4, tmp)), verbose, "slice ! '34'", &ok);
  return ok;
}


x86 assembly (clang, -O0):
<test_slice_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
lea    0xeb7(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdx
xor    %edi,%edi
mov    $0x2,%esi
call   1030 <slice_str@plt>
mov    %eax,%esi
lea    0xea5(%rip),%rdi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
mov    -0x4(%rbp),%esi
lea    0xe8c(%rip),%rdx
lea    -0x8(%rbp),%rcx
call   1050 <assert_log@plt>
mov    -0x10(%rbp),%rdx
mov    $0x2,%edi
mov    $0x4,%esi
call   1030 <slice_str@plt>
mov    %eax,%esi
lea    0xe74(%rip),%rdi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
mov    -0x4(%rbp),%esi
lea    0xe5b(%rip),%rdx
lea    -0x8(%rbp),%rcx
call   1050 <assert_log@plt>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_slice_str>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
movl   $0x1,0xc(%rsp)
lea    0xeb6(%rip),%r14
xor    %edi,%edi
mov    $0x2,%esi
mov    %r14,%rdx
call   1030 <slice_str@plt>
lea    0xeab(%rip),%rdi
mov    %eax,%esi
call   1040 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
lea    0xe98(%rip),%rdx
lea    0xc(%rsp),%r15
mov    %ebx,%esi
mov    %r15,%rcx
call   1050 <assert_log@plt>
mov    $0x2,%edi
mov    $0x4,%esi
mov    %r14,%rdx
call   1030 <slice_str@plt>
lea    0xe7d(%rip),%rdi
mov    %eax,%esi
call   1040 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
lea    0xe6a(%rip),%rdx
mov    %ebx,%esi
mov    %r15,%rcx
call   1050 <assert_log@plt>
mov    0xc(%rsp),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c"0123456789\00"
@.str.1 = [3 x i8] c"01\00"
@.str.2 = [13 x i8] c"slice ! '01'\00"
@.str.3 = [3 x i8] c"23\00"
@.str.4 = [13 x i8] c"slice ! '34'\00"
define i32 @test_slice_str(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %2
store i32 1, i32* %3
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %4
%5 = load i8*, i8** %4
%6 = call i32 @slice_str(i32 0, i32 2, i8* %5)
%7 = call i32 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = icmp ne i32 %7, 0
%9 = xor i1 %8, true
%10 = zext i1 %9 to i32
%11 = load i32, i32* %2
%12 = call i32 @assert_log(i32 %10, i32 %11, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%13 = load i8*, i8** %4
%14 = call i32 @slice_str(i32 2, i32 4, i8* %13)
%15 = call i32 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %14)
%16 = icmp ne i32 %15, 0
%17 = xor i1 %16, true
%18 = zext i1 %17 to i32
%19 = load i32, i32* %2
%20 = call i32 @assert_log(i32 %18, i32 %19, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%21 = load i32, i32* %3
ret i32 %21
}

LLVM IR (-O2):
@.str = [11 x i8] c"0123456789\00"
@.str.1 = [3 x i8] c"01\00"
@.str.2 = [13 x i8] c"slice ! '01'\00"
@.str.3 = [3 x i8] c"23\00"
@.str.4 = [13 x i8] c"slice ! '34'\00"
define i32 @test_slice_str(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
store i32 1, i32* %2
%4 = tail call i32 @slice_str(i32 0, i32 2, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %4)
%6 = icmp eq i32 %5, 0
%7 = zext i1 %6 to i32
%8 = call i32 @assert_log(i32 %7, i32 %0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%9 = call i32 @slice_str(i32 2, i32 4, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %9)
%11 = icmp eq i32 %10, 0
%12 = zext i1 %11 to i32
%13 = call i32 @assert_log(i32 %12, i32 %0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%14 = load i32, i32* %2
ret i32 %14
}