#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 */
struct sembuf {
  int sem_op;
  scalar_t__ sem_flg;
  scalar_t__ sem_num;
};

/* Variables and functions */
int /*<<< orphan*/ LogError(char *, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ errno;
scalar_t__ semop(int, struct sembuf *, int);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
void sem_unlock(int sem_set_id) {
  struct sembuf sem_op;
  sem_op.sem_num = 0;
  sem_op.sem_op = 1;
  sem_op.sem_flg = 0;
  if (semop(sem_set_id, &sem_op, 1) == 0)
    return;
  LogError("semop() error in %s line %d: %s",
           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/OpenNetworkInsight/oni-nfdump/refs/heads/"
           "master/bin/bookkeeper.c",
           130, strerror(errno));
}


x86 assembly (clang, -O0):
<sem_unlock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movl   $0x1,-0x20(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0x1,%edx
call   1040 <semop@plt>
cmp    $0x0,%rax
jne    1172 <sem_unlock+0x42>
jmp    119a <sem_unlock+0x6a>
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    %eax,%ecx
lea    0xe77(%rip),%rdi
lea    0xe90(%rip),%rsi
mov    $0x82,%edx
call   1030 <LogError@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sem_unlock>:
sub    $0x18,%rsp
movl   $0x1,(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x8(%rsp)
mov    %rsp,%rsi
mov    $0x1,%edx
call   1040 <semop@plt>
test   %rax,%rax
je     117d <sem_unlock+0x4d>
mov    0x2e84(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
lea    0xe96(%rip),%rdi
lea    0xeaf(%rip),%rsi
mov    $0x82,%edx
mov    %eax,%ecx
call   1030 <LogError@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.sembuf = type { i32, i64, i64 }
@.str = [32 x i8] c"semop() error in %s line %d: %s\00"
@.str.1 = [155 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/OpenNetworkInsight/oni-nfdump/refs/heads/master/bin/bookkeeper.c\00"
@errno = global i32 0
define void @sem_unlock(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.sembuf
store i32 %0, i32* %2
%4 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %3, i32 0, i32 2
store i64 0, i64* %4
%5 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %3, i32 0, i32 0
store i32 1, i32* %5
%6 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %3, i32 0, i32 1
store i64 0, i64* %6
%7 = load i32, i32* %2
%8 = call i64 @semop(i32 %7, %struct.sembuf* %3, i32 1)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %1
br label %15
11: ; preds = %1
%12 = load i32, i32* @errno
%13 = call i32 @strerror(i32 %12)
%14 = call i32 @LogError(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([155 x i8], [155 x i8]* @.str.1, i64 0, i64 0), i32 130, i32 %13)
br label %15
15: ; preds = %11, %10
ret void
}

LLVM IR (-O2):
%struct.sembuf = type { i32, i64, i64 }
@.str = [32 x i8] c"semop() error in %s line %d: %s\00"
@.str.1 = [155 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/OpenNetworkInsight/oni-nfdump/refs/heads/master/bin/bookkeeper.c\00"
@errno = global i32 0
define void @sem_unlock(i32 %0) {
%2 = alloca %struct.sembuf
%3 = bitcast %struct.sembuf* %2 to i8*
%4 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %2, i64 0, i32 0
store i32 1, i32* %4
%5 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %2, i64 0, i32 1
%6 = bitcast i64* %5 to <2 x i64>*
store <2 x i64> zeroinitializer, <2 x i64>* %6
%7 = call i64 @semop(i32 %0, %struct.sembuf* %2, i32 1)
%8 = icmp eq i64 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %1
%10 = load i32, i32* @errno
%11 = call i32 @strerror(i32 %10)
%12 = call i32 @LogError(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([155 x i8], [155 x i8]* @.str.1, i64 0, i64 0), i32 130, i32 %11)
br label %13
13: ; preds = %1, %9
ret void
}