#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*/ compose_message(char *, unsigned char, unsigned int);
int /*<<< orphan*/ perror(char *);
scalar_t__ write_to_stick(char *, int);
int display_repo_status(unsigned char led, int status) {
  char message[80];
  unsigned int color;
  if (status == 0) {
    color = 0x000500;
  } else if (status == 1) {
    color = 0x000005;
  } else {
    color = 0x050000;
  }
  compose_message(message, led, color);
  if (write_to_stick(message, 10) != 0) {
    perror("write_to_stick() error");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<display_repo_status>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1157 <display_repo_status+0x27>
movl   $0x500,-0x64(%rbp)
jmp    1179 <display_repo_status+0x49>
cmpl   $0x1,-0xc(%rbp)
jne    116d <display_repo_status+0x3d>
movl   $0x5,-0x64(%rbp)
jmp    1174 <display_repo_status+0x44>
movl   $0x50000,-0x64(%rbp)
jmp    1179 <display_repo_status+0x49>
lea    -0x60(%rbp),%rdi
mov    -0x5(%rbp),%al
mov    -0x64(%rbp),%edx
movzbl %al,%esi
call   1030 <compose_message@plt>
lea    -0x60(%rbp),%rdi
mov    $0xa,%esi
call   1050 <write_to_stick@plt>
cmp    $0x0,%rax
je     11bb <display_repo_status+0x8b>
lea    0xe56(%rip),%rdi
call   1040 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c2 <display_repo_status+0x92>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display_repo_status>:
push   %rbx
sub    $0x50,%rsp
mov    %edi,%eax
cmp    $0x1,%esi
mov    $0x5,%ecx
mov    $0x50000,%edi
cmove  %ecx,%edi
test   %esi,%esi
mov    $0x500,%edx
cmovne %edi,%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <compose_message@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1050 <write_to_stick@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    117b <display_repo_status+0x4b>
add    $0x50,%rsp
pop    %rbx
ret
lea    0xe7e(%rip),%rdi
call   1040 <perror@plt>
mov    $0xffffffff,%eax
jmp    1175 <display_repo_status+0x45>

LLVM IR (-O0):
@.str = [23 x i8] c"write_to_stick() error\00"
define i32 @display_repo_status(i8 zeroext %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8
%5 = alloca i32
%6 = alloca [80 x i8]
%7 = alloca i32
store i8 %0, i8* %4
store i32 %1, i32* %5
%8 = load i32, i32* %5
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 1280, i32* %7
br label %17
11: ; preds = %2
%12 = load i32, i32* %5
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %15
14: ; preds = %11
store i32 5, i32* %7
br label %16
15: ; preds = %11
store i32 327680, i32* %7
br label %16
16: ; preds = %15, %14
br label %17
17: ; preds = %16, %10
%18 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%19 = load i8, i8* %4
%20 = load i32, i32* %7
%21 = call i32 @compose_message(i8* %18, i8 zeroext %19, i32 %20)
%22 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%23 = call i64 @write_to_stick(i8* %22, i32 10)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %17
%26 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %28
27: ; preds = %17
store i32 0, i32* %3
br label %28
28: ; preds = %27, %25
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
@.str = [23 x i8] c"write_to_stick() error\00"
define i32 @display_repo_status(i8 zeroext %0, i32 %1) {
%3 = alloca [80 x i8]
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %1, 1
%6 = select i1 %5, i32 5, i32 327680
%7 = icmp eq i32 %1, 0
%8 = select i1 %7, i32 1280, i32 %6
%9 = call i32 @compose_message(i8* %4, i8 zeroext %0, i32 %8)
%10 = call i64 @write_to_stick(i8* %4, i32 10)
%11 = icmp eq i64 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %2
%13 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %2, %12
%15 = phi i32 [ -1, %12 ], [ 0, %2 ]
ret i32 %15
}