#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 */
unsigned int p4_escr_addr(unsigned int, unsigned int);
unsigned int p4_escr_addr_orig(unsigned int, unsigned int);
int /*<<< orphan*/ printf(char *, unsigned int, unsigned int, unsigned int,
                          unsigned int);
void check_p4_escr_addr(void) {
  unsigned int pmc, escr_select, escr_addr_orig, escr_addr;
  for (pmc = 0; pmc < 0x12; ++pmc) {
    for (escr_select = 0; escr_select < 8; ++escr_select) {
      escr_addr_orig = p4_escr_addr_orig(pmc, escr_select);
      escr_addr = p4_escr_addr(pmc, escr_select);
      if (escr_addr_orig != escr_addr)
        printf("p4_escr_addr(%u, %u) is 0x%03x, should be 0x%03x\n", pmc,
               escr_select, escr_addr, escr_addr_orig);
    }
  }
}


x86 assembly (clang, -O0):
<check_p4_escr_addr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
cmpl   $0x12,-0x4(%rbp)
jae    11c1 <check_p4_escr_addr+0x91>
movl   $0x0,-0x8(%rbp)
cmpl   $0x8,-0x8(%rbp)
jae    11ae <check_p4_escr_addr+0x7e>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1050 <p4_escr_addr_orig@plt>
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <p4_escr_addr@plt>
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
je     119b <check_p4_escr_addr+0x6b>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0xc(%rbp),%r8d
lea    0xe6a(%rip),%rdi
call   1040 <printf@plt>
jmp    11a0 <check_p4_escr_addr+0x70>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1150 <check_p4_escr_addr+0x20>
jmp    11b3 <check_p4_escr_addr+0x83>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    113f <check_p4_escr_addr+0xf>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_p4_escr_addr>:
push   %rbp
push   %r14
push   %rbx
xor    %ebx,%ebx
lea    0xec3(%rip),%r14
jmp    114c <check_p4_escr_addr+0x1c>
nop
add    $0x1,%ebx
cmp    $0x12,%ebx
je     12dc <check_p4_escr_addr+0x1ac>
mov    %ebx,%edi
xor    %esi,%esi
call   1050 <p4_escr_addr_orig@plt>
mov    %eax,%ebp
mov    %ebx,%edi
xor    %esi,%esi
call   1030 <p4_escr_addr@plt>
cmp    %eax,%ebp
je     1175 <check_p4_escr_addr+0x45>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %edx,%edx
mov    %eax,%ecx
mov    %ebp,%r8d
call   1040 <printf@plt>
mov    %ebx,%edi
mov    $0x1,%esi
call   1050 <p4_escr_addr_orig@plt>
mov    %eax,%ebp
mov    %ebx,%edi
mov    $0x1,%esi
call   1030 <p4_escr_addr@plt>
cmp    %eax,%ebp
je     11a7 <check_p4_escr_addr+0x77>
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x1,%edx
mov    %eax,%ecx
mov    %ebp,%r8d
call   1040 <printf@plt>
mov    %ebx,%edi
mov    $0x2,%esi
call   1050 <p4_escr_addr_orig@plt>
mov    %eax,%ebp
mov    %ebx,%edi
mov    $0x2,%esi
call   1030 <p4_escr_addr@plt>
cmp    %eax,%ebp
je     11d9 <check_p4_escr_addr+0xa9>
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x2,%edx
mov    %eax,%ecx
mov    %ebp,%r8d
call   1040 <printf@plt>
mov    %ebx,%edi
mov    $0x3,%esi
call   1050 <p4_escr_addr_orig@plt>
mov    %eax,%ebp
mov    %ebx,%edi
mov    $0x3,%esi
call   1030 <p4_escr_addr@plt>
cmp    %eax,%ebp
je     120b <check_p4_escr_addr+0xdb>
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x3,%edx
mov    %eax,%ecx
mov    %ebp,%r8d
call   1040 <printf@plt>
mov    %ebx,%edi
mov    $0x4,%esi
call   1050 <p4_escr_addr_orig@plt>
mov    %eax,%ebp
mov    %ebx,%edi
mov    $0x4,%esi
call   1030 <p4_escr_addr@plt>
cmp    %eax,%ebp
je     123d <check_p4_escr_addr+0x10d>
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x4,%edx
mov    %eax,%ecx
mov    %ebp,%r8d
call   1040 <printf@plt>
mov    %ebx,%edi
mov    $0x5,%esi
call   1050 <p4_escr_addr_orig@plt>
mov    %eax,%ebp
mov    %ebx,%edi
mov    $0x5,%esi
call   1030 <p4_escr_addr@plt>
cmp    %eax,%ebp
je     126f <check_p4_escr_addr+0x13f>
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x5,%edx
mov    %eax,%ecx
mov    %ebp,%r8d
call   1040 <printf@plt>
mov    %ebx,%edi
mov    $0x6,%esi
call   1050 <p4_escr_addr_orig@plt>
mov    %eax,%ebp
mov    %ebx,%edi
mov    $0x6,%esi
call   1030 <p4_escr_addr@plt>
cmp    %eax,%ebp
je     12a1 <check_p4_escr_addr+0x171>
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x6,%edx
mov    %eax,%ecx
mov    %ebp,%r8d
call   1040 <printf@plt>
mov    %ebx,%edi
mov    $0x7,%esi
call   1050 <p4_escr_addr_orig@plt>
mov    %eax,%ebp
mov    %ebx,%edi
mov    $0x7,%esi
call   1030 <p4_escr_addr@plt>
cmp    %eax,%ebp
je     1140 <check_p4_escr_addr+0x10>
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x7,%edx
mov    %eax,%ecx
mov    %ebp,%r8d
call   1040 <printf@plt>
jmp    1140 <check_p4_escr_addr+0x10>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [50 x i8] c"p4_escr_addr(%u, %u) is 0x%03x, should be 0x%03x\0A\00"
define void @check_p4_escr_addr() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
br label %5
5: ; preds = %33, %0
%6 = load i32, i32* %1
%7 = icmp ult i32 %6, 18
br i1 %7, label %8, label %36
8: ; preds = %5
store i32 0, i32* %2
br label %9
9: ; preds = %29, %8
%10 = load i32, i32* %2
%11 = icmp ult i32 %10, 8
br i1 %11, label %12, label %32
12: ; preds = %9
%13 = load i32, i32* %1
%14 = load i32, i32* %2
%15 = call i32 @p4_escr_addr_orig(i32 %13, i32 %14)
store i32 %15, i32* %3
%16 = load i32, i32* %1
%17 = load i32, i32* %2
%18 = call i32 @p4_escr_addr(i32 %16, i32 %17)
store i32 %18, i32* %4
%19 = load i32, i32* %3
%20 = load i32, i32* %4
%21 = icmp ne i32 %19, %20
br i1 %21, label %22, label %28
22: ; preds = %12
%23 = load i32, i32* %1
%24 = load i32, i32* %2
%25 = load i32, i32* %4
%26 = load i32, i32* %3
%27 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i32 %23, i32 %24, i32 %25, i32 %26)
br label %28
28: ; preds = %22, %12
br label %29
29: ; preds = %28
%30 = load i32, i32* %2
%31 = add i32 %30, 1
store i32 %31, i32* %2
br label %9
32: ; preds = %9
br label %33
33: ; preds = %32
%34 = load i32, i32* %1
%35 = add i32 %34, 1
store i32 %35, i32* %1
br label %5
36: ; preds = %5
ret void
}

