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

/* Variables and functions */
int createS_M();
int /*<<< orphan*/ deleteS_M(int);
int /*<<< orphan*/ deletesem();
int /*<<< orphan*/ detachS_M(void *);
int /*<<< orphan*/ detachsem();
int /*<<< orphan*/ opensem();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sender(void *);
void *shmat(int, int /*<<< orphan*/ *, int /*<<< orphan*/);
int main() {
  opensem();
  int shmid = createS_M();
  void *shmp_p = shmat(shmid, NULL, 0);
  sender(shmp_p);
  detachsem();
  deletesem();
  detachS_M(shmp_p);
  deleteS_M(shmid);
  printf("exit program!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1070 <opensem@plt>
mov    $0x0,%al
call   1030 <createS_M@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   10a0 <shmat@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   10b0 <sender@plt>
mov    $0x0,%al
call   1080 <detachsem@plt>
mov    $0x0,%al
call   1040 <deletesem@plt>
mov    -0x10(%rbp),%rdi
call   1050 <detachS_M@plt>
mov    -0x8(%rbp),%edi
call   1090 <deleteS_M@plt>
lea    0xe0f(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1070 <opensem@plt>
xor    %eax,%eax
call   1030 <createS_M@plt>
mov    %eax,%ebp
mov    %eax,%edi
xor    %esi,%esi
xor    %edx,%edx
call   10a0 <shmat@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   10b0 <sender@plt>
xor    %eax,%eax
call   1080 <detachsem@plt>
xor    %eax,%eax
call   1040 <deletesem@plt>
mov    %rbx,%rdi
call   1060 <detachS_M@plt>
mov    %ebp,%edi
call   1090 <deleteS_M@plt>
lea    0xe23(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"exit program!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
store i32 0, i32* %1
%4 = call i32 (...) @opensem()
%5 = call i32 (...) @createS_M()
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = call i8* @shmat(i32 %6, i32* null, i32 0)
store i8* %7, i8** %3
%8 = load i8*, i8** %3
%9 = call i32 @sender(i8* %8)
%10 = call i32 (...) @detachsem()
%11 = call i32 (...) @deletesem()
%12 = load i8*, i8** %3
%13 = call i32 @detachS_M(i8* %12)
%14 = load i32, i32* %2
%15 = call i32 @deleteS_M(i32 %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@str = [14 x i8] c"exit program!\00"
define i32 @main() {
%1 = tail call i32 (...) @opensem()
%2 = tail call i32 (...) @createS_M()
%3 = tail call i8* @shmat(i32 %2, i32* null, i32 0)
%4 = tail call i32 @sender(i8* %3)
%5 = tail call i32 (...) @detachsem()
%6 = tail call i32 (...) @deletesem()
%7 = tail call i32 @detachS_M(i8* %3)
%8 = tail call i32 @deleteS_M(i32 %2)
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
ret i32 0
}