char *comma(char *line, char **residue) {
  char *q, *r;
  if ((q = strchr(line, ',')) != ((void *)0)) {
    *q++ = 0;
    if (*q == ' ')
      q++;
  }
  *residue = q;
  if ((r = strchr(line, ' ')) != ((void *)0))
    *r = 0;
  if (*line == ' ')
    line++;
  return line;
}


x86 assembly (clang, -O0):
<comma>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x2c,%esi
call   1030 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     116f <comma+0x5f>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    116a <comma+0x5a>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    116f <comma+0x5f>
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rdi
mov    $0x20,%esi
call   1030 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     119d <comma+0x8d>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    11b9 <comma+0xa9>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<comma>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x2c,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     1141 <comma+0x31>
lea    0x1(%rax),%rdx
movb   $0x0,(%rax)
mov    %rax,%rcx
add    $0x2,%rcx
cmpb   $0x20,0x1(%rax)
cmovne %rdx,%rcx
jmp    1143 <comma+0x33>
xor    %ecx,%ecx
mov    %rcx,(%r14)
mov    %rbx,%rdi
mov    $0x20,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     115b <comma+0x4b>
movb   $0x0,(%rax)
xor    %eax,%eax
cmpb   $0x20,(%rbx)
sete   %al
add    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @comma(i8* %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %3
store i8** %1, i8*** %4
%7 = load i8*, i8** %3
%8 = call i8* @strchr(i8* %7, i32 44)
store i8* %8, i8** %5
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %21
10: ; preds = %2
%11 = load i8*, i8** %5
%12 = getelementptr inbounds i8, i8* %11, i32 1
store i8* %12, i8** %5
store i8 0, i8* %11
%13 = load i8*, i8** %5
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 32
br i1 %16, label %17, label %20
17: ; preds = %10
%18 = load i8*, i8** %5
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %5
br label %20
20: ; preds = %17, %10
br label %21
21: ; preds = %20, %2
%22 = load i8*, i8** %5
%23 = load i8**, i8*** %4
store i8* %22, i8** %23
%24 = load i8*, i8** %3
%25 = call i8* @strchr(i8* %24, i32 32)
store i8* %25, i8** %6
%26 = icmp ne i8* %25, null
br i1 %26, label %27, label %29
27: ; preds = %21
%28 = load i8*, i8** %6
store i8 0, i8* %28
br label %29
29: ; preds = %27, %21
%30 = load i8*, i8** %3
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 32
br i1 %33, label %34, label %37
34: ; preds = %29
%35 = load i8*, i8** %3
%36 = getelementptr inbounds i8, i8* %35, i32 1
store i8* %36, i8** %3
br label %37
37: ; preds = %34, %29
%38 = load i8*, i8** %3
ret i8* %38
}

LLVM IR (-O2):
define i8* @comma(i8* %0, i8** nocapture writeonly %1) {
%3 = tail call i8* @strchr(i8* dereferenceable(1) %0, i32 44)
%4 = icmp eq i8* %3, null
br i1 %4, label %11, label %5
5: ; preds = %2
%6 = getelementptr inbounds i8, i8* %3, i64 1
store i8 0, i8* %3
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 32
%9 = getelementptr inbounds i8, i8* %3, i64 2
%10 = select i1 %8, i8* %9, i8* %6
br label %11
11: ; preds = %5, %2
%12 = phi i8* [ null, %2 ], [ %10, %5 ]
store i8* %12, i8** %1
%13 = tail call i8* @strchr(i8* dereferenceable(1) %0, i32 32)
%14 = icmp eq i8* %13, null
br i1 %14, label %16, label %15
15: ; preds = %11
store i8 0, i8* %13
br label %16
16: ; preds = %15, %11
%17 = load i8, i8* %0
%18 = icmp eq i8 %17, 32
%19 = zext i1 %18 to i64
%20 = getelementptr i8, i8* %0, i64 %19
ret i8* %20
}