#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 *_mymalloc(int, char *, int);
int /*<<< orphan*/ memcpy(char *, char *, int);
char *parse_strdup(char *line_buffer, int start_index, int end_index) {
  char *str = _mymalloc((end_index - start_index + 1) * sizeof(char),
                        "/scratch/repos/new/home/jordi_armengol_estape/"
                        "c-scraper/outputs/2022-01-22/02-19-57/repos/qpliu/"
                        "esolang/refs/heads/master/DGOL/c/parse.c",
                        61);
  memcpy(str, line_buffer + start_index,
         (end_index - start_index) * sizeof(char));
  str[end_index - start_index] = 0;
  return str;
}


x86 assembly (clang, -O0):
<parse_strdup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%eax
sub    -0xc(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
lea    0xeb6(%rip),%rsi
mov    $0x3d,%edx
call   1030 <_mymalloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
movslq -0xc(%rbp),%rax
add    %rax,%rsi
mov    -0x10(%rbp),%eax
sub    -0xc(%rbp),%eax
cltq
shl    $0x0,%rax
mov    %eax,%edx
call   1040 <memcpy@plt>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%ecx
sub    -0xc(%rbp),%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_strdup>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %esi,%r15d
mov    %rdi,%r14
sub    %esi,%ebx
lea    0x1(%rbx),%edi
lea    0xec5(%rip),%rsi
mov    $0x3d,%edx
call   1030 <_mymalloc@plt>
mov    %rax,%rbp
movslq %r15d,%rsi
add    %r14,%rsi
movslq %ebx,%rbx
mov    %rax,%rdi
mov    %ebx,%edx
call   1040 <memcpy@plt>
movb   $0x0,0x0(%rbp,%rbx,1)
mov    %rbp,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [137 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/qpliu/esolang/refs/heads/master/DGOL/c/parse.c\00"
define i8* @parse_strdup(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %6
%9 = load i32, i32* %5
%10 = sub nsw i32 %8, %9
%11 = add nsw i32 %10, 1
%12 = sext i32 %11 to i64
%13 = mul i64 %12, 1
%14 = trunc i64 %13 to i32
%15 = call i8* @_mymalloc(i32 %14, i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str, i64 0, i64 0), i32 61)
store i8* %15, i8** %7
%16 = load i8*, i8** %7
%17 = load i8*, i8** %4
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i32, i32* %6
%22 = load i32, i32* %5
%23 = sub nsw i32 %21, %22
%24 = sext i32 %23 to i64
%25 = mul i64 %24, 1
%26 = trunc i64 %25 to i32
%27 = call i32 @memcpy(i8* %16, i8* %20, i32 %26)
%28 = load i8*, i8** %7
%29 = load i32, i32* %6
%30 = load i32, i32* %5
%31 = sub nsw i32 %29, %30
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %28, i64 %32
store i8 0, i8* %33
%34 = load i8*, i8** %7
ret i8* %34
}

LLVM IR (-O2):
@.str = [137 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/qpliu/esolang/refs/heads/master/DGOL/c/parse.c\00"
define i8* @parse_strdup(i8* %0, i32 %1, i32 %2) {
%4 = sub nsw i32 %2, %1
%5 = add nsw i32 %4, 1
%6 = tail call i8* @_mymalloc(i32 %5, i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str, i64 0, i64 0), i32 61)
%7 = sext i32 %1 to i64
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = sext i32 %4 to i64
%10 = tail call i32 @memcpy(i8* %6, i8* %8, i32 %4)
%11 = getelementptr inbounds i8, i8* %6, i64 %9
store i8 0, i8* %11
ret i8* %6
}