#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 */
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, char const *, char const *,
                            char const *);
void i830_debug_pp_status(char *result, int len, int reg, uint32_t val,
                          uint32_t devid) {
  const char *status = val & (1 << 31) ? "on" : "off";
  const char *ready = val & (1 << 30) ? "ready" : "not ready";
  const char *seq = "unknown";
  switch (val & 0x30000000) {
  case (0 << 28):
    seq = "idle";
    break;
  case (1 << 28):
    seq = "on";
    break;
  case (2 << 28):
    seq = "off";
    break;
  }
  snprintf(result, len, "%s, %s, sequencing %s", status, ready, seq);
}


x86 assembly (clang, -O0):
<i830_debug_pp_status>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    -0x14(%rbp),%edx
lea    0xecd(%rip),%rcx
lea    0xec9(%rip),%rax
test   $0x80000000,%edx
cmovne %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%edx
lea    0xeb9(%rip),%rcx
lea    0xeae(%rip),%rax
test   $0x40000000,%edx
cmovne %rcx,%rax
mov    %rax,-0x28(%rbp)
lea    0xea3(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x14(%rbp),%eax
and    $0x30000000,%eax
mov    %eax,-0x34(%rbp)
je     11ae <i830_debug_pp_status+0x9e>
jmp    1188 <i830_debug_pp_status+0x78>
mov    -0x34(%rbp),%eax
sub    $0x10000000,%eax
je     11be <i830_debug_pp_status+0xae>
jmp    119b <i830_debug_pp_status+0x8b>
mov    -0x34(%rbp),%eax
sub    $0x20000000,%eax
je     11ce <i830_debug_pp_status+0xbe>
jmp    11d9 <i830_debug_pp_status+0xc9>
lea    0xe64(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    11d9 <i830_debug_pp_status+0xc9>
lea    0xe3b(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    11d9 <i830_debug_pp_status+0xc9>
lea    0xe2e(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x30(%rbp),%r9
lea    0xe2b(%rip),%rdx
call   1030 <snprintf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<i830_debug_pp_status>:
mov    %ecx,%eax
and    $0x30000000,%eax
cmp    $0x20000000,%eax
je     1132 <i830_debug_pp_status+0x22>
cmp    $0x10000000,%eax
je     113b <i830_debug_pp_status+0x2b>
test   %eax,%eax
jne    1144 <i830_debug_pp_status+0x34>
lea    0xee9(%rip),%r9
jmp    114b <i830_debug_pp_status+0x3b>
lea    0xeca(%rip),%r9
jmp    114b <i830_debug_pp_status+0x3b>
lea    0xebe(%rip),%r9
jmp    114b <i830_debug_pp_status+0x3b>
lea    0xec6(%rip),%r9
test   $0x40000000,%ecx
lea    0xeaf(%rip),%rax
lea    0xeac(%rip),%r8
cmove  %rax,%r8
test   %ecx,%ecx
lea    0xe97(%rip),%rax
lea    0xe8d(%rip),%rcx
cmovns %rax,%rcx
lea    0xea0(%rip),%rdx
jmp    1030 <snprintf@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"on\00"
@.str.1 = [4 x i8] c"off\00"
@.str.2 = [6 x i8] c"ready\00"
@.str.3 = [10 x i8] c"not ready\00"
@.str.4 = [8 x i8] c"unknown\00"
@.str.5 = [5 x i8] c"idle\00"
@.str.6 = [22 x i8] c"%s, %s, sequencing %s\00"
define void @i830_debug_pp_status(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%14 = load i32, i32* %9
%15 = and i32 %14, -2147483648
%16 = icmp ne i32 %15, 0
%17 = zext i1 %16 to i64
%18 = select i1 %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0)
store i8* %18, i8** %11
%19 = load i32, i32* %9
%20 = and i32 %19, 1073741824
%21 = icmp ne i32 %20, 0
%22 = zext i1 %21 to i64
%23 = select i1 %21, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0)
store i8* %23, i8** %12
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8** %13
%24 = load i32, i32* %9
%25 = and i32 %24, 805306368
switch i32 %25, label %29 [
i32 0, label %26
i32 268435456, label %27
i32 536870912, label %28
]
26: ; preds = %5
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8** %13
br label %29
27: ; preds = %5
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %13
br label %29
28: ; preds = %5
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %13
br label %29
29: ; preds = %5, %28, %27, %26
%30 = load i8*, i8** %6
%31 = load i32, i32* %7
%32 = load i8*, i8** %11
%33 = load i8*, i8** %12
%34 = load i8*, i8** %13
%35 = call i32 @snprintf(i8* %30, i32 %31, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i8* %32, i8* %33, i8* %34)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"on\00"
@.str.1 = [4 x i8] c"off\00"
@.str.2 = [6 x i8] c"ready\00"
@.str.3 = [10 x i8] c"not ready\00"
@.str.4 = [8 x i8] c"unknown\00"
@.str.5 = [5 x i8] c"idle\00"
@.str.6 = [22 x i8] c"%s, %s, sequencing %s\00"
define void @i830_debug_pp_status(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = and i32 %3, 805306368
switch i32 %6, label %10 [
i32 0, label %7
i32 268435456, label %8
i32 536870912, label %9
]
7: ; preds = %5
br label %10
8: ; preds = %5
br label %10
9: ; preds = %5
br label %10
10: ; preds = %5, %9, %8, %7
%11 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), %5 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), %9 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %8 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), %7 ]
%12 = and i32 %3, 1073741824
%13 = icmp eq i32 %12, 0
%14 = select i1 %13, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0)
%15 = icmp sgt i32 %3, -1
%16 = select i1 %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0)
%17 = tail call i32 @snprintf(i8* %0, i32 %1, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i8* %16, i8* %14, i8* %11)
ret void
}