int nxmail_count_addrstr(char *addrstring) {
  char *startptr = addrstring;
  int count = 0;
  if (*startptr)
    count = 1;
  else
    return (0);
  while (1) {
    for (; *startptr != ',' && *startptr; startptr++)
      ;
    if (!*startptr++)
      return (count);
    count++;
  }
}


x86 assembly (clang, -O0):
<nxmail_count_addrstr>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     1130 <nxmail_count_addrstr+0x30>
movl   $0x1,-0x1c(%rbp)
jmp    113c <nxmail_count_addrstr+0x3c>
movl   $0x0,-0x4(%rbp)
jmp    11c2 <nxmail_count_addrstr+0xc2>
jmp    1141 <nxmail_count_addrstr+0x41>
jmp    1146 <nxmail_count_addrstr+0x46>
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x2c,%ecx
mov    %al,-0x1d(%rbp)
je     116b <nxmail_count_addrstr+0x6b>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    117b <nxmail_count_addrstr+0x7b>
jmp    1191 <nxmail_count_addrstr+0x91>
jmp    1180 <nxmail_count_addrstr+0x80>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1146 <nxmail_count_addrstr+0x46>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
cmpb   $0x0,(%rax)
jne    11b4 <nxmail_count_addrstr+0xb4>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11c2 <nxmail_count_addrstr+0xc2>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1141 <nxmail_count_addrstr+0x41>
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<nxmail_count_addrstr>:
cmpb   $0x0,(%rdi)
je     1126 <nxmail_count_addrstr+0x26>
mov    $0x1,%eax
nopw   0x0(%rax,%rax,1)
add    $0x1,%rdi
movzbl -0x1(%rdi),%ecx
test   %cl,%cl
je     1128 <nxmail_count_addrstr+0x28>
cmp    $0x2c,%cl
jne    1110 <nxmail_count_addrstr+0x10>
add    $0x1,%eax
jmp    1110 <nxmail_count_addrstr+0x10>
xor    %eax,%eax
ret

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

LLVM IR (-O2):
define i32 @nxmail_count_addrstr(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %15, label %4
4: ; preds = %1, %12
%5 = phi i8* [ %13, %12 ], [ %0, %1 ]
%6 = phi i32 [ %14, %12 ], [ 1, %1 ]
br label %7
7: ; preds = %10, %4
%8 = phi i8* [ %5, %4 ], [ %11, %10 ]
%9 = load i8, i8* %8
switch i8 %9, label %10 [
i8 0, label %15
i8 44, label %12
]
10: ; preds = %7
%11 = getelementptr inbounds i8, i8* %8, i64 1
br label %7
12: ; preds = %7
%13 = getelementptr inbounds i8, i8* %8, i64 1
%14 = add nuw nsw i32 %6, 1
br label %4
15: ; preds = %7, %1
%16 = phi i32 [ 0, %1 ], [ %6, %7 ]
ret i32 %16
}