#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_item_name(char *item_text) {
  char *p;
  if (*item_text == '*')
    item_text++;
  while (*item_text == ' ')
    item_text++;
  p = item_text;
  while (*p && *p != ':')
    p++;
  return copy_string(item_text, p - item_text);
}


x86 assembly (clang, -O0):
<extract_menu_item_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2a,%eax
jne    1138 <extract_menu_item_name+0x28>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    113d <extract_menu_item_name+0x2d>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    115e <extract_menu_item_name+0x4e>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    113d <extract_menu_item_name+0x2d>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x11(%rbp)
je     118b <extract_menu_item_name+0x7b>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    119b <extract_menu_item_name+0x8b>
jmp    11ac <extract_menu_item_name+0x9c>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1166 <extract_menu_item_name+0x56>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
call   1030 <copy_string@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extract_menu_item_name>:
xor    %eax,%eax
cmpb   $0x2a,(%rdi)
sete   %al
add    %rax,%rdi
add    $0xffffffffffffffff,%rdi
nop
movzbl 0x1(%rdi),%eax
add    $0x1,%rdi
cmp    $0x20,%al
je     1120 <extract_menu_item_name+0x10>
xor    %esi,%esi
test   %al,%al
je     1151 <extract_menu_item_name+0x41>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    $0x3a,%al
je     1151 <extract_menu_item_name+0x41>
movzbl 0x1(%rdi,%rsi,1),%eax
add    $0x1,%rsi
test   %al,%al
jne    1140 <extract_menu_item_name+0x30>
jmp    1030 <copy_string@plt>

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

LLVM IR (-O2):
define i8* @extract_menu_item_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 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
%18 = ptrtoint i8* %13 to i64
%19 = ptrtoint i8* %7 to i64
%20 = sub i64 %18, %19
%21 = trunc i64 %20 to i32
%22 = tail call i8* @copy_string(i8* %7, i32 %21)
ret i8* %22
}