#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 */
typedef int /*<<< orphan*/ key_t;

/* Variables and functions */
int IPC_CREAT;
int IPC_EXCL;
int S_IRWXG;
int S_IRWXO;
int S_IRWXU;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int semget(int /*<<< orphan*/, int, int);
int /*<<< orphan*/ stderr;
int sem_create(key_t key) {
  int sem_anfordid;
  if ((sem_anfordid = semget(
           key, 1, S_IRWXU | S_IRWXG | S_IRWXO | IPC_CREAT | IPC_EXCL)) == -1) {
    fprintf(stderr,
            "Error: semaphore (Anforderungen) konnte nicht angelegt werden\n");
    exit(-1);
  }
  return (sem_anfordid);
}


x86 assembly (clang, -O0):
<sem_create>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e93(%rip),%rax
mov    (%rax),%edx
mov    0x2e82(%rip),%rax
or     (%rax),%edx
mov    0x2e91(%rip),%rax
or     (%rax),%edx
mov    0x2e58(%rip),%rax
or     (%rax),%edx
mov    0x2e87(%rip),%rax
or     (%rax),%edx
mov    $0x1,%esi
call   1030 <semget@plt>
mov    %eax,-0x8(%rbp)
cmp    $0xffffffff,%eax
jne    11a0 <sem_create+0x70>
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
lea    0xe6f(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sem_create>:
push   %rax
mov    0x2ea0(%rip),%rax
mov    0x2e91(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2e9e(%rip),%rax
or     (%rax),%edx
mov    0x2e65(%rip),%rax
or     (%rax),%edx
mov    0x2e94(%rip),%rax
or     (%rax),%edx
mov    $0x1,%esi
call   1030 <semget@plt>
cmp    $0xffffffff,%eax
je     116f <sem_create+0x3f>
pop    %rcx
ret
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
lea    0xe81(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@S_IRWXU = global i32 0
@S_IRWXG = global i32 0
@S_IRWXO = global i32 0
@IPC_CREAT = global i32 0
@IPC_EXCL = global i32 0
@stderr = global i32 0
@.str = [63 x i8] c"Error: semaphore (Anforderungen) konnte nicht angelegt werden\0A\00"
define i32 @sem_create(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = load i32, i32* @S_IRWXU
%6 = load i32, i32* @S_IRWXG
%7 = or i32 %5, %6
%8 = load i32, i32* @S_IRWXO
%9 = or i32 %7, %8
%10 = load i32, i32* @IPC_CREAT
%11 = or i32 %9, %10
%12 = load i32, i32* @IPC_EXCL
%13 = or i32 %11, %12
%14 = call i32 @semget(i32 %4, i32 1, i32 %13)
store i32 %14, i32* %3
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %20
16: ; preds = %1
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @exit(i32 -1)
unreachable
20: ; preds = %1
%21 = load i32, i32* %3
ret i32 %21
}

LLVM IR (-O2):
@S_IRWXU = global i32 0
@S_IRWXG = global i32 0
@S_IRWXO = global i32 0
@IPC_CREAT = global i32 0
@IPC_EXCL = global i32 0
@stderr = global i32 0
@.str = [63 x i8] c"Error: semaphore (Anforderungen) konnte nicht angelegt werden\0A\00"
define i32 @sem_create(i32 %0) {
%2 = load i32, i32* @S_IRWXU
%3 = load i32, i32* @S_IRWXG
%4 = or i32 %3, %2
%5 = load i32, i32* @S_IRWXO
%6 = or i32 %4, %5
%7 = load i32, i32* @IPC_CREAT
%8 = or i32 %6, %7
%9 = load i32, i32* @IPC_EXCL
%10 = or i32 %8, %9
%11 = tail call i32 @semget(i32 %0, i32 1, i32 %10)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %17
13: ; preds = %1
%14 = load i32, i32* @stderr
%15 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str, i64 0, i64 0))
%16 = tail call i32 @exit(i32 -1)
unreachable
17: ; preds = %1
ret i32 %11
}