#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_string(char *);
char *str_dup(char *);
char *string_delete(char *orig, int line) {
  char buf[8192];
  char *rdesc;
  int current_line = 1;
  int i = 0;
  buf[0] = '\0';
  for (rdesc = orig; *rdesc; rdesc++) {
    if (current_line != line) {
      buf[i] = *rdesc;
      i++;
    }
    if (*rdesc == '\r')
      current_line++;
  }
  if (orig)
    free_string(orig);
  buf[i] = 0;
  return str_dup(buf);
}


x86 assembly (clang, -O0):
<string_delete>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2020,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x1,-0x201c(%rbp)
movl   $0x0,-0x2020(%rbp)
movb   $0x0,-0x2010(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x2018(%rbp)
mov    -0x2018(%rbp),%rax
cmpb   $0x0,(%rax)
je     11db <string_delete+0xbb>
mov    -0x201c(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     119d <string_delete+0x7d>
mov    -0x2018(%rbp),%rax
mov    (%rax),%cl
movslq -0x2020(%rbp),%rax
mov    %cl,-0x2010(%rbp,%rax,1)
mov    -0x2020(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2020(%rbp)
mov    -0x2018(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
jne    11bf <string_delete+0x9f>
mov    -0x201c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x201c(%rbp)
jmp    11c4 <string_delete+0xa4>
mov    -0x2018(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x2018(%rbp)
jmp    1158 <string_delete+0x38>
cmpq   $0x0,-0x8(%rbp)
je     11ef <string_delete+0xcf>
mov    -0x8(%rbp),%rdi
call   1030 <free_string@plt>
movslq -0x2020(%rbp),%rax
movb   $0x0,-0x2010(%rbp,%rax,1)
lea    -0x2010(%rbp),%rdi
call   1040 <str_dup@plt>
add    $0x2020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<string_delete>:
push   %r14
push   %rbx
sub    $0x2008,%rsp
movb   $0x0,(%rsp)
mov    (%rdi),%dl
test   %dl,%dl
je     1176 <string_delete+0x56>
lea    0x1(%rdi),%rax
mov    $0x1,%ecx
xor    %r14d,%r14d
jmp    1165 <string_delete+0x45>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %ebx,%ebx
cmp    $0xd,%dl
sete   %bl
add    %ebx,%ecx
movzbl (%rax),%edx
add    $0x1,%rax
test   %dl,%dl
je     1179 <string_delete+0x59>
cmp    %esi,%ecx
je     1150 <string_delete+0x30>
movslq %r14d,%r14
mov    %dl,(%rsp,%r14,1)
add    $0x1,%r14d
jmp    1150 <string_delete+0x30>
xor    %r14d,%r14d
call   1030 <free_string@plt>
movslq %r14d,%rax
movb   $0x0,(%rsp,%rax,1)
mov    %rsp,%rdi
call   1040 <str_dup@plt>
add    $0x2008,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @string_delete(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [8192 x i8]
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 1, i32* %7
store i32 0, i32* %8
%9 = getelementptr inbounds [8192 x i8], [8192 x i8]* %5, i64 0, i64 0
store i8 0, i8* %9
%10 = load i8*, i8** %3
store i8* %10, i8** %6
br label %11
11: ; preds = %36, %2
%12 = load i8*, i8** %6
%13 = load i8, i8* %12
%14 = icmp ne i8 %13, 0
br i1 %14, label %15, label %39
15: ; preds = %11
%16 = load i32, i32* %7
%17 = load i32, i32* %4
%18 = icmp ne i32 %16, %17
br i1 %18, label %19, label %27
19: ; preds = %15
%20 = load i8*, i8** %6
%21 = load i8, i8* %20
%22 = load i32, i32* %8
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [8192 x i8], [8192 x i8]* %5, i64 0, i64 %23
store i8 %21, i8* %24
%25 = load i32, i32* %8
%26 = add nsw i32 %25, 1
store i32 %26, i32* %8
br label %27
27: ; preds = %19, %15
%28 = load i8*, i8** %6
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 13
br i1 %31, label %32, label %35
32: ; preds = %27
%33 = load i32, i32* %7
%34 = add nsw i32 %33, 1
store i32 %34, i32* %7
br label %35
35: ; preds = %32, %27
br label %36
36: ; preds = %35
%37 = load i8*, i8** %6
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %6
br label %11
39: ; preds = %11
%40 = load i8*, i8** %3
%41 = icmp ne i8* %40, null
br i1 %41, label %42, label %45
42: ; preds = %39
%43 = load i8*, i8** %3
%44 = call i32 @free_string(i8* %43)
br label %45
45: ; preds = %42, %39
%46 = load i32, i32* %8
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [8192 x i8], [8192 x i8]* %5, i64 0, i64 %47
store i8 0, i8* %48
%49 = getelementptr inbounds [8192 x i8], [8192 x i8]* %5, i64 0, i64 0
%50 = call i8* @str_dup(i8* %49)
ret i8* %50
}

LLVM IR (-O2):
define i8* @string_delete(i8* %0, i32 %1) {
%3 = alloca [8192 x i8]
%4 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 0
store i8 0, i8* %4
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 0
br i1 %6, label %25, label %7
7: ; preds = %2, %17
%8 = phi i8 [ %23, %17 ], [ %5, %2 ]
%9 = phi i32 [ %18, %17 ], [ 0, %2 ]
%10 = phi i32 [ %21, %17 ], [ 1, %2 ]
%11 = phi i8* [ %22, %17 ], [ %0, %2 ]
%12 = icmp eq i32 %10, %1
br i1 %12, label %17, label %13
13: ; preds = %7
%14 = sext i32 %9 to i64
%15 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 %14
store i8 %8, i8* %15
%16 = add nsw i32 %9, 1
br label %17
17: ; preds = %13, %7
%18 = phi i32 [ %16, %13 ], [ %9, %7 ]
%19 = icmp eq i8 %8, 13
%20 = zext i1 %19 to i32
%21 = add nuw nsw i32 %10, %20
%22 = getelementptr inbounds i8, i8* %11, i64 1
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 0
br i1 %24, label %25, label %7
25: ; preds = %17, %2
%26 = phi i32 [ 0, %2 ], [ %18, %17 ]
%27 = tail call i32 @free_string(i8* %0)
%28 = sext i32 %26 to i64
%29 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 %28
store i8 0, i8* %29
%30 = call i8* @str_dup(i8* %4)
ret i8* %30
}