#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 getopt(int, char **, char *);
int /*<<< orphan*/ ipc_send_message(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ ipc_start_listening(char *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ strlen(char *);
int main(int argc, char *argv[]) {
  int opt;
  if (argc == 1) {
    sleep(20);
    return -1;
  }
  while ((opt = getopt(argc, argv, "sc")) != -1) {
    switch (opt) {
    case 's':
      ipc_start_listening("/tmp/ipctest");
      break;
    case 'c':
      ipc_send_message("/tmp/ipctest", argv[2], strlen(argv[2]));
      break;
    }
  }
  return 0;
}


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    1186 <main+0x36>
mov    $0x14,%edi
call   1070 <sleep@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1217 <main+0xc7>
jmp    118b <main+0x3b>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe67(%rip),%rdx
call   1050 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     1210 <main+0xc0>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0x63,%eax
je     11e0 <main+0x90>
jmp    11be <main+0x6e>
mov    -0x18(%rbp),%eax
sub    $0x73,%eax
jne    120b <main+0xbb>
jmp    11cf <main+0x7f>
lea    0xe2d(%rip),%rdi
call   1060 <ipc_start_listening@plt>
jmp    120b <main+0xbb>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <strlen@plt>
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
lea    0xdfd(%rip),%rdi
call   1040 <ipc_send_message@plt>
jmp    118b <main+0x3b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    $0x1,%edi
jne    116e <main+0x1e>
mov    $0x14,%edi
call   1070 <sleep@plt>
mov    $0xffffffff,%eax
jmp    11dd <main+0x8d>
mov    %rsi,%rbx
mov    %edi,%r12d
lea    0xe85(%rip),%r14
lea    0xe81(%rip),%r15
jmp    1198 <main+0x48>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
call   1060 <ipc_start_listening@plt>
mov    %r12d,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1050 <getopt@plt>
cmp    $0x63,%eax
je     11c0 <main+0x70>
cmp    $0x73,%eax
je     1190 <main+0x40>
cmp    $0xffffffff,%eax
jne    1198 <main+0x48>
jmp    11db <main+0x8b>
nopw   0x0(%rax,%rax,1)
mov    0x10(%rbx),%rbp
mov    %rbp,%rdi
call   1030 <strlen@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   1040 <ipc_send_message@plt>
jmp    1198 <main+0x48>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"sc\00"
@.str.1 = [13 x i8] c"/tmp/ipctest\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @sleep(i32 20)
store i32 -1, i32* %3
br label %32
11: ; preds = %2
br label %12
12: ; preds = %30, %11
%13 = load i32, i32* %4
%14 = load i8**, i8*** %5
%15 = call i32 @getopt(i32 %13, i8** %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %15, i32* %6
%16 = icmp ne i32 %15, -1
br i1 %16, label %17, label %31
17: ; preds = %12
%18 = load i32, i32* %6
switch i32 %18, label %30 [
i32 115, label %19
i32 99, label %21
]
19: ; preds = %17
%20 = call i32 @ipc_start_listening(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %30
21: ; preds = %17
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
%28 = call i32 @strlen(i8* %27)
%29 = call i32 @ipc_send_message(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %24, i32 %28)
br label %30
30: ; preds = %17, %21, %19
br label %12
31: ; preds = %12
store i32 0, i32* %3
br label %32
32: ; preds = %31, %9
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
@.str = [3 x i8] c"sc\00"
@.str.1 = [13 x i8] c"/tmp/ipctest\00"
define i32 @main(i32 %0, i8** %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 2
br label %8
6: ; preds = %2
%7 = tail call i32 @sleep(i32 20)
br label %17
8: ; preds = %10, %4
%9 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
switch i32 %9, label %10 [
i32 -1, label %17
i32 115, label %11
i32 99, label %13
]
10: ; preds = %8, %13, %11
br label %8
11: ; preds = %8
%12 = tail call i32 @ipc_start_listening(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %10
13: ; preds = %8
%14 = load i8*, i8** %5
%15 = tail call i32 @strlen(i8* %14)
%16 = tail call i32 @ipc_send_message(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %14, i32 %15)
br label %10
17: ; preds = %8, %6
%18 = phi i32 [ -1, %6 ], [ 0, %8 ]
ret i32 %18
}