#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 /*<<< orphan*/ free(char *);
char *new_str(char *);
char *s_addchar(char *, char);
char *l_getParam(char **ptr) {
  char *tmp;
  if (*(++(*ptr)) != '(')
    return NULL;
  if (*(++(*ptr)) == ')')
    return NULL;
  tmp = new_str("");
  while ((**ptr) != ')') {
    if ((**ptr) == '\0') {
      free(tmp);
      return NULL;
    }
    tmp = s_addchar(tmp, *(*ptr));
    (*ptr)++;
  }
  return tmp;
}


x86 assembly (clang, -O0):
<l_getParam>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rcx
mov    (%rcx),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,(%rcx)
movsbl 0x1(%rax),%eax
cmp    $0x28,%eax
je     1167 <l_getParam+0x37>
movq   $0x0,-0x8(%rbp)
jmp    1210 <l_getParam+0xe0>
mov    -0x10(%rbp),%rcx
mov    (%rcx),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,(%rcx)
movsbl 0x1(%rax),%eax
cmp    $0x29,%eax
jne    1192 <l_getParam+0x62>
movq   $0x0,-0x8(%rbp)
jmp    1210 <l_getParam+0xe0>
lea    0xe67(%rip),%rdi
call   1050 <new_str@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x29,%eax
je     1208 <l_getParam+0xd8>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11de <l_getParam+0xae>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1210 <l_getParam+0xe0>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%esi
call   1040 <s_addchar@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
jmp    11a2 <l_getParam+0x72>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<l_getParam>:
push   %rbx
mov    (%rdi),%rax
lea    0x1(%rax),%rcx
mov    %rcx,(%rdi)
cmpb   $0x28,0x1(%rax)
jne    118b <l_getParam+0x5b>
mov    %rdi,%rbx
lea    0x2(%rax),%rcx
mov    %rcx,(%rdi)
cmpb   $0x29,0x2(%rax)
je     118b <l_getParam+0x5b>
lea    0xea8(%rip),%rdi
call   1050 <new_str@plt>
mov    (%rbx),%rcx
movzbl (%rcx),%ecx
cmp    $0x29,%cl
je     118d <l_getParam+0x5d>
test   %cl,%cl
je     1183 <l_getParam+0x53>
movsbl %cl,%esi
mov    %rax,%rdi
call   1040 <s_addchar@plt>
mov    (%rbx),%rcx
add    $0x1,%rcx
mov    %rcx,(%rbx)
jmp    1160 <l_getParam+0x30>
mov    %rax,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
define i8* @l_getParam(i8** %0) {
%2 = alloca i8*
%3 = alloca i8**
%4 = alloca i8*
store i8** %0, i8*** %3
%5 = load i8**, i8*** %3
%6 = load i8*, i8** %5
%7 = getelementptr inbounds i8, i8* %6, i32 1
store i8* %7, i8** %5
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 40
br i1 %10, label %11, label %12
11: ; preds = %1
store i8* null, i8** %2
br label %48
12: ; preds = %1
%13 = load i8**, i8*** %3
%14 = load i8*, i8** %13
%15 = getelementptr inbounds i8, i8* %14, i32 1
store i8* %15, i8** %13
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 41
br i1 %18, label %19, label %20
19: ; preds = %12
store i8* null, i8** %2
br label %48
20: ; preds = %12
%21 = call i8* @new_str(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i8* %21, i8** %4
br label %22
22: ; preds = %37, %20
%23 = load i8**, i8*** %3
%24 = load i8*, i8** %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 41
br i1 %27, label %28, label %46
28: ; preds = %22
%29 = load i8**, i8*** %3
%30 = load i8*, i8** %29
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %28
%35 = load i8*, i8** %4
%36 = call i32 @free(i8* %35)
store i8* null, i8** %2
br label %48
37: ; preds = %28
%38 = load i8*, i8** %4
%39 = load i8**, i8*** %3
%40 = load i8*, i8** %39
%41 = load i8, i8* %40
%42 = call i8* @s_addchar(i8* %38, i8 signext %41)
store i8* %42, i8** %4
%43 = load i8**, i8*** %3
%44 = load i8*, i8** %43
%45 = getelementptr inbounds i8, i8* %44, i32 1
store i8* %45, i8** %43
br label %22
46: ; preds = %22
%47 = load i8*, i8** %4
store i8* %47, i8** %2
br label %48
48: ; preds = %46, %34, %19, %11
%49 = load i8*, i8** %2
ret i8* %49
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
define i8* @l_getParam(i8** nocapture %0) {
%2 = load i8*, i8** %0
%3 = getelementptr inbounds i8, i8* %2, i64 1
store i8* %3, i8** %0
%4 = load i8, i8* %3
%5 = icmp eq i8 %4, 40
br i1 %5, label %6, label %23
6: ; preds = %1
%7 = getelementptr inbounds i8, i8* %2, i64 2
store i8* %7, i8** %0
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 41
br i1 %9, label %23, label %10
10: ; preds = %6
%11 = tail call i8* @new_str(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%12 = load i8*, i8** %0
br label %13
13: ; preds = %19, %10
%14 = phi i8* [ %12, %10 ], [ %22, %19 ]
%15 = phi i8* [ %11, %10 ], [ %20, %19 ]
%16 = load i8, i8* %14
switch i8 %16, label %19 [
i8 41, label %23
i8 0, label %17
]
17: ; preds = %13
%18 = tail call i32 @free(i8* %15)
br label %23
19: ; preds = %13
%20 = tail call i8* @s_addchar(i8* %15, i8 signext %16)
%21 = load i8*, i8** %0
%22 = getelementptr inbounds i8, i8* %21, i64 1
store i8* %22, i8** %0
br label %13
23: ; preds = %13, %6, %1, %17
%24 = phi i8* [ null, %17 ], [ null, %1 ], [ null, %6 ], [ %15, %13 ]
ret i8* %24
}