#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 *easy_malloc(size_t);
int /*<<< orphan*/ memcpy(char *, char *, size_t);
char *strchr(char *, char const);
int strlen(char const *);
char *strstr(char const *, char const *);
char *extract_string_from_line_without_exit(char *line,
                                            const char *start_string,
                                            const char end_char) {
  if (!(line = strstr((const char *)line, start_string))) {
    return NULL;
  }
  char *start = strstr(line, start_string) + strlen(start_string);
  char *end = strchr(start, end_char);
  char *rss_string = easy_malloc((size_t)(end - start + 1) * sizeof(char));
  memcpy(rss_string, start, (size_t)(end - start) * sizeof(char));
  rss_string[end - start] = '\0';
  return rss_string;
}


x86 assembly (clang, -O0):
<extract_string_from_line_without_exit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %dl,%al
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %al,-0x19(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <strstr@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    118d <extract_string_from_line_without_exit+0x3d>
movq   $0x0,-0x8(%rbp)
jmp    121b <extract_string_from_line_without_exit+0xcb>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <strstr@plt>
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
movsbl -0x19(%rbp),%esi
call   1050 <strchr@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rax
sub    %rax,%rdi
add    $0x1,%rdi
shl    $0x0,%rdi
call   1030 <easy_malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x28(%rbp),%rax
sub    %rax,%rdx
shl    $0x0,%rdx
call   1060 <memcpy@plt>
mov    -0x38(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    -0x28(%rbp),%rdx
sub    %rdx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extract_string_from_line_without_exit>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%rbx
call   1070 <strstr@plt>
test   %rax,%rax
je     11b6 <extract_string_from_line_without_exit+0x66>
mov    %rax,%rdi
mov    %rbx,%rsi
call   1070 <strstr@plt>
mov    %rax,%r15
mov    %rbx,%rdi
call   1040 <strlen@plt>
movslq %eax,%rbp
add    %r15,%rbp
movsbl %r14b,%esi
mov    %rbp,%rdi
call   1050 <strchr@plt>
mov    %rax,%rbx
sub    %rbp,%rbx
lea    0x1(%rbx),%rdi
call   1030 <easy_malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
call   1060 <memcpy@plt>
movb   $0x0,(%r14,%rbx,1)
jmp    11b9 <extract_string_from_line_without_exit+0x69>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i8* @extract_string_from_line_without_exit(i8* %0, i8* %1, i8 signext %2) {
%4 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) %1)
%5 = icmp eq i8* %4, null
br i1 %5, label %19, label %6
6: ; preds = %3
%7 = tail call i8* @strstr(i8* %4, i8* dereferenceable(1) %1)
%8 = tail call i32 @strlen(i8* %1)
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %7, i64 %9
%11 = tail call i8* @strchr(i8* dereferenceable(1) %10, i8 signext %2)
%12 = ptrtoint i8* %11 to i64
%13 = ptrtoint i8* %10 to i64
%14 = sub i64 %12, %13
%15 = add nsw i64 %14, 1
%16 = tail call i8* @easy_malloc(i64 %15)
%17 = tail call i32 @memcpy(i8* %16, i8* %10, i64 %14)
%18 = getelementptr inbounds i8, i8* %16, i64 %14
store i8 0, i8* %18
br label %19
19: ; preds = %3, %6
%20 = phi i8* [ %16, %6 ], [ null, %3 ]
ret i8* %20
}