#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 */
char *copy_string(char *, int);
char *extract_menu_file_name(char *item_text) {
  char *p = item_text;
  if (*p == '*')
    p++;
  while (*p == ' ')
    p++;
  while (*p && *p != '\n' && *p != ':')
    p++;
  if (*p == ':')
    p++;
  while (1) {
    if (*p == '(')
      break;
    else if (*p == ' ' || *p == '\t')
      p++;
    else
      return "(none)";
  }
  p++;
  item_text = p;
  while (*p && *p != '\n' && *p != ')')
    p++;
  if (*p != ')')
    return "(none)";
  return copy_string(item_text, p - item_text);
}


x86 assembly (clang, -O0):
<extract_menu_file_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2a,%eax
jne    1140 <extract_menu_file_name+0x30>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1145 <extract_menu_file_name+0x35>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    1166 <extract_menu_file_name+0x56>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1145 <extract_menu_file_name+0x35>
jmp    116b <extract_menu_file_name+0x5b>
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
je     11a5 <extract_menu_file_name+0x95>
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x19(%rbp)
je     11a5 <extract_menu_file_name+0x95>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    11b5 <extract_menu_file_name+0xa5>
jmp    11c6 <extract_menu_file_name+0xb6>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    116b <extract_menu_file_name+0x5b>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
jne    11e2 <extract_menu_file_name+0xd2>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11e7 <extract_menu_file_name+0xd7>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x28,%eax
jne    11fc <extract_menu_file_name+0xec>
jmp    1247 <extract_menu_file_name+0x137>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
je     121c <extract_menu_file_name+0x10c>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
jne    122d <extract_menu_file_name+0x11d>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    123d <extract_menu_file_name+0x12d>
lea    0xdcc(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12f0 <extract_menu_file_name+0x1e0>
jmp    1242 <extract_menu_file_name+0x132>
jmp    11e7 <extract_menu_file_name+0xd7>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x1a(%rbp)
je     1295 <extract_menu_file_name+0x185>
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x1a(%rbp)
je     1295 <extract_menu_file_name+0x185>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x29,%eax
setne  %al
mov    %al,-0x1a(%rbp)
mov    -0x1a(%rbp),%al
test   $0x1,%al
jne    12a5 <extract_menu_file_name+0x195>
jmp    12b6 <extract_menu_file_name+0x1a6>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    125b <extract_menu_file_name+0x14b>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x29,%eax
je     12d6 <extract_menu_file_name+0x1c6>
lea    0xd33(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12f0 <extract_menu_file_name+0x1e0>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
call   1030 <copy_string@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extract_menu_file_name>:
xor    %eax,%eax
cmpb   $0x2a,(%rdi)
sete   %al
add    %rdi,%rax
nopl   0x0(%rax,%rax,1)
movzbl (%rax),%ecx
add    $0x1,%rax
cmp    $0x20,%cl
je     1120 <extract_menu_file_name+0x10>
movabs $0x400000000000401,%rdx
jmp    1147 <extract_menu_file_name+0x37>
nopl   0x0(%rax,%rax,1)
movzbl (%rax),%ecx
add    $0x1,%rax
cmp    $0x3a,%cl
ja     1140 <extract_menu_file_name+0x30>
movzbl %cl,%esi
bt     %rsi,%rdx
jae    1140 <extract_menu_file_name+0x30>
xor    %edx,%edx
cmp    $0x3a,%cl
sete   %dl
lea    (%rax,%rdx,1),%rdi
add    %rdx,%rax
add    $0xffffffffffffffff,%rax
jmp    1178 <extract_menu_file_name+0x68>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rax
add    $0x1,%rdi
movzbl (%rax),%ecx
cmp    $0x9,%cl
je     1170 <extract_menu_file_name+0x60>
cmp    $0x20,%cl
je     1170 <extract_menu_file_name+0x60>
cmp    $0x28,%cl
jne    11a6 <extract_menu_file_name+0x96>
xor    %esi,%esi
nopl   0x0(%rax)
movzbl (%rdi,%rsi,1),%eax
test   %al,%al
je     11a6 <extract_menu_file_name+0x96>
cmp    $0xa,%al
je     11a6 <extract_menu_file_name+0x96>
cmp    $0x29,%al
je     11ae <extract_menu_file_name+0x9e>
add    $0x1,%rsi
jmp    1190 <extract_menu_file_name+0x80>
lea    0xe53(%rip),%rax
ret
jmp    1030 <copy_string@plt>

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

LLVM IR (-O2):
@.str = [7 x i8] c"(none)\00"
define i8* @extract_menu_file_name(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 42
%4 = zext i1 %3 to i64
%5 = getelementptr i8, i8* %0, i64 %4
br label %6
6: ; preds = %6, %1
%7 = phi i8* [ %5, %1 ], [ %10, %6 ]
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 32
%10 = getelementptr inbounds i8, i8* %7, i64 1
br i1 %9, label %6, label %11
11: ; preds = %6, %14
%12 = phi i8 [ %16, %14 ], [ %8, %6 ]
%13 = phi i8* [ %15, %14 ], [ %7, %6 ]
switch i8 %12, label %14 [
i8 0, label %17
i8 10, label %17
i8 58, label %17
]
14: ; preds = %11
%15 = getelementptr inbounds i8, i8* %13, i64 1
%16 = load i8, i8* %15
br label %11
17: ; preds = %11, %11, %11
%18 = icmp eq i8 %12, 58
%19 = zext i1 %18 to i64
%20 = getelementptr i8, i8* %13, i64 %19
br label %21
21: ; preds = %24, %17
%22 = phi i8* [ %20, %17 ], [ %25, %24 ]
%23 = load i8, i8* %22
switch i8 %23, label %39 [
i8 40, label %26
i8 32, label %24
i8 9, label %24
]
24: ; preds = %21, %21
%25 = getelementptr inbounds i8, i8* %22, i64 1
br label %21
26: ; preds = %21
%27 = getelementptr inbounds i8, i8* %22, i64 1
br label %28
28: ; preds = %31, %26
%29 = phi i8* [ %27, %26 ], [ %32, %31 ]
%30 = load i8, i8* %29
switch i8 %30, label %31 [
i8 41, label %33
i8 0, label %39
i8 10, label %39
]
31: ; preds = %28
%32 = getelementptr inbounds i8, i8* %29, i64 1
br label %28
33: ; preds = %28
%34 = ptrtoint i8* %29 to i64
%35 = ptrtoint i8* %27 to i64
%36 = sub i64 %34, %35
%37 = trunc i64 %36 to i32
%38 = tail call i8* @copy_string(i8* %27, i32 %37)
br label %39
39: ; preds = %21, %28, %28, %33
%40 = phi i8* [ %38, %33 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), %28 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), %28 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), %21 ]
ret i8* %40
}