#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 atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
scalar_t__ get_line(char *, int /*<<< orphan*/);
scalar_t__ piece(char *, char, char *, int);
int /*<<< orphan*/ piece_quoted(char *, char, char *, int, char);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int main(int argc, char **argv) {
  char buffer[4096];
  char offset_str[128];
  char component[4096];
  char delimiter;
  char quote_delimiter;
  char *offset_list_string;
  int offset, i;
  if (argc != 4) {
    fprintf(stderr,
            "Usage: %s delimiter quote_delimiter offset_1[,...,offset_n]\n",
            argv[0]);
    exit(1);
  }
  delimiter = *argv[1];
  quote_delimiter = *argv[2];
  offset_list_string = argv[3];
  while (get_line(buffer, stdin)) {
    for (i = 0; piece(offset_str, ',', offset_list_string, i); i++) {
      offset = atoi(offset_str);
      if (offset < 0) {
        fprintf(stderr, "ERROR in :%s: Offset (%d) is less than zero\n",
                argv[0], offset);
        exit(1);
      }
      if (!piece_quoted(component, delimiter, buffer, offset,
                        quote_delimiter)) {
        fprintf(stderr,
                "Warning %s: There are less than %d delimiters (%c) in: (%s)\n",
                argv[0], offset, delimiter, buffer);
      } else {
        if (i == 0)
          printf("%s", component);
        else
          printf("%c%s", delimiter, component);
      }
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20b0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     11bb <main+0x4b>
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe56(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%al
mov    %al,-0x2091(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    (%rax),%al
mov    %al,-0x2092(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x20a0(%rbp)
lea    -0x1010(%rbp),%rdi
mov    0x2df0(%rip),%rax
mov    (%rax),%esi
call   1030 <get_line@plt>
cmp    $0x0,%rax
je     1367 <main+0x1f7>
movl   $0x0,-0x20a8(%rbp)
lea    -0x1090(%rbp),%rdi
mov    -0x20a0(%rbp),%rdx
mov    -0x20a8(%rbp),%ecx
mov    $0x2c,%esi
call   1090 <piece@plt>
cmp    $0x0,%rax
je     1354 <main+0x1e4>
lea    -0x1090(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x20a4(%rbp)
cmpl   $0x0,-0x20a4(%rbp)
jge    1288 <main+0x118>
mov    0x2d77(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x20a4(%rbp),%ecx
lea    0xdc6(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    -0x2090(%rbp),%rdi
mov    -0x2091(%rbp),%al
lea    -0x1010(%rbp),%rdx
mov    -0x20a4(%rbp),%ecx
movsbl %al,%esi
movsbl -0x2092(%rbp),%r8d
ff
call   1060 <piece_quoted@plt>
cmp    $0x0,%eax
jne    12f3 <main+0x183>
mov    0x2d16(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x20a4(%rbp),%ecx
movsbl -0x2091(%rbp),%r8d
ff
lea    -0x1010(%rbp),%r9
lea    0xd83(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    133b <main+0x1cb>
cmpl   $0x0,-0x20a8(%rbp)
jne    131a <main+0x1aa>
lea    -0x2090(%rbp),%rsi
lea    0xd9b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1336 <main+0x1c6>
movsbl -0x2091(%rbp),%esi
lea    -0x2090(%rbp),%rdx
lea    0xd78(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    133b <main+0x1cb>
jmp    1340 <main+0x1d0>
mov    -0x20a8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20a8(%rbp)
jmp    1213 <main+0xa3>
lea    0xd4a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11ea <main+0x7a>
xor    %eax,%eax
add    $0x20b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20a8,%rsp
cmp    $0x4,%edi
jne    139f <main+0x21f>
mov    0x8(%rsi),%rax
mov    0x10(%rsi),%rcx
movsbl (%rax),%ebp
mov    (%rcx),%r14b
mov    %rsi,0x10(%rsp)
mov    0x18(%rsi),%rax
mov    %rax,0x18(%rsp)
mov    0x2e2b(%rip),%rax
mov    (%rax),%esi
lea    0xa0(%rsp),%rdi
call   1040 <get_line@plt>
test   %rax,%rax
je     135f <main+0x1df>
lea    0x20(%rsp),%r13
movsbl %r14b,%eax
mov    %eax,0xc(%rsp)
lea    0x10a0(%rsp),%rbx
jmp    1219 <main+0x99>
nopl   0x0(%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x2de7(%rip),%rax
mov    (%rax),%esi
lea    0xa0(%rsp),%rdi
call   1040 <get_line@plt>
test   %rax,%rax
je     135f <main+0x1df>
mov    %r13,%rdi
mov    $0x2c,%esi
mov    0x18(%rsp),%rdx
xor    %ecx,%ecx
call   10a0 <piece@plt>
test   %rax,%rax
je     11f0 <main+0x70>
mov    %r13,%rdi
call   1080 <atoi@plt>
mov    %eax,%r12d
test   %eax,%eax
js     1373 <main+0x1f3>
mov    %rbx,%rdi
mov    %ebp,%esi
lea    0xa0(%rsp),%r14
mov    %r14,%rdx
mov    %r12d,%ecx
mov    0xc(%rsp),%r8d
call   1070 <piece_quoted@plt>
test   %eax,%eax
je     1280 <main+0x100>
lea    0xe3c(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    12a8 <main+0x128>
nopl   0x0(%rax)
mov    0x2d51(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rsp),%rax
mov    (%rax),%rdx
lea    0xdd2(%rip),%rsi
mov    %r12d,%ecx
mov    %ebp,%r8d
mov    %r14,%r9
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %r13,%rdi
mov    $0x2c,%esi
mov    0x18(%rsp),%rdx
mov    $0x1,%ecx
call   10a0 <piece@plt>
test   %rax,%rax
je     11f0 <main+0x70>
mov    $0x2,%r14d
jmp    1305 <main+0x185>
lea    0xdd0(%rip),%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r13,%rdi
mov    $0x2c,%esi
mov    0x18(%rsp),%rdx
mov    %r14d,%ecx
call   10a0 <piece@plt>
add    $0x1,%r14d
test   %rax,%rax
je     11f0 <main+0x70>
mov    %r13,%rdi
call   1080 <atoi@plt>
mov    %eax,%r12d
test   %eax,%eax
js     1373 <main+0x1f3>
mov    %rbx,%rdi
mov    %ebp,%esi
lea    0xa0(%rsp),%r15
mov    %r15,%rdx
mov    %r12d,%ecx
mov    0xc(%rsp),%r8d
call   1070 <piece_quoted@plt>
test   %eax,%eax
jne    12d0 <main+0x150>
mov    0x2c9c(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rsp),%rax
mov    (%rax),%rdx
lea    0xd1d(%rip),%rsi
mov    %r12d,%ecx
mov    %ebp,%r8d
mov    %r15,%r9
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    12e3 <main+0x163>
xor    %eax,%eax
add    $0x20a8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c5e(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rsp),%rax
mov    (%rax),%rdx
lea    0xcb2(%rip),%rsi
mov    %r12d,%ecx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    0x2c32(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xc4e(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [61 x i8] c"Usage: %s delimiter quote_delimiter offset_1[,...,offset_n]\0A\00"
@stdin = global i32 0
@.str.1 = [45 x i8] c"ERROR in :%s: Offset (%d) is less than zero\0A\00"
@.str.2 = [61 x i8] c"Warning %s: There are less than %d delimiters (%c) in: (%s)\0A\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [5 x i8] c"%c%s\00"
@.str.5 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [4096 x i8]
%7 = alloca [128 x i8]
%8 = alloca [4096 x i8]
%9 = alloca i8
%10 = alloca i8
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 4
br i1 %15, label %16, label %23
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = load i8, i8* %26
store i8 %27, i8* %9
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 2
%30 = load i8*, i8** %29
%31 = load i8, i8* %30
store i8 %31, i8* %10
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 3
%34 = load i8*, i8** %33
store i8* %34, i8** %11
br label %35
35: ; preds = %94, %23
%36 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%37 = load i32, i32* @stdin
%38 = call i64 @get_line(i8* %36, i32 %37)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %96
40: ; preds = %35
store i32 0, i32* %13
br label %41
41: ; preds = %91, %40
%42 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%43 = load i8*, i8** %11
%44 = load i32, i32* %13
%45 = call i64 @piece(i8* %42, i8 signext 44, i8* %43, i32 %44)
%46 = icmp ne i64 %45, 0
br i1 %46, label %47, label %94
47: ; preds = %41
%48 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%49 = call i32 @atoi(i8* %48)
store i32 %49, i32* %12
%50 = load i32, i32* %12
%51 = icmp slt i32 %50, 0
br i1 %51, label %52, label %60
52: ; preds = %47
%53 = load i32, i32* @stderr
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 0
%56 = load i8*, i8** %55
%57 = load i32, i32* %12
%58 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i8* %56, i32 %57)
%59 = call i32 @exit(i32 1)
unreachable
60: ; preds = %47
%61 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%62 = load i8, i8* %9
%63 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%64 = load i32, i32* %12
%65 = load i8, i8* %10
%66 = call i32 @piece_quoted(i8* %61, i8 signext %62, i8* %63, i32 %64, i8 signext %65)
%67 = icmp ne i32 %66, 0
br i1 %67, label %78, label %68
68: ; preds = %60
%69 = load i32, i32* @stderr
%70 = load i8**, i8*** %5
%71 = getelementptr inbounds i8*, i8** %70, i64 0
%72 = load i8*, i8** %71
%73 = load i32, i32* %12
%74 = load i8, i8* %9
%75 = sext i8 %74 to i32
%76 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%77 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.2, i64 0, i64 0), i8* %72, i32 %73, i32 %75, i8* %76)
br label %90
78: ; preds = %60
%79 = load i32, i32* %13
%80 = icmp eq i32 %79, 0
br i1 %80, label %81, label %84
81: ; preds = %78
%82 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %82)
br label %89
84: ; preds = %78
%85 = load i8, i8* %9
%86 = sext i8 %85 to i32
%87 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %86, i8* %87)
br label %89
89: ; preds = %84, %81
br label %90
90: ; preds = %89, %68
br label %91
91: ; preds = %90
%92 = load i32, i32* %13
%93 = add nsw i32 %92, 1
store i32 %93, i32* %13
br label %41
94: ; preds = %41
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %35
96: ; preds = %35
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [61 x i8] c"Usage: %s delimiter quote_delimiter offset_1[,...,offset_n]\0A\00"
@stdin = global i32 0
@.str.1 = [45 x i8] c"ERROR in :%s: Offset (%d) is less than zero\0A\00"
@.str.2 = [61 x i8] c"Warning %s: There are less than %d delimiters (%c) in: (%s)\0A\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [5 x i8] c"%c%s\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4096 x i8]
%4 = alloca [128 x i8]
%5 = alloca [4096 x i8]
%6 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%9 = icmp eq i32 %0, 4
br i1 %9, label %15, label %10
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8*, i8** %1
%13 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = tail call i32 @exit(i32 1)
unreachable
15: ; preds = %2
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = load i8, i8* %17
%19 = getelementptr inbounds i8*, i8** %1, i64 2
%20 = load i8*, i8** %19
%21 = load i8, i8* %20
%22 = getelementptr inbounds i8*, i8** %1, i64 3
%23 = load i8*, i8** %22
%24 = load i32, i32* @stdin
%25 = call i64 @get_line(i8* %6, i32 %24)
%26 = icmp eq i64 %25, 0
br i1 %26, label %75, label %27
27: ; preds = %15
%28 = sext i8 %18 to i32
br label %29
29: ; preds = %27, %70
%30 = call i64 @piece(i8* %7, i8 signext 44, i8* %23, i32 0)
%31 = icmp eq i64 %30, 0
br i1 %31, label %70, label %32
32: ; preds = %29
%33 = call i32 @atoi(i8* %7)
%34 = icmp slt i32 %33, 0
br i1 %34, label %51, label %35
35: ; preds = %32
%36 = call i32 @piece_quoted(i8* %8, i8 signext %18, i8* %6, i32 %33, i8 signext %21)
%37 = icmp eq i32 %36, 0
br i1 %37, label %40, label %38
38: ; preds = %35
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %8)
br label %44
40: ; preds = %35
%41 = load i32, i32* @stderr
%42 = load i8*, i8** %1
%43 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.2, i64 0, i64 0), i8* %42, i32 %33, i32 %28, i8* %6)
br label %44
44: ; preds = %40, %38
%45 = call i64 @piece(i8* %7, i8 signext 44, i8* %23, i32 1)
%46 = icmp eq i64 %45, 0
br i1 %46, label %70, label %47
47: ; preds = %44, %66
%48 = phi i32 [ %67, %66 ], [ 1, %44 ]
%49 = call i32 @atoi(i8* %7)
%50 = icmp slt i32 %49, 0
br i1 %50, label %51, label %57
51: ; preds = %32, %47
%52 = phi i32 [ %49, %47 ], [ %33, %32 ]
%53 = load i32, i32* @stderr
%54 = load i8*, i8** %1
%55 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i8* %54, i32 %52)
%56 = call i32 @exit(i32 1)
unreachable
57: ; preds = %47
%58 = call i32 @piece_quoted(i8* %8, i8 signext %18, i8* %6, i32 %49, i8 signext %21)
%59 = icmp eq i32 %58, 0
br i1 %59, label %60, label %64
60: ; preds = %57
%61 = load i32, i32* @stderr
%62 = load i8*, i8** %1
%63 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.2, i64 0, i64 0), i8* %62, i32 %49, i32 %28, i8* %6)
br label %66
64: ; preds = %57
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %28, i8* %8)
br label %66
66: ; preds = %60, %64
%67 = add nuw nsw i32 %48, 1
%68 = call i64 @piece(i8* %7, i8 signext 44, i8* %23, i32 %67)
%69 = icmp eq i64 %68, 0
br i1 %69, label %70, label %47
70: ; preds = %66, %44, %29
%71 = call i32 @putchar(i32 10)
%72 = load i32, i32* @stdin
%73 = call i64 @get_line(i8* %6, i32 %72)
%74 = icmp eq i64 %73, 0
br i1 %74, label %75, label %29
75: ; preds = %70, %15
ret i32 0
}