#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ close(int);
int getopt(int, char **, char *);
int ipc_init(int /*<<< orphan*/);
int /*<<< orphan*/ ipc_send(int, char, int /*<<< orphan*/);
int /*<<< orphan*/ optarg;
int /*<<< orphan*/ usage();
int main(int argc, char **argv) {
  int opt;
  int ipc_fd;
  int ret;
  if (argc == 1) {
    usage();
    return EXIT_FAILURE;
  }
  ret = EXIT_SUCCESS;
  while ((opt = getopt(argc, argv, "hlr:")) != -1) {
    switch (opt) {
    case 'l':
    case 'r':
      ipc_fd = ipc_init(0);
      if (ipc_fd < 0)
        return EXIT_FAILURE;
      if (!ipc_send(ipc_fd, (char)opt, optarg))
        ret = EXIT_FAILURE;
      close(ipc_fd);
      break;
    default:
    case 'h':
      usage();
    }
  }
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1188 <main+0x38>
mov    $0x0,%al
call   1060 <usage@plt>
mov    0x2e5a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    125e <main+0x10e>
mov    0x2e41(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe5e(%rip),%rdx
call   1070 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     1258 <main+0x108>
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
sub    $0x68,%eax
je     124c <main+0xfc>
jmp    11c7 <main+0x77>
mov    -0x20(%rbp),%eax
sub    $0x6c,%eax
je     11e9 <main+0x99>
jmp    11d8 <main+0x88>
mov    -0x20(%rbp),%eax
sub    $0x72,%eax
jne    1247 <main+0xf7>
jmp    11e9 <main+0x99>
xor    %edi,%edi
call   1030 <ipc_init@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    120e <main+0xbe>
mov    0x2dd4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    125e <main+0x10e>
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%eax
mov    0x2ddd(%rip),%rcx
mov    (%rcx),%edx
movsbl %al,%esi
call   1040 <ipc_send@plt>
cmp    $0x0,%eax
jne    123a <main+0xea>
mov    0x2da3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%edi
call   1050 <close@plt>
jmp    1253 <main+0x103>
jmp    124c <main+0xfc>
mov    $0x0,%al
call   1060 <usage@plt>
jmp    1194 <main+0x44>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x1,%edi
jne    1183 <main+0x33>
xor    %eax,%eax
call   1060 <usage@plt>
mov    0x2e6a(%rip),%rax
mov    (%rax),%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsi,%r12
mov    %edi,%ebp
mov    0x2e41(%rip),%rax
mov    (%rax),%r14d
lea    0xe67(%rip),%r15
jmp    11a7 <main+0x57>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <usage@plt>
mov    %ebp,%edi
mov    %r12,%rsi
mov    %r15,%rdx
call   1070 <getopt@plt>
cmp    $0xffffffff,%eax
je     1171 <main+0x21>
mov    %eax,%ebx
cmp    $0x72,%eax
je     11c5 <main+0x75>
cmp    $0x6c,%ebx
jne    11a0 <main+0x50>
xor    %edi,%edi
call   1030 <ipc_init@plt>
test   %eax,%eax
js     1167 <main+0x17>
mov    %eax,%r13d
mov    0x2e1e(%rip),%rax
mov    (%rax),%edx
movsbl %bl,%esi
mov    %r13d,%edi
call   1040 <ipc_send@plt>
test   %eax,%eax
jne    11f5 <main+0xa5>
mov    0x2de6(%rip),%rax
mov    (%rax),%r14d
mov    %r13d,%edi
call   1050 <close@plt>
jmp    11a7 <main+0x57>

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
@.str = [5 x i8] c"hlr:\00"
@optarg = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = call i32 (...) @usage()
%13 = load i32, i32* @EXIT_FAILURE
store i32 %13, i32* %3
br label %47
14: ; preds = %2
%15 = load i32, i32* @EXIT_SUCCESS
store i32 %15, i32* %8
br label %16
16: ; preds = %44, %14
%17 = load i32, i32* %4
%18 = load i8**, i8*** %5
%19 = call i32 @getopt(i32 %17, i8** %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %19, i32* %6
%20 = icmp ne i32 %19, -1
br i1 %20, label %21, label %45
21: ; preds = %16
%22 = load i32, i32* %6
switch i32 %22, label %41 [
i32 108, label %23
i32 114, label %23
i32 104, label %42
]
23: ; preds = %21, %21
%24 = call i32 @ipc_init(i32 0)
store i32 %24, i32* %7
%25 = load i32, i32* %7
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %23
%28 = load i32, i32* @EXIT_FAILURE
store i32 %28, i32* %3
br label %47
29: ; preds = %23
%30 = load i32, i32* %7
%31 = load i32, i32* %6
%32 = trunc i32 %31 to i8
%33 = load i32, i32* @optarg
%34 = call i32 @ipc_send(i32 %30, i8 signext %32, i32 %33)
%35 = icmp ne i32 %34, 0
br i1 %35, label %38, label %36
36: ; preds = %29
%37 = load i32, i32* @EXIT_FAILURE
store i32 %37, i32* %8
br label %38
38: ; preds = %36, %29
%39 = load i32, i32* %7
%40 = call i32 @close(i32 %39)
br label %44
41: ; preds = %21
br label %42
42: ; preds = %21, %41
%43 = call i32 (...) @usage()
br label %44
44: ; preds = %42, %38
br label %16
45: ; preds = %16
%46 = load i32, i32* %8
store i32 %46, i32* %3
br label %47
47: ; preds = %45, %27, %11
%48 = load i32, i32* %3
ret i32 %48
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
@.str = [5 x i8] c"hlr:\00"
@optarg = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = tail call i32 (...) @usage()
%6 = load i32, i32* @EXIT_FAILURE
br label %28
7: ; preds = %2
%8 = load i32, i32* @EXIT_SUCCESS
br label %9
9: ; preds = %18, %7
%10 = phi i32 [ %24, %18 ], [ %8, %7 ]
br label %11
11: ; preds = %9, %26
%12 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
switch i32 %12, label %26 [
i32 -1, label %28
i32 108, label %13
i32 114, label %13
]
13: ; preds = %11, %11
%14 = tail call i32 @ipc_init(i32 0)
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = load i32, i32* @EXIT_FAILURE
br label %28
18: ; preds = %13
%19 = trunc i32 %12 to i8
%20 = load i32, i32* @optarg
%21 = tail call i32 @ipc_send(i32 %14, i8 signext %19, i32 %20)
%22 = icmp eq i32 %21, 0
%23 = load i32, i32* @EXIT_FAILURE
%24 = select i1 %22, i32 %23, i32 %10
%25 = tail call i32 @close(i32 %14)
br label %9
26: ; preds = %11
%27 = tail call i32 (...) @usage()
br label %11
28: ; preds = %11, %16, %4
%29 = phi i32 [ %6, %4 ], [ %17, %16 ], [ %10, %11 ]
ret i32 %29
}