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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ *stderr;
void __attribute__((__noreturn__)) usage(FILE *out) {
  fprintf(out, "Helper tool to create/remove shared memory segments.\n");
  fprintf(out, "Options:\n");
  fprintf(out, " -m, --shmem <size>       create shared memory segment of size "
               "<size>\n");
  fprintf(out, " -r, --remove <shmid>        remove shared memory segment with "
               "id <shmid>\n");
  fprintf(out, " -p, --perm <permission>    permissions for memory segment to "
               "create. Default: 0644\n");
  fprintf(out, " -h, --help     display this help and exit\n");
  exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<usage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xec9(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xeef(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xee9(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xf20(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xf5b(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xfa0(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rax
mov    0x2e49(%rip),%rcx
cmp    (%rcx),%rax
jne    11b1 <usage+0x91>
mov    0x2e31(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
jmp    11bd <usage+0x9d>
mov    0x2e18(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<usage>:
push   %rbx
mov    %rdi,%rbx
lea    0xed5(%rip),%rdi
mov    $0x35,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fwrite@plt>
lea    0xef2(%rip),%rdi
mov    $0x9,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fwrite@plt>
lea    0xee3(%rip),%rdi
mov    $0x46,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fwrite@plt>
lea    0xf11(%rip),%rdi
mov    $0x4a,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fwrite@plt>
lea    0xf43(%rip),%rdi
mov    $0x54,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fwrite@plt>
lea    0xf7f(%rip),%rdi
mov    $0x2b,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fwrite@plt>
mov    0x2e1f(%rip),%rax
cmp    %rbx,(%rax)
jne    11d4 <usage+0xb4>
mov    0x2e0b(%rip),%rax
mov    (%rax),%edi
call   1030 <exit@plt>
mov    0x2df5(%rip),%rax
mov    (%rax),%edi
call   1030 <exit@plt>

LLVM IR (-O0):
@.str = [54 x i8] c"Helper tool to create/remove shared memory segments.\0A\00"
@.str.1 = [10 x i8] c"Options:\0A\00"
@.str.2 = [71 x i8] c" -m, --shmem <size> create shared memory segment of size <size>\0A\00"
@.str.3 = [75 x i8] c" -r, --remove <shmid> remove shared memory segment with id <shmid>\0A\00"
@.str.4 = [85 x i8] c" -p, --perm <permission> permissions for memory segment to create. Default: 0644\0A\00"
@.str.5 = [44 x i8] c" -h, --help display this help and exit\0A\00"
@stderr = global i32* null
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define void @usage(i32* %0) {
%2 = alloca i32*
store i32* %0, i32** %2
%3 = load i32*, i32** %2
%4 = call i32 @fprintf(i32* %3, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%5 = load i32*, i32** %2
%6 = call i32 @fprintf(i32* %5, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%7 = load i32*, i32** %2
%8 = call i32 @fprintf(i32* %7, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.2, i64 0, i64 0))
%9 = load i32*, i32** %2
%10 = call i32 @fprintf(i32* %9, i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.3, i64 0, i64 0))
%11 = load i32*, i32** %2
%12 = call i32 @fprintf(i32* %11, i8* getelementptr inbounds ([85 x i8], [85 x i8]* @.str.4, i64 0, i64 0))
%13 = load i32*, i32** %2
%14 = call i32 @fprintf(i32* %13, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0))
%15 = load i32*, i32** %2
%16 = load i32*, i32** @stderr
%17 = icmp eq i32* %15, %16
br i1 %17, label %18, label %20
18: ; preds = %1
%19 = load i32, i32* @EXIT_FAILURE
br label %22
20: ; preds = %1
%21 = load i32, i32* @EXIT_SUCCESS
br label %22
22: ; preds = %20, %18
%23 = phi i32 [ %19, %18 ], [ %21, %20 ]
%24 = call i32 @exit(i32 %23)
unreachable
}

LLVM IR (-O2):
@.str = [54 x i8] c"Helper tool to create/remove shared memory segments.\0A\00"
@.str.1 = [10 x i8] c"Options:\0A\00"
@.str.2 = [71 x i8] c" -m, --shmem <size> create shared memory segment of size <size>\0A\00"
@.str.3 = [75 x i8] c" -r, --remove <shmid> remove shared memory segment with id <shmid>\0A\00"
@.str.4 = [85 x i8] c" -p, --perm <permission> permissions for memory segment to create. Default: 0644\0A\00"
@.str.5 = [44 x i8] c" -h, --help display this help and exit\0A\00"
@stderr = global i32* null
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define void @usage(i32* nocapture %0) {
%2 = tail call i64 @fwrite(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i64 53, i64 1, i32* %0)
%3 = tail call i64 @fwrite(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i64 9, i64 1, i32* %0)
%4 = tail call i64 @fwrite(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.2, i64 0, i64 0), i64 70, i64 1, i32* %0)
%5 = tail call i64 @fwrite(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.3, i64 0, i64 0), i64 74, i64 1, i32* %0)
%6 = tail call i64 @fwrite(i8* getelementptr inbounds ([85 x i8], [85 x i8]* @.str.4, i64 0, i64 0), i64 84, i64 1, i32* %0)
%7 = tail call i64 @fwrite(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), i64 43, i64 1, i32* %0)
%8 = load i32*, i32** @stderr
%9 = icmp eq i32* %8, %0
%10 = load i32, i32* @EXIT_FAILURE
%11 = load i32, i32* @EXIT_SUCCESS
%12 = select i1 %9, i32 %10, i32 %11
%13 = tail call i32 @exit(i32 %12)
unreachable
}