#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_get(unsigned int, int, unsigned int *, int);
int eg_smib_table_common_get(unsigned int dev_id, unsigned int *pentry) {
  int i;
  int entry_offset = 0;
  unsigned int cmd = 0;
  for (i = 256; i < 261 + 1; i++) {
    cmd = (0x1 << 30) | (3 << 12) | i;
    eg_table_cmd_set(dev_id, (union eg_table_cmd_u *)&cmd);
    egress_reg_tbl_get(dev_id, 0x140, (pentry + entry_offset), 2);
    entry_offset += 2;
  }
  return 0;
}


x86 assembly (clang, -O0):
<eg_smib_table_common_get>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x100,-0x14(%rbp)
cmpl   $0x106,-0x14(%rbp)
jge    11a0 <eg_smib_table_common_get+0x80>
mov    -0x14(%rbp),%eax
or     $0x40003000,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x1c(%rbp),%rsi
call   1030 <eg_table_cmd_set@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rdx
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
mov    $0x140,%esi
mov    $0x2,%ecx
call   1040 <egress_reg_tbl_get@plt>
mov    -0x18(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1144 <eg_smib_table_common_get+0x24>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eg_smib_table_common_get>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
movl   $0x40003100,0xc(%rsp)
40
lea    0xc(%rsp),%r14
mov    %r14,%rsi
call   1030 <eg_table_cmd_set@plt>
mov    %ebp,%edi
mov    $0x140,%esi
mov    %rbx,%rdx
mov    $0x2,%ecx
call   1040 <egress_reg_tbl_get@plt>
movl   $0x40003101,0xc(%rsp)
40
mov    %ebp,%edi
mov    %r14,%rsi
call   1030 <eg_table_cmd_set@plt>
lea    0x8(%rbx),%rdx
mov    %ebp,%edi
mov    $0x140,%esi
mov    $0x2,%ecx
call   1040 <egress_reg_tbl_get@plt>
movl   $0x40003102,0xc(%rsp)
40
mov    %ebp,%edi
mov    %r14,%rsi
call   1030 <eg_table_cmd_set@plt>
lea    0x10(%rbx),%rdx
mov    %ebp,%edi
mov    $0x140,%esi
mov    $0x2,%ecx
call   1040 <egress_reg_tbl_get@plt>
movl   $0x40003103,0xc(%rsp)
40
mov    %ebp,%edi
mov    %r14,%rsi
call   1030 <eg_table_cmd_set@plt>
lea    0x18(%rbx),%rdx
mov    %ebp,%edi
mov    $0x140,%esi
mov    $0x2,%ecx
call   1040 <egress_reg_tbl_get@plt>
movl   $0x40003104,0xc(%rsp)
40
mov    %ebp,%edi
mov    %r14,%rsi
call   1030 <eg_table_cmd_set@plt>
lea    0x20(%rbx),%rdx
mov    %ebp,%edi
mov    $0x140,%esi
mov    $0x2,%ecx
call   1040 <egress_reg_tbl_get@plt>
movl   $0x40003105,0xc(%rsp)
40
mov    %ebp,%edi
mov    %r14,%rsi
call   1030 <eg_table_cmd_set@plt>
add    $0x28,%rbx
mov    %ebp,%edi
mov    $0x140,%esi
mov    %rbx,%rdx
mov    $0x2,%ecx
call   1040 <egress_reg_tbl_get@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_smib_table_common_get(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i32* %1, i32** %4
store i32 0, i32* %6
store i32 0, i32* %7
store i32 256, i32* %5
br label %8
8: ; preds = %25, %2
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 262
br i1 %10, label %11, label %28
11: ; preds = %8
%12 = load i32, i32* %5
%13 = or i32 1073754112, %12
store i32 %13, i32* %7
%14 = load i32, i32* %3
%15 = bitcast i32* %7 to %union.eg_table_cmd_u*
%16 = call i32 @eg_table_cmd_set(i32 %14, %union.eg_table_cmd_u* %15)
%17 = load i32, i32* %3
%18 = load i32*, i32** %4
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %18, i64 %20
%22 = call i32 @egress_reg_tbl_get(i32 %17, i32 320, i32* %21, i32 2)
%23 = load i32, i32* %6
%24 = add nsw i32 %23, 2
store i32 %24, i32* %6
br label %25
25: ; preds = %11
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 1
store i32 %27, i32* %5
br label %8
28: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
%union.eg_table_cmd_u = type { i32 }
define i32 @eg_smib_table_common_get(i32 %0, i32* %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = bitcast i32* %3 to %union.eg_table_cmd_u*
store i32 1073754368, i32* %3
%6 = call i32 @eg_table_cmd_set(i32 %0, %union.eg_table_cmd_u* %5)
%7 = call i32 @egress_reg_tbl_get(i32 %0, i32 320, i32* %1, i32 2)
store i32 1073754369, i32* %3
%8 = call i32 @eg_table_cmd_set(i32 %0, %union.eg_table_cmd_u* %5)
%9 = getelementptr inbounds i32, i32* %1, i64 2
%10 = call i32 @egress_reg_tbl_get(i32 %0, i32 320, i32* %9, i32 2)
store i32 1073754370, i32* %3
%11 = call i32 @eg_table_cmd_set(i32 %0, %union.eg_table_cmd_u* %5)
%12 = getelementptr inbounds i32, i32* %1, i64 4
%13 = call i32 @egress_reg_tbl_get(i32 %0, i32 320, i32* %12, i32 2)
store i32 1073754371, i32* %3
%14 = call i32 @eg_table_cmd_set(i32 %0, %union.eg_table_cmd_u* %5)
%15 = getelementptr inbounds i32, i32* %1, i64 6
%16 = call i32 @egress_reg_tbl_get(i32 %0, i32 320, i32* %15, i32 2)
store i32 1073754372, i32* %3
%17 = call i32 @eg_table_cmd_set(i32 %0, %union.eg_table_cmd_u* %5)
%18 = getelementptr inbounds i32, i32* %1, i64 8
%19 = call i32 @egress_reg_tbl_get(i32 %0, i32 320, i32* %18, i32 2)
store i32 1073754373, i32* %3
%20 = call i32 @eg_table_cmd_set(i32 %0, %union.eg_table_cmd_u* %5)
%21 = getelementptr inbounds i32, i32* %1, i64 10
%22 = call i32 @egress_reg_tbl_get(i32 %0, i32 320, i32* %21, i32 2)
ret i32 0
}