#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 union eg_table_cmd_u {
  int dummy;
} eg_table_cmd_u;

/* Variables and functions */
int /*<<< orphan*/ eg_table_cmd_set(unsigned int, union eg_table_cmd_u *);
int /*<<< orphan*/ egress_reg_tbl_set(unsigned int, int, unsigned int *,
                                      unsigned int);
int eg_indirect_table_set(unsigned int dev_id, unsigned int table_type,
                          unsigned int index, unsigned int entry_len,
                          unsigned int *pentry) {
  unsigned int cmd = 0;
  egress_reg_tbl_set(dev_id, 0x140, pentry, entry_len);
  cmd = (0x2 << 30) | (table_type << 12) | index;
  eg_table_cmd_set(dev_id, (union eg_table_cmd_u *)&cmd);
  return 0;
}


x86 assembly (clang, -O0):
<eg_indirect_table_set>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%ecx
mov    $0x140,%esi
call   1030 <egress_reg_tbl_set@plt>
mov    -0x8(%rbp),%eax
shl    $0xc,%eax
or     $0x80000000,%eax
or     -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x1c(%rbp),%rsi
call   1040 <eg_table_cmd_set@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eg_indirect_table_set>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%r14d
mov    %esi,%ebp
mov    %edi,%ebx
mov    $0x140,%esi
mov    %r8,%rdx
call   1030 <egress_reg_tbl_set@plt>
shl    $0xc,%ebp
or     %r14d,%ebp
or     $0x80000000,%ebp
mov    %ebp,0xc(%rsp)
lea    0xc(%rsp),%rsi
mov    %ebx,%edi
call   1040 <eg_table_cmd_set@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%union.eg_table_cmd_u = type { i32 }
define i32 @eg_indirect_table_set(i32 %0, i32 %1, i32 %2, i32 %3, i32* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32* %4, i32** %10
store i32 0, i32* %11
%12 = load i32, i32* %6
%13 = load i32*, i32** %10
%14 = load i32, i32* %9
%15 = call i32 @egress_reg_tbl_set(i32 %12, i32 320, i32* %13, i32 %14)
%16 = load i32, i32* %7
%17 = shl i32 %16, 12
%18 = or i32 -2147483648, %17
%19 = load i32, i32* %8
%20 = or i32 %18, %19
store i32 %20, i32* %11
%21 = load i32, i32* %6
%22 = bitcast i32* %11 to %union.eg_table_cmd_u*
%23 = call i32 @eg_table_cmd_set(i32 %21, %union.eg_table_cmd_u* %22)
ret i32 0
}

LLVM IR (-O2):
%union.eg_table_cmd_u = type { i32 }
define i32 @eg_indirect_table_set(i32 %0, i32 %1, i32 %2, i32 %3, i32* %4) {
%6 = alloca i32
%7 = bitcast i32* %6 to i8*
%8 = tail call i32 @egress_reg_tbl_set(i32 %0, i32 320, i32* %4, i32 %3)
%9 = shl i32 %1, 12
%10 = or i32 %9, %2
%11 = or i32 %10, -2147483648
store i32 %11, i32* %6
%12 = bitcast i32* %6 to %union.eg_table_cmd_u*
%13 = call i32 @eg_table_cmd_set(i32 %0, %union.eg_table_cmd_u* %12)
ret i32 0
}