int dcbCleanupSize_x86_fast_gnu(const char *signature) {
  const char *ptr = signature;
  char ch;
  int size = 0;
  int regs = 0;
  while ((ch = *ptr++) != ')') {
    switch (ch) {
    case 'f':
      size += 4;
      break;
    case 'd':
      size += 8;
      break;
    case 'l':
    case 'L':
      regs = 2;
      size += 8;
      break;
    default:
      if (regs < 2)
        regs++;
      else
        size += 4;
      break;
    }
  }
  return size;
}


x86 assembly (clang, -O0):
<dcbCleanupSize_x86_fast_gnu>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%al
mov    %al,-0x11(%rbp)
movsbl %al,%eax
cmp    $0x29,%eax
je     11c4 <dcbCleanupSize_x86_fast_gnu+0xc4>
movsbl -0x11(%rbp),%eax
add    $0xffffffb4,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x20,%eax
ja     1199 <dcbCleanupSize_x86_fast_gnu+0x99>
mov    -0x28(%rbp),%rax
lea    0xea1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x18(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x18(%rbp)
jmp    11bf <dcbCleanupSize_x86_fast_gnu+0xbf>
mov    -0x18(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x18(%rbp)
jmp    11bf <dcbCleanupSize_x86_fast_gnu+0xbf>
movl   $0x2,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x18(%rbp)
jmp    11bf <dcbCleanupSize_x86_fast_gnu+0xbf>
cmpl   $0x2,-0x1c(%rbp)
jge    11b1 <dcbCleanupSize_x86_fast_gnu+0xb1>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11ba <dcbCleanupSize_x86_fast_gnu+0xba>
mov    -0x18(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x18(%rbp)
jmp    11bf <dcbCleanupSize_x86_fast_gnu+0xbf>
jmp    111e <dcbCleanupSize_x86_fast_gnu+0x1e>
mov    -0x18(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<dcbCleanupSize_x86_fast_gnu>:
mov    (%rdi),%cl
xor    %eax,%eax
cmp    $0x29,%cl
jne    110a <dcbCleanupSize_x86_fast_gnu+0xa>
ret
add    $0x1,%rdi
xor    %edx,%edx
lea    0xee9(%rip),%rsi
xor    %eax,%eax
jmp    113c <dcbCleanupSize_x86_fast_gnu+0x3c>
nopl   0x0(%rax,%rax,1)
add    $0x8,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl (%rdi),%ecx
add    $0x1,%rdi
cmp    $0x29,%cl
je     1109 <dcbCleanupSize_x86_fast_gnu+0x9>
movsbl %cl,%ecx
add    $0xffffffb4,%ecx
cmp    $0x20,%ecx
ja     1160 <dcbCleanupSize_x86_fast_gnu+0x60>
movslq (%rsi,%rcx,4),%rcx
add    %rsi,%rcx
jmp    *%rcx
add    $0x8,%eax
mov    $0x2,%edx
jmp    1130 <dcbCleanupSize_x86_fast_gnu+0x30>
nopw   0x0(%rax,%rax,1)
cmp    $0x1,%edx
jg     1175 <dcbCleanupSize_x86_fast_gnu+0x75>
add    $0x1,%edx
jmp    1130 <dcbCleanupSize_x86_fast_gnu+0x30>
nopw   0x0(%rax,%rax,1)
add    $0x4,%eax
jmp    1130 <dcbCleanupSize_x86_fast_gnu+0x30>
add    $0x4,%eax
jmp    1153 <dcbCleanupSize_x86_fast_gnu+0x53>

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

LLVM IR (-O2):
define i32 @dcbCleanupSize_x86_fast_gnu(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 41
br i1 %3, label %28, label %4
4: ; preds = %1, %23
%5 = phi i8 [ %26, %23 ], [ %2, %1 ]
%6 = phi i8* [ %9, %23 ], [ %0, %1 ]
%7 = phi i32 [ %25, %23 ], [ 0, %1 ]
%8 = phi i32 [ %24, %23 ], [ 0, %1 ]
%9 = getelementptr inbounds i8, i8* %6, i64 1
%10 = sext i8 %5 to i32
switch i32 %10, label %17 [
i32 102, label %11
i32 100, label %13
i32 108, label %15
i32 76, label %15
]
11: ; preds = %4
%12 = add nsw i32 %8, 4
br label %23
13: ; preds = %4
%14 = add nsw i32 %8, 8
br label %23
15: ; preds = %4, %4
%16 = add nsw i32 %8, 8
br label %23
17: ; preds = %4
%18 = icmp slt i32 %7, 2
br i1 %18, label %19, label %21
19: ; preds = %17
%20 = add nsw i32 %7, 1
br label %23
21: ; preds = %17
%22 = add nsw i32 %8, 4
br label %23
23: ; preds = %19, %21, %15, %13, %11
%24 = phi i32 [ %8, %19 ], [ %22, %21 ], [ %16, %15 ], [ %14, %13 ], [ %12, %11 ]
%25 = phi i32 [ %20, %19 ], [ 2, %21 ], [ 2, %15 ], [ %7, %13 ], [ %7, %11 ]
%26 = load i8, i8* %9
%27 = icmp eq i8 %26, 41
br i1 %27, label %28, label %4
28: ; preds = %23, %1
%29 = phi i32 [ 0, %1 ], [ %24, %23 ]
ret i32 %29
}