#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 */
typedef int /*<<< orphan*/ responseLen;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *);
int send(int, char *, unsigned int, int /*<<< orphan*/);
int nsStreamSocketResponse(int socketfd, char *buffer,
                           unsigned int buffersize) {
  printf("nsStreamSocketResponse: %s \n", buffer);
  char responseLen[4] = {0};
  responseLen[0] = (buffersize >> 24) & 0xff;
  responseLen[1] = (buffersize >> 16) & 0xff;
  responseLen[2] = (buffersize >> 8) & 0xff;
  responseLen[3] = buffersize & 0xff;
  send(socketfd, responseLen, sizeof(responseLen), 0);
  return send(socketfd, buffer, buffersize, 0);
}


x86 assembly (clang, -O0):
<nsStreamSocketResponse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xeb3(%rip),%rdi
call   1040 <printf@plt>
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1050 <memset@plt>
mov    -0x14(%rbp),%eax
shr    $0x18,%eax
and    $0xff,%eax
mov    %al,-0x18(%rbp)
mov    -0x14(%rbp),%eax
shr    $0x10,%eax
and    $0xff,%eax
mov    %al,-0x17(%rbp)
mov    -0x14(%rbp),%eax
shr    $0x8,%eax
and    $0xff,%eax
mov    %al,-0x16(%rbp)
mov    -0x14(%rbp),%eax
and    $0xff,%eax
mov    %al,-0x15(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    $0x4,%edx
xor    %ecx,%ecx
call   1030 <send@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
xor    %ecx,%ecx
call   1030 <send@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nsStreamSocketResponse>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xec9(%rip),%rdi
call   1040 <printf@plt>
mov    %r14d,%eax
bswap  %eax
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rsi
mov    %ebp,%edi
mov    $0x4,%edx
xor    %ecx,%ecx
call   1030 <send@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14d,%edx
xor    %ecx,%ecx
call   1030 <send@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"nsStreamSocketResponse: %s \0A\00"
define i32 @nsStreamSocketResponse(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca [4 x i8]
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = load i8*, i8** %5
%9 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = bitcast [4 x i8]* %7 to i8*
%11 = load i32, i32* %6
%12 = lshr i32 %11, 24
%13 = and i32 %12, 255
%14 = trunc i32 %13 to i8
%15 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
store i8 %14, i8* %15
%16 = load i32, i32* %6
%17 = lshr i32 %16, 16
%18 = and i32 %17, 255
%19 = trunc i32 %18 to i8
%20 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 1
store i8 %19, i8* %20
%21 = load i32, i32* %6
%22 = lshr i32 %21, 8
%23 = and i32 %22, 255
%24 = trunc i32 %23 to i8
%25 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 2
store i8 %24, i8* %25
%26 = load i32, i32* %6
%27 = and i32 %26, 255
%28 = trunc i32 %27 to i8
%29 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 3
store i8 %28, i8* %29
%30 = load i32, i32* %4
%31 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%32 = call i32 @send(i32 %30, i8* %31, i32 4, i32 0)
%33 = load i32, i32* %4
%34 = load i8*, i8** %5
%35 = load i32, i32* %6
%36 = call i32 @send(i32 %33, i8* %34, i32 %35, i32 0)
ret i32 %36
}

LLVM IR (-O2):
@.str = [29 x i8] c"nsStreamSocketResponse: %s \0A\00"
define i32 @nsStreamSocketResponse(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to [4 x i8]*
%6 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %1)
%7 = bitcast i32* %4 to i8*
%8 = lshr i32 %2, 24
%9 = trunc i32 %8 to i8
store i8 %9, i8* %7
%10 = lshr i32 %2, 16
%11 = trunc i32 %10 to i8
%12 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 1
store i8 %11, i8* %12
%13 = lshr i32 %2, 8
%14 = trunc i32 %13 to i8
%15 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 2
store i8 %14, i8* %15
%16 = trunc i32 %2 to i8
%17 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 3
store i8 %16, i8* %17
%18 = call i32 @send(i32 %0, i8* %7, i32 4, i32 0)
%19 = call i32 @send(i32 %0, i8* %1, i32 %2, i32 0)
ret i32 %19
}