#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 strlen(char *);
int /*<<< orphan*/ write(int, char *, int);
void keyup(int xte_fd, char *key, int *state) {
  if (*state) {
    write(xte_fd, "keyup ", 6);
    write(xte_fd, key, strlen(key));
    write(xte_fd, "\n", 1);
    *state = 0;
  }
}


x86 assembly (clang, -O0):
<keyup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
je     1197 <keyup+0x77>
mov    -0x4(%rbp),%edi
lea    0xeb6(%rip),%rsi
mov    $0x6,%edx
call   1030 <write@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    -0x4(%rbp),%edi
lea    0xe84(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<keyup>:
push   %rbp
push   %r14
push   %rbx
cmpl   $0x0,(%rdx)
je     1170 <keyup+0x50>
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xec8(%rip),%rsi
mov    $0x6,%edx
call   1030 <write@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
lea    0xeaa(%rip),%rsi
mov    %ebp,%edi
mov    $0x1,%edx
call   1030 <write@plt>
movl   $0x0,(%r14)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"keyup \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @keyup(i32 %0, i8* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32*
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32* %2, i32** %6
%7 = load i32*, i32** %6
%8 = load i32, i32* %7
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %21
10: ; preds = %3
%11 = load i32, i32* %4
%12 = call i32 @write(i32 %11, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6)
%13 = load i32, i32* %4
%14 = load i8*, i8** %5
%15 = load i8*, i8** %5
%16 = call i32 @strlen(i8* %15)
%17 = call i32 @write(i32 %13, i8* %14, i32 %16)
%18 = load i32, i32* %4
%19 = call i32 @write(i32 %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%20 = load i32*, i32** %6
store i32 0, i32* %20
br label %21
21: ; preds = %10, %3
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"keyup \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @keyup(i32 %0, i8* %1, i32* nocapture %2) {
%4 = load i32, i32* %2
%5 = icmp eq i32 %4, 0
br i1 %5, label %11, label %6
6: ; preds = %3
%7 = tail call i32 @write(i32 %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6)
%8 = tail call i32 @strlen(i8* %1)
%9 = tail call i32 @write(i32 %0, i8* %1, i32 %8)
%10 = tail call i32 @write(i32 %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
store i32 0, i32* %2
br label %11
11: ; preds = %6, %3
ret void
}