#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 */
void __xassert_failed(char *, char *, int, char *);
int /*<<< orphan*/ _xstrcat(char **, char *);
int /*<<< orphan*/ memcpy(char *, char *, size_t);
void _xmemcat(char **str, char *start, char *end) {
  char buf[4096];
  size_t len;
  (void)({
    (end >= start)
        ? ((void)0)
        : __xassert_failed(
              "end >= start",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/Q-Leap-Networks/debian-slurm/refs/"
              "heads/master/src/common/xstring.c",
              316, "");
  });
  len = (size_t)end - (size_t)start;
  if (len == 0)
    return;
  if (len > 4095)
    len = 4095;
  memcpy(buf, start, len);
  buf[len] = '\0';
  _xstrcat(&(*str), buf);
}


x86 assembly (clang, -O0):
<_xmemcat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1030,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jb     115a <_xmemcat+0x2a>
jmp    1179 <_xmemcat+0x49>
lea    0xe9f(%rip),%rdi
lea    0xea5(%rip),%rsi
mov    $0x13c,%edx
lea    0xf36(%rip),%rcx
call   1050 <__xassert_failed@plt>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x1028(%rbp)
cmpq   $0x0,-0x1028(%rbp)
jne    119e <_xmemcat+0x6e>
jmp    11f0 <_xmemcat+0xc0>
cmpq   $0xfff,-0x1028(%rbp)
jbe    11ba <_xmemcat+0x8a>
movq   $0xfff,-0x1028(%rbp)
lea    -0x1020(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1028(%rbp),%rdx
call   1040 <memcpy@plt>
mov    -0x1028(%rbp),%rax
movb   $0x0,-0x1020(%rbp,%rax,1)
mov    -0x8(%rbp),%rdi
lea    -0x1020(%rbp),%rsi
call   1030 <_xstrcat@plt>
add    $0x1030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_xmemcat>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1008,%rsp
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %rdi,%r14
cmp    %rsi,%rdx
jae    116b <_xmemcat+0x3b>
lea    0xead(%rip),%rdi
lea    0xeb3(%rip),%rsi
lea    0xf49(%rip),%rcx
mov    $0x13c,%edx
call   1050 <__xassert_failed@plt>
sub    %r15,%rbx
je     11a2 <_xmemcat+0x72>
cmp    $0xfff,%rbx
mov    $0xfff,%r12d
cmovb  %rbx,%r12
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1040 <memcpy@plt>
movb   $0x0,(%rsp,%r12,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <_xstrcat@plt>
add    $0x1008,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [13 x i8] c"end >= start\00"
@.str.1 = [158 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Q-Leap-Networks/debian-slurm/refs/heads/master/src/common/xstring.c\00"
@.str.2 = [1 x i8] zeroinitializer
define void @_xmemcat(i8** %0, i8* %1, i8* %2) {
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [4096 x i8]
%8 = alloca i64
store i8** %0, i8*** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%9 = load i8*, i8** %6
%10 = load i8*, i8** %5
%11 = icmp uge i8* %9, %10
br i1 %11, label %12, label %13
12: ; preds = %3
br label %14
13: ; preds = %3
br label %14
14: ; preds = %13, %12
%15 = load i8*, i8** %6
%16 = ptrtoint i8* %15 to i64
%17 = load i8*, i8** %5
%18 = ptrtoint i8* %17 to i64
%19 = sub i64 %16, %18
store i64 %19, i64* %8
%20 = load i64, i64* %8
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %14
br label %37
23: ; preds = %14
%24 = load i64, i64* %8
%25 = icmp ugt i64 %24, 4095
br i1 %25, label %26, label %27
26: ; preds = %23
store i64 4095, i64* %8
br label %27
27: ; preds = %26, %23
%28 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%29 = load i8*, i8** %5
%30 = load i64, i64* %8
%31 = call i32 @memcpy(i8* %28, i8* %29, i64 %30)
%32 = load i64, i64* %8
%33 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 %32
store i8 0, i8* %33
%34 = load i8**, i8*** %4
%35 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%36 = call i32 @_xstrcat(i8** %34, i8* %35)
br label %37
37: ; preds = %27, %22
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"end >= start\00"
@.str.1 = [158 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Q-Leap-Networks/debian-slurm/refs/heads/master/src/common/xstring.c\00"
@.str.2 = [1 x i8] zeroinitializer
define void @_xmemcat(i8** %0, i8* %1, i8* %2) {
%4 = alloca [4096 x i8]
%5 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%6 = icmp ult i8* %2, %1
br i1 %6, label %7, label %8
7: ; preds = %3
tail call void @__xassert_failed(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([158 x i8], [158 x i8]* @.str.1, i64 0, i64 0), i32 316, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
br label %8
8: ; preds = %3, %7
%9 = ptrtoint i8* %2 to i64
%10 = ptrtoint i8* %1 to i64
%11 = sub i64 %9, %10
%12 = icmp eq i64 %11, 0
br i1 %12, label %19, label %13
13: ; preds = %8
%14 = icmp ult i64 %11, 4095
%15 = select i1 %14, i64 %11, i64 4095
%16 = call i32 @memcpy(i8* %5, i8* %1, i64 %15)
%17 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 %15
store i8 0, i8* %17
%18 = call i32 @_xstrcat(i8** %0, i8* %5)
br label %19
19: ; preds = %8, %13
ret void
}