#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*/ comm_handshake(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int recv(int, int *, int, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
void docomm(int sock) {
  int cmd;
  int numbytes;
  comm_handshake(sock);
  if ((numbytes = recv(sock, &cmd, sizeof cmd, 0)) == -1) {
    return;
  }
  switch (cmd) {
  case 0x00000001:
    break;
  default:
    fprintf(stderr, "What?!? %x\n", cmd);
    break;
  }
}


x86 assembly (clang, -O0):
<docomm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <comm_handshake@plt>
mov    -0x4(%rbp),%edi
lea    -0x8(%rbp),%rsi
mov    $0x4,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0xc(%rbp)
cmp    $0xffffffff,%eax
jne    1167 <docomm+0x37>
jmp    1195 <docomm+0x65>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
jne    117d <docomm+0x4d>
jmp    1178 <docomm+0x48>
jmp    1195 <docomm+0x65>
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
lea    0xe70(%rip),%rsi
call   1040 <fprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<docomm>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
call   1050 <comm_handshake@plt>
lea    0xc(%rsp),%rsi
mov    %ebx,%edi
mov    $0x4,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
cmp    $0xffffffff,%eax
je     1172 <docomm+0x42>
mov    0xc(%rsp),%edx
cmp    $0x1,%edx
je     1172 <docomm+0x42>
mov    0x2e7c(%rip),%rax
mov    (%rax),%edi
lea    0xe93(%rip),%rsi
call   1040 <fprintf@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [12 x i8] c"What?!? %x\0A\00"
define void @docomm(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = call i32 @comm_handshake(i32 %5)
%7 = load i32, i32* %2
%8 = call i32 @recv(i32 %7, i32* %3, i32 4, i32 0)
store i32 %8, i32* %4
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %11
10: ; preds = %1
br label %18
11: ; preds = %1
%12 = load i32, i32* %3
switch i32 %12, label %14 [
i32 1, label %13
]
13: ; preds = %11
br label %18
14: ; preds = %11
%15 = load i32, i32* @stderr
%16 = load i32, i32* %3
%17 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %16)
br label %18
18: ; preds = %10, %14, %13
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [12 x i8] c"What?!? %x\0A\00"
define void @docomm(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i32 @comm_handshake(i32 %0)
%5 = call i32 @recv(i32 %0, i32* %2, i32 4, i32 0)
%6 = icmp eq i32 %5, -1
br i1 %6, label %13, label %7
7: ; preds = %1
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, 1
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %8)
br label %13
13: ; preds = %10, %7, %1
ret void
}