#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 strlen(char *);
void substring(char *src, int stripFromBewb, int stripFromAss, char *dest) {
  for (int destIndex = 0; stripFromBewb <= (strlen(src) - 1 - stripFromAss);
       stripFromBewb++, destIndex++)
    dest[destIndex] = src[stripFromBewb];
}


x86 assembly (clang, -O0):
<substring>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
sub    $0x1,%ecx
sub    -0x10(%rbp),%ecx
cmp    %ecx,%eax
jg     117c <substring+0x6c>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112d <substring+0x1d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<substring>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%rbx
mov    %edx,%r14d
mov    %esi,%r15d
mov    %rdi,%r12
call   1030 <strlen@plt>
not    %r14d
add    %r14d,%eax
cmp    %r15d,%eax
jl     1162 <substring+0x52>
movslq %r15d,%rbp
add    $0xffffffffffffffff,%rbp
nopl   0x0(%rax,%rax,1)
movzbl 0x1(%r12,%rbp,1),%eax
mov    %al,(%rbx)
mov    %r12,%rdi
call   1030 <strlen@plt>
add    %r14d,%eax
cltq
add    $0x1,%rbp
add    $0x1,%rbx
cmp    %rax,%rbp
jl     1140 <substring+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @substring(i8* %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8* %3, i8** %8
store i32 0, i32* %9
br label %10
10: ; preds = %28, %4
%11 = load i32, i32* %6
%12 = load i8*, i8** %5
%13 = call i32 @strlen(i8* %12)
%14 = sub nsw i32 %13, 1
%15 = load i32, i32* %7
%16 = sub nsw i32 %14, %15
%17 = icmp sle i32 %11, %16
br i1 %17, label %18, label %33
18: ; preds = %10
%19 = load i8*, i8** %5
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
%24 = load i8*, i8** %8
%25 = load i32, i32* %9
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
store i8 %23, i8* %27
br label %28
28: ; preds = %18
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %6
%31 = load i32, i32* %9
%32 = add nsw i32 %31, 1
store i32 %32, i32* %9
br label %10
33: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @substring(i8* %0, i32 %1, i32 %2, i8* nocapture writeonly %3) {
%5 = tail call i32 @strlen(i8* %0)
%6 = xor i32 %2, -1
%7 = add i32 %5, %6
%8 = icmp slt i32 %7, %1
br i1 %8, label %11, label %9
9: ; preds = %4
%10 = sext i32 %1 to i64
br label %12
11: ; preds = %12, %4
ret void
12: ; preds = %9, %12
%13 = phi i64 [ %10, %9 ], [ %18, %12 ]
%14 = phi i64 [ 0, %9 ], [ %19, %12 ]
%15 = getelementptr inbounds i8, i8* %0, i64 %13
%16 = load i8, i8* %15
%17 = getelementptr inbounds i8, i8* %3, i64 %14
store i8 %16, i8* %17
%18 = add nsw i64 %13, 1
%19 = add nuw nsw i64 %14, 1
%20 = tail call i32 @strlen(i8* %0)
%21 = add i32 %20, %6
%22 = sext i32 %21 to i64
%23 = icmp slt i64 %13, %22
br i1 %23, label %12, label %11
}