void report_sem_errors(int s) {
  switch (s) {
  case -1:
    printf(1, "nroError:%d-sem_id is not in use, should be created\n", s);
    break;
  case -2:
    printf(
        1,
        "nroError:%d-the process has the maximun number of semaphores allowed",
        s);
    break;
  case -3:
    printf(1, "nroError:%d-the system don't have any free semaphore", s);
    break;
  case -4:
    printf(1,
           "nroError:%d-wrong sem_id parameter, sem_id cannot be less than -1",
           s);
    break;
  }
}


x86 assembly (clang, -O0):
<report_sem_errors>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x4,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x3,%eax
ja     11ab <report_sem_errors+0x9b>
mov    -0x10(%rbp),%rax
lea    0xec5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x4(%rbp),%edx
mov    $0x1,%edi
lea    0xebd(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ab <report_sem_errors+0x9b>
mov    -0x4(%rbp),%edx
mov    $0x1,%edi
lea    0xed7(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ab <report_sem_errors+0x9b>
mov    -0x4(%rbp),%edx
mov    $0x1,%edi
lea    0xf01(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ab <report_sem_errors+0x9b>
mov    -0x4(%rbp),%edx
mov    $0x1,%edi
lea    0xf1b(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<report_sem_errors>:
add    $0x4,%edi
cmp    $0x3,%edi
ja     1140 <report_sem_errors+0x30>
lea    0xee1(%rip),%rax
movslq (%rax,%rdi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
lea    0xf90(%rip),%rsi
mov    $0x1,%edi
mov    $0xfffffffc,%edx
xor    %eax,%eax
jmp    1030 <printf@plt>
ret
lea    0xf42(%rip),%rsi
mov    $0x1,%edi
mov    $0xfffffffd,%edx
xor    %eax,%eax
jmp    1030 <printf@plt>
lea    0xee5(%rip),%rsi
mov    $0x1,%edi
mov    $0xfffffffe,%edx
xor    %eax,%eax
jmp    1030 <printf@plt>
lea    0xe98(%rip),%rsi
mov    $0x1,%edi
mov    $0xffffffff,%edx
xor    %eax,%eax
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [53 x i8] c"nroError:%d-sem_id is not in use, should be created\0A\00"
@.str.1 = [69 x i8] c"nroError:%d-the process has the maximun number of semaphores allowed\00"
@.str.2 = [53 x i8] c"nroError:%d-the system don't have any free semaphore\00"
@.str.3 = [66 x i8] c"nroError:%d-wrong sem_id parameter, sem_id cannot be less than -1\00"
define void @report_sem_errors(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
switch i32 %3, label %16 [
i32 -1, label %4
i32 -2, label %7
i32 -3, label %10
i32 -4, label %13
]
4: ; preds = %1
%5 = load i32, i32* %2
%6 = call i32 (i8*, ...) @printf(i8* inttoptr (i64 1 to i8*), i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i32 %5)
br label %16
7: ; preds = %1
%8 = load i32, i32* %2
%9 = call i32 (i8*, ...) @printf(i8* inttoptr (i64 1 to i8*), i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.1, i64 0, i64 0), i32 %8)
br label %16
10: ; preds = %1
%11 = load i32, i32* %2
%12 = call i32 (i8*, ...) @printf(i8* inttoptr (i64 1 to i8*), i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0), i32 %11)
br label %16
13: ; preds = %1
%14 = load i32, i32* %2
%15 = call i32 (i8*, ...) @printf(i8* inttoptr (i64 1 to i8*), i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.3, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %1, %13, %10, %7, %4
ret void
}

LLVM IR (-O2):
@.str = [53 x i8] c"nroError:%d-sem_id is not in use, should be created\0A\00"
@.str.1 = [69 x i8] c"nroError:%d-the process has the maximun number of semaphores allowed\00"
@.str.2 = [53 x i8] c"nroError:%d-the system don't have any free semaphore\00"
@.str.3 = [66 x i8] c"nroError:%d-wrong sem_id parameter, sem_id cannot be less than -1\00"
define void @report_sem_errors(i32 %0) {
switch i32 %0, label %10 [
i32 -1, label %2
i32 -2, label %4
i32 -3, label %6
i32 -4, label %8
]
2: ; preds = %1
%3 = tail call i32 (i8*, ...) @printf(i8* inttoptr (i64 1 to i8*), i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i32 -1)
br label %10
4: ; preds = %1
%5 = tail call i32 (i8*, ...) @printf(i8* inttoptr (i64 1 to i8*), i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.1, i64 0, i64 0), i32 -2)
br label %10
6: ; preds = %1
%7 = tail call i32 (i8*, ...) @printf(i8* inttoptr (i64 1 to i8*), i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0), i32 -3)
br label %10
8: ; preds = %1
%9 = tail call i32 (i8*, ...) @printf(i8* inttoptr (i64 1 to i8*), i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.3, i64 0, i64 0), i32 -4)
br label %10
10: ; preds = %1, %8, %6, %4, %2
ret void
}