#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 /*<<< orphan*/ printf(char *);
int shmget(int /*<<< orphan*/, int, int);
int crearZonaMemoriaCompartida(key_t clave, int tamano) {
  int idMemoria;
  idMemoria = shmget(clave, tamano, 0777 | IPC_CREAT);
  if (idMemoria == -1) {
    printf("No consigo Id para la memoria compartida");
    return -1;
  }
  printf("Creado Id para la memoria compartida\n");
  return idMemoria;
}


x86 assembly (clang, -O0):
<crearZonaMemoriaCompartida>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    0x2ea5(%rip),%rax
mov    (%rax),%edx
or     $0x1ff,%edx
call   1040 <shmget@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0xffffffff,-0x10(%rbp)
jne    116d <crearZonaMemoriaCompartida+0x4d>
lea    0xea4(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    117f <crearZonaMemoriaCompartida+0x5f>
lea    0xeb5(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<crearZonaMemoriaCompartida>:
push   %rbx
mov    0x2ea8(%rip),%rax
mov    $0x1ff,%edx
or     (%rax),%edx
call   1050 <shmget@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
je     1159 <crearZonaMemoriaCompartida+0x29>
lea    0xed7(%rip),%rdi
call   1030 <puts@plt>
jmp    1165 <crearZonaMemoriaCompartida+0x35>
lea    0xea0(%rip),%rdi
call   1040 <printf@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@IPC_CREAT = global i32 0
@.str = [41 x i8] c"No consigo Id para la memoria compartida\00"
@.str.1 = [38 x i8] c"Creado Id para la memoria compartida\0A\00"
define i32 @crearZonaMemoriaCompartida(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%7 = load i32, i32* %4
%8 = load i32, i32* %5
%9 = load i32, i32* @IPC_CREAT
%10 = or i32 511, %9
%11 = call i32 @shmget(i32 %7, i32 %8, i32 %10)
store i32 %11, i32* %6
%12 = load i32, i32* %6
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %19
16: ; preds = %2
%17 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
%18 = load i32, i32* %6
store i32 %18, i32* %3
br label %19
19: ; preds = %16, %14
%20 = load i32, i32* %3
ret i32 %20
}

LLVM IR (-O2):
@IPC_CREAT = global i32 0
@.str = [41 x i8] c"No consigo Id para la memoria compartida\00"
@str = [37 x i8] c"Creado Id para la memoria compartida\00"
define i32 @crearZonaMemoriaCompartida(i32 %0, i32 %1) {
%3 = load i32, i32* @IPC_CREAT
%4 = or i32 %3, 511
%5 = tail call i32 @shmget(i32 %0, i32 %1, i32 %4)
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
br label %11
9: ; preds = %2
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
br label %11
11: ; preds = %9, %7
ret i32 %5
}