#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__ mpu_read_mem(int, int, unsigned char *);
int dmp_get_pedometer_step_count(unsigned long *count) {
  unsigned char tmp[4];
  if (!count)
    return -1;
  if (mpu_read_mem((768 + 0x60), 4, tmp))
    return -1;
  count[0] = ((unsigned long)tmp[0] << 24) | ((unsigned long)tmp[1] << 16) |
             ((unsigned long)tmp[2] << 8) | tmp[3];
  return 0;
}


x86 assembly (clang, -O0):
<dmp_get_pedometer_step_count>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1133 <dmp_get_pedometer_step_count+0x23>
movl   $0xffffffff,-0x4(%rbp)
jmp    1191 <dmp_get_pedometer_step_count+0x81>
lea    -0x14(%rbp),%rdx
mov    $0x360,%edi
mov    $0x4,%esi
call   1030 <mpu_read_mem@plt>
cmp    $0x0,%rax
je     115c <dmp_get_pedometer_step_count+0x4c>
movl   $0xffffffff,-0x4(%rbp)
jmp    1191 <dmp_get_pedometer_step_count+0x81>
movzbl -0x14(%rbp),%eax
mov    %eax,%ecx
shl    $0x18,%rcx
movzbl -0x13(%rbp),%eax
shl    $0x10,%rax
or     %rax,%rcx
movzbl -0x12(%rbp),%eax
shl    $0x8,%rax
or     %rax,%rcx
movzbl -0x11(%rbp),%eax
or     %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dmp_get_pedometer_step_count>:
push   %rbp
push   %rbx
push   %rax
mov    $0xffffffff,%ebp
test   %rdi,%rdi
je     1149 <dmp_get_pedometer_step_count+0x39>
mov    %rdi,%rbx
lea    0x4(%rsp),%rdx
mov    $0x360,%edi
mov    $0x4,%esi
call   1030 <mpu_read_mem@plt>
test   %rax,%rax
jne    1149 <dmp_get_pedometer_step_count+0x39>
mov    0x4(%rsp),%eax
shl    $0x20,%rax
bswap  %rax
mov    %rax,(%rbx)
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @dmp_get_pedometer_step_count(i64* %0) {
%2 = alloca i32
%3 = alloca i64*
%4 = alloca [4 x i8]
store i64* %0, i64** %3
%5 = load i64*, i64** %3
%6 = icmp ne i64* %5, null
br i1 %6, label %8, label %7
7: ; preds = %1
store i32 -1, i32* %2
br label %34
8: ; preds = %1
%9 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%10 = call i64 @mpu_read_mem(i32 864, i32 4, i8* %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %8
store i32 -1, i32* %2
br label %34
13: ; preds = %8
%14 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%15 = load i8, i8* %14
%16 = zext i8 %15 to i64
%17 = shl i64 %16, 24
%18 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 1
%19 = load i8, i8* %18
%20 = zext i8 %19 to i64
%21 = shl i64 %20, 16
%22 = or i64 %17, %21
%23 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 2
%24 = load i8, i8* %23
%25 = zext i8 %24 to i64
%26 = shl i64 %25, 8
%27 = or i64 %22, %26
%28 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 3
%29 = load i8, i8* %28
%30 = zext i8 %29 to i64
%31 = or i64 %27, %30
%32 = load i64*, i64** %3
%33 = getelementptr inbounds i64, i64* %32, i64 0
store i64 %31, i64* %33
store i32 0, i32* %2
br label %34
34: ; preds = %13, %12, %7
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
define i32 @dmp_get_pedometer_step_count(i64* writeonly %0) {
%2 = alloca [4 x i8]
%3 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%4 = icmp eq i64* %0, null
br i1 %4, label %26, label %5
5: ; preds = %1
%6 = call i64 @mpu_read_mem(i32 864, i32 4, i8* %3)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %26
8: ; preds = %5
%9 = load i8, i8* %3
%10 = zext i8 %9 to i64
%11 = shl nuw nsw i64 %10, 24
%12 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 1
%13 = load i8, i8* %12
%14 = zext i8 %13 to i64
%15 = shl nuw nsw i64 %14, 16
%16 = or i64 %15, %11
%17 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 2
%18 = load i8, i8* %17
%19 = zext i8 %18 to i64
%20 = shl nuw nsw i64 %19, 8
%21 = or i64 %16, %20
%22 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 3
%23 = load i8, i8* %22
%24 = zext i8 %23 to i64
%25 = or i64 %21, %24
store i64 %25, i64* %0
br label %26
26: ; preds = %5, %1, %8
%27 = phi i32 [ 0, %8 ], [ -1, %1 ], [ -1, %5 ]
ret i32 %27
}