LLVM IR (-O2):
@.str = [50 x i8] c"p4_escr_addr(%u, %u) is 0x%03x, should be 0x%03x\0A\00"
define void @check_p4_escr_addr() {
br label %1
1: ; preds = %0, %50
%2 = phi i32 [ 0, %0 ], [ %51, %50 ]
%3 = tail call i32 @p4_escr_addr_orig(i32 %2, i32 0)
%4 = tail call i32 @p4_escr_addr(i32 %2, i32 0)
%5 = icmp eq i32 %3, %4
br i1 %5, label %8, label %6
6: ; preds = %1
%7 = tail call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i32 %2, i32 0, i32 %4, i32 %3)
br label %8
8: ; preds = %1, %6
%9 = tail call i32 @p4_escr_addr_orig(i32 %2, i32 1)
%10 = tail call i32 @p4_escr_addr(i32 %2, i32 1)
%11 = icmp eq i32 %9, %10
br i1 %11, label %14, label %12
12: ; preds = %8
%13 = tail call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i32 %2, i32 1, i32 %10, i32 %9)
br label %14
14: ; preds = %12, %8
%15 = tail call i32 @p4_escr_addr_orig(i32 %2, i32 2)
%16 = tail call i32 @p4_escr_addr(i32 %2, i32 2)
%17 = icmp eq i32 %15, %16
br i1 %17, label %20, label %18
18: ; preds = %14
%19 = tail call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i32 %2, i32 2, i32 %16, i32 %15)
br label %20
20: ; preds = %18, %14
%21 = tail call i32 @p4_escr_addr_orig(i32 %2, i32 3)
%22 = tail call i32 @p4_escr_addr(i32 %2, i32 3)
%23 = icmp eq i32 %21, %22
br i1 %23, label %26, label %24
24: ; preds = %20
%25 = tail call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i32 %2, i32 3, i32 %22, i32 %21)
br label %26
26: ; preds = %24, %20
%27 = tail call i32 @p4_escr_addr_orig(i32 %2, i32 4)
%28 = tail call i32 @p4_escr_addr(i32 %2, i32 4)
%29 = icmp eq i32 %27, %28
br i1 %29, label %32, label %30
30: ; preds = %26
%31 = tail call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i32 %2, i32 4, i32 %28, i32 %27)
br label %32
32: ; preds = %30, %26
%33 = tail call i32 @p4_escr_addr_orig(i32 %2, i32 5)
%34 = tail call i32 @p4_escr_addr(i32 %2, i32 5)
%35 = icmp eq i32 %33, %34
br i1 %35, label %38, label %36
36: ; preds = %32
%37 = tail call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i32 %2, i32 5, i32 %34, i32 %33)
br label %38
38: ; preds = %36, %32
%39 = tail call i32 @p4_escr_addr_orig(i32 %2, i32 6)
%40 = tail call i32 @p4_escr_addr(i32 %2, i32 6)
%41 = icmp eq i32 %39, %40
br i1 %41, label %44, label %42
42: ; preds = %38
%43 = tail call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i32 %2, i32 6, i32 %40, i32 %39)
br label %44
44: ; preds = %42, %38
%45 = tail call i32 @p4_escr_addr_orig(i32 %2, i32 7)
%46 = tail call i32 @p4_escr_addr(i32 %2, i32 7)
%47 = icmp eq i32 %45, %46
br i1 %47, label %50, label %48
48: ; preds = %44
%49 = tail call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i32 %2, i32 7, i32 %46, i32 %45)
br label %50
50: ; preds = %48, %44
%51 = add nuw nsw i32 %2, 1
%52 = icmp eq i32 %51, 18
br i1 %52, label %53, label %1
53: ; preds = %50
ret void
}