#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*/ strcpy(char *, char *);
int strlen(char *);
char *delete (char *source, int index, int n) {
  char rest_str[100];
  if (strlen(source) <= index + n) {
    source[index] = '\0';
  } else {
    strcpy(rest_str, &source[index + n]);
    strcpy(&source[index], rest_str);
  }
  return (source);
}


x86 assembly (clang, -O0):
<delete>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0xc(%rbp),%ecx
add    -0x10(%rbp),%ecx
cmp    %ecx,%eax
jg     115d <delete+0x3d>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    1189 <delete+0x69>
lea    -0x80(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
cltq
add    %rax,%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
add    %rax,%rdi
lea    -0x80(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<delete>:
push   %rbp
push   %r14
push   %rbx
sub    $0x70,%rsp
mov    %edx,%ebp
mov    %esi,%r14d
mov    %rdi,%rbx
call   1040 <strlen@plt>
add    %r14d,%ebp
cmp    %ebp,%eax
jle    115d <delete+0x3d>
movslq %ebp,%rsi
add    %rbx,%rsi
mov    %rsp,%rbp
mov    %rbp,%rdi
call   1030 <strcpy@plt>
movslq %r14d,%rdi
add    %rbx,%rdi
mov    %rbp,%rsi
call   1030 <strcpy@plt>
jmp    1164 <delete+0x44>
movslq %r14d,%rax
movb   $0x0,(%rbx,%rax,1)
mov    %rbx,%rax
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i8* @delete(i8* returned %0, i32 %1, i32 %2) {
%4 = alloca [100 x i8]
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%6 = tail call i32 @strlen(i8* %0)
%7 = add nsw i32 %2, %1
%8 = icmp sgt i32 %6, %7
br i1 %8, label %12, label %9
9: ; preds = %3
%10 = sext i32 %1 to i64
%11 = getelementptr inbounds i8, i8* %0, i64 %10
store i8 0, i8* %11
br label %19
12: ; preds = %3
%13 = sext i32 %7 to i64
%14 = getelementptr inbounds i8, i8* %0, i64 %13
%15 = call i32 @strcpy(i8* %5, i8* %14)
%16 = sext i32 %1 to i64
%17 = getelementptr inbounds i8, i8* %0, i64 %16
%18 = call i32 @strcpy(i8* %17, i8* %5)
br label %19
19: ; preds = %12, %9
ret i8* %0
}