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

/* Variables and functions */
int /*<<< orphan*/ ig_table_cmd_set(unsigned int, union ig_table_cmd_u *);
int /*<<< orphan*/ ingress_reg_tbl_get(unsigned int, int, unsigned int *, int);
int ig_smib_table_common_get(unsigned int dev_id, unsigned int *pentry) {
  int i;
  int entry_offset = 0;
  unsigned int cmd = 0;
  for (i = 384; i < 399 + 1; i++) {
    cmd = (0x1 << 30) | (6 << 12) | i;
    ig_table_cmd_set(dev_id, (union ig_table_cmd_u *)&cmd);
    ingress_reg_tbl_get(dev_id, 0x140, (pentry + entry_offset), 2);
    entry_offset += 2;
  }
  return 0;
}


x86 assembly (clang, -O0):
<ig_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   $0x180,-0x14(%rbp)
cmpl   $0x190,-0x14(%rbp)
jge    11a0 <ig_smib_table_common_get+0x80>
mov    -0x14(%rbp),%eax
or     $0x40006000,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x1c(%rbp),%rsi
call   1030 <ig_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 <ingress_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 <ig_smib_table_common_get+0x24>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ig_smib_table_common_get>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%r15d
mov    $0x180,%ebp
lea    0x4(%rsp),%r14
nopw   0x0(%rax,%rax,1)
mov    %ebp,%eax
or     $0x40006000,%eax
mov    %eax,0x4(%rsp)
mov    %r15d,%edi
mov    %r14,%rsi
call   1030 <ig_table_cmd_set@plt>
mov    %r15d,%edi
mov    $0x140,%esi
mov    %rbx,%rdx
mov    $0x2,%ecx
call   1040 <ingress_reg_tbl_get@plt>
add    $0x1,%ebp
add    $0x8,%rbx
cmp    $0x190,%ebp
jne    1140 <ig_smib_table_common_get+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%union.ig_table_cmd_u = type { i32 }
define i32 @ig_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 384, i32* %5
br label %8
8: ; preds = %25, %2
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 400
br i1 %10, label %11, label %28
11: ; preds = %8
%12 = load i32, i32* %5
%13 = or i32 1073766400, %12
store i32 %13, i32* %7
%14 = load i32, i32* %3
%15 = bitcast i32* %7 to %union.ig_table_cmd_u*
%16 = call i32 @ig_table_cmd_set(i32 %14, %union.ig_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 @ingress_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.ig_table_cmd_u = type { i32 }
define i32 @ig_smib_table_common_get(i32 %0, i32* %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = bitcast i32* %3 to %union.ig_table_cmd_u*
br label %6
6: ; preds = %2, %6
%7 = phi i64 [ 0, %2 ], [ %13, %6 ]
%8 = phi i32 [ 384, %2 ], [ %14, %6 ]
%9 = or i32 %8, 1073766400
store i32 %9, i32* %3
%10 = call i32 @ig_table_cmd_set(i32 %0, %union.ig_table_cmd_u* %5)
%11 = getelementptr inbounds i32, i32* %1, i64 %7
%12 = call i32 @ingress_reg_tbl_get(i32 %0, i32 320, i32* %11, i32 2)
%13 = add nuw nsw i64 %7, 2
%14 = add nuw nsw i32 %8, 1
%15 = icmp eq i32 %14, 400
br i1 %15, label %16, label %6
16: ; preds = %6
ret i32 0
}