#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 */
#define EAGAIN 131
#define EDEADLK 130
#define EINTR 129
#define EINVAL 128
int /*<<< orphan*/ printf(char *, char *);
void validaSemWait(int e) {
  char *mensaje = "\n\t-Se produjo el error";
  switch (e) {
  case EINVAL:
    printf("%s EINVAL (The sem argument does not refer to a valid semaphore.) "
           "\n\n",
           mensaje);
    break;
  case EINTR:
    printf("%s EINTR (A signal interrupted this function.) \n\n", mensaje);
    break;
  case EDEADLK:
    printf("%s EDEADLK (A deadlock condition was detected..) \n\n", mensaje);
    break;
  case EAGAIN:
    printf("%s EAGAIN (The semaphore was already locked, so it cannot be "
           "immediately locked by the sem_trywait() operation.) \n\n",
           mensaje);
    break;
  }
}


x86 assembly (clang, -O0):
<validaSemWait>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
lea    0xeee(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x3,%eax
ja     119e <validaSemWait+0x8e>
mov    -0x18(%rbp),%rax
lea    0xeba(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rsi
lea    0xecd(%rip),%rdi
call   1030 <printf@plt>
jmp    119e <validaSemWait+0x8e>
mov    -0x10(%rbp),%rsi
lea    0xefd(%rip),%rdi
call   1030 <printf@plt>
jmp    119e <validaSemWait+0x8e>
mov    -0x10(%rbp),%rsi
lea    0xf1a(%rip),%rdi
call   1030 <printf@plt>
jmp    119e <validaSemWait+0x8e>
mov    -0x10(%rbp),%rsi
lea    0xf39(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<validaSemWait>:
add    $0xffffff80,%edi
cmp    $0x3,%edi
ja     1135 <validaSemWait+0x25>
movslq %edi,%rax
lea    0x1016(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
lea    0xed0(%rip),%rsi
jmp    1030 <printf@plt>
ret

LLVM IR (-O0):
@.str = [23 x i8] c"\0A\09-Se produjo el error\00"
@.str.1 = [69 x i8] c"%s EINVAL (The sem argument does not refer to a valid semaphore.) \0A\0A\00"
@.str.2 = [50 x i8] c"%s EINTR (A signal interrupted this function.) \0A\0A\00"
@.str.3 = [52 x i8] c"%s EDEADLK (A deadlock condition was detected..) \0A\0A\00"
@.str.4 = [116 x i8] c"%s EAGAIN (The semaphore was already locked, so it cannot be immediately locked by the sem_trywait() operation.) \0A\0A\00"
define void @validaSemWait(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
store i32 %0, i32* %2
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8** %3
%4 = load i32, i32* %2
switch i32 %4, label %17 [
i32 128, label %5
i32 129, label %8
i32 130, label %11
i32 131, label %14
]
5: ; preds = %1
%6 = load i8*, i8** %3
%7 = call i32 @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.1, i64 0, i64 0), i8* %6)
br label %17
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0), i8* %9)
br label %17
11: ; preds = %1
%12 = load i8*, i8** %3
%13 = call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.3, i64 0, i64 0), i8* %12)
br label %17
14: ; preds = %1
%15 = load i8*, i8** %3
%16 = call i32 @printf(i8* getelementptr inbounds ([116 x i8], [116 x i8]* @.str.4, i64 0, i64 0), i8* %15)
br label %17
17: ; preds = %1, %14, %11, %8, %5
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"\0A\09-Se produjo el error\00"
@.str.1 = [69 x i8] c"%s EINVAL (The sem argument does not refer to a valid semaphore.) \0A\0A\00"
@.str.2 = [50 x i8] c"%s EINTR (A signal interrupted this function.) \0A\0A\00"
@.str.3 = [52 x i8] c"%s EDEADLK (A deadlock condition was detected..) \0A\0A\00"
@.str.4 = [116 x i8] c"%s EAGAIN (The semaphore was already locked, so it cannot be immediately locked by the sem_trywait() operation.) \0A\0A\00"
@reltable.validaSemWait = [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([69 x i8]* @.str.1 to i64), i64 ptrtoint ([4 x i32]* @reltable.validaSemWait to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([50 x i8]* @.str.2 to i64), i64 ptrtoint ([4 x i32]* @reltable.validaSemWait to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([52 x i8]* @.str.3 to i64), i64 ptrtoint ([4 x i32]* @reltable.validaSemWait to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([116 x i8]* @.str.4 to i64), i64 ptrtoint ([4 x i32]* @reltable.validaSemWait to i64)) to i32)]
define void @validaSemWait(i32 %0) {
%2 = add i32 %0, -128
%3 = icmp ult i32 %2, 4
br i1 %3, label %4, label %9
4: ; preds = %1
%5 = sext i32 %2 to i64
%6 = shl i64 %5, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.validaSemWait to i8*), i64 %6)
%8 = tail call i32 @printf(i8* %7, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %1, %4
ret void
}