#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 */
int /*<<< orphan*/ piece(char *, char, char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *);
void test_escaped_delimiter() {
  char str[100];
  char buffer[100];
  sprintf(str, "label: Note\\: this should be one piece");
  printf("str = (%s)\n", str);
  printf("should be: (Note: this should be one piece)\n");
  piece(buffer, ':', str, 1);
  printf("is:        (%s)\n", buffer);
  sprintf(str, "label= Note\\= this should be one piece");
  printf("str = (%s)\n", str);
  printf("should be: (Note= this should be one piece)\n");
  piece(buffer, '=', str, 1);
  printf("is:        (%s)\n", buffer);
}


x86 assembly (clang, -O0):
<test_escaped_delimiter>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
lea    -0x70(%rbp),%rdi
lea    0xeba(%rip),%rsi
call   1040 <sprintf@plt>
lea    -0x70(%rbp),%rsi
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xe0(%rbp),%rdi
lea    -0x70(%rbp),%rdx
mov    $0x3a,%esi
mov    $0x1,%ecx
call   1050 <piece@plt>
lea    -0xe0(%rbp),%rsi
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x70(%rbp),%rdi
lea    0xecc(%rip),%rsi
call   1040 <sprintf@plt>
lea    -0x70(%rbp),%rsi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xe0(%rbp),%rdi
lea    -0x70(%rbp),%rdx
mov    $0x3d,%esi
mov    $0x1,%ecx
call   1050 <piece@plt>
lea    -0xe0(%rbp),%rsi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_escaped_delimiter>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xe0,%rsp
movups 0xeb9(%rip),%xmm0
movaps %xmm0,(%rsp)
movups 0xebe(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movabs $0x65636569702065,%r13
mov    %r13,0x1f(%rsp)
lea    0xeba(%rip),%r15
mov    %rsp,%r14
mov    %r15,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xee7(%rip),%rdi
call   1030 <puts@plt>
lea    0x70(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x3a,%esi
mov    %r14,%rdx
mov    $0x1,%ecx
call   1050 <piece@plt>
lea    0xe89(%rip),%r12
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13,0x1f(%rsp)
movups 0xe81(%rip),%xmm0
movaps %xmm0,(%rsp)
movups 0xe86(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
mov    %r15,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb0(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0x3d,%esi
mov    %r14,%rdx
mov    $0x1,%ecx
call   1050 <piece@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xe0,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [39 x i8] c"label: Note\\: this should be one piece\00"
@.str.1 = [12 x i8] c"str = (%s)\0A\00"
@.str.2 = [45 x i8] c"should be: (Note: this should be one piece)\0A\00"
@.str.3 = [17 x i8] c"is: (%s)\0A\00"
@.str.4 = [39 x i8] c"label= Note\\= this should be one piece\00"
@.str.5 = [45 x i8] c"should be: (Note= this should be one piece)\0A\00"
define void @test_escaped_delimiter() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = call i32 @sprintf(i8* %3, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%10 = call i32 @piece(i8* %8, i8 signext 58, i8* %9, i32 1)
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* %11)
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%14 = call i32 @sprintf(i8* %13, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0))
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0))
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%20 = call i32 @piece(i8* %18, i8 signext 61, i8* %19, i32 1)
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* %21)
ret void
}

LLVM IR (-O2):
@.str = [39 x i8] c"label: Note\\: this should be one piece\00"
@.str.1 = [12 x i8] c"str = (%s)\0A\00"
@.str.3 = [17 x i8] c"is: (%s)\0A\00"
@.str.4 = [39 x i8] c"label= Note\\= this should be one piece\00"
@str = [44 x i8] c"should be: (Note: this should be one piece)\00"
@str.6 = [44 x i8] c"should be: (Note= this should be one piece)\00"
define void @test_escaped_delimiter() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str, i64 0, i64 0))
%7 = call i32 @piece(i8* %4, i8 signext 58, i8* %3, i32 1)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.6, i64 0, i64 0))
%11 = call i32 @piece(i8* %4, i8 signext 61, i8* %3, i32 1)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* %4)
ret void
}