#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 */
struct input_event {
  scalar_t__ type;
  scalar_t__ code;
  int value;
};

/* Variables and functions */
scalar_t__ EV_KEY;
scalar_t__ KEY_MUTE;
const char *mute_string(struct input_event event) {
  if (event.type == EV_KEY && event.code == KEY_MUTE) {
    static size_t repeat_count;
    if (event.value == 1) {
      repeat_count = 1;
      return "button/mute MUTE (key pressed)";
    } else if (event.value == 2) {
      repeat_count++;
      return NULL;
    } else if (event.value == 0) {
      if (repeat_count % 2 == 0) {
        return "button/mute MUTE (key released)";
      }
    }
  }
  return NULL;
}


x86 assembly (clang, -O0):
<mute_string>:
push   %rbp
mov    %rsp,%rbp
lea    0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    (%rax),%rax
mov    0x2eca(%rip),%rcx
cmp    (%rcx),%rax
jne    11d4 <mute_string+0xd4>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x2eba(%rip),%rcx
cmp    (%rcx),%rax
jne    11d4 <mute_string+0xd4>
mov    -0x10(%rbp),%rax
cmpl   $0x1,0x10(%rax)
jne    1160 <mute_string+0x60>
movq   $0x1,0x2ee8(%rip)
lea    0xea9(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11dc <mute_string+0xdc>
mov    -0x10(%rbp),%rax
cmpl   $0x2,0x10(%rax)
jne    118d <mute_string+0x8d>
mov    0x2ec3(%rip),%rax
add    $0x1,%rax
mov    %rax,0x2eb8(%rip)
movq   $0x0,-0x8(%rbp)
jmp    11dc <mute_string+0xdc>
mov    -0x10(%rbp),%rax
cmpl   $0x0,0x10(%rax)
jne    11c5 <mute_string+0xc5>
mov    0x2e96(%rip),%rax
and    $0x1,%rax
cmp    $0x0,%rax
jne    11c0 <mute_string+0xc0>
lea    0xe68(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11dc <mute_string+0xdc>
jmp    11c5 <mute_string+0xc5>
jmp    11ca <mute_string+0xca>
jmp    11cf <mute_string+0xcf>
jmp    11d4 <mute_string+0xd4>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<mute_string>:
mov    0x8(%rsp),%rax
mov    0x2ed4(%rip),%rcx
cmp    (%rcx),%rax
jne    1165 <mute_string+0x65>
lea    0x8(%rsp),%rax
mov    0x8(%rax),%rcx
mov    0x2ec7(%rip),%rdx
cmp    (%rdx),%rcx
jne    1165 <mute_string+0x65>
mov    0x10(%rax),%eax
test   %eax,%eax
je     1154 <mute_string+0x54>
cmp    $0x2,%eax
je     114a <mute_string+0x4a>
cmp    $0x1,%eax
jne    1165 <mute_string+0x65>
movq   $0x1,0x2ef6(%rip)
lea    0xeb7(%rip),%rax
ret
addq   $0x1,0x2ee6(%rip)
01
jmp    1165 <mute_string+0x65>
testb  $0x1,0x2edd(%rip)
jne    1165 <mute_string+0x65>
lea    0xebb(%rip),%rax
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
%struct.input_event = type { i64, i64, i32 }
@EV_KEY = global i64 0
@KEY_MUTE = global i64 0
@mute_string.repeat_count = internal global i64 0
@.str = [31 x i8] c"button/mute MUTE (key pressed)\00"
@.str.1 = [32 x i8] c"button/mute MUTE (key released)\00"
define i8* @mute_string(%struct.input_event* byval(%struct.input_event) align 8 %0) {
%2 = alloca i8*
%3 = getelementptr inbounds %struct.input_event, %struct.input_event* %0, i32 0, i32 0
%4 = load i64, i64* %3
%5 = load i64, i64* @EV_KEY
%6 = icmp eq i64 %4, %5
br i1 %6, label %7, label %37
7: ; preds = %1
%8 = getelementptr inbounds %struct.input_event, %struct.input_event* %0, i32 0, i32 1
%9 = load i64, i64* %8
%10 = load i64, i64* @KEY_MUTE
%11 = icmp eq i64 %9, %10
br i1 %11, label %12, label %37
12: ; preds = %7
%13 = getelementptr inbounds %struct.input_event, %struct.input_event* %0, i32 0, i32 2
%14 = load i32, i32* %13
%15 = icmp eq i32 %14, 1
br i1 %15, label %16, label %17
16: ; preds = %12
store i64 1, i64* @mute_string.repeat_count
store i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8** %2
br label %38
17: ; preds = %12
%18 = getelementptr inbounds %struct.input_event, %struct.input_event* %0, i32 0, i32 2
%19 = load i32, i32* %18
%20 = icmp eq i32 %19, 2
br i1 %20, label %21, label %24
21: ; preds = %17
%22 = load i64, i64* @mute_string.repeat_count
%23 = add i64 %22, 1
store i64 %23, i64* @mute_string.repeat_count
store i8* null, i8** %2
br label %38
24: ; preds = %17
%25 = getelementptr inbounds %struct.input_event, %struct.input_event* %0, i32 0, i32 2
%26 = load i32, i32* %25
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %34
28: ; preds = %24
%29 = load i64, i64* @mute_string.repeat_count
%30 = urem i64 %29, 2
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %28
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %38
33: ; preds = %28
br label %34
34: ; preds = %33, %24
br label %35
35: ; preds = %34
br label %36
36: ; preds = %35
br label %37
37: ; preds = %36, %7, %1
store i8* null, i8** %2
br label %38
38: ; preds = %37, %32, %21, %16
%39 = load i8*, i8** %2
ret i8* %39
}

LLVM IR (-O2):
%struct.input_event = type { i64, i64, i32 }
@EV_KEY = global i64 0
@KEY_MUTE = global i64 0
@mute_string.repeat_count = internal unnamed_addr global i64 0
@.str = [31 x i8] c"button/mute MUTE (key pressed)\00"
@.str.1 = [32 x i8] c"button/mute MUTE (key released)\00"
define i8* @mute_string(%struct.input_event* nocapture byval(%struct.input_event) align 8 %0) {
%2 = getelementptr inbounds %struct.input_event, %struct.input_event* %0, i64 0, i32 0
%3 = load i64, i64* %2
%4 = load i64, i64* @EV_KEY
%5 = icmp eq i64 %3, %4
br i1 %5, label %6, label %22
6: ; preds = %1
%7 = getelementptr inbounds %struct.input_event, %struct.input_event* %0, i64 0, i32 1
%8 = load i64, i64* %7
%9 = load i64, i64* @KEY_MUTE
%10 = icmp eq i64 %8, %9
br i1 %10, label %11, label %22
11: ; preds = %6
%12 = getelementptr inbounds %struct.input_event, %struct.input_event* %0, i64 0, i32 2
%13 = load i32, i32* %12
switch i32 %13, label %22 [
i32 1, label %14
i32 2, label %15
i32 0, label %18
]
14: ; preds = %11
store i64 1, i64* @mute_string.repeat_count
br label %23
15: ; preds = %11
%16 = load i64, i64* @mute_string.repeat_count
%17 = add i64 %16, 1
store i64 %17, i64* @mute_string.repeat_count
br label %23
18: ; preds = %11
%19 = load i64, i64* @mute_string.repeat_count
%20 = and i64 %19, 1
%21 = icmp eq i64 %20, 0
br i1 %21, label %23, label %22
22: ; preds = %11, %18, %6, %1
br label %23
23: ; preds = %18, %22, %15, %14
%24 = phi i8* [ getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), %14 ], [ null, %15 ], [ null, %22 ], [ getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), %18 ]
ret i8* %24
}