#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ XIC;
struct TYPE_3__ {
  int /*<<< orphan*/ xkey;
};
typedef TYPE_1__ XEvent;
typedef scalar_t__ Status;
typedef int /*<<< orphan*/ KeySym;

/* Variables and functions */
scalar_t__ XBufferOverflow;
int XmbLookupString(int /*<<< orphan*/, int /*<<< orphan*/ *, char *, int,
                    int /*<<< orphan*/ *, scalar_t__ *);
int lookupString(XIC xic, XEvent *xevent, char *str, KeySym *sym) {
  Status status = 0;
  const int n = XmbLookupString(xic, &xevent->xkey, str, 7, sym, &status);
  return status == XBufferOverflow ? 0 : n;
}


x86 assembly (clang, -O0):
<lookupString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%r8
mov    $0x7,%ecx
lea    -0x28(%rbp),%r9
call   1030 <XmbLookupString@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rax
mov    0x2e8e(%rip),%rcx
cmp    (%rcx),%rax
jne    116d <lookupString+0x5d>
xor    %eax,%eax
mov    %eax,-0x30(%rbp)
jmp    1173 <lookupString+0x63>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lookupString>:
push   %rax
mov    %rcx,%r8
movq   $0x0,(%rsp)
mov    %rsp,%r9
mov    $0x7,%ecx
call   1030 <XmbLookupString@plt>
mov    (%rsp),%rcx
mov    0x2eb4(%rip),%rdx
xor    %esi,%esi
cmp    (%rdx),%rcx
cmove  %esi,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32 }
@XBufferOverflow = global i64 0
define i32 @lookupString(i32 %0, %struct.TYPE_3__* %1, i8* %2, i32* %3) {
%5 = alloca i32
%6 = alloca %struct.TYPE_3__*
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i64
%10 = alloca i32
store i32 %0, i32* %5
store %struct.TYPE_3__* %1, %struct.TYPE_3__** %6
store i8* %2, i8** %7
store i32* %3, i32** %8
store i64 0, i64* %9
%11 = load i32, i32* %5
%12 = load %struct.TYPE_3__*, %struct.TYPE_3__** %6
%13 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %12, i32 0, i32 0
%14 = load i8*, i8** %7
%15 = load i32*, i32** %8
%16 = call i32 @XmbLookupString(i32 %11, i32* %13, i8* %14, i32 7, i32* %15, i64* %9)
store i32 %16, i32* %10
%17 = load i64, i64* %9
%18 = load i64, i64* @XBufferOverflow
%19 = icmp eq i64 %17, %18
br i1 %19, label %20, label %21
20: ; preds = %4
br label %23
21: ; preds = %4
%22 = load i32, i32* %10
br label %23
23: ; preds = %21, %20
%24 = phi i32 [ 0, %20 ], [ %22, %21 ]
ret i32 %24
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32 }
@XBufferOverflow = global i64 0
define i32 @lookupString(i32 %0, %struct.TYPE_3__* %1, i8* %2, i32* %3) {
%5 = alloca i64
%6 = bitcast i64* %5 to i8*
store i64 0, i64* %5
%7 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 0
%8 = call i32 @XmbLookupString(i32 %0, i32* %7, i8* %2, i32 7, i32* %3, i64* %5)
%9 = load i64, i64* %5
%10 = load i64, i64* @XBufferOverflow
%11 = icmp eq i64 %9, %10
%12 = select i1 %11, i32 0, i32 %8
ret i32 %12
}