#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 */
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ emit(char *);
int /*<<< orphan*/ memcpy(char *, char const *, size_t);
void emit_extent(const char *start, const char *end) {
  char buf[32 + 1];
  size_t bufmax = sizeof(buf) - 1;
  buf[32] = 0;
  size_t bytes = end - start + 1;
  while (bytes >= bufmax) {
    memcpy(buf, start, bufmax);
    emit(buf);
    bytes -= bufmax;
    start += bufmax;
  }
  if (bytes == 0)
    return;
  memcpy(buf, start, bytes);
  buf[bytes] = 0;
  emit(buf);
}


x86 assembly (clang, -O0):
<emit_extent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x20,-0x48(%rbp)
movb   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
cmp    -0x48(%rbp),%rax
jb     1197 <emit_extent+0x77>
lea    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x48(%rbp),%rdx
call   1030 <memcpy@plt>
lea    -0x40(%rbp),%rdi
call   1040 <emit@plt>
mov    -0x48(%rbp),%rcx
mov    -0x50(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x50(%rbp)
mov    -0x48(%rbp),%rax
add    -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    114f <emit_extent+0x2f>
cmpq   $0x0,-0x50(%rbp)
jne    11a7 <emit_extent+0x87>
jmp    11ca <emit_extent+0xaa>
lea    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x50(%rbp),%rdx
call   1030 <memcpy@plt>
mov    -0x50(%rbp),%rax
movb   $0x0,-0x40(%rbp,%rax,1)
lea    -0x40(%rbp),%rdi
call   1040 <emit@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<emit_extent>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movb   $0x0,0x20(%rsp)
sub    %rdi,%r14
add    $0x1,%r14
cmp    $0x20,%r14
jb     1176 <emit_extent+0x56>
mov    %rsp,%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x20,%edx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <memcpy@plt>
mov    %r15,%rdi
call   1040 <emit@plt>
add    $0xffffffffffffffe0,%r14
add    $0x20,%rbx
cmp    $0x1f,%r14
ja     1150 <emit_extent+0x30>
test   %r14,%r14
je     1199 <emit_extent+0x79>
mov    %rsp,%r15
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1030 <memcpy@plt>
movb   $0x0,(%rsp,%r14,1)
mov    %r15,%rdi
call   1040 <emit@plt>
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @emit_extent(i8* %0, i8* %1) {
%3 = alloca [33 x i8]
%4 = getelementptr inbounds [33 x i8], [33 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds [33 x i8], [33 x i8]* %3, i64 0, i64 32
store i8 0, i8* %5
%6 = ptrtoint i8* %1 to i64
%7 = ptrtoint i8* %0 to i64
%8 = sub i64 1, %7
%9 = add i64 %8, %6
%10 = icmp ugt i64 %9, 31
br i1 %10, label %11, label %19
11: ; preds = %2, %11
%12 = phi i64 [ %16, %11 ], [ %9, %2 ]
%13 = phi i8* [ %17, %11 ], [ %0, %2 ]
%14 = call i32 @memcpy(i8* %4, i8* %13, i64 32)
%15 = call i32 @emit(i8* %4)
%16 = add i64 %12, -32
%17 = getelementptr inbounds i8, i8* %13, i64 32
%18 = icmp ugt i64 %16, 31
br i1 %18, label %11, label %19
19: ; preds = %11, %2
%20 = phi i8* [ %0, %2 ], [ %17, %11 ]
%21 = phi i64 [ %9, %2 ], [ %16, %11 ]
%22 = icmp eq i64 %21, 0
br i1 %22, label %27, label %23
23: ; preds = %19
%24 = call i32 @memcpy(i8* %4, i8* %20, i64 %21)
%25 = getelementptr inbounds [33 x i8], [33 x i8]* %3, i64 0, i64 %21
store i8 0, i8* %25
%26 = call i32 @emit(i8* %4)
br label %27
27: ; preds = %19, %23
ret void
}