#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 *piece_unknown(char *, char *, char *, int);
int /*<<< orphan*/ printf(char *, char *);
void test_piece_quoted_string(void) {
  char buffer[128];
  char *string;
  char delimiter = 0;
  string =
      "12-MONTH IRA CD (xxxxxx577-30),$4.43 ,\"$2,621.54 \",\"$2,621.54 \"";
  printf("piece_offset = 0, should be [12-MONTH IRA CD (xxxxxx577-30)] is = "
         "[%s]\n",
         piece_unknown(buffer, &delimiter, string, 0));
  printf("piece_offset = 2, should be ($2,621.54): is = (%s)\n",
         piece_unknown(buffer, &delimiter, string, 2));
}


x86 assembly (clang, -O0):
<test_piece_quoted_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movb   $0x0,-0x89(%rbp)
lea    0xec7(%rip),%rax
mov    %rax,-0x88(%rbp)
lea    -0x80(%rbp),%rdi
mov    -0x88(%rbp),%rdx
lea    -0x89(%rbp),%rsi
xor    %ecx,%ecx
call   1040 <piece_unknown@plt>
mov    %rax,%rsi
lea    0xedd(%rip),%rdi
call   1030 <printf@plt>
lea    -0x80(%rbp),%rdi
mov    -0x88(%rbp),%rdx
lea    -0x89(%rbp),%rsi
mov    $0x2,%ecx
call   1040 <piece_unknown@plt>
mov    %rax,%rsi
lea    0xefa(%rip),%rdi
call   1030 <printf@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_piece_quoted_string>:
push   %r15
push   %r14
push   %rbx
sub    $0x90,%rsp
movb   $0x0,0xf(%rsp)
lea    0xec8(%rip),%r14
lea    0x10(%rsp),%rbx
lea    0xf(%rsp),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
xor    %ecx,%ecx
call   1040 <piece_unknown@plt>
lea    0xee7(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    $0x2,%ecx
call   1040 <piece_unknown@plt>
lea    0xf0d(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
add    $0x90,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [64 x i8] c"12-MONTH IRA CD (xxxxxx577-30),$4.43 ,\22$2,621.54 \22,\22$2,621.54 \22\00"
@.str.1 = [72 x i8] c"piece_offset = 0, should be [12-MONTH IRA CD (xxxxxx577-30)] is = [%s]\0A\00"
@.str.2 = [52 x i8] c"piece_offset = 2, should be ($2,621.54): is = (%s)\0A\00"
define void @test_piece_quoted_string() {
%1 = alloca [128 x i8]
%2 = alloca i8*
%3 = alloca i8
store i8 0, i8* %3
store i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0), i8** %2
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%5 = load i8*, i8** %2
%6 = call i8* @piece_unknown(i8* %4, i8* %3, i8* %5, i32 0)
%7 = call i32 @printf(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%8 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%9 = load i8*, i8** %2
%10 = call i8* @piece_unknown(i8* %8, i8* %3, i8* %9, i32 2)
%11 = call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i8* %10)
ret void
}

LLVM IR (-O2):
@.str = [64 x i8] c"12-MONTH IRA CD (xxxxxx577-30),$4.43 ,\22$2,621.54 \22,\22$2,621.54 \22\00"
@.str.1 = [72 x i8] c"piece_offset = 0, should be [12-MONTH IRA CD (xxxxxx577-30)] is = [%s]\0A\00"
@.str.2 = [52 x i8] c"piece_offset = 2, should be ($2,621.54): is = (%s)\0A\00"
define void @test_piece_quoted_string() {
%1 = alloca [128 x i8]
%2 = alloca i8
%3 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
store i8 0, i8* %2
%4 = call i8* @piece_unknown(i8* %3, i8* %2, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0), i32 0)
%5 = call i32 @printf(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%6 = call i8* @piece_unknown(i8* %3, i8* %2, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0), i32 2)
%7 = call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i8* %6)
ret void
}