#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*/ perror(char *);
int semop(int, struct sembuf *, int);
int V(int semID) {
  struct sembuf buff;
  buff.sem_num = 0;
  buff.sem_op = 1;
  buff.sem_flg = 0;
  if (semop(semID, &buff, 1) == -1) {
    perror("CFSCHED semop V operation error");
    return 0;
  }
  return -1;
}


x86 assembly (clang, -O0):
<V>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movl   $0x1,-0x20(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0x1,%edx
call   1040 <semop@plt>
cmp    $0xffffffff,%eax
jne    1174 <V+0x54>
lea    0xe9d(%rip),%rdi
call   1030 <perror@plt>
movl   $0x0,-0x4(%rbp)
jmp    117b <V+0x5b>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<V>:
sub    $0x18,%rsp
movl   $0x1,(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x8(%rsp)
mov    %rsp,%rsi
mov    $0x1,%edx
call   1040 <semop@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    $0xffffffff,%ecx
je     1151 <V+0x31>
add    $0x18,%rsp
ret
lea    0xea8(%rip),%rdi
call   1030 <perror@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.sembuf = type { i32, i64, i64 }
@.str = [32 x i8] c"CFSCHED semop V operation error\00"
define i32 @V(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.sembuf
store i32 %0, i32* %3
%5 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %4, i32 0, i32 2
store i64 0, i64* %5
%6 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %4, i32 0, i32 0
store i32 1, i32* %6
%7 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %4, i32 0, i32 1
store i64 0, i64* %7
%8 = load i32, i32* %3
%9 = call i32 @semop(i32 %8, %struct.sembuf* %4, i32 1)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %13
11: ; preds = %1
%12 = call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %14
13: ; preds = %1
store i32 -1, i32* %2
br label %14
14: ; preds = %13, %11
%15 = load i32, i32* %2
ret i32 %15
}

LLVM IR (-O2):
%struct.sembuf = type { i32, i64, i64 }
@.str = [32 x i8] c"CFSCHED semop V operation error\00"
define i32 @V(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 i32 @semop(i32 %0, %struct.sembuf* %2, i32 1)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %1, %9
%12 = phi i32 [ 0, %9 ], [ -1, %1 ]
ret i32 %12
}