#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*/ isspace(unsigned char);
char *skip_spaces(const char *buf) {
  unsigned char c;
  int brackets = 0;
  while ((c = *buf)) {
    if (!c)
      break;
    if (c == '(')
      brackets++;
    else if (c == ')' && brackets)
      brackets--;
    else if (!isspace(c) && !brackets)
      break;
    buf++;
  }
  return (char *)buf;
}


x86 assembly (clang, -O0):
<skip_spaces>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x9(%rbp)
cmp    $0x0,%al
je     11bf <skip_spaces+0xaf>
cmpb   $0x0,-0x9(%rbp)
jne    1143 <skip_spaces+0x33>
jmp    11bf <skip_spaces+0xaf>
movzbl -0x9(%rbp),%eax
cmp    $0x28,%eax
jne    115e <skip_spaces+0x4e>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11ae <skip_spaces+0x9e>
movzbl -0x9(%rbp),%eax
cmp    $0x29,%eax
jne    1183 <skip_spaces+0x73>
cmpl   $0x0,-0x10(%rbp)
je     1183 <skip_spaces+0x73>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    11a9 <skip_spaces+0x99>
movzbl -0x9(%rbp),%edi
call   1030 <isspace@plt>
cmp    $0x0,%eax
jne    11a4 <skip_spaces+0x94>
cmpl   $0x0,-0x10(%rbp)
jne    11a4 <skip_spaces+0x94>
jmp    11bf <skip_spaces+0xaf>
jmp    11a9 <skip_spaces+0x99>
jmp    11ae <skip_spaces+0x9e>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1123 <skip_spaces+0x13>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<skip_spaces>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
xor    %ebp,%ebp
jmp    1127 <skip_spaces+0x17>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebp
add    $0x1,%rbx
movzbl (%rbx),%eax
cmp    $0x28,%al
je     1120 <skip_spaces+0x10>
test   %al,%al
je     1162 <skip_spaces+0x52>
cmp    $0x29,%al
jne    1150 <skip_spaces+0x40>
test   %ebp,%ebp
je     1150 <skip_spaces+0x40>
add    $0xffffffff,%ebp
add    $0x1,%rbx
jmp    1127 <skip_spaces+0x17>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl %al,%edi
call   1030 <isspace@plt>
or     %ebp,%eax
je     1162 <skip_spaces+0x52>
add    $0x1,%rbx
jmp    1127 <skip_spaces+0x17>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i8* @skip_spaces(i8* %0) {
%2 = alloca i8*
%3 = alloca i8
%4 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %4
br label %5
5: ; preds = %40, %1
%6 = load i8*, i8** %2
%7 = load i8, i8* %6
store i8 %7, i8* %3
%8 = icmp ne i8 %7, 0
br i1 %8, label %9, label %43
9: ; preds = %5
%10 = load i8, i8* %3
%11 = icmp ne i8 %10, 0
br i1 %11, label %13, label %12
12: ; preds = %9
br label %43
13: ; preds = %9
%14 = load i8, i8* %3
%15 = zext i8 %14 to i32
%16 = icmp eq i32 %15, 40
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = load i32, i32* %4
%19 = add nsw i32 %18, 1
store i32 %19, i32* %4
br label %40
20: ; preds = %13
%21 = load i8, i8* %3
%22 = zext i8 %21 to i32
%23 = icmp eq i32 %22, 41
br i1 %23, label %24, label %30
24: ; preds = %20
%25 = load i32, i32* %4
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = load i32, i32* %4
%29 = add nsw i32 %28, -1
store i32 %29, i32* %4
br label %39
30: ; preds = %24, %20
%31 = load i8, i8* %3
%32 = call i32 @isspace(i8 zeroext %31)
%33 = icmp ne i32 %32, 0
br i1 %33, label %38, label %34
34: ; preds = %30
%35 = load i32, i32* %4
%36 = icmp ne i32 %35, 0
br i1 %36, label %38, label %37
37: ; preds = %34
br label %43
38: ; preds = %34, %30
br label %39
39: ; preds = %38, %27
br label %40
40: ; preds = %39, %17
%41 = load i8*, i8** %2
%42 = getelementptr inbounds i8, i8* %41, i32 1
store i8* %42, i8** %2
br label %5
43: ; preds = %37, %12, %5
%44 = load i8*, i8** %2
ret i8* %44
}

LLVM IR (-O2):
define i8* @skip_spaces(i8* %0) {
br label %2
2: ; preds = %18, %1
%3 = phi i8* [ %0, %1 ], [ %20, %18 ]
%4 = phi i32 [ 0, %1 ], [ %19, %18 ]
%5 = load i8, i8* %3
switch i8 %5, label %8 [
i8 0, label %21
i8 40, label %6
]
6: ; preds = %2
%7 = add nsw i32 %4, 1
br label %18
8: ; preds = %2
%9 = icmp eq i8 %5, 41
%10 = icmp ne i32 %4, 0
%11 = select i1 %9, i1 %10, i1 false
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = add nsw i32 %4, -1
br label %18
14: ; preds = %8
%15 = tail call i32 @isspace(i8 zeroext %5)
%16 = icmp ne i32 %15, 0
%17 = select i1 %16, i1 true, i1 %10
br i1 %17, label %18, label %21
18: ; preds = %12, %14, %6
%19 = phi i32 [ %7, %6 ], [ %13, %12 ], [ %4, %14 ]
%20 = getelementptr inbounds i8, i8* %3, i64 1
br label %2
21: ; preds = %2, %14
ret i8* %3
}