#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*/ uint64_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
void *sem_get(int /*<<< orphan*/);
int /*<<< orphan*/ sem_up(void *);
char *shm_get(int /*<<< orphan*/);
int /*<<< orphan*/ stoi(char *);
void main_test_2_ipc(int argc, char **argv) {
  uint64_t key = stoi(argv[0]);
  void *sem = sem_get(key);
  char *shm = shm_get(key);
  printf("Ingrese mensaje: ");
  scanf("%s\n", shm);
  sem_up(sem);
}


x86 assembly (clang, -O0):
<main_test_2_ipc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1080 <stoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1070 <sem_get@plt>
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
call   1060 <shm_get@plt>
mov    %rax,-0x28(%rbp)
lea    0xe63(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xe65(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <sem_up@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main_test_2_ipc>:
push   %r14
push   %rbx
push   %rax
mov    (%rsi),%rdi
call   1080 <stoi@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1070 <sem_get@plt>
mov    %rax,%r14
mov    %ebx,%edi
call   1060 <shm_get@plt>
mov    %rax,%rbx
lea    0xe77(%rip),%rdi
call   1040 <printf@plt>
lea    0xe7d(%rip),%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <sem_up@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"Ingrese mensaje: \00"
@.str.1 = [4 x i8] c"%s\0A\00"
define void @main_test_2_ipc(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%8 = load i8**, i8*** %4
%9 = getelementptr inbounds i8*, i8** %8, i64 0
%10 = load i8*, i8** %9
%11 = call i32 @stoi(i8* %10)
store i32 %11, i32* %5
%12 = load i32, i32* %5
%13 = call i8* @sem_get(i32 %12)
store i8* %13, i8** %6
%14 = load i32, i32* %5
%15 = call i8* @shm_get(i32 %14)
store i8* %15, i8** %7
%16 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%17 = load i8*, i8** %7
%18 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = load i8*, i8** %6
%20 = call i32 @sem_up(i8* %19)
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"Ingrese mensaje: \00"
@.str.1 = [4 x i8] c"%s\0A\00"
define void @main_test_2_ipc(i32 %0, i8** nocapture %1) {
%3 = load i8*, i8** %1
%4 = tail call i32 @stoi(i8* %3)
%5 = tail call i8* @sem_get(i32 %4)
%6 = tail call i8* @shm_get(i32 %4)
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%9 = tail call i32 @sem_up(i8* %5)
ret void
}