#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 bc(char);
char *segment(char *, int, int);
char *partone(char *g) {
  int brackets = 0, i = 0;
  while (1) {
    char c = g[i];
    if (c == '(') {
      brackets += 1;
    }
    if (c == ')') {
      brackets -= 1;
    }
    if (bc(c) == 1 && brackets == 1) {
      char *fmla1 = segment(g, 2, i + 1);
      return fmla1;
      break;
    }
    i++;
  }
}


x86 assembly (clang, -O0):
<partone>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
cmp    $0x28,%eax
jne    115e <partone+0x3e>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
movsbl -0x11(%rbp),%eax
cmp    $0x29,%eax
jne    1174 <partone+0x54>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
movsbl -0x11(%rbp),%edi
call   1030 <bc@plt>
cmp    $0x1,%eax
jne    11b2 <partone+0x92>
cmpl   $0x1,-0xc(%rbp)
jne    11b2 <partone+0x92>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%edx
add    $0x1,%edx
mov    $0x2,%esi
call   1040 <segment@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113a <partone+0x1a>

x86 assembly (clang, -O2):
<partone>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
xor    %ebx,%ebx
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
movsbl (%r14,%rbx,1),%edi
xor    %eax,%eax
cmp    $0x29,%edi
sete   %al
xor    %ecx,%ecx
cmp    $0x28,%edi
sete   %cl
add    %ecx,%ebp
sub    %eax,%ebp
call   1030 <bc@plt>
add    $0x1,%rbx
cmp    $0x1,%eax
jne    1130 <partone+0x10>
cmp    $0x1,%ebp
jne    1130 <partone+0x10>
mov    %r14,%rdi
mov    $0x2,%esi
mov    %ebx,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <segment@plt>

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

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