#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 strlen(char const *const);
int /*<<< orphan*/ *strpbrk(char const *const, char *);
int cvNeedsParentheses(const char *const string) {
  return strpbrk(string, " \t") != NULL &&
         (string[0] != '(' || string[strlen(string) - 1] != ')');
}


x86 assembly (clang, -O0):
<cvNeedsParentheses>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xec9(%rip),%rsi
call   1040 <strpbrk@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x9(%rbp)
je     1193 <cvNeedsParentheses+0x73>
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x28,%ecx
mov    %al,-0xa(%rbp)
jne    118d <cvNeedsParentheses+0x6d>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x29,%eax
setne  %al
mov    %al,-0xa(%rbp)
mov    -0xa(%rbp),%al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cvNeedsParentheses>:
push   %rbx
mov    %rdi,%rbx
lea    0xed5(%rip),%rsi
call   1040 <strpbrk@plt>
test   %rax,%rax
je     1156 <cvNeedsParentheses+0x36>
mov    $0x1,%eax
cmpb   $0x28,(%rbx)
jne    1154 <cvNeedsParentheses+0x34>
mov    %rbx,%rdi
call   1030 <strlen@plt>
movslq %eax,%rcx
xor    %eax,%eax
cmpb   $0x29,-0x1(%rcx,%rbx,1)
setne  %al
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c" \09\00"
define i32 @cvNeedsParentheses(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i32* @strpbrk(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp ne i32* %4, null
br i1 %5, label %6, label %24
6: ; preds = %1
%7 = load i8*, i8** %2
%8 = getelementptr inbounds i8, i8* %7, i64 0
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 40
br i1 %11, label %22, label %12
12: ; preds = %6
%13 = load i8*, i8** %2
%14 = load i8*, i8** %2
%15 = call i32 @strlen(i8* %14)
%16 = sub nsw i32 %15, 1
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %13, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 41
br label %22
22: ; preds = %12, %6
%23 = phi i1 [ true, %6 ], [ %21, %12 ]
br label %24
24: ; preds = %22, %1
%25 = phi i1 [ false, %1 ], [ %23, %22 ]
%26 = zext i1 %25 to i32
ret i32 %26
}

LLVM IR (-O2):
@.str = [3 x i8] c" \09\00"
define i32 @cvNeedsParentheses(i8* %0) {
%2 = tail call i32* @strpbrk(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %15, label %4
4: ; preds = %1
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 40
br i1 %6, label %7, label %15
7: ; preds = %4
%8 = tail call i32 @strlen(i8* %0)
%9 = add nsw i32 %8, -1
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
%13 = icmp ne i8 %12, 41
%14 = zext i1 %13 to i32
br label %15
15: ; preds = %4, %7, %1
%16 = phi i32 [ 0, %1 ], [ 1, %4 ], [ %14, %7 ]
ret i32 %16
}