#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 */
typedef int uint8_t;
typedef scalar_t__ color;

/* Variables and functions */
int /*<<< orphan*/ clearGPIO(int, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ setGPIO(int, int);
bool setLED(uint8_t color) {
  if (color > 7) {
    printf("Invalid color code %d\n", color);
    return false;
  }
  clearGPIO(2, 10);
  clearGPIO(2, 11);
  clearGPIO(2, 12);
  if (((color) & (1 << (0)))) {
    setGPIO(2, 10);
  }
  if (((color) & (1 << (1)))) {
    setGPIO(2, 11);
  }
  if (((color) & (1 << (2)))) {
    setGPIO(2, 12);
  }
  return true;
}


x86 assembly (clang, -O0):
<setLED>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x7,-0x8(%rbp)
jle    1160 <setLED+0x30>
mov    -0x8(%rbp),%esi
lea    0xeb1(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11ee <setLED+0xbe>
mov    $0x2,%edi
mov    $0xa,%esi
call   1030 <clearGPIO@plt>
mov    $0x2,%edi
mov    $0xb,%esi
call   1030 <clearGPIO@plt>
mov    $0x2,%edi
mov    $0xc,%esi
call   1030 <clearGPIO@plt>
mov    -0x8(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11ab <setLED+0x7b>
mov    $0x2,%edi
mov    $0xa,%esi
call   1050 <setGPIO@plt>
mov    -0x8(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     11c9 <setLED+0x99>
mov    $0x2,%edi
mov    $0xb,%esi
call   1050 <setGPIO@plt>
mov    -0x8(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     11e7 <setLED+0xb7>
mov    $0x2,%edi
mov    $0xc,%esi
call   1050 <setGPIO@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setLED>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
cmp    $0x8,%edi
jl     114c <setLED+0x1c>
lea    0xebf(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
xor    %ebp,%ebp
jmp    11ba <setLED+0x8a>
mov    $0x2,%edi
mov    $0xa,%esi
call   1030 <clearGPIO@plt>
mov    $0x2,%edi
mov    $0xb,%esi
call   1030 <clearGPIO@plt>
mov    $0x2,%edi
mov    $0xc,%esi
call   1030 <clearGPIO@plt>
test   $0x1,%bl
je     118d <setLED+0x5d>
mov    $0x2,%edi
mov    $0xa,%esi
call   1050 <setGPIO@plt>
test   $0x2,%bl
je     11a1 <setLED+0x71>
mov    $0x2,%edi
mov    $0xb,%esi
call   1050 <setGPIO@plt>
mov    $0x1,%ebp
test   $0x4,%bl
je     11ba <setLED+0x8a>
mov    $0x2,%edi
mov    $0xc,%esi
call   1050 <setGPIO@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Invalid color code %d\0A\00"
define i32 @setLED(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp sgt i32 %4, 7
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = load i32, i32* %3
%8 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %7)
store i32 0, i32* %2
br label %31
9: ; preds = %1
%10 = call i32 @clearGPIO(i32 2, i32 10)
%11 = call i32 @clearGPIO(i32 2, i32 11)
%12 = call i32 @clearGPIO(i32 2, i32 12)
%13 = load i32, i32* %3
%14 = and i32 %13, 1
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %9
%17 = call i32 @setGPIO(i32 2, i32 10)
br label %18
18: ; preds = %16, %9
%19 = load i32, i32* %3
%20 = and i32 %19, 2
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = call i32 @setGPIO(i32 2, i32 11)
br label %24
24: ; preds = %22, %18
%25 = load i32, i32* %3
%26 = and i32 %25, 4
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %24
%29 = call i32 @setGPIO(i32 2, i32 12)
br label %30
30: ; preds = %28, %24
store i32 1, i32* %2
br label %31
31: ; preds = %30, %6
%32 = load i32, i32* %2
ret i32 %32
}

LLVM IR (-O2):
@.str = [23 x i8] c"Invalid color code %d\0A\00"
define i32 @setLED(i32 %0) {
%2 = icmp sgt i32 %0, 7
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %23
5: ; preds = %1
%6 = tail call i32 @clearGPIO(i32 2, i32 10)
%7 = tail call i32 @clearGPIO(i32 2, i32 11)
%8 = tail call i32 @clearGPIO(i32 2, i32 12)
%9 = and i32 %0, 1
%10 = icmp eq i32 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %5
%12 = tail call i32 @setGPIO(i32 2, i32 10)
br label %13
13: ; preds = %11, %5
%14 = and i32 %0, 2
%15 = icmp eq i32 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %13
%17 = tail call i32 @setGPIO(i32 2, i32 11)
br label %18
18: ; preds = %16, %13
%19 = and i32 %0, 4
%20 = icmp eq i32 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %18
%22 = tail call i32 @setGPIO(i32 2, i32 12)
br label %23
23: ; preds = %18, %21, %3
%24 = phi i32 [ 0, %3 ], [ 1, %21 ], [ 1, %18 ]
ret i32 %24
}