#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 instr(char *, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ timlib_strcpy(char *, char *, int);
int /*<<< orphan*/ timlib_strncpy(char *, char *, int);
char *piece_delete_quote_comma(char *destination, char *source,
                               int piece_offset) {
  int start_offset;
  int end_offset;
  char *delimiter = "\",\"";
  *destination = '\0';
  if (!source)
    return (char *)0;
  if (!*source)
    return "";
  if (piece_offset == 0) {
    start_offset = 0;
  } else {
    start_offset = instr(delimiter, source, piece_offset) + 2;
  }
  end_offset = instr(delimiter, source, piece_offset + 1);
  if (start_offset == 1 && end_offset == -1)
    return (char *)0;
  if (start_offset == 0 && end_offset == -1)
    return "";
  if (start_offset == 0) {
    timlib_strcpy(destination, source + end_offset + 2, 9999);
  } else {
    if (end_offset != -1) {
      timlib_strncpy(destination, source, start_offset);
      strcat(destination, source + end_offset + 2);
    } else {
      timlib_strncpy(destination, source, start_offset - 1);
    }
  }
  return destination;
}


x86 assembly (clang, -O0):
<piece_delete_quote_comma>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
lea    0xea6(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
cmpq   $0x0,-0x18(%rbp)
jne    117d <piece_delete_quote_comma+0x3d>
movq   $0x0,-0x8(%rbp)
jmp    12a4 <piece_delete_quote_comma+0x164>
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
jne    119a <piece_delete_quote_comma+0x5a>
lea    0xe72(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12a4 <piece_delete_quote_comma+0x164>
cmpl   $0x0,-0x1c(%rbp)
jne    11b0 <piece_delete_quote_comma+0x70>
movl   $0x0,-0x20(%rbp)
jmp    11c6 <piece_delete_quote_comma+0x86>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1040 <instr@plt>
add    $0x2,%eax
mov    %eax,-0x20(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
add    $0x1,%edx
call   1040 <instr@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x1,-0x20(%rbp)
jne    11fd <piece_delete_quote_comma+0xbd>
cmpl   $0xffffffff,-0x24(%rbp)
jne    11fd <piece_delete_quote_comma+0xbd>
movq   $0x0,-0x8(%rbp)
jmp    12a4 <piece_delete_quote_comma+0x164>
cmpl   $0x0,-0x20(%rbp)
jne    1221 <piece_delete_quote_comma+0xe1>
cmpl   $0xffffffff,-0x24(%rbp)
jne    1221 <piece_delete_quote_comma+0xe1>
lea    0xdeb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12a4 <piece_delete_quote_comma+0x164>
cmpl   $0x0,-0x20(%rbp)
jne    124d <piece_delete_quote_comma+0x10d>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movslq -0x24(%rbp),%rax
add    %rax,%rsi
add    $0x2,%rsi
mov    $0x270f,%edx
call   1030 <timlib_strcpy@plt>
jmp    129c <piece_delete_quote_comma+0x15c>
cmpl   $0xffffffff,-0x24(%rbp)
je     1284 <piece_delete_quote_comma+0x144>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%edx
call   1060 <timlib_strncpy@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movslq -0x24(%rbp),%rax
add    %rax,%rsi
add    $0x2,%rsi
call   1050 <strcat@plt>
jmp    1297 <piece_delete_quote_comma+0x157>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%edx
sub    $0x1,%edx
call   1060 <timlib_strncpy@plt>
jmp    129c <piece_delete_quote_comma+0x15c>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<piece_delete_quote_comma>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
movb   $0x0,(%rdi)
test   %rsi,%rsi
je     11a6 <piece_delete_quote_comma+0x66>
mov    %rsi,%rbx
lea    0xea9(%rip),%r15
cmpb   $0x0,(%rsi)
je     11a9 <piece_delete_quote_comma+0x69>
mov    %edx,%ebp
mov    %rdi,%r14
test   %edx,%edx
je     1182 <piece_delete_quote_comma+0x42>
lea    0xe91(%rip),%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1040 <instr@plt>
mov    %eax,%r12d
add    $0x2,%r12d
jmp    1185 <piece_delete_quote_comma+0x45>
xor    %r12d,%r12d
add    $0x1,%ebp
lea    0xe71(%rip),%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1040 <instr@plt>
mov    %eax,%ebp
cmp    $0x1,%r12d
jne    11b5 <piece_delete_quote_comma+0x75>
cmp    $0xffffffff,%ebp
jne    11b5 <piece_delete_quote_comma+0x75>
xor    %r15d,%r15d
mov    %r15,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
test   %r12d,%r12d
jne    11bf <piece_delete_quote_comma+0x7f>
cmp    $0xffffffff,%ebp
je     11a9 <piece_delete_quote_comma+0x69>
test   %r12d,%r12d
je     11ec <piece_delete_quote_comma+0xac>
cmp    $0xffffffff,%ebp
je     1206 <piece_delete_quote_comma+0xc6>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r12d,%edx
call   1060 <timlib_strncpy@plt>
movslq %ebp,%rax
lea    (%rbx,%rax,1),%rsi
add    $0x2,%rsi
mov    %r14,%rdi
call   1050 <strcat@plt>
jmp    1218 <piece_delete_quote_comma+0xd8>
movslq %ebp,%rax
lea    (%rbx,%rax,1),%rsi
add    $0x2,%rsi
mov    %r14,%rdi
mov    $0x270f,%edx
call   1030 <timlib_strcpy@plt>
jmp    1218 <piece_delete_quote_comma+0xd8>
add    $0xffffffff,%r12d
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r12d,%edx
call   1060 <timlib_strncpy@plt>
mov    %r14,%r15
jmp    11a9 <piece_delete_quote_comma+0x69>

LLVM IR (-O0):
@.str = [4 x i8] c"\22,\22\00"
@.str.1 = [1 x i8] zeroinitializer
define i8* @piece_delete_quote_comma(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %10
%11 = load i8*, i8** %5
store i8 0, i8* %11
%12 = load i8*, i8** %6
%13 = icmp ne i8* %12, null
br i1 %13, label %15, label %14
14: ; preds = %3
store i8* null, i8** %4
br label %84
15: ; preds = %3
%16 = load i8*, i8** %6
%17 = load i8, i8* %16
%18 = icmp ne i8 %17, 0
br i1 %18, label %20, label %19
19: ; preds = %15
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8** %4
br label %84
20: ; preds = %15
%21 = load i32, i32* %7
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %20
store i32 0, i32* %8
br label %30
24: ; preds = %20
%25 = load i8*, i8** %10
%26 = load i8*, i8** %6
%27 = load i32, i32* %7
%28 = call i32 @instr(i8* %25, i8* %26, i32 %27)
%29 = add nsw i32 %28, 2
store i32 %29, i32* %8
br label %30
30: ; preds = %24, %23
%31 = load i8*, i8** %10
%32 = load i8*, i8** %6
%33 = load i32, i32* %7
%34 = add nsw i32 %33, 1
%35 = call i32 @instr(i8* %31, i8* %32, i32 %34)
store i32 %35, i32* %9
%36 = load i32, i32* %8
%37 = icmp eq i32 %36, 1
br i1 %37, label %38, label %42
38: ; preds = %30
%39 = load i32, i32* %9
%40 = icmp eq i32 %39, -1
br i1 %40, label %41, label %42
41: ; preds = %38
store i8* null, i8** %4
br label %84
42: ; preds = %38, %30
%43 = load i32, i32* %8
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %49
45: ; preds = %42
%46 = load i32, i32* %9
%47 = icmp eq i32 %46, -1
br i1 %47, label %48, label %49
48: ; preds = %45
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8** %4
br label %84
49: ; preds = %45, %42
%50 = load i32, i32* %8
%51 = icmp eq i32 %50, 0
br i1 %51, label %52, label %60
52: ; preds = %49
%53 = load i8*, i8** %5
%54 = load i8*, i8** %6
%55 = load i32, i32* %9
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %54, i64 %56
%58 = getelementptr inbounds i8, i8* %57, i64 2
%59 = call i32 @timlib_strcpy(i8* %53, i8* %58, i32 9999)
br label %82
60: ; preds = %49
%61 = load i32, i32* %9
%62 = icmp ne i32 %61, -1
br i1 %62, label %63, label %75
63: ; preds = %60
%64 = load i8*, i8** %5
%65 = load i8*, i8** %6
%66 = load i32, i32* %8
%67 = call i32 @timlib_strncpy(i8* %64, i8* %65, i32 %66)
%68 = load i8*, i8** %5
%69 = load i8*, i8** %6
%70 = load i32, i32* %9
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i8, i8* %69, i64 %71
%73 = getelementptr inbounds i8, i8* %72, i64 2
%74 = call i32 @strcat(i8* %68, i8* %73)
br label %81
75: ; preds = %60
%76 = load i8*, i8** %5
%77 = load i8*, i8** %6
%78 = load i32, i32* %8
%79 = sub nsw i32 %78, 1
%80 = call i32 @timlib_strncpy(i8* %76, i8* %77, i32 %79)
br label %81
81: ; preds = %75, %63
br label %82
82: ; preds = %81, %52
%83 = load i8*, i8** %5
store i8* %83, i8** %4
br label %84
84: ; preds = %82, %48, %41, %19, %14
%85 = load i8*, i8** %4
ret i8* %85
}

LLVM IR (-O2):
@.str = [4 x i8] c"\22,\22\00"
@.str.1 = [1 x i8] zeroinitializer
define i8* @piece_delete_quote_comma(i8* %0, i8* %1, i32 %2) {
store i8 0, i8* %0
%4 = icmp eq i8* %1, null
br i1 %4, label %39, label %5
5: ; preds = %3
%6 = load i8, i8* %1
%7 = icmp eq i8 %6, 0
br i1 %7, label %39, label %8
8: ; preds = %5
%9 = icmp eq i32 %2, 0
br i1 %9, label %13, label %10
10: ; preds = %8
%11 = tail call i32 @instr(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %1, i32 %2)
%12 = add nsw i32 %11, 2
br label %13
13: ; preds = %8, %10
%14 = phi i32 [ %12, %10 ], [ 0, %8 ]
%15 = add nsw i32 %2, 1
%16 = tail call i32 @instr(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %1, i32 %15)
%17 = icmp eq i32 %14, 1
%18 = icmp eq i32 %16, -1
%19 = select i1 %17, i1 %18, i1 false
br i1 %19, label %39, label %20
20: ; preds = %13
%21 = icmp eq i32 %14, 0
%22 = select i1 %21, i1 %18, i1 false
br i1 %22, label %39, label %23
23: ; preds = %20
br i1 %21, label %24, label %29
24: ; preds = %23
%25 = sext i32 %16 to i64
%26 = getelementptr inbounds i8, i8* %1, i64 %25
%27 = getelementptr inbounds i8, i8* %26, i64 2
%28 = tail call i32 @timlib_strcpy(i8* %0, i8* %27, i32 9999)
br label %39
29: ; preds = %23
br i1 %18, label %36, label %30
30: ; preds = %29
%31 = tail call i32 @timlib_strncpy(i8* %0, i8* %1, i32 %14)
%32 = sext i32 %16 to i64
%33 = getelementptr inbounds i8, i8* %1, i64 %32
%34 = getelementptr inbounds i8, i8* %33, i64 2
%35 = tail call i32 @strcat(i8* %0, i8* %34)
br label %39
36: ; preds = %29
%37 = add nsw i32 %14, -1
%38 = tail call i32 @timlib_strncpy(i8* %0, i8* %1, i32 %37)
br label %39
39: ; preds = %24, %36, %30, %20, %13, %5, %3
%40 = phi i8* [ null, %3 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), %5 ], [ null, %13 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), %20 ], [ %0, %30 ], [ %0, %36 ], [ %0, %24 ]
ret i8* %40
}