#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 size_t int32_t;
typedef int /*<<< orphan*/ charBuf;
typedef int /*<<< orphan*/ UChar;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, size_t, size_t, char *);
int /*<<< orphan*/ u_austrncpy(char *, int /*<<< orphan*/ *, int);
void printTextRange(UChar *str, int32_t start, int32_t end) {
  char charBuf[1000];
  UChar savedEndChar;
  savedEndChar = str[end];
  str[end] = 0;
  u_austrncpy(charBuf, str + start, sizeof(charBuf) - 1);
  charBuf[sizeof(charBuf) - 1] = 0;
  printf("string[%2d..%2d] \"%s\"\n", start, end - 1, charBuf);
  str[end] = savedEndChar;
}


x86 assembly (clang, -O0):
<printTextRange>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x404(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
lea    -0x400(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
mov    $0x3e7,%edx
call   1040 <u_austrncpy@plt>
movb   $0x0,-0x19(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
sub    $0x1,%rdx
lea    -0x400(%rbp),%rcx
lea    0xe6b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x404(%rbp),%edx
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printTextRange>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x3f0,%rsp
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rdi,%rdx,4),%ebp
movl   $0x0,(%rdi,%rdx,4)
lea    (%rdi,%rsi,4),%rsi
mov    %rsp,%r12
mov    %r12,%rdi
mov    $0x3e7,%edx
call   1040 <u_austrncpy@plt>
movb   $0x0,0x3e7(%rsp)
lea    -0x1(%r15),%rdx
lea    0xe97(%rip),%rdi
mov    %r14,%rsi
mov    %r12,%rcx
call   1030 <printf@plt>
mov    %ebp,(%rbx,%r15,4)
add    $0x3f0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"string[%2d..%2d] \22%s\22\0A\00"
define void @printTextRange(i32* %0, i64 %1, i64 %2) {
%4 = alloca i32*
%5 = alloca i64
%6 = alloca i64
%7 = alloca [1000 x i8]
%8 = alloca i32
store i32* %0, i32** %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%9 = load i32*, i32** %4
%10 = load i64, i64* %6
%11 = getelementptr inbounds i32, i32* %9, i64 %10
%12 = load i32, i32* %11
store i32 %12, i32* %8
%13 = load i32*, i32** %4
%14 = load i64, i64* %6
%15 = getelementptr inbounds i32, i32* %13, i64 %14
store i32 0, i32* %15
%16 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%17 = load i32*, i32** %4
%18 = load i64, i64* %5
%19 = getelementptr inbounds i32, i32* %17, i64 %18
%20 = call i32 @u_austrncpy(i8* %16, i32* %19, i32 999)
%21 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 999
store i8 0, i8* %21
%22 = load i64, i64* %5
%23 = load i64, i64* %6
%24 = sub i64 %23, 1
%25 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%26 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i64 %22, i64 %24, i8* %25)
%27 = load i32, i32* %8
%28 = load i32*, i32** %4
%29 = load i64, i64* %6
%30 = getelementptr inbounds i32, i32* %28, i64 %29
store i32 %27, i32* %30
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"string[%2d..%2d] \22%s\22\0A\00"
define void @printTextRange(i32* %0, i64 %1, i64 %2) {
%4 = alloca [1000 x i8]
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%6 = getelementptr inbounds i32, i32* %0, i64 %2
%7 = load i32, i32* %6
store i32 0, i32* %6
%8 = getelementptr inbounds i32, i32* %0, i64 %1
%9 = call i32 @u_austrncpy(i8* %5, i32* %8, i32 999)
%10 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 999
store i8 0, i8* %10
%11 = add i64 %2, -1
%12 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i64 %1, i64 %11, i8* %5)
store i32 %7, i32* %6
ret void
}