#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*/ memset(char *, int /*<<< orphan*/, int);
scalar_t__ net_control_write(int, char *, int);
int /*<<< orphan*/ printf(char *, char, char, char);
int strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, int);
int hub_make_call(int fd, char *fifoargs) {
  char tmpbuf[256];
  int i = strlen(fifoargs);
  memset(tmpbuf, 0, 256);
  tmpbuf[0] = 'C';
  tmpbuf[1] = i;
  strncat(&tmpbuf[2], fifoargs, 253);
  printf("%02x %02x %02x\n", tmpbuf[0], tmpbuf[1], tmpbuf[2]);
  if (net_control_write(fd, tmpbuf, i + 2) < 0)
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<hub_make_call>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x114(%rbp)
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
movb   $0x43,-0x110(%rbp)
mov    -0x114(%rbp),%eax
mov    %al,-0x10f(%rbp)
lea    -0x110(%rbp),%rdi
add    $0x2,%rdi
mov    -0x10(%rbp),%rsi
mov    $0xfd,%edx
call   1060 <strncat@plt>
mov    -0x110(%rbp),%cl
mov    -0x10f(%rbp),%al
lea    0xe3d(%rip),%rdi
movsbl %cl,%esi
movsbl %al,%edx
movsbl -0x10e(%rbp),%ecx
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
lea    -0x110(%rbp),%rsi
mov    -0x114(%rbp),%edx
add    $0x2,%edx
call   1070 <net_control_write@plt>
cmp    $0x0,%rax
jge    1203 <hub_make_call+0xb3>
movl   $0xffffffff,-0x4(%rbp)
jmp    120a <hub_make_call+0xba>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hub_make_call>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %rsi,%rbx
mov    %edi,%r15d
mov    %rsi,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
movb   $0x43,(%rsp)
mov    %bpl,0x1(%rsp)
lea    0x2(%rsp),%rdi
mov    %rbx,%rsi
mov    $0xfd,%edx
call   1060 <strncat@plt>
movsbl (%rsp),%esi
movsbl 0x1(%rsp),%edx
movsbl 0x2(%rsp),%ecx
lea    0xe51(%rip),%rdi
call   1040 <printf@plt>
add    $0x2,%ebp
mov    %r15d,%edi
mov    %r14,%rsi
mov    %ebp,%edx
call   1070 <net_control_write@plt>
sar    $0x3f,%rax
add    $0x108,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"%02x %02x %02x\0A\00"
define i32 @hub_make_call(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca [256 x i8]
%7 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
%8 = load i8*, i8** %5
%9 = call i32 @strlen(i8* %8)
store i32 %9, i32* %7
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%11 = call i32 @memset(i8* %10, i32 0, i32 256)
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
store i8 67, i8* %12
%13 = load i32, i32* %7
%14 = trunc i32 %13 to i8
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 1
store i8 %14, i8* %15
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 2
%17 = load i8*, i8** %5
%18 = call i32 @strncat(i8* %16, i8* %17, i32 253)
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%20 = load i8, i8* %19
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 1
%22 = load i8, i8* %21
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 2
%24 = load i8, i8* %23
%25 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8 signext %20, i8 signext %22, i8 signext %24)
%26 = load i32, i32* %4
%27 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 2
%30 = call i64 @net_control_write(i32 %26, i8* %27, i32 %29)
%31 = icmp slt i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %2
store i32 -1, i32* %3
br label %34
33: ; preds = %2
store i32 0, i32* %3
br label %34
34: ; preds = %33, %32
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
@.str = [16 x i8] c"%02x %02x %02x\0A\00"
define i32 @hub_make_call(i32 %0, i8* %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @strlen(i8* %1)
%6 = call i32 @memset(i8* %4, i32 0, i32 256)
store i8 67, i8* %4
%7 = trunc i32 %5 to i8
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 1
store i8 %7, i8* %8
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 2
%10 = call i32 @strncat(i8* %9, i8* %1, i32 253)
%11 = load i8, i8* %4
%12 = load i8, i8* %8
%13 = load i8, i8* %9
%14 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8 signext %11, i8 signext %12, i8 signext %13)
%15 = add nsw i32 %5, 2
%16 = call i64 @net_control_write(i32 %0, i8* %4, i32 %15)
%17 = ashr i64 %16, 63
%18 = trunc i64 %17 to i32
ret i32 %18
}