#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 */
char *dstrpos(char *, size_t);
int /*<<< orphan*/ memmove(char *, char *, int);
char *realloc(char *, int);
int strlen(char *);
char *dstrdeln(char *str, size_t pos, size_t n) {
  char *sptr;
  char *eptr;
  sptr = dstrpos(str, pos);
  if (sptr == NULL)
    return str;
  eptr = dstrpos(sptr, n);
  if (eptr == NULL)
    eptr = sptr + strlen(sptr);
  memmove(sptr, eptr, strlen(eptr) + 1);
  return realloc(str, strlen(str) + 1);
}


x86 assembly (clang, -O0):
<dstrdeln>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <dstrpos@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    117d <dstrdeln+0x3d>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1208 <dstrdeln+0xc8>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <dstrpos@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11ba <dstrdeln+0x7a>
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x50(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    %eax,%edx
add    $0x1,%edx
call   1060 <memmove@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x40(%rbp),%rdi
mov    %eax,%esi
add    $0x1,%esi
call   1050 <realloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dstrdeln>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %rdi,%r14
call   1040 <dstrpos@plt>
test   %rax,%rax
je     11a9 <dstrdeln+0x69>
mov    %rax,%r15
mov    %rax,%rdi
mov    %rbx,%rsi
call   1040 <dstrpos@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    117b <dstrdeln+0x3b>
mov    %r15,%rdi
call   1030 <strlen@plt>
cltq
mov    %r15,%rbx
add    %rax,%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    0x1(%rax),%edx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <memmove@plt>
mov    %r14,%rdi
call   1030 <strlen@plt>
lea    0x1(%rax),%esi
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <realloc@plt>
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @dstrdeln(i8* %0, i64 %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i8*
store i8* %0, i8** %5
store i64 %1, i64* %6
store i64 %2, i64* %7
%10 = load i8*, i8** %5
%11 = load i64, i64* %6
%12 = call i8* @dstrpos(i8* %10, i64 %11)
store i8* %12, i8** %8
%13 = load i8*, i8** %8
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %17
15: ; preds = %3
%16 = load i8*, i8** %5
store i8* %16, i8** %4
br label %41
17: ; preds = %3
%18 = load i8*, i8** %8
%19 = load i64, i64* %7
%20 = call i8* @dstrpos(i8* %18, i64 %19)
store i8* %20, i8** %9
%21 = load i8*, i8** %9
%22 = icmp eq i8* %21, null
br i1 %22, label %23, label %29
23: ; preds = %17
%24 = load i8*, i8** %8
%25 = load i8*, i8** %8
%26 = call i32 @strlen(i8* %25)
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %24, i64 %27
store i8* %28, i8** %9
br label %29
29: ; preds = %23, %17
%30 = load i8*, i8** %8
%31 = load i8*, i8** %9
%32 = load i8*, i8** %9
%33 = call i32 @strlen(i8* %32)
%34 = add nsw i32 %33, 1
%35 = call i32 @memmove(i8* %30, i8* %31, i32 %34)
%36 = load i8*, i8** %5
%37 = load i8*, i8** %5
%38 = call i32 @strlen(i8* %37)
%39 = add nsw i32 %38, 1
%40 = call i8* @realloc(i8* %36, i32 %39)
store i8* %40, i8** %4
br label %41
41: ; preds = %29, %15
%42 = load i8*, i8** %4
ret i8* %42
}

LLVM IR (-O2):
define i8* @dstrdeln(i8* %0, i64 %1, i64 %2) {
%4 = tail call i8* @dstrpos(i8* %0, i64 %1)
%5 = icmp eq i8* %4, null
br i1 %5, label %21, label %6
6: ; preds = %3
%7 = tail call i8* @dstrpos(i8* %4, i64 %2)
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %13
9: ; preds = %6
%10 = tail call i32 @strlen(i8* %4)
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %4, i64 %11
br label %13
13: ; preds = %9, %6
%14 = phi i8* [ %12, %9 ], [ %7, %6 ]
%15 = tail call i32 @strlen(i8* %14)
%16 = add nsw i32 %15, 1
%17 = tail call i32 @memmove(i8* %4, i8* %14, i32 %16)
%18 = tail call i32 @strlen(i8* %0)
%19 = add nsw i32 %18, 1
%20 = tail call i8* @realloc(i8* %0, i32 %19)
br label %21
21: ; preds = %3, %13
%22 = phi i8* [ %20, %13 ], [ %0, %3 ]
ret i8* %22
}