#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 uint32_t;

/* Variables and functions */
int readlong(char *packet, char **src, uint32_t *dst) {
  unsigned char *p;
  p = (unsigned char *)*src;
  *dst = ((uint32_t)p[0] << 24) | ((uint32_t)p[1] << 16) |
         ((uint32_t)p[2] << 8) | ((uint32_t)p[3]);
  (*src) += sizeof(uint32_t);
  return sizeof(uint32_t);
}


x86 assembly (clang, -O0):
<readlong>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movzbl (%rax),%ecx
shl    $0x18,%ecx
mov    -0x20(%rbp),%rax
movzbl 0x1(%rax),%eax
shl    $0x10,%eax
or     %eax,%ecx
mov    -0x20(%rbp),%rax
movzbl 0x2(%rax),%eax
shl    $0x8,%eax
or     %eax,%ecx
mov    -0x20(%rbp),%rax
movzbl 0x3(%rax),%eax
or     %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
add    $0x4,%rcx
mov    %rcx,(%rax)
mov    $0x4,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<readlong>:
mov    (%rsi),%rax
mov    (%rax),%ecx
bswap  %ecx
mov    %ecx,(%rdx)
add    $0x4,%rax
mov    %rax,(%rsi)
mov    $0x4,%eax
ret

LLVM IR (-O0):
define i32 @readlong(i8* %0, i8** %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8*
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i32* %2, i32** %6
%8 = load i8**, i8*** %5
%9 = load i8*, i8** %8
store i8* %9, i8** %7
%10 = load i8*, i8** %7
%11 = getelementptr inbounds i8, i8* %10, i64 0
%12 = load i8, i8* %11
%13 = zext i8 %12 to i32
%14 = shl i32 %13, 24
%15 = load i8*, i8** %7
%16 = getelementptr inbounds i8, i8* %15, i64 1
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
%19 = shl i32 %18, 16
%20 = or i32 %14, %19
%21 = load i8*, i8** %7
%22 = getelementptr inbounds i8, i8* %21, i64 2
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = shl i32 %24, 8
%26 = or i32 %20, %25
%27 = load i8*, i8** %7
%28 = getelementptr inbounds i8, i8* %27, i64 3
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = or i32 %26, %30
%32 = load i32*, i32** %6
store i32 %31, i32* %32
%33 = load i8**, i8*** %5
%34 = load i8*, i8** %33
%35 = getelementptr inbounds i8, i8* %34, i64 4
store i8* %35, i8** %33
ret i32 4
}

LLVM IR (-O2):
define i32 @readlong(i8* nocapture readnone %0, i8** nocapture %1, i32* nocapture writeonly %2) {
%4 = load i8*, i8** %1
%5 = load i8, i8* %4
%6 = zext i8 %5 to i32
%7 = shl nuw i32 %6, 24
%8 = getelementptr inbounds i8, i8* %4, i64 1
%9 = load i8, i8* %8
%10 = zext i8 %9 to i32
%11 = shl nuw nsw i32 %10, 16
%12 = or i32 %11, %7
%13 = getelementptr inbounds i8, i8* %4, i64 2
%14 = load i8, i8* %13
%15 = zext i8 %14 to i32
%16 = shl nuw nsw i32 %15, 8
%17 = or i32 %12, %16
%18 = getelementptr inbounds i8, i8* %4, i64 3
%19 = load i8, i8* %18
%20 = zext i8 %19 to i32
%21 = or i32 %17, %20
store i32 %21, i32* %2
%22 = getelementptr inbounds i8, i8* %4, i64 4
store i8* %22, i8** %1
ret i32 4
}