#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*/ armprintf(char *, ...);
int /*<<< orphan*/ ledctl_getLOD(int);
int /*<<< orphan*/ ledctl_getTEF();
int /*<<< orphan*/ ledctl_geterr();
void ui_statled(char *cmdstr) {
  int i;
  armprintf("XERR status: %d\r", ledctl_geterr());
  for (i = 0; i < 3; i++)
    armprintf("LOD %d status: %x\r", i, ledctl_getLOD(i));
  armprintf("TEF status: %x\r", ledctl_getTEF());
  armprintf("If LOD or TEF != 0 and XERR is on or vice-versa, "
            "report to MGB.\r");
  armprintf("\r");
}


x86 assembly (clang, -O0):
<ui_statled>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1050 <ledctl_geterr@plt>
mov    %eax,%esi
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <armprintf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x3,-0xc(%rbp)
jge    11a3 <ui_statled+0x63>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <ledctl_getLOD@plt>
mov    -0x10(%rbp),%esi
mov    %eax,%edx
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <armprintf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    116a <ui_statled+0x2a>
mov    $0x0,%al
call   1060 <ledctl_getTEF@plt>
mov    %eax,%esi
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1030 <armprintf@plt>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <armprintf@plt>
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <armprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ui_statled>:
push   %rbx
xor    %eax,%eax
call   1050 <ledctl_geterr@plt>
lea    0xeb1(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <armprintf@plt>
xor    %edi,%edi
call   1040 <ledctl_getLOD@plt>
lea    0xeab(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <armprintf@plt>
mov    $0x1,%edi
call   1040 <ledctl_getLOD@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <armprintf@plt>
mov    $0x2,%edi
call   1040 <ledctl_getLOD@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <armprintf@plt>
xor    %eax,%eax
call   1060 <ledctl_getTEF@plt>
lea    0xe6c(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <armprintf@plt>
lea    0xe6c(%rip),%rdi
xor    %eax,%eax
call   1030 <armprintf@plt>
lea    0xe9d(%rip),%rdi
xor    %eax,%eax
pop    %rbx
jmp    1030 <armprintf@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"XERR status: %d\0D\00"
@.str.1 = [19 x i8] c"LOD %d status: %x\0D\00"
@.str.2 = [16 x i8] c"TEF status: %x\0D\00"
@.str.3 = [65 x i8] c"If LOD or TEF != 0 and XERR is on or vice-versa, report to MGB.\0D\00"
@.str.4 = [2 x i8] c"\0D\00"
define void @ui_statled(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = call i32 (...) @ledctl_geterr()
%5 = call i32 (i8*, ...) @armprintf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %4)
store i32 0, i32* %3
br label %6
6: ; preds = %14, %1
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 3
br i1 %8, label %9, label %17
9: ; preds = %6
%10 = load i32, i32* %3
%11 = load i32, i32* %3
%12 = call i32 @ledctl_getLOD(i32 %11)
%13 = call i32 (i8*, ...) @armprintf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %10, i32 %12)
br label %14
14: ; preds = %9
%15 = load i32, i32* %3
%16 = add nsw i32 %15, 1
store i32 %16, i32* %3
br label %6
17: ; preds = %6
%18 = call i32 (...) @ledctl_getTEF()
%19 = call i32 (i8*, ...) @armprintf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%20 = call i32 (i8*, ...) @armprintf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.3, i64 0, i64 0))
%21 = call i32 (i8*, ...) @armprintf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"XERR status: %d\0D\00"
@.str.1 = [19 x i8] c"LOD %d status: %x\0D\00"
@.str.2 = [16 x i8] c"TEF status: %x\0D\00"
@.str.3 = [65 x i8] c"If LOD or TEF != 0 and XERR is on or vice-versa, report to MGB.\0D\00"
@.str.4 = [2 x i8] c"\0D\00"
define void @ui_statled(i8* nocapture readnone %0) {
%2 = tail call i32 (...) @ledctl_geterr()
%3 = tail call i32 (i8*, ...) @armprintf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %2)
%4 = tail call i32 @ledctl_getLOD(i32 0)
%5 = tail call i32 (i8*, ...) @armprintf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 %4)
%6 = tail call i32 @ledctl_getLOD(i32 1)
%7 = tail call i32 (i8*, ...) @armprintf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 %6)
%8 = tail call i32 @ledctl_getLOD(i32 2)
%9 = tail call i32 (i8*, ...) @armprintf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 %8)
%10 = tail call i32 (...) @ledctl_getTEF()
%11 = tail call i32 (i8*, ...) @armprintf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %10)
%12 = tail call i32 (i8*, ...) @armprintf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.3, i64 0, i64 0))
%13 = tail call i32 (i8*, ...) @armprintf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
ret void
}