#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*/ printf(char *, unsigned int);
void checaEstado(void *lampadas, void *idxLampada) {
  unsigned char *pLampadas = (unsigned char *)lampadas;
  unsigned int *pIdxLampada = (unsigned int *)idxLampada;
  if (pLampadas[*pIdxLampada] == 0) {
    printf("Estado da lampada %d: DESLIGADA!\n", *pIdxLampada);
  } else {
    printf("Estado da lampada %d: LIGADA!\n", *pIdxLampada);
  }
}


x86 assembly (clang, -O0):
<checaEstado>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rcx),%ecx
movzbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    115e <checaEstado+0x4e>
mov    -0x20(%rbp),%rax
mov    (%rax),%esi
lea    0xeac(%rip),%rdi
call   1030 <printf@plt>
jmp    1170 <checaEstado+0x60>
mov    -0x20(%rbp),%rax
mov    (%rax),%esi
lea    0xeb7(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checaEstado>:
mov    (%rsi),%esi
cmpb   $0x0,(%rdi,%rsi,1)
lea    0xee3(%rip),%rax
lea    0xefe(%rip),%rdi
cmove  %rax,%rdi
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [34 x i8] c"Estado da lampada %d: DESLIGADA!\0A\00"
@.str.1 = [31 x i8] c"Estado da lampada %d: LIGADA!\0A\00"
define void @checaEstado(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
store i8* %7, i8** %5
%8 = load i8*, i8** %4
%9 = bitcast i8* %8 to i32*
store i32* %9, i32** %6
%10 = load i8*, i8** %5
%11 = load i32*, i32** %6
%12 = load i32, i32* %11
%13 = zext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %10, i64 %13
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %2
%19 = load i32*, i32** %6
%20 = load i32, i32* %19
%21 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %20)
br label %26
22: ; preds = %2
%23 = load i32*, i32** %6
%24 = load i32, i32* %23
%25 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %22, %18
ret void
}

LLVM IR (-O2):
@.str = [34 x i8] c"Estado da lampada %d: DESLIGADA!\0A\00"
@.str.1 = [31 x i8] c"Estado da lampada %d: LIGADA!\0A\00"
define void @checaEstado(i8* nocapture %0, i8* nocapture %1) {
%3 = bitcast i8* %1 to i32*
%4 = load i32, i32* %3
%5 = zext i32 %4 to i64
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 0
%9 = select i1 %8, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0)
%10 = tail call i32 @printf(i8* %9, i32 %4)
ret void
}