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

/* Variables and functions */
int create_mask(int /*<<< orphan*/, int);
int parse_get_pgn(u_int32_t can_id) {
  int PGN;
  can_id = (can_id & create_mask(0, 28));
  int PF = (can_id >> 16) & create_mask(0, 7);
  if (PF < 240) {
    PGN = ((can_id >> 16) << 8) & create_mask(0, 17);
  } else {
    PGN = (can_id >> 8) & create_mask(0, 17);
  }
  return PGN;
}


x86 assembly (clang, -O0):
<parse_get_pgn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
xor    %edi,%edi
mov    $0x1c,%esi
call   1030 <create_mask@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
and    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x10,%eax
mov    %eax,-0x10(%rbp)
xor    %edi,%edi
mov    $0x7,%esi
call   1030 <create_mask@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
and    %ecx,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0xf0,-0xc(%rbp)
jge    118a <parse_get_pgn+0x7a>
mov    -0x4(%rbp),%eax
sar    $0x10,%eax
shl    $0x8,%eax
mov    %eax,-0x18(%rbp)
xor    %edi,%edi
mov    $0x11,%esi
call   1030 <create_mask@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
and    %ecx,%eax
mov    %eax,-0x8(%rbp)
jmp    11a9 <parse_get_pgn+0x99>
mov    -0x4(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0x1c(%rbp)
xor    %edi,%edi
mov    $0x11,%esi
call   1030 <create_mask@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
and    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_get_pgn>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
xor    %edi,%edi
mov    $0x1c,%esi
call   1030 <create_mask@plt>
mov    %eax,%ebp
and    %ebx,%ebp
mov    %ebp,%ebx
sar    $0x10,%ebx
xor    %edi,%edi
mov    $0x7,%esi
call   1030 <create_mask@plt>
and    %ebx,%eax
sar    $0x8,%ebp
shl    $0x8,%ebx
cmp    $0xf0,%eax
cmovge %ebp,%ebx
xor    %edi,%edi
mov    $0x11,%esi
call   1030 <create_mask@plt>
and    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @parse_get_pgn(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = call i32 @create_mask(i32 0, i32 28)
%7 = and i32 %5, %6
store i32 %7, i32* %2
%8 = load i32, i32* %2
%9 = ashr i32 %8, 16
%10 = call i32 @create_mask(i32 0, i32 7)
%11 = and i32 %9, %10
store i32 %11, i32* %4
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 240
br i1 %13, label %14, label %20
14: ; preds = %1
%15 = load i32, i32* %2
%16 = ashr i32 %15, 16
%17 = shl i32 %16, 8
%18 = call i32 @create_mask(i32 0, i32 17)
%19 = and i32 %17, %18
store i32 %19, i32* %3
br label %25
20: ; preds = %1
%21 = load i32, i32* %2
%22 = ashr i32 %21, 8
%23 = call i32 @create_mask(i32 0, i32 17)
%24 = and i32 %22, %23
store i32 %24, i32* %3
br label %25
25: ; preds = %20, %14
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
define i32 @parse_get_pgn(i32 %0) {
%2 = tail call i32 @create_mask(i32 0, i32 28)
%3 = and i32 %2, %0
%4 = ashr i32 %3, 16
%5 = tail call i32 @create_mask(i32 0, i32 7)
%6 = and i32 %4, %5
%7 = icmp slt i32 %6, 240
%8 = ashr i32 %3, 8
%9 = shl nsw i32 %4, 8
%10 = select i1 %7, i32 %9, i32 %8
%11 = tail call i32 @create_mask(i32 0, i32 17)
%12 = and i32 %11, %10
ret i32 %12
}