delins(dlength, instr) int dlength;
char *instr;
{
  int status;
  char tmpc;
  if (!(status = ldelete((long)dlength, 0))) {
    mlwrite("%%ERROR while deleting");
    return (0);
  } else
    while (tmpc = *instr) {
      status = (tmpc == '\n' ? lnewline() : linsert(1, tmpc));
      if (!status) {
        mlwrite("%%Out of memory while inserting");
        break;
      }
      instr++;
    }
  return (status);
}


x86 assembly (clang, -O0):
<delins>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movslq -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x0,%al
call   1060 <ldelete@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jne    1182 <delins+0x42>
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1040 <mlwrite@plt>
movl   $0x0,-0x4(%rbp)
jmp    1206 <delins+0xc6>
jmp    1187 <delins+0x47>
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x15(%rbp)
cmp    $0x0,%al
je     11fb <delins+0xbb>
movsbl -0x15(%rbp),%eax
cmp    $0xa,%eax
jne    11b4 <delins+0x74>
mov    $0x0,%al
call   1050 <lnewline@plt>
mov    %eax,-0x1c(%rbp)
jmp    11c7 <delins+0x87>
movsbl -0x15(%rbp),%esi
mov    $0x1,%edi
mov    $0x0,%al
call   1030 <linsert@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    11ea <delins+0xaa>
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1040 <mlwrite@plt>
jmp    11fb <delins+0xbb>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1187 <delins+0x47>
jmp    1200 <delins+0xc0>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<delins>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
movslq %edi,%rdi
xor    %r14d,%r14d
xor    %esi,%esi
xor    %eax,%eax
call   1060 <ldelete@plt>
test   %eax,%eax
je     119a <delins+0x5a>
lea    0xeb6(%rip),%rbp
jmp    117f <delins+0x3f>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1050 <lnewline@plt>
add    $0x1,%rbx
test   %eax,%eax
je     11a1 <delins+0x61>
movsbl (%rbx),%esi
cmp    $0xa,%esi
je     1170 <delins+0x30>
test   %sil,%sil
je     11ad <delins+0x6d>
mov    $0x1,%edi
xor    %eax,%eax
call   1030 <linsert@plt>
jmp    1177 <delins+0x37>
lea    0xe5f(%rip),%rbp
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <mlwrite@plt>
jmp    11b0 <delins+0x70>
mov    %eax,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"%%ERROR while deleting\00"
@.str.1 = [32 x i8] c"%%Out of memory while inserting\00"
define i32 @delins(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8
store i32 %0, i32* %4
store i8* %1, i8** %5
%8 = load i32, i32* %4
%9 = sext i32 %8 to i64
%10 = call i32 (i64, i32, ...) bitcast (i32 (...)* @ldelete to i32 (i64, i32, ...)*)(i64 %9, i32 0)
store i32 %10, i32* %6
%11 = icmp ne i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %2
%13 = call i32 (i8*, ...) bitcast (i32 (...)* @mlwrite to i32 (i8*, ...)*)(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %41
14: ; preds = %2
br label %15
15: ; preds = %35, %14
%16 = load i8*, i8** %5
%17 = load i8, i8* %16
store i8 %17, i8* %7
%18 = icmp ne i8 %17, 0
br i1 %18, label %19, label %38
19: ; preds = %15
%20 = load i8, i8* %7
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 10
br i1 %22, label %23, label %25
23: ; preds = %19
%24 = call i32 (...) @lnewline()
br label %29
25: ; preds = %19
%26 = load i8, i8* %7
%27 = sext i8 %26 to i32
%28 = call i32 (i32, i32, ...) bitcast (i32 (...)* @linsert to i32 (i32, i32, ...)*)(i32 1, i32 %27)
br label %29
29: ; preds = %25, %23
%30 = phi i32 [ %24, %23 ], [ %28, %25 ]
store i32 %30, i32* %6
%31 = load i32, i32* %6
%32 = icmp ne i32 %31, 0
br i1 %32, label %35, label %33
33: ; preds = %29
%34 = call i32 (i8*, ...) bitcast (i32 (...)* @mlwrite to i32 (i8*, ...)*)(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
br label %38
35: ; preds = %29
%36 = load i8*, i8** %5
%37 = getelementptr inbounds i8, i8* %36, i32 1
store i8* %37, i8** %5
br label %15
38: ; preds = %33, %15
br label %39
39: ; preds = %38
%40 = load i32, i32* %6
store i32 %40, i32* %3
br label %41
41: ; preds = %39, %12
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
@.str = [23 x i8] c"%%ERROR while deleting\00"
@.str.1 = [32 x i8] c"%%Out of memory while inserting\00"
define i32 @delins(i32 %0, i8* nocapture %1) {
%3 = sext i32 %0 to i64
%4 = tail call i32 (i64, i32, ...) bitcast (i32 (...)* @ldelete to i32 (i64, i32, ...)*)(i64 %3, i32 0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %19, label %6
6: ; preds = %2, %15
%7 = phi i8* [ %18, %15 ], [ %1, %2 ]
%8 = phi i32 [ %16, %15 ], [ %4, %2 ]
%9 = load i8, i8* %7
switch i8 %9, label %12 [
i8 0, label %22
i8 10, label %10
]
10: ; preds = %6
%11 = tail call i32 (...) @lnewline()
br label %15
12: ; preds = %6
%13 = sext i8 %9 to i32
%14 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @linsert to i32 (i32, i32, ...)*)(i32 1, i32 %13)
br label %15
15: ; preds = %12, %10
%16 = phi i32 [ %11, %10 ], [ %14, %12 ]
%17 = icmp eq i32 %16, 0
%18 = getelementptr inbounds i8, i8* %7, i64 1
br i1 %17, label %19, label %6
19: ; preds = %15, %2
%20 = phi i8* [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), %2 ], [ getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), %15 ]
%21 = tail call i32 (i8*, ...) bitcast (i32 (...)* @mlwrite to i32 (i8*, ...)*)(i8* %20)
br label %22
22: ; preds = %6, %19
%23 = phi i32 [ 0, %19 ], [ %8, %6 ]
ret i32 %23
}