#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 /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ receiver();
int /*<<< orphan*/ sender();
int /*<<< orphan*/ strlen(char *);
scalar_t__ strncmp(char *, char *, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  if (argc != 2) {
    printf("ERROR: bad arg count %d; \"-send\" or \"-recv\" expected\n", argc);
    exit(-1);
  }
  if (strncmp(argv[1], "-send", strlen("-send")) == 0) {
    sender();
  } else if (strncmp(argv[1], "-recv", strlen("-recv")) == 0) {
    receiver();
  } else {
    printf("ERROR: unknown arg %s; \"-send\" or \"-recv\" expected\n", argv[1]);
    exit(-1);
  }
  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   $0x2,-0x8(%rbp)
je     119b <main+0x3b>
mov    -0x8(%rbp),%esi
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
lea    0xe88(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x18(%rbp),%rdi
mov    %eax,%edx
lea    0xe76(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11db <main+0x7b>
mov    $0x0,%al
call   1070 <sender@plt>
jmp    1240 <main+0xe0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
lea    0xe4e(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%edx
lea    0xe3c(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    121b <main+0xbb>
mov    $0x0,%al
call   1060 <receiver@plt>
jmp    123b <main+0xdb>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
jmp    1240 <main+0xe0>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
cmp    $0x2,%edi
jne    11cf <main+0x6f>
mov    %rsi,%r14
mov    0x8(%rsi),%rbx
lea    0xebe(%rip),%r15
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11c0 <main+0x60>
mov    0x8(%r14),%rbx
lea    0xe9f(%rip),%r15
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    11e9 <main+0x89>
xor    %eax,%eax
call   1060 <receiver@plt>
jmp    11c7 <main+0x67>
xor    %eax,%eax
call   1070 <sender@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
mov    %edi,%esi
lea    0xe28(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
mov    0x8(%r14),%rsi
lea    0xe4e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [54 x i8] c"ERROR: bad arg count %d; \22-send\22 or \22-recv\22 expected\0A\00"
@.str.1 = [6 x i8] c"-send\00"
@.str.2 = [6 x i8] c"-recv\00"
@.str.3 = [52 x i8] c"ERROR: unknown arg %s; \22-send\22 or \22-recv\22 expected\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp ne i32 %6, 2
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = load i32, i32* %4
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = call i32 @exit(i32 -1)
unreachable
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%17 = call i64 @strncmp(i8* %15, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %12
%20 = call i32 (...) @sender()
br label %37
21: ; preds = %12
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%26 = call i64 @strncmp(i8* %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %25)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %21
%29 = call i32 (...) @receiver()
br label %36
30: ; preds = %21
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.3, i64 0, i64 0), i8* %33)
%35 = call i32 @exit(i32 -1)
unreachable
36: ; preds = %28
br label %37
37: ; preds = %36, %19
ret i32 0
}

LLVM IR (-O2):
@.str = [54 x i8] c"ERROR: bad arg count %d; \22-send\22 or \22-recv\22 expected\0A\00"
@.str.1 = [6 x i8] c"-send\00"
@.str.2 = [6 x i8] c"-recv\00"
@.str.3 = [52 x i8] c"ERROR: unknown arg %s; \22-send\22 or \22-recv\22 expected\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i32 %0)
%6 = tail call i32 @exit(i32 -1)
unreachable
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%11 = tail call i64 @strncmp(i8* %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %7
%14 = tail call i32 (...) @sender()
br label %26
15: ; preds = %7
%16 = load i8*, i8** %8
%17 = tail call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%18 = tail call i64 @strncmp(i8* %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %15
%21 = tail call i32 (...) @receiver()
br label %26
22: ; preds = %15
%23 = load i8*, i8** %8
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.3, i64 0, i64 0), i8* %23)
%25 = tail call i32 @exit(i32 -1)
unreachable
26: ; preds = %20, %13
ret i32 0
}