#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 */
struct buffer {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ get_buffer_data(struct buffer *);
int /*<<< orphan*/ memcpy(int /*<<< orphan*/, char *, int);
void rewrite_request_size(struct buffer *req_buf, int req_size) {
  char buf[4];
  buf[0] = req_size >> 24;
  buf[1] = req_size >> 16;
  buf[2] = req_size >> 8;
  buf[3] = req_size & 0xff;
  memcpy(get_buffer_data(req_buf), buf, 4);
}


x86 assembly (clang, -O0):
<rewrite_request_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sar    $0x18,%eax
mov    %al,-0x10(%rbp)
mov    -0xc(%rbp),%eax
sar    $0x10,%eax
mov    %al,-0xf(%rbp)
mov    -0xc(%rbp),%eax
sar    $0x8,%eax
mov    %al,-0xe(%rbp)
mov    -0xc(%rbp),%eax
and    $0xff,%eax
mov    %al,-0xd(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <get_buffer_data@plt>
mov    %eax,%edi
lea    -0x10(%rbp),%rsi
mov    $0x4,%edx
call   1030 <memcpy@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rewrite_request_size>:
push   %rax
bswap  %esi
mov    %esi,0x4(%rsp)
call   1040 <get_buffer_data@plt>
lea    0x4(%rsp),%rsi
mov    %eax,%edi
mov    $0x4,%edx
call   1030 <memcpy@plt>
pop    %rax
ret

LLVM IR (-O0):
%struct.buffer = type { i32 }
define void @rewrite_request_size(%struct.buffer* %0, i32 %1) {
%3 = alloca %struct.buffer*
%4 = alloca i32
%5 = alloca [4 x i8]
store %struct.buffer* %0, %struct.buffer** %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = ashr i32 %6, 24
%8 = trunc i32 %7 to i8
%9 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
store i8 %8, i8* %9
%10 = load i32, i32* %4
%11 = ashr i32 %10, 16
%12 = trunc i32 %11 to i8
%13 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 1
store i8 %12, i8* %13
%14 = load i32, i32* %4
%15 = ashr i32 %14, 8
%16 = trunc i32 %15 to i8
%17 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 2
store i8 %16, i8* %17
%18 = load i32, i32* %4
%19 = and i32 %18, 255
%20 = trunc i32 %19 to i8
%21 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 3
store i8 %20, i8* %21
%22 = load %struct.buffer*, %struct.buffer** %3
%23 = call i32 @get_buffer_data(%struct.buffer* %22)
%24 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%25 = call i32 @memcpy(i32 %23, i8* %24, i32 4)
ret void
}

LLVM IR (-O2):
%struct.buffer = type { i32 }
define void @rewrite_request_size(%struct.buffer* %0, i32 %1) {
%3 = alloca [4 x i8]
%4 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%5 = lshr i32 %1, 24
%6 = trunc i32 %5 to i8
store i8 %6, i8* %4
%7 = lshr i32 %1, 16
%8 = trunc i32 %7 to i8
%9 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 1
store i8 %8, i8* %9
%10 = lshr i32 %1, 8
%11 = trunc i32 %10 to i8
%12 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 2
store i8 %11, i8* %12
%13 = trunc i32 %1 to i8
%14 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 3
store i8 %13, i8* %14
%15 = tail call i32 @get_buffer_data(%struct.buffer* %0)
%16 = call i32 @memcpy(i32 %15, i8* %4, i32 4)
ret void
}