#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 */
int Mali_RdReg(int, int, int);
int /*<<< orphan*/ printk(char *, int, int, ...);
void Mali_CheckReg(int unit, int core, int regnum, int value) {
  int v = Mali_RdReg(unit, core, regnum);
  if (v != value)
    printk("Reg Compare Fail: 0x%08x Value: %08x should be=%08x\n",
           (unit << 28) + (core << 16) + regnum, v, value);
  else
    printk("Reg Compare: 0x%08x Value: %08x\n",
           (unit << 28) + (core << 16) + regnum, v);
}


x86 assembly (clang, -O0):
<Mali_CheckReg>:
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    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1040 <Mali_RdReg@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
je     117b <Mali_CheckReg+0x5b>
mov    -0x4(%rbp),%esi
shl    $0x1c,%esi
mov    -0x8(%rbp),%eax
shl    $0x10,%eax
add    %eax,%esi
add    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printk@plt>
jmp    119d <Mali_CheckReg+0x7d>
mov    -0x4(%rbp),%esi
shl    $0x1c,%esi
mov    -0x8(%rbp),%eax
shl    $0x10,%eax
add    %eax,%esi
add    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printk@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Mali_CheckReg>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %esi,%ebp
mov    %edi,%ebx
call   1040 <Mali_RdReg@plt>
shl    $0x1c,%ebx
shl    $0x10,%ebp
add    %ebx,%ebp
add    %r15d,%ebp
cmp    %r14d,%eax
jne    1163 <Mali_CheckReg+0x43>
lea    0xee8(%rip),%rdi
mov    %ebp,%esi
mov    %r14d,%edx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printk@plt>
lea    0xe96(%rip),%rdi
mov    %ebp,%esi
mov    %eax,%edx
mov    %r14d,%ecx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printk@plt>

LLVM IR (-O0):
@.str = [53 x i8] c"Reg Compare Fail: 0x%08x Value: %08x should be=%08x\0A\00"
@.str.1 = [33 x i8] c"Reg Compare: 0x%08x Value: %08x\0A\00"
define void @Mali_CheckReg(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32, i32* %5
%11 = load i32, i32* %6
%12 = load i32, i32* %7
%13 = call i32 @Mali_RdReg(i32 %10, i32 %11, i32 %12)
store i32 %13, i32* %9
%14 = load i32, i32* %9
%15 = load i32, i32* %8
%16 = icmp ne i32 %14, %15
br i1 %16, label %17, label %28
17: ; preds = %4
%18 = load i32, i32* %5
%19 = shl i32 %18, 28
%20 = load i32, i32* %6
%21 = shl i32 %20, 16
%22 = add nsw i32 %19, %21
%23 = load i32, i32* %7
%24 = add nsw i32 %22, %23
%25 = load i32, i32* %9
%26 = load i32, i32* %8
%27 = call i32 (i8*, i32, i32, ...) @printk(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i32 %24, i32 %25, i32 %26)
br label %38
28: ; preds = %4
%29 = load i32, i32* %5
%30 = shl i32 %29, 28
%31 = load i32, i32* %6
%32 = shl i32 %31, 16
%33 = add nsw i32 %30, %32
%34 = load i32, i32* %7
%35 = add nsw i32 %33, %34
%36 = load i32, i32* %9
%37 = call i32 (i8*, i32, i32, ...) @printk(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 %35, i32 %36)
br label %38
38: ; preds = %28, %17
ret void
}

LLVM IR (-O2):
@.str = [53 x i8] c"Reg Compare Fail: 0x%08x Value: %08x should be=%08x\0A\00"
@.str.1 = [33 x i8] c"Reg Compare: 0x%08x Value: %08x\0A\00"
define void @Mali_CheckReg(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = tail call i32 @Mali_RdReg(i32 %0, i32 %1, i32 %2)
%6 = icmp eq i32 %5, %3
%7 = shl i32 %0, 28
%8 = shl i32 %1, 16
%9 = add nsw i32 %8, %7
%10 = add nsw i32 %9, %2
br i1 %6, label %13, label %11
11: ; preds = %4
%12 = tail call i32 (i8*, i32, i32, ...) @printk(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %5, i32 %3)
br label %15
13: ; preds = %4
%14 = tail call i32 (i8*, i32, i32, ...) @printk(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 %10, i32 %3)
br label %15
15: ; preds = %13, %11
ret void
}