#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*/ COLOR_PAIR(int);
int /*<<< orphan*/ attroff(int /*<<< orphan*/);
int /*<<< orphan*/ attron(int /*<<< orphan*/);
int /*<<< orphan*/ move(int, int /*<<< orphan*/);
int /*<<< orphan*/ printw(char *);
int /*<<< orphan*/ refresh();
scalar_t__ strcmp(char *, char *);
void cli_set_led(char *name, bool state) {
  int led = -1;
  if (strcmp(name, "LED_0") == 0) {
    led = 0;
  }
  if (strcmp(name, "LED_1") == 0) {
    led = 1;
  }
  if (strcmp(name, "LED_2") == 0) {
    led = 2;
  }
  if (led >= 0) {
    move(led, 0);
    if (state) {
      attron(COLOR_PAIR(2));
    } else {
      attron(COLOR_PAIR(1));
    }
    printw(" ");
    if (state) {
      attroff(COLOR_PAIR(2));
    } else {
      attroff(COLOR_PAIR(1));
    }
    switch (led) {
    case 0:
      printw(" DOWN");
      break;
    case 1:
      printw(" CLOSED");
      break;
    case 2:
      printw(" MEMBER");
      break;
    }
    refresh();
  }
}


x86 assembly (clang, -O0):
<cli_set_led>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0xffffffff,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe6f(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11a7 <cli_set_led+0x37>
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe54(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11c8 <cli_set_led+0x58>
movl   $0x1,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe39(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11e9 <cli_set_led+0x79>
movl   $0x2,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jl     12d5 <cli_set_led+0x165>
mov    -0x10(%rbp),%edi
xor    %esi,%esi
call   1090 <move@plt>
cmpl   $0x0,-0xc(%rbp)
je     121d <cli_set_led+0xad>
mov    $0x2,%edi
call   1070 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1040 <attron@plt>
jmp    122e <cli_set_led+0xbe>
mov    $0x1,%edi
call   1070 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1040 <attron@plt>
lea    0xddd(%rip),%rdi
call   1060 <printw@plt>
cmpl   $0x0,-0xc(%rbp)
je     125a <cli_set_led+0xea>
mov    $0x2,%edi
call   1070 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1030 <attroff@plt>
jmp    126b <cli_set_led+0xfb>
mov    $0x1,%edi
call   1070 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1030 <attroff@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
test   %eax,%eax
je     12a0 <cli_set_led+0x130>
jmp    127e <cli_set_led+0x10e>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
je     12b1 <cli_set_led+0x141>
jmp    128f <cli_set_led+0x11f>
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
je     12c2 <cli_set_led+0x152>
jmp    12ce <cli_set_led+0x15e>
lea    0xd6d(%rip),%rdi
call   1060 <printw@plt>
jmp    12ce <cli_set_led+0x15e>
lea    0xd62(%rip),%rdi
call   1060 <printw@plt>
jmp    12ce <cli_set_led+0x15e>
lea    0xd59(%rip),%rdi
call   1060 <printw@plt>
mov    $0x0,%al
call   1080 <refresh@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cli_set_led>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%rbp
lea    0xe7c(%rip),%rsi
call   1050 <strcmp@plt>
neg    %rax
sbb    %r15d,%r15d
lea    0xe70(%rip),%rsi
mov    %rbp,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
mov    $0x1,%ebx
cmovne %r15d,%ebx
lea    0xe5b(%rip),%rsi
mov    %rbp,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
mov    $0x2,%ebp
cmove  %ebp,%ebx
test   %ebx,%ebx
js     122c <cli_set_led+0xbc>
mov    %ebx,%edi
xor    %esi,%esi
call   1090 <move@plt>
cmp    $0x1,%r14d
sbb    $0x0,%ebp
mov    %ebp,%edi
call   1070 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1040 <attron@plt>
lea    0xe25(%rip),%rdi
call   1060 <printw@plt>
mov    %ebp,%edi
call   1070 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1030 <attroff@plt>
cmp    $0x2,%ebx
ja     121b <cli_set_led+0xab>
movslq %ebx,%rax
lea    0xe1d(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
call   1060 <printw@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1080 <refresh@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"LED_0\00"
@.str.1 = [6 x i8] c"LED_1\00"
@.str.2 = [6 x i8] c"LED_2\00"
@.str.3 = [2 x i8] c" \00"
@.str.4 = [6 x i8] c" DOWN\00"
@.str.5 = [8 x i8] c" CLOSED\00"
@.str.6 = [8 x i8] c" MEMBER\00"
define void @cli_set_led(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 -1, i32* %5
%6 = load i8*, i8** %3
%7 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %2
store i32 0, i32* %5
br label %10
10: ; preds = %9, %2
%11 = load i8*, i8** %3
%12 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %10
store i32 1, i32* %5
br label %15
15: ; preds = %14, %10
%16 = load i8*, i8** %3
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %15
store i32 2, i32* %5
br label %20
20: ; preds = %19, %15
%21 = load i32, i32* %5
%22 = icmp sge i32 %21, 0
br i1 %22, label %23, label %54
23: ; preds = %20
%24 = load i32, i32* %5
%25 = call i32 @move(i32 %24, i32 0)
%26 = load i32, i32* %4
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %23
%29 = call i32 @COLOR_PAIR(i32 2)
%30 = call i32 @attron(i32 %29)
br label %34
31: ; preds = %23
%32 = call i32 @COLOR_PAIR(i32 1)
%33 = call i32 @attron(i32 %32)
br label %34
34: ; preds = %31, %28
%35 = call i32 @printw(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%36 = load i32, i32* %4
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %34
%39 = call i32 @COLOR_PAIR(i32 2)
%40 = call i32 @attroff(i32 %39)
br label %44
41: ; preds = %34
%42 = call i32 @COLOR_PAIR(i32 1)
%43 = call i32 @attroff(i32 %42)
br label %44
44: ; preds = %41, %38
%45 = load i32, i32* %5
switch i32 %45, label %52 [
i32 0, label %46
i32 1, label %48
i32 2, label %50
]
46: ; preds = %44
%47 = call i32 @printw(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %52
48: ; preds = %44
%49 = call i32 @printw(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
br label %52
50: ; preds = %44
%51 = call i32 @printw(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
br label %52
52: ; preds = %44, %50, %48, %46
%53 = call i32 (...) @refresh()
br label %54
54: ; preds = %52, %20
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"LED_0\00"
@.str.1 = [6 x i8] c"LED_1\00"
@.str.2 = [6 x i8] c"LED_2\00"
@.str.3 = [2 x i8] c" \00"
@.str.4 = [6 x i8] c" DOWN\00"
@.str.5 = [8 x i8] c" CLOSED\00"
@.str.6 = [8 x i8] c" MEMBER\00"
@reltable.cli_set_led = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.4 to i64), i64 ptrtoint ([3 x i32]* @reltable.cli_set_led to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.5 to i64), i64 ptrtoint ([3 x i32]* @reltable.cli_set_led to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.6 to i64), i64 ptrtoint ([3 x i32]* @reltable.cli_set_led to i64)) to i32)]
define void @cli_set_led(i8* %0, i32 %1) {
%3 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%4 = icmp ne i64 %3, 0
%5 = sext i1 %4 to i32
%6 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
%8 = select i1 %7, i32 1, i32 %5
%9 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
%11 = select i1 %10, i32 2, i32 %8
%12 = icmp sgt i32 %11, -1
br i1 %12, label %13, label %30
13: ; preds = %2
%14 = tail call i32 @move(i32 %11, i32 0)
%15 = icmp eq i32 %1, 0
%16 = select i1 %15, i32 1, i32 2
%17 = tail call i32 @COLOR_PAIR(i32 %16)
%18 = tail call i32 @attron(i32 %17)
%19 = tail call i32 @printw(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%20 = tail call i32 @COLOR_PAIR(i32 %16)
%21 = tail call i32 @attroff(i32 %20)
%22 = icmp ult i32 %11, 3
br i1 %22, label %23, label %28
23: ; preds = %13
%24 = sext i32 %11 to i64
%25 = shl i64 %24, 2
%26 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.cli_set_led to i8*), i64 %25)
%27 = tail call i32 @printw(i8* %26)
br label %28
28: ; preds = %13, %23
%29 = tail call i32 (...) @refresh()
br label %30
30: ; preds = %28, %2
ret void
}