#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 */
scalar_t__ I2C_IF_ReadFrom(int, unsigned char *, int, unsigned char *, int);
int /*<<< orphan*/ Report(char *);
int GetRegisterValue(unsigned char ucRegAddr, unsigned short *pusRegValue) {
  unsigned char ucRegData[2];
  if (I2C_IF_ReadFrom(0x41, &ucRegAddr, 1, &ucRegData[0], 2) != 0) {
    Report("I2C readfrom failed\n\r");
    return -1;
  }
  *pusRegValue = (unsigned short)(ucRegData[0] << 8) | ucRegData[1];
  return 0;
}


x86 assembly (clang, -O0):
<GetRegisterValue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x12(%rbp),%rcx
mov    $0x41,%edi
lea    -0x5(%rbp),%rsi
mov    $0x1,%edx
mov    $0x2,%r8d
call   1030 <I2C_IF_ReadFrom@plt>
cmp    $0x0,%rax
je     1171 <GetRegisterValue+0x51>
lea    0xea0(%rip),%rdi
call   1040 <Report@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1192 <GetRegisterValue+0x72>
movzbl -0x12(%rbp),%eax
shl    $0x8,%eax
movzwl %ax,%eax
movzbl -0x11(%rbp),%ecx
or     %ecx,%eax
mov    %ax,%cx
mov    -0x10(%rbp),%rax
mov    %cx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetRegisterValue>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %dil,0xd(%rsp)
lea    0xd(%rsp),%rsi
lea    0xe(%rsp),%rcx
mov    $0x41,%edi
mov    $0x1,%edx
mov    $0x2,%r8d
call   1030 <I2C_IF_ReadFrom@plt>
test   %rax,%rax
je     1164 <GetRegisterValue+0x44>
lea    0xea8(%rip),%rdi
call   1040 <Report@plt>
mov    $0xffffffff,%eax
jmp    1172 <GetRegisterValue+0x52>
movzwl 0xe(%rsp),%eax
rol    $0x8,%ax
mov    %ax,(%rbx)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [22 x i8] c"I2C readfrom failed\0A\0D\00"
define i32 @GetRegisterValue(i8 zeroext %0, i16* %1) {
%3 = alloca i32
%4 = alloca i8
%5 = alloca i16*
%6 = alloca [2 x i8]
store i8 %0, i8* %4
store i16* %1, i16** %5
%7 = getelementptr inbounds [2 x i8], [2 x i8]* %6, i64 0, i64 0
%8 = call i64 @I2C_IF_ReadFrom(i32 65, i8* %4, i32 1, i8* %7, i32 2)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 @Report(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %25
12: ; preds = %2
%13 = getelementptr inbounds [2 x i8], [2 x i8]* %6, i64 0, i64 0
%14 = load i8, i8* %13
%15 = zext i8 %14 to i32
%16 = shl i32 %15, 8
%17 = trunc i32 %16 to i16
%18 = zext i16 %17 to i32
%19 = getelementptr inbounds [2 x i8], [2 x i8]* %6, i64 0, i64 1
%20 = load i8, i8* %19
%21 = zext i8 %20 to i32
%22 = or i32 %18, %21
%23 = trunc i32 %22 to i16
%24 = load i16*, i16** %5
store i16 %23, i16* %24
store i32 0, i32* %3
br label %25
25: ; preds = %12, %10
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
@.str = [22 x i8] c"I2C readfrom failed\0A\0D\00"
define i32 @GetRegisterValue(i8 zeroext %0, i16* nocapture writeonly %1) {
%3 = alloca i8
%4 = alloca [2 x i8]
store i8 %0, i8* %3
%5 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%6 = call i64 @I2C_IF_ReadFrom(i32 65, i8* %3, i32 1, i8* %5, i32 2)
%7 = icmp eq i64 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = call i32 @Report(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %18
10: ; preds = %2
%11 = load i8, i8* %5
%12 = zext i8 %11 to i16
%13 = shl nuw i16 %12, 8
%14 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 1
%15 = load i8, i8* %14
%16 = zext i8 %15 to i16
%17 = or i16 %13, %16
store i16 %17, i16* %1
br label %18
18: ; preds = %10, %8
%19 = phi i32 [ -1, %8 ], [ 0, %10 ]
ret i32 %19
}