#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*/ strchr(char const *, char);
int iupStrFindMnemonic(const char *str) {
  int c = 0, found = 0;
  if (!str)
    return 0;
  if (!strchr(str, '&'))
    return 0;
  while (*str) {
    if (*str == '&') {
      if (*(str + 1) == '&') {
        found = -1;
        str++;
      } else if (found != 1) {
        found = 1;
        c = *(str + 1);
      }
    }
    str++;
  }
  if (found == 0)
    return 0;
  else
    return c;
}


x86 assembly (clang, -O0):
<iupStrFindMnemonic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1141 <iupStrFindMnemonic+0x31>
movl   $0x0,-0x4(%rbp)
jmp    1202 <iupStrFindMnemonic+0xf2>
mov    -0x10(%rbp),%rdi
mov    $0x26,%esi
call   1030 <strchr@plt>
cmp    $0x0,%eax
jne    1164 <iupStrFindMnemonic+0x54>
movl   $0x0,-0x4(%rbp)
jmp    1202 <iupStrFindMnemonic+0xf2>
jmp    1169 <iupStrFindMnemonic+0x59>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     11e6 <iupStrFindMnemonic+0xd6>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x26,%eax
jne    11d5 <iupStrFindMnemonic+0xc5>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x26,%eax
jne    11af <iupStrFindMnemonic+0x9f>
movl   $0xffffffff,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11d0 <iupStrFindMnemonic+0xc0>
cmpl   $0x1,-0x18(%rbp)
je     11cb <iupStrFindMnemonic+0xbb>
movl   $0x1,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
mov    %eax,-0x14(%rbp)
jmp    11d0 <iupStrFindMnemonic+0xc0>
jmp    11d5 <iupStrFindMnemonic+0xc5>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1169 <iupStrFindMnemonic+0x59>
cmpl   $0x0,-0x18(%rbp)
jne    11fc <iupStrFindMnemonic+0xec>
movl   $0x0,-0x4(%rbp)
jmp    1202 <iupStrFindMnemonic+0xf2>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iupStrFindMnemonic>:
push   %rbp
push   %rbx
push   %rax
xor    %ebp,%ebp
test   %rdi,%rdi
je     1182 <iupStrFindMnemonic+0x72>
mov    %rdi,%rbx
mov    $0x26,%esi
call   1030 <strchr@plt>
test   %eax,%eax
je     1182 <iupStrFindMnemonic+0x72>
xor    %ebp,%ebp
xor    %eax,%eax
jmp    1148 <iupStrFindMnemonic+0x38>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
test   %cl,%cl
je     117d <iupStrFindMnemonic+0x6d>
add    $0x1,%rbx
movzbl (%rbx),%ecx
cmp    $0x26,%cl
jne    1140 <iupStrFindMnemonic+0x30>
movsbl 0x1(%rbx),%ecx
cmp    $0x26,%ecx
jne    1170 <iupStrFindMnemonic+0x60>
add    $0x1,%rbx
mov    $0xffffffff,%eax
add    $0x1,%rbx
jmp    1148 <iupStrFindMnemonic+0x38>
nopl   0x0(%rax,%rax,1)
cmp    $0x1,%eax
cmovne %ecx,%ebp
mov    $0x1,%eax
jmp    1144 <iupStrFindMnemonic+0x34>
test   %eax,%eax
cmove  %eax,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @iupStrFindMnemonic(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
store i32 0, i32* %5
%6 = load i8*, i8** %3
%7 = icmp ne i8* %6, null
br i1 %7, label %9, label %8
8: ; preds = %1
store i32 0, i32* %2
br label %52
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i32 @strchr(i8* %10, i8 signext 38)
%12 = icmp ne i32 %11, 0
br i1 %12, label %14, label %13
13: ; preds = %9
store i32 0, i32* %2
br label %52
14: ; preds = %9
br label %15
15: ; preds = %43, %14
%16 = load i8*, i8** %3
%17 = load i8, i8* %16
%18 = icmp ne i8 %17, 0
br i1 %18, label %19, label %46
19: ; preds = %15
%20 = load i8*, i8** %3
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 38
br i1 %23, label %24, label %43
24: ; preds = %19
%25 = load i8*, i8** %3
%26 = getelementptr inbounds i8, i8* %25, i64 1
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 38
br i1 %29, label %30, label %33
30: ; preds = %24
store i32 -1, i32* %5
%31 = load i8*, i8** %3
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %3
br label %42
33: ; preds = %24
%34 = load i32, i32* %5
%35 = icmp ne i32 %34, 1
br i1 %35, label %36, label %41
36: ; preds = %33
store i32 1, i32* %5
%37 = load i8*, i8** %3
%38 = getelementptr inbounds i8, i8* %37, i64 1
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
store i32 %40, i32* %4
br label %41
41: ; preds = %36, %33
br label %42
42: ; preds = %41, %30
br label %43
43: ; preds = %42, %19
%44 = load i8*, i8** %3
%45 = getelementptr inbounds i8, i8* %44, i32 1
store i8* %45, i8** %3
br label %15
46: ; preds = %15
%47 = load i32, i32* %5
%48 = icmp eq i32 %47, 0
br i1 %48, label %49, label %50
49: ; preds = %46
store i32 0, i32* %2
br label %52
50: ; preds = %46
%51 = load i32, i32* %4
store i32 %51, i32* %2
br label %52
52: ; preds = %50, %49, %13, %8
%53 = load i32, i32* %2
ret i32 %53
}

LLVM IR (-O2):
define i32 @iupStrFindMnemonic(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %27, label %3
3: ; preds = %1
%4 = tail call i32 @strchr(i8* %0, i8 signext 38)
%5 = icmp eq i32 %4, 0
br i1 %5, label %27, label %6
6: ; preds = %3, %19
%7 = phi i8* [ %23, %19 ], [ %0, %3 ]
%8 = phi i32 [ %21, %19 ], [ 0, %3 ]
%9 = phi i32 [ %22, %19 ], [ 0, %3 ]
%10 = load i8, i8* %7
switch i8 %10, label %19 [
i8 0, label %24
i8 38, label %11
]
11: ; preds = %6
%12 = getelementptr inbounds i8, i8* %7, i64 1
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 38
br i1 %14, label %19, label %15
15: ; preds = %11
%16 = sext i8 %13 to i32
%17 = icmp eq i32 %9, 1
%18 = select i1 %17, i32 %8, i32 %16
br label %19
19: ; preds = %11, %15, %6
%20 = phi i8* [ %7, %6 ], [ %7, %15 ], [ %12, %11 ]
%21 = phi i32 [ %8, %6 ], [ %18, %15 ], [ %8, %11 ]
%22 = phi i32 [ %9, %6 ], [ 1, %15 ], [ -1, %11 ]
%23 = getelementptr inbounds i8, i8* %20, i64 1
br label %6
24: ; preds = %6
%25 = icmp eq i32 %9, 0
%26 = select i1 %25, i32 0, i32 %8
br label %27
27: ; preds = %24, %3, %1
%28 = phi i32 [ 0, %1 ], [ 0, %3 ], [ %26, %24 ]
ret i32 %28
}