#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 /*<<< orphan*/ accel_get_output(int);
unsigned char accel_get_status();
int /*<<< orphan*/ armprintf(char *, ...);
void ui_getaccel(char *cmdstr) {
  int i;
  unsigned char status = accel_get_status();
  armprintf("Accelerometer status: %d ", status);
  for (i = 0; i < 3; i++)
    armprintf(" %d", accel_get_output(i));
  armprintf("\r");
}


x86 assembly (clang, -O0):
<ui_getaccel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1040 <accel_get_status@plt>
mov    %al,-0xd(%rbp)
movzbl -0xd(%rbp),%esi
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <armprintf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x3,-0xc(%rbp)
jge    118f <ui_getaccel+0x5f>
mov    -0xc(%rbp),%edi
call   1050 <accel_get_output@plt>
mov    %eax,%esi
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <armprintf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115f <ui_getaccel+0x2f>
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1030 <armprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ui_getaccel>:
push   %rbx
xor    %eax,%eax
call   1040 <accel_get_status@plt>
movzbl %al,%esi
lea    0xebe(%rip),%rdi
xor    %eax,%eax
call   1030 <armprintf@plt>
xor    %edi,%edi
call   1050 <accel_get_output@plt>
lea    0xec3(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <armprintf@plt>
mov    $0x1,%edi
call   1050 <accel_get_output@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <armprintf@plt>
mov    $0x2,%edi
call   1050 <accel_get_output@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <armprintf@plt>
lea    0xe88(%rip),%rdi
xor    %eax,%eax
pop    %rbx
jmp    1030 <armprintf@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"Accelerometer status: %d \00"
@.str.1 = [4 x i8] c" %d\00"
@.str.2 = [2 x i8] c"\0D\00"
define void @ui_getaccel(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8
store i8* %0, i8** %2
%5 = call zeroext i8 (...) @accel_get_status()
store i8 %5, i8* %4
%6 = load i8, i8* %4
%7 = zext i8 %6 to i32
%8 = call i32 (i8*, ...) @armprintf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %7)
store i32 0, i32* %3
br label %9
9: ; preds = %16, %1
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 3
br i1 %11, label %12, label %19
12: ; preds = %9
%13 = load i32, i32* %3
%14 = call i32 @accel_get_output(i32 %13)
%15 = call i32 (i8*, ...) @armprintf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %12
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %3
br label %9
19: ; preds = %9
%20 = call i32 (i8*, ...) @armprintf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [26 x i8] c"Accelerometer status: %d \00"
@.str.1 = [4 x i8] c" %d\00"
@.str.2 = [2 x i8] c"\0D\00"
define void @ui_getaccel(i8* nocapture readnone %0) {
%2 = tail call zeroext i8 (...) @accel_get_status()
%3 = zext i8 %2 to i32
%4 = tail call i32 (i8*, ...) @armprintf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = tail call i32 @accel_get_output(i32 0)
%6 = tail call i32 (i8*, ...) @armprintf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%7 = tail call i32 @accel_get_output(i32 1)
%8 = tail call i32 (i8*, ...) @armprintf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = tail call i32 @accel_get_output(i32 2)
%10 = tail call i32 (i8*, ...) @armprintf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = tail call i32 (i8*, ...) @armprintf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}