#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*/ free(char *);
char *pl_slice(char *, int, int);
int /*<<< orphan*/ printf(char *, char *, ...);
int main() {
  char the_string[] = "subdermatoglyphic";
  char *sliced;
  sliced = pl_slice(the_string, 3, 10);
  if (sliced != NULL) {
    printf("the_string: %s\nsliced 3, 10: %s\n", the_string, sliced);
    free(sliced);
  }
  sliced = pl_slice(the_string, 0, -10);
  if (sliced != NULL) {
    printf("sliced 0,-10: %s\n", sliced);
    free(sliced);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeb7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeb4(%rip),%ax
mov    %ax,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0x3,%esi
mov    $0xa,%edx
call   1040 <pl_slice@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11a1 <main+0x71>
lea    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0xfffffff6,%edx
call   1040 <pl_slice@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11db <main+0xab>
mov    -0x28(%rbp),%rsi
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
movaps 0xec4(%rip),%xmm0
movaps %xmm0,(%rsp)
movw   $0x63,0x10(%rsp)
mov    %rsp,%rdi
mov    $0x3,%esi
mov    $0xa,%edx
call   1040 <pl_slice@plt>
test   %rax,%rax
je     117d <main+0x4d>
mov    %rax,%rbx
lea    0xeaa(%rip),%rdi
mov    %rsp,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0xfffffff6,%edx
call   1040 <pl_slice@plt>
test   %rax,%rax
je     11ad <main+0x7d>
mov    %rax,%rbx
lea    0xe98(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.the_string = [18 x i8] c"subdermatoglyphic\00"
@.str = [33 x i8] c"the_string: %s\0Asliced 3, 10: %s\0A\00"
@.str.1 = [18 x i8] c"sliced 0,-10: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [18 x i8]
%3 = alloca i8*
store i32 0, i32* %1
%4 = bitcast [18 x i8]* %2 to i8*
%5 = getelementptr inbounds [18 x i8], [18 x i8]* %2, i64 0, i64 0
%6 = call i8* @pl_slice(i8* %5, i32 3, i32 10)
store i8* %6, i8** %3
%7 = load i8*, i8** %3
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %15
9: ; preds = %0
%10 = getelementptr inbounds [18 x i8], [18 x i8]* %2, i64 0, i64 0
%11 = load i8*, i8** %3
%12 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %10, i8* %11)
%13 = load i8*, i8** %3
%14 = call i32 @free(i8* %13)
br label %15
15: ; preds = %9, %0
%16 = getelementptr inbounds [18 x i8], [18 x i8]* %2, i64 0, i64 0
%17 = call i8* @pl_slice(i8* %16, i32 0, i32 -10)
store i8* %17, i8** %3
%18 = load i8*, i8** %3
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %25
20: ; preds = %15
%21 = load i8*, i8** %3
%22 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %21)
%23 = load i8*, i8** %3
%24 = call i32 @free(i8* %23)
br label %25
25: ; preds = %20, %15
ret i32 0
}

LLVM IR (-O2):
@__const.main.the_string = [18 x i8] c"subdermatoglyphic\00"
@.str = [33 x i8] c"the_string: %s\0Asliced 3, 10: %s\0A\00"
@.str.1 = [18 x i8] c"sliced 0,-10: %s\0A\00"
define i32 @main() {
%1 = alloca [18 x i8]
%2 = getelementptr inbounds [18 x i8], [18 x i8]* %1, i64 0, i64 0
%3 = call i8* @pl_slice(i8* %2, i32 3, i32 10)
%4 = icmp eq i8* %3, null
br i1 %4, label %8, label %5
5: ; preds = %0
%6 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %2, i8* %3)
%7 = call i32 @free(i8* %3)
br label %8
8: ; preds = %5, %0
%9 = call i8* @pl_slice(i8* %2, i32 0, i32 -10)
%10 = icmp eq i8* %9, null
br i1 %10, label %14, label %11
11: ; preds = %8
%12 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%13 = call i32 @free(i8* %9)
br label %14
14: ; preds = %11, %8
ret i32 0
}