#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_walk_time(unsigned long *time) {
  unsigned char tmp[4];
  if (!time)
    return -1;
  if (mpu_read_mem((964), 4, tmp))
    return -1;
  time[0] = (((unsigned long)tmp[0] << 24) | ((unsigned long)tmp[1] << 16) |
             ((unsigned long)tmp[2] << 8) | tmp[3]) *
            20;
  return 0;
}


x86 assembly (clang, -O0):
<dmp_get_pedometer_walk_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1133 <dmp_get_pedometer_walk_time+0x23>
movl   $0xffffffff,-0x4(%rbp)
jmp    1193 <dmp_get_pedometer_walk_time+0x83>
lea    -0x14(%rbp),%rdx
mov    $0x3c4,%edi
mov    $0x4,%esi
call   1030 <mpu_read_mem@plt>
cmp    $0x0,%rax
je     115c <dmp_get_pedometer_walk_time+0x4c>
movl   $0xffffffff,-0x4(%rbp)
jmp    1193 <dmp_get_pedometer_walk_time+0x83>
movzbl -0x14(%rbp),%eax
shl    $0x18,%rax
movzbl -0x13(%rbp),%ecx
shl    $0x10,%rcx
or     %rcx,%rax
movzbl -0x12(%rbp),%ecx
shl    $0x8,%rcx
or     %rcx,%rax
movzbl -0x11(%rbp),%ecx
or     %rcx,%rax
imul   $0x14,%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_walk_time>:
push   %rbp
push   %rbx
push   %rax
mov    $0xffffffff,%ebp
test   %rdi,%rdi
je     1151 <dmp_get_pedometer_walk_time+0x41>
mov    %rdi,%rbx
lea    0x4(%rsp),%rdx
mov    $0x3c4,%edi
mov    $0x4,%esi
call   1030 <mpu_read_mem@plt>
test   %rax,%rax
jne    1151 <dmp_get_pedometer_walk_time+0x41>
mov    0x4(%rsp),%eax
shl    $0x20,%rax
bswap  %rax
shl    $0x2,%rax
lea    (%rax,%rax,4),%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_walk_time(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 %35
8: ; preds = %1
%9 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%10 = call i64 @mpu_read_mem(i32 964, 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 %35
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 = mul i64 %31, 20
%33 = load i64*, i64** %3
%34 = getelementptr inbounds i64, i64* %33, i64 0
store i64 %32, i64* %34
store i32 0, i32* %2
br label %35
35: ; preds = %13, %12, %7
%36 = load i32, i32* %2
ret i32 %36
}

LLVM IR (-O2):
define i32 @dmp_get_pedometer_walk_time(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 %27, label %5
5: ; preds = %1
%6 = call i64 @mpu_read_mem(i32 964, i32 4, i8* %3)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %27
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
%26 = mul nuw nsw i64 %25, 20
store i64 %26, i64* %0
br label %27
27: ; preds = %5, %1, %8
%28 = phi i32 [ 0, %8 ], [ -1, %1 ], [ -1, %5 ]
ret i32 %28
}