#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 */
scalar_t__ count_white_spaces(char const *);
size_t strlen(char const *);
size_t get_function_name(char *name, const char *buf) {
  size_t pos = 0;
  const size_t len = strlen(buf);
  name[0] = 0;
  while (pos < len) {
    if (';' == buf[pos]) {
      break;
    }
    name[pos] = buf[pos];
    pos++;
    if ('(' == buf[pos]) {
      name[pos] = 0;
      pos += 1;
      pos += count_white_spaces(&buf[pos]);
      return pos;
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<get_function_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    11f2 <get_function_name+0xd2>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
mov    $0x3b,%eax
cmp    %ecx,%eax
jne    1178 <get_function_name+0x58>
jmp    11f2 <get_function_name+0xd2>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
mov    $0x28,%eax
cmp    %ecx,%eax
jne    11ed <get_function_name+0xcd>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
add    -0x20(%rbp),%rdi
call   1040 <count_white_spaces@plt>
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11fa <get_function_name+0xda>
jmp    114c <get_function_name+0x2c>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_function_name>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rsi,%rdi
call   1030 <strlen@plt>
mov    %rax,%rdi
movb   $0x0,(%r14)
mov    $0xffffffffffffffff,%rax
xor    %edx,%edx
mov    $0xffffffffffffffff,%rbx
nopw   0x0(%rax,%rax,1)
lea    (%rdi,%rbx,1),%rcx
cmp    $0xffffffffffffffff,%rcx
je     118e <get_function_name+0x6e>
movzbl (%r15,%rdx,1),%ecx
cmp    $0x3b,%cl
je     118e <get_function_name+0x6e>
mov    %cl,(%r14,%rdx,1)
lea    0x1(%rdx),%rsi
add    $0xffffffffffffffff,%rbx
cmpb   $0x28,0x1(%r15,%rdx,1)
mov    %rsi,%rdx
jne    1150 <get_function_name+0x30>
movb   $0x0,(%r14,%rsi,1)
sub    %rbx,%r15
mov    %r15,%rdi
call   1040 <count_white_spaces@plt>
sub    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @get_function_name(i8* %0, i8* %1) {
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 0, i64* %6
%8 = load i8*, i8** %5
%9 = call i64 @strlen(i8* %8)
store i64 %9, i64* %7
%10 = load i8*, i8** %4
%11 = getelementptr inbounds i8, i8* %10, i64 0
store i8 0, i8* %11
br label %12
12: ; preds = %53, %2
%13 = load i64, i64* %6
%14 = load i64, i64* %7
%15 = icmp ult i64 %13, %14
br i1 %15, label %16, label %54
16: ; preds = %12
%17 = load i8*, i8** %5
%18 = load i64, i64* %6
%19 = getelementptr inbounds i8, i8* %17, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 59, %21
br i1 %22, label %23, label %24
23: ; preds = %16
br label %54
24: ; preds = %16
%25 = load i8*, i8** %5
%26 = load i64, i64* %6
%27 = getelementptr inbounds i8, i8* %25, i64 %26
%28 = load i8, i8* %27
%29 = load i8*, i8** %4
%30 = load i64, i64* %6
%31 = getelementptr inbounds i8, i8* %29, i64 %30
store i8 %28, i8* %31
%32 = load i64, i64* %6
%33 = add i64 %32, 1
store i64 %33, i64* %6
%34 = load i8*, i8** %5
%35 = load i64, i64* %6
%36 = getelementptr inbounds i8, i8* %34, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp eq i32 40, %38
br i1 %39, label %40, label %53
40: ; preds = %24
%41 = load i8*, i8** %4
%42 = load i64, i64* %6
%43 = getelementptr inbounds i8, i8* %41, i64 %42
store i8 0, i8* %43
%44 = load i64, i64* %6
%45 = add i64 %44, 1
store i64 %45, i64* %6
%46 = load i8*, i8** %5
%47 = load i64, i64* %6
%48 = getelementptr inbounds i8, i8* %46, i64 %47
%49 = call i64 @count_white_spaces(i8* %48)
%50 = load i64, i64* %6
%51 = add i64 %50, %49
store i64 %51, i64* %6
%52 = load i64, i64* %6
store i64 %52, i64* %3
br label %55
53: ; preds = %24
br label %12
54: ; preds = %23, %12
store i64 -1, i64* %3
br label %55
55: ; preds = %54, %40
%56 = load i64, i64* %3
ret i64 %56
}

LLVM IR (-O2):
define i64 @get_function_name(i8* nocapture writeonly %0, i8* %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %1)
store i8 0, i8* %0
br label %4
4: ; preds = %11, %2
%5 = phi i64 [ 0, %2 ], [ %13, %11 ]
%6 = icmp eq i64 %5, %3
br i1 %6, label %23, label %7
7: ; preds = %4
%8 = getelementptr inbounds i8, i8* %1, i64 %5
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 59
br i1 %10, label %23, label %11
11: ; preds = %7
%12 = getelementptr inbounds i8, i8* %0, i64 %5
store i8 %9, i8* %12
%13 = add i64 %5, 1
%14 = getelementptr inbounds i8, i8* %1, i64 %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 40
br i1 %16, label %17, label %4
17: ; preds = %11
%18 = getelementptr inbounds i8, i8* %0, i64 %13
store i8 0, i8* %18
%19 = add i64 %5, 2
%20 = getelementptr inbounds i8, i8* %1, i64 %19
%21 = tail call i64 @count_white_spaces(i8* %20)
%22 = add i64 %21, %19
br label %23
23: ; preds = %4, %7, %17
%24 = phi i64 [ %22, %17 ], [ -1, %7 ], [ -1, %4 ]
ret i64 %24
}