#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*/ memcpy(char *, char *, int);
int /*<<< orphan*/ parse_buffer(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
scalar_t__ strstr(char *, char *);
void parse_innermost(char *line) {
  int pos = 0, length = 0;
  for (int i = 0; i < strlen(line); i++) {
    length++;
    if (line[i] == '(') {
      pos = i;
      length = 0;
    } else if (line[i] == ')') {
      break;
    }
  }
  char subseq[length + 2];
  memcpy(subseq, &line[pos], length + 1);
  subseq[length + 1] = 0x00;
  parse_buffer(subseq);
  int sufc = strlen(line) - pos + length + 1;
  char pre[pos];
  char suf[sufc];
  int mergedc = strlen(pre) + strlen(suf) + strlen(subseq);
  char merged[mergedc];
  if (pos > 0) {
    memcpy(pre, &line[0], pos);
    pre[pos + 1] = 0x00;
    sprintf(merged, "%s", pre);
  }
  sprintf(merged, "%s%s", merged, subseq);
  if (sufc > 0) {
    memcpy(suf, &line[pos + length + 1], sufc);
    suf[sufc + 1] = 0x00;
    sprintf(merged, "%s%s", merged, suf);
  }
  strcpy(line, merged);
  if (strstr(line, "(")) {
    parse_innermost(line);
  }
}


x86 assembly (clang, -O0):
<parse_innermost>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x54(%rbp),%eax
cmp    %ecx,%eax
jge    1212 <parse_innermost+0xa2>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x28,%eax
jne    11e0 <parse_innermost+0x70>
mov    -0x14(%rbp),%eax
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
jmp    11ff <parse_innermost+0x8f>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x29,%eax
jne    11fa <parse_innermost+0x8a>
jmp    1212 <parse_innermost+0xa2>
jmp    11ff <parse_innermost+0x8f>
jmp    1204 <parse_innermost+0x94>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1194 <parse_innermost+0x24>
mov    -0x10(%rbp),%eax
add    $0x2,%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x70(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rsi
movslq -0xc(%rbp),%rax
add    %rax,%rsi
mov    -0x10(%rbp),%edx
add    $0x1,%edx
call   1060 <memcpy@plt>
mov    -0x70(%rbp),%rdi
movslq -0x10(%rbp),%rax
movb   $0x0,0x1(%rax,%rdi,1)
call   1070 <parse_buffer@plt>
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%edx
mov    -0xc(%rbp),%eax
sub    %eax,%edx
mov    -0x10(%rbp),%eax
mov    %eax,%ecx
mov    %edx,%eax
lea    0x1(%rax,%rcx,1),%eax
mov    %eax,-0x2c(%rbp)
mov    -0xc(%rbp),%eax
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x80(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x38(%rbp)
mov    -0x2c(%rbp),%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x78(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x40(%rbp)
call   1050 <strlen@plt>
mov    -0x78(%rbp),%rdi
mov    %eax,-0x68(%rbp)
call   1050 <strlen@plt>
mov    -0x70(%rbp),%rdi
mov    %eax,%ecx
mov    -0x68(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x64(%rbp)
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x64(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x60(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x50(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    1348 <parse_innermost+0x1d8>
mov    -0x80(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1060 <memcpy@plt>
mov    -0x60(%rbp),%rdi
mov    -0x80(%rbp),%rdx
mov    -0xc(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0x0,(%rdx,%rax,1)
lea    0xcc1(%rip),%rsi
mov    $0x0,%al
call   1080 <sprintf@plt>
mov    -0x70(%rbp),%rcx
mov    -0x60(%rbp),%rdx
lea    0xca9(%rip),%rsi
mov    %rdx,%rdi
mov    $0x0,%al
call   1080 <sprintf@plt>
cmpl   $0x0,-0x2c(%rbp)
jle    13ae <parse_innermost+0x23e>
mov    -0x78(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
add    $0x1,%eax
cltq
add    %rax,%rsi
mov    -0x2c(%rbp),%edx
call   1060 <memcpy@plt>
mov    -0x60(%rbp),%rdx
mov    -0x78(%rbp),%rcx
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0x0,(%rcx,%rax,1)
lea    0xc5c(%rip),%rsi
mov    %rdx,%rdi
mov    $0x0,%al
call   1080 <sprintf@plt>
mov    -0x60(%rbp),%rsi
mov    -0x8(%rbp),%rdi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
lea    0xc3f(%rip),%rsi
call   1090 <strstr@plt>
cmp    $0x0,%rax
je     13de <parse_innermost+0x26e>
mov    -0x8(%rbp),%rdi
call   1040 <parse_innermost@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_innermost>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rdi,%r14
call   1050 <strlen@plt>
test   %eax,%eax
jle    11cc <parse_innermost+0x5c>
xor    %ebx,%ebx
xor    %r13d,%r13d
xor    %r15d,%r15d
jmp    11b9 <parse_innermost+0x49>
nopw   0x0(%rax,%rax,1)
xor    %r15d,%r15d
mov    %ebx,%r13d
add    $0x1,%rbx
mov    %r14,%rdi
call   1050 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    11d2 <parse_innermost+0x62>
movzbl (%r14,%rbx,1),%eax
cmp    $0x28,%al
je     11a0 <parse_innermost+0x30>
add    $0x1,%r15d
cmp    $0x29,%al
jne    11a6 <parse_innermost+0x36>
jmp    11d2 <parse_innermost+0x62>
xor    %r13d,%r13d
xor    %r15d,%r15d
mov    %r13,-0x68(%rbp)
lea    0x2(%r15),%eax
mov    %rsp,%r12
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
movslq %r13d,%r13
lea    (%r14,%r13,1),%rsi
movslq %r15d,%rbx
lea    0x1(%rbx),%rdx
mov    %r12,%rdi
call   1060 <memcpy@plt>
movb   $0x0,0x1(%rbx,%r12,1)
mov    %r12,%rdi
call   1070 <parse_buffer@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %r13,-0x60(%rbp)
sub    %r13d,%eax
lea    (%rax,%rbx,1),%ecx
add    $0x1,%ecx
add    %r15d,%eax
mov    %eax,-0x34(%rbp)
mov    %r13d,%eax
mov    %rsp,%rdi
mov    %rax,-0x48(%rbp)
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rdi
mov    %rdi,%rsp
mov    %rcx,-0x58(%rbp)
lea    0xf(%rcx),%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%rbx
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rdi,-0x40(%rbp)
call   1050 <strlen@plt>
mov    %eax,-0x30(%rbp)
mov    %rbx,-0x50(%rbp)
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,%r13d
add    -0x30(%rbp),%r13d
mov    %r12,-0x30(%rbp)
mov    %r12,%rdi
call   1050 <strlen@plt>
add    %r13d,%eax
mov    -0x68(%rbp),%r13
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%r12
sub    %rax,%r12
mov    %r12,%rsp
cmpl   $0x0,-0x60(%rbp)
jle    12c6 <parse_innermost+0x156>
mov    -0x40(%rbp),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r13d,%edx
call   1060 <memcpy@plt>
mov    -0x48(%rbp),%rax
movb   $0x0,0x1(%rax,%rbx,1)
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
lea    0xd33(%rip),%rsi
mov    %r12,%rdi
mov    %r12,%rdx
mov    -0x30(%rbp),%rcx
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    -0x34(%rbp),%ebx
test   %ebx,%ebx
js     1321 <parse_innermost+0x1b1>
lea    (%r15,%r13,1),%eax
add    $0x1,%eax
movslq %eax,%rsi
add    %r14,%rsi
mov    -0x50(%rbp),%r15
mov    %r15,%rdi
mov    -0x58(%rbp),%rdx
call   1060 <memcpy@plt>
mov    %ebx,%eax
movb   $0x0,0x2(%rax,%r15,1)
lea    0xcef(%rip),%rsi
mov    %r12,%rdi
mov    %r12,%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
lea    0xcd2(%rip),%rsi
mov    %r14,%rdi
call   1090 <strstr@plt>
test   %rax,%rax
je     1348 <parse_innermost+0x1d8>
mov    %r14,%rdi
call   1040 <parse_innermost@plt>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [5 x i8] c"%s%s\00"
@.str.2 = [2 x i8] c"(\00"
define void @parse_innermost(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
%9 = alloca i64
%10 = alloca i64
%11 = alloca i32
%12 = alloca i64
store i8* %0, i8** %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
br label %13
13: ; preds = %41, %1
%14 = load i32, i32* %5
%15 = load i8*, i8** %2
%16 = call i32 @strlen(i8* %15)
%17 = icmp slt i32 %14, %16
br i1 %17, label %18, label %44
18: ; preds = %13
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
%21 = load i8*, i8** %2
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 40
br i1 %27, label %28, label %30
28: ; preds = %18
%29 = load i32, i32* %5
store i32 %29, i32* %3
store i32 0, i32* %4
br label %40
30: ; preds = %18
%31 = load i8*, i8** %2
%32 = load i32, i32* %5
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 41
br i1 %37, label %38, label %39
38: ; preds = %30
br label %44
39: ; preds = %30
br label %40
40: ; preds = %39, %28
br label %41
41: ; preds = %40
%42 = load i32, i32* %5
%43 = add nsw i32 %42, 1
store i32 %43, i32* %5
br label %13
44: ; preds = %38, %13
%45 = load i32, i32* %4
%46 = add nsw i32 %45, 2
%47 = zext i32 %46 to i64
%48 = call i8* @llvm.stacksave()
store i8* %48, i8** %6
%49 = alloca i8, i64 %47
store i64 %47, i64* %7
%50 = load i8*, i8** %2
%51 = load i32, i32* %3
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %50, i64 %52
%54 = load i32, i32* %4
%55 = add nsw i32 %54, 1
%56 = call i32 @memcpy(i8* %49, i8* %53, i32 %55)
%57 = load i32, i32* %4
%58 = add nsw i32 %57, 1
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8, i8* %49, i64 %59
store i8 0, i8* %60
%61 = call i32 @parse_buffer(i8* %49)
%62 = load i8*, i8** %2
%63 = call i32 @strlen(i8* %62)
%64 = load i32, i32* %3
%65 = sub nsw i32 %63, %64
%66 = load i32, i32* %4
%67 = add nsw i32 %65, %66
%68 = add nsw i32 %67, 1
store i32 %68, i32* %8
%69 = load i32, i32* %3
%70 = zext i32 %69 to i64
%71 = alloca i8, i64 %70
store i64 %70, i64* %9
%72 = load i32, i32* %8
%73 = zext i32 %72 to i64
%74 = alloca i8, i64 %73
store i64 %73, i64* %10
%75 = call i32 @strlen(i8* %71)
%76 = call i32 @strlen(i8* %74)
%77 = add nsw i32 %75, %76
%78 = call i32 @strlen(i8* %49)
%79 = add nsw i32 %77, %78
store i32 %79, i32* %11
%80 = load i32, i32* %11
%81 = zext i32 %80 to i64
%82 = alloca i8, i64 %81
store i64 %81, i64* %12
%83 = load i32, i32* %3
%84 = icmp sgt i32 %83, 0
br i1 %84, label %85, label %95
85: ; preds = %44
%86 = load i8*, i8** %2
%87 = getelementptr inbounds i8, i8* %86, i64 0
%88 = load i32, i32* %3
%89 = call i32 @memcpy(i8* %71, i8* %87, i32 %88)
%90 = load i32, i32* %3
%91 = add nsw i32 %90, 1
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds i8, i8* %71, i64 %92
store i8 0, i8* %93
%94 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %82, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %71)
br label %95
95: ; preds = %85, %44
%96 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %82, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %82, i8* %49)
%97 = load i32, i32* %8
%98 = icmp sgt i32 %97, 0
br i1 %98, label %99, label %114
99: ; preds = %95
%100 = load i8*, i8** %2
%101 = load i32, i32* %3
%102 = load i32, i32* %4
%103 = add nsw i32 %101, %102
%104 = add nsw i32 %103, 1
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds i8, i8* %100, i64 %105
%107 = load i32, i32* %8
%108 = call i32 @memcpy(i8* %74, i8* %106, i32 %107)
%109 = load i32, i32* %8
%110 = add nsw i32 %109, 1
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds i8, i8* %74, i64 %111
store i8 0, i8* %112
%113 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %82, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %82, i8* %74)
br label %114
114: ; preds = %99, %95
%115 = load i8*, i8** %2
%116 = call i32 @strcpy(i8* %115, i8* %82)
%117 = load i8*, i8** %2
%118 = call i64 @strstr(i8* %117, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%119 = icmp ne i64 %118, 0
br i1 %119, label %120, label %122
120: ; preds = %114
%121 = load i8*, i8** %2
br label %122
122: ; preds = %120, %114
%123 = load i8*, i8** %6
ret void
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"%s%s\00"
@.str.2 = [2 x i8] c"(\00"
define void @parse_innermost(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %20
4: ; preds = %1, %13
%5 = phi i64 [ %16, %13 ], [ 0, %1 ]
%6 = phi i32 [ %15, %13 ], [ 0, %1 ]
%7 = phi i32 [ %14, %13 ], [ 0, %1 ]
%8 = add nsw i32 %7, 1
%9 = getelementptr inbounds i8, i8* %0, i64 %5
%10 = load i8, i8* %9
%11 = trunc i64 %5 to i32
switch i8 %10, label %12 [
i8 40, label %13
i8 41, label %20
]
12: ; preds = %4
br label %13
13: ; preds = %4, %12
%14 = phi i32 [ 0, %4 ], [ %8, %12 ]
%15 = phi i32 [ %11, %4 ], [ %6, %12 ]
%16 = add nuw nsw i64 %5, 1
%17 = tail call i32 @strlen(i8* %0)
%18 = sext i32 %17 to i64
%19 = icmp slt i64 %16, %18
br i1 %19, label %4, label %20
20: ; preds = %13, %4, %1
%21 = phi i32 [ 0, %1 ], [ %6, %4 ], [ %15, %13 ]
%22 = phi i32 [ 0, %1 ], [ %8, %4 ], [ %14, %13 ]
%23 = add nsw i32 %22, 2
%24 = zext i32 %23 to i64
%25 = alloca i8, i64 %24
%26 = sext i32 %21 to i64
%27 = getelementptr inbounds i8, i8* %0, i64 %26
%28 = add nsw i32 %22, 1
%29 = call i32 @memcpy(i8* %25, i8* %27, i32 %28)
%30 = sext i32 %28 to i64
%31 = getelementptr inbounds i8, i8* %25, i64 %30
store i8 0, i8* %31
%32 = call i32 @parse_buffer(i8* %25)
%33 = call i32 @strlen(i8* %0)
%34 = sub nsw i32 %33, %21
%35 = add nsw i32 %34, %22
%36 = add nsw i32 %35, 1
%37 = zext i32 %21 to i64
%38 = alloca i8, i64 %37
%39 = zext i32 %36 to i64
%40 = alloca i8, i64 %39
%41 = call i32 @strlen(i8* %38)
%42 = call i32 @strlen(i8* %40)
%43 = add nsw i32 %42, %41
%44 = call i32 @strlen(i8* %25)
%45 = add nsw i32 %43, %44
%46 = zext i32 %45 to i64
%47 = alloca i8, i64 %46
%48 = icmp sgt i32 %21, 0
br i1 %48, label %49, label %55
49: ; preds = %20
%50 = call i32 @memcpy(i8* %38, i8* %0, i32 %21)
%51 = add nuw nsw i32 %21, 1
%52 = zext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %38, i64 %52
store i8 0, i8* %53
%54 = call i8* bitcast (i32 (i8*, i8*)* @strcpy to i8* (i8*, i8*)*)(i8* %47, i8* %38)
br label %55
55: ; preds = %49, %20
%56 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %47, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %47, i8* %25)
%57 = icmp sgt i32 %35, -1
br i1 %57, label %58, label %68
58: ; preds = %55
%59 = add i32 %21, 1
%60 = add i32 %59, %22
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8, i8* %0, i64 %61
%63 = call i32 @memcpy(i8* %40, i8* %62, i32 %36)
%64 = add nuw nsw i32 %35, 2
%65 = zext i32 %64 to i64
%66 = getelementptr inbounds i8, i8* %40, i64 %65
store i8 0, i8* %66
%67 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %47, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %47, i8* %40)
br label %68
68: ; preds = %58, %55
%69 = call i32 @strcpy(i8* %0, i8* %47)
%70 = call i64 @strstr(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%71 = icmp eq i64 %70, 0
br i1 %71, label %73, label %72
72: ; preds = %68
br label %73
73: ; preds = %72, %68
ret void
}