#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 getw_packet(int, char **);
int hash_packet(int, char **);
int /*<<< orphan*/ raw_recv(int, char **, int);
int get_packet(int sockd) {
  char buf[300];
  int ret;
  raw_recv(sockd, &buf, 300);
  switch (buf[0]) {
  case 0x02:
    ret = hash_packet(sockd, &buf);
    break;
  case 0x03:
    ret = getw_packet(sockd, &buf);
    break;
  }
  return ret;
}


x86 assembly (clang, -O0):
<get_packet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x130(%rbp),%rsi
mov    $0x12c,%edx
call   1030 <raw_recv@plt>
movsbl -0x130(%rbp),%eax
mov    %eax,-0x138(%rbp)
sub    $0x2,%eax
je     1181 <get_packet+0x51>
jmp    116d <get_packet+0x3d>
mov    -0x138(%rbp),%eax
sub    $0x3,%eax
je     119b <get_packet+0x6b>
jmp    11b0 <get_packet+0x80>
mov    -0x4(%rbp),%edi
lea    -0x130(%rbp),%rsi
call   1040 <hash_packet@plt>
mov    %eax,-0x134(%rbp)
jmp    11b0 <get_packet+0x80>
mov    -0x4(%rbp),%edi
lea    -0x130(%rbp),%rsi
call   1050 <getw_packet@plt>
mov    %eax,-0x134(%rbp)
mov    -0x134(%rbp),%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_packet>:
push   %rbx
sub    $0x130,%rsp
mov    %edi,%ebx
mov    %rsp,%rsi
mov    $0x12c,%edx
call   1030 <raw_recv@plt>
movsbl (%rsp),%ecx
cmp    $0x3,%ecx
je     1161 <get_packet+0x31>
cmp    $0x2,%ecx
jne    116b <get_packet+0x3b>
mov    %rsp,%rsi
mov    %ebx,%edi
call   1040 <hash_packet@plt>
jmp    116b <get_packet+0x3b>
mov    %rsp,%rsi
mov    %ebx,%edi
call   1050 <getw_packet@plt>
add    $0x130,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @get_packet(i32 %0) {
%2 = alloca i32
%3 = alloca [300 x i8]
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = bitcast [300 x i8]* %3 to i8**
%7 = call i32 @raw_recv(i32 %5, i8** %6, i32 300)
%8 = getelementptr inbounds [300 x i8], [300 x i8]* %3, i64 0, i64 0
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
switch i32 %10, label %19 [
i32 2, label %11
i32 3, label %15
]
11: ; preds = %1
%12 = load i32, i32* %2
%13 = bitcast [300 x i8]* %3 to i8**
%14 = call i32 @hash_packet(i32 %12, i8** %13)
store i32 %14, i32* %4
br label %19
15: ; preds = %1
%16 = load i32, i32* %2
%17 = bitcast [300 x i8]* %3 to i8**
%18 = call i32 @getw_packet(i32 %16, i8** %17)
store i32 %18, i32* %4
br label %19
19: ; preds = %1, %15, %11
%20 = load i32, i32* %4
ret i32 %20
}

LLVM IR (-O2):
define i32 @get_packet(i32 %0) {
%2 = alloca [300 x i8]
%3 = getelementptr inbounds [300 x i8], [300 x i8]* %2, i64 0, i64 0
%4 = bitcast [300 x i8]* %2 to i8**
%5 = call i32 @raw_recv(i32 %0, i8** %4, i32 300)
%6 = load i8, i8* %3
%7 = sext i8 %6 to i32
switch i32 %7, label %12 [
i32 2, label %8
i32 3, label %10
]
8: ; preds = %1
%9 = call i32 @hash_packet(i32 %0, i8** %4)
br label %12
10: ; preds = %1
%11 = call i32 @getw_packet(i32 %0, i8** %4)
br label %12
12: ; preds = %1, %10, %8
%13 = phi i32 [ undef, %1 ], [ %11, %10 ], [ %9, %8 ]
ret i32 %13
}