#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 u_short;
typedef int u_char;
struct mbuf {
  int dummy;
};

/* Variables and functions */
struct mbuf *m_prepend(struct mbuf *, int *, int, int);
struct mbuf *proto_Prepend(struct mbuf *bp, u_short proto, unsigned comp,
                           int extra) {
  u_char cp[2];
  cp[0] = proto >> 8;
  cp[1] = proto & 0xff;
  if (comp && cp[0] == 0)
    bp = m_prepend(bp, cp + 1, 1, extra);
  else
    bp = m_prepend(bp, cp, 2, extra);
  return bp;
}


x86 assembly (clang, -O0):
<proto_Prepend>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0xc(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     116f <proto_Prepend+0x5f>
cmpl   $0x0,-0x1c(%rbp)
jne    116f <proto_Prepend+0x5f>
mov    -0x8(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
add    $0x4,%rsi
mov    -0x14(%rbp),%ecx
mov    $0x1,%edx
call   1030 <m_prepend@plt>
mov    %rax,-0x8(%rbp)
jmp    1188 <proto_Prepend+0x78>
mov    -0x8(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
mov    -0x14(%rbp),%ecx
mov    $0x2,%edx
call   1030 <m_prepend@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<proto_Prepend>:
push   %rax
mov    %esi,%eax
sar    $0x8,%eax
mov    %eax,(%rsp)
movzbl %sil,%eax
mov    %eax,0x4(%rsp)
cmp    $0xff,%esi
ja     1139 <proto_Prepend+0x29>
test   %edx,%edx
je     1139 <proto_Prepend+0x29>
lea    0x4(%rsp),%rsi
mov    $0x1,%edx
jmp    1141 <proto_Prepend+0x31>
mov    %rsp,%rsi
mov    $0x2,%edx
call   1030 <m_prepend@plt>
pop    %rcx
ret

LLVM IR (-O0):
%struct.mbuf = type { i32 }
define %struct.mbuf* @proto_Prepend(%struct.mbuf* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca %struct.mbuf*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [2 x i32]
store %struct.mbuf* %0, %struct.mbuf** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32, i32* %6
%11 = ashr i32 %10, 8
%12 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
store i32 %11, i32* %12
%13 = load i32, i32* %6
%14 = and i32 %13, 255
%15 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 1
store i32 %14, i32* %15
%16 = load i32, i32* %7
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %28
18: ; preds = %4
%19 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%20 = load i32, i32* %19
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %28
22: ; preds = %18
%23 = load %struct.mbuf*, %struct.mbuf** %5
%24 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%25 = getelementptr inbounds i32, i32* %24, i64 1
%26 = load i32, i32* %8
%27 = call %struct.mbuf* @m_prepend(%struct.mbuf* %23, i32* %25, i32 1, i32 %26)
store %struct.mbuf* %27, %struct.mbuf** %5
br label %33
28: ; preds = %18, %4
%29 = load %struct.mbuf*, %struct.mbuf** %5
%30 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%31 = load i32, i32* %8
%32 = call %struct.mbuf* @m_prepend(%struct.mbuf* %29, i32* %30, i32 2, i32 %31)
store %struct.mbuf* %32, %struct.mbuf** %5
br label %33
33: ; preds = %28, %22
%34 = load %struct.mbuf*, %struct.mbuf** %5
ret %struct.mbuf* %34
}

LLVM IR (-O2):
%struct.mbuf = type { i32 }
define %struct.mbuf* @proto_Prepend(%struct.mbuf* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca [2 x i32]
%6 = bitcast [2 x i32]* %5 to i8*
%7 = ashr i32 %1, 8
%8 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
store i32 %7, i32* %8
%9 = and i32 %1, 255
%10 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
store i32 %9, i32* %10
%11 = icmp ne i32 %2, 0
%12 = icmp ult i32 %1, 256
%13 = and i1 %12, %11
br i1 %13, label %14, label %16
14: ; preds = %4
%15 = call %struct.mbuf* @m_prepend(%struct.mbuf* %0, i32* %10, i32 1, i32 %3)
br label %18
16: ; preds = %4
%17 = call %struct.mbuf* @m_prepend(%struct.mbuf* %0, i32* %8, i32 2, i32 %3)
br label %18
18: ; preds = %16, %14
%19 = phi %struct.mbuf* [ %15, %14 ], [ %17, %16 ]
ret %struct.mbuf* %19
}