#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 */
int findParantRange(char const *, int, int *, int *);
char *malloc(int);
int /*<<< orphan*/ memcpy(char *, char const *, int);
char *findFunctionName(const char *line, int length, int *outEnd) {
  int start, functionLen;
  char *functionName;
  functionLen = findParantRange(line, length, &start, outEnd);
  functionName = malloc(functionLen);
  memcpy(functionName, &line[start + 2], functionLen);
  functionName[functionLen - 2] = 0;
  *outEnd += 1;
  return functionName;
}


x86 assembly (clang, -O0):
<findFunctionName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rcx
lea    -0x1c(%rbp),%rdx
call   1050 <findParantRange@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edi
call   1040 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x1c(%rbp),%eax
add    $0x2,%eax
cltq
add    %rax,%rsi
mov    -0x20(%rbp),%edx
call   1030 <memcpy@plt>
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findFunctionName>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rdi,%r15
lea    0x4(%rsp),%rdx
mov    %r14,%rcx
call   1050 <findParantRange@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
movslq 0x4(%rsp),%rax
lea    (%rax,%r15,1),%rsi
add    $0x2,%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
call   1030 <memcpy@plt>
movslq %ebp,%rax
movb   $0x0,-0x2(%rax,%rbx,1)
addl   $0x1,(%r14)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @findFunctionName(i8* %0, i32 %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32* %2, i32** %6
%10 = load i8*, i8** %4
%11 = load i32, i32* %5
%12 = load i32*, i32** %6
%13 = call i32 @findParantRange(i8* %10, i32 %11, i32* %7, i32* %12)
store i32 %13, i32* %8
%14 = load i32, i32* %8
%15 = call i8* @malloc(i32 %14)
store i8* %15, i8** %9
%16 = load i8*, i8** %9
%17 = load i8*, i8** %4
%18 = load i32, i32* %7
%19 = add nsw i32 %18, 2
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %17, i64 %20
%22 = load i32, i32* %8
%23 = call i32 @memcpy(i8* %16, i8* %21, i32 %22)
%24 = load i8*, i8** %9
%25 = load i32, i32* %8
%26 = sub nsw i32 %25, 2
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %24, i64 %27
store i8 0, i8* %28
%29 = load i32*, i32** %6
%30 = load i32, i32* %29
%31 = add nsw i32 %30, 1
store i32 %31, i32* %29
%32 = load i8*, i8** %9
ret i8* %32
}

LLVM IR (-O2):
define i8* @findFunctionName(i8* %0, i32 %1, i32* %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
%6 = call i32 @findParantRange(i8* %0, i32 %1, i32* %4, i32* %2)
%7 = call i8* @malloc(i32 %6)
%8 = load i32, i32* %4
%9 = add nsw i32 %8, 2
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = call i32 @memcpy(i8* %7, i8* %11, i32 %6)
%13 = add nsw i32 %6, -2
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %7, i64 %14
store i8 0, i8* %15
%16 = load i32, i32* %2
%17 = add nsw i32 %16, 1
store i32 %17, i32* %2
ret i8* %7
}