#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 *memchr(char *, char, size_t);
int /*<<< orphan*/ memcpy(char *, char *, size_t);
void remcomma(char *line, size_t *len) {
  char *pline = line, *loc;
  size_t plen = *len;
  while ((loc = memchr(pline, ' ', plen)) != NULL) {
    plen -= loc - pline + 1;
    pline = loc;
    if (loc[1] == ',') {
      (void)memcpy(loc, &loc[1], plen);
      (*len)--;
    } else
      pline++;
  }
}


x86 assembly (clang, -O0):
<remcomma>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0x20,%esi
call   1030 <memchr@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11cf <remcomma+0xaf>
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rax
sub    %rax,%rcx
add    $0x1,%rcx
mov    -0x28(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2c,%eax
jne    11be <remcomma+0x9e>
mov    -0x20(%rbp),%rdi
mov    -0x20(%rbp),%rsi
add    $0x1,%rsi
mov    -0x28(%rbp),%rdx
call   1040 <memcpy@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,(%rax)
jmp    11ca <remcomma+0xaa>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1143 <remcomma+0x23>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remcomma>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r12
mov    (%rsi),%r15
mov    $0x20,%esi
mov    %r15,%rdx
call   1030 <memchr@plt>
test   %rax,%rax
je     1198 <remcomma+0x78>
mov    %rax,%rbx
jmp    117a <remcomma+0x5a>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r15,%rdx
call   1040 <memcpy@plt>
addq   $0xffffffffffffffff,(%r14)
mov    %rbx,%r12
mov    %rbx,%rdi
mov    $0x20,%esi
mov    %r15,%rdx
call   1030 <memchr@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1198 <remcomma+0x78>
mov    %r15,%rax
add    %r12,%rax
mov    %rbx,%r15
not    %r15
add    %rax,%r15
lea    0x1(%rbx),%rsi
cmpb   $0x2c,0x1(%rbx)
je     1150 <remcomma+0x30>
mov    %rsi,%rbx
jmp    115f <remcomma+0x3f>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @remcomma(i8* %0, i64* nocapture %1) {
%3 = load i64, i64* %1
%4 = tail call i8* @memchr(i8* %0, i8 signext 32, i64 %3)
%5 = icmp eq i8* %4, null
br i1 %5, label %26, label %6
6: ; preds = %2, %22
%7 = phi i8* [ %24, %22 ], [ %4, %2 ]
%8 = phi i64 [ %14, %22 ], [ %3, %2 ]
%9 = phi i8* [ %23, %22 ], [ %0, %2 ]
%10 = ptrtoint i8* %7 to i64
%11 = ptrtoint i8* %9 to i64
%12 = xor i64 %10, -1
%13 = add i64 %8, %11
%14 = add i64 %13, %12
%15 = getelementptr inbounds i8, i8* %7, i64 1
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 44
br i1 %17, label %18, label %22
18: ; preds = %6
%19 = tail call i32 @memcpy(i8* %7, i8* %15, i64 %14)
%20 = load i64, i64* %1
%21 = add i64 %20, -1
store i64 %21, i64* %1
br label %22
22: ; preds = %6, %18
%23 = phi i8* [ %7, %18 ], [ %15, %6 ]
%24 = tail call i8* @memchr(i8* %23, i8 signext 32, i64 %14)
%25 = icmp eq i8* %24, null
br i1 %25, label %26, label %6
26: ; preds = %22, %2
ret void
}