#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*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ printf(char *, unsigned char, ...);
int /*<<< orphan*/ stderr;
int decode_power_condition(unsigned char *buff, int len) {
  if (len < 18) {
    fprintf(stderr, "Power condition VPD page length too short=%d\n", len);
    return 97;
  }
  printf("  Standby_y=%d Standby_z=%d Idle_c=%d Idle_b=%d Idle_a=%d\n",
         !!(buff[4] & 0x2), !!(buff[4] & 0x1), !!(buff[5] & 0x4),
         !!(buff[5] & 0x2), !!(buff[5] & 0x1));
  printf("  Stopped condition recovery time (ms) %d\n",
         (buff[6] << 8) + buff[7]);
  printf("  Standby_z condition recovery time (ms) %d\n",
         (buff[8] << 8) + buff[9]);
  printf("  Standby_y condition recovery time (ms) %d\n",
         (buff[10] << 8) + buff[11]);
  printf("  Idle_a condition recovery time (ms) %d\n",
         (buff[12] << 8) + buff[13]);
  printf("  Idle_b condition recovery time (ms) %d\n",
         (buff[14] << 8) + buff[15]);
  printf("  Idle_c condition recovery time (ms) %d\n",
         (buff[16] << 8) + buff[17]);
  return 0;
}


x86 assembly (clang, -O0):
<decode_power_condition>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpl   $0x12,-0x14(%rbp)
jge    115d <decode_power_condition+0x3d>
mov    0x2ea0(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xeb4(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x61,-0x4(%rbp)
jmp    12f1 <decode_power_condition+0x1d1>
mov    -0x10(%rbp),%rax
movzbl 0x4(%rax),%eax
and    $0x2,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    -0x10(%rbp),%rcx
movzbl 0x4(%rcx),%ecx
and    $0x1,%ecx
cmp    $0x0,%ecx
setne  %cl
xor    $0xff,%cl
xor    $0xff,%cl
and    $0x1,%cl
movzbl %cl,%edx
mov    -0x10(%rbp),%rcx
movzbl 0x5(%rcx),%ecx
and    $0x4,%ecx
cmp    $0x0,%ecx
setne  %cl
xor    $0xff,%cl
xor    $0xff,%cl
and    $0x1,%cl
movzbl %cl,%ecx
mov    -0x10(%rbp),%rsi
movzbl 0x5(%rsi),%esi
and    $0x2,%esi
cmp    $0x0,%esi
setne  %sil
xor    $0xff,%sil
xor    $0xff,%sil
and    $0x1,%sil
movzbl %sil,%r8d
mov    -0x10(%rbp),%rsi
movzbl 0x5(%rsi),%esi
and    $0x1,%esi
cmp    $0x0,%esi
setne  %sil
xor    $0xff,%sil
xor    $0xff,%sil
and    $0x1,%sil
movzbl %sil,%r9d
lea    0xe32(%rip),%rdi
movzbl %al,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movzbl 0x6(%rax),%eax
shl    $0x8,%eax
mov    -0x10(%rbp),%rcx
movzbl 0x7(%rcx),%ecx
add    %ecx,%eax
lea    0xe47(%rip),%rdi
movzbl %al,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movzbl 0x8(%rax),%eax
shl    $0x8,%eax
mov    -0x10(%rbp),%rcx
movzbl 0x9(%rcx),%ecx
add    %ecx,%eax
lea    0xe4c(%rip),%rdi
movzbl %al,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movzbl 0xa(%rax),%eax
shl    $0x8,%eax
mov    -0x10(%rbp),%rcx
movzbl 0xb(%rcx),%ecx
add    %ecx,%eax
lea    0xe53(%rip),%rdi
movzbl %al,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movzbl 0xc(%rax),%eax
shl    $0x8,%eax
mov    -0x10(%rbp),%rcx
movzbl 0xd(%rcx),%ecx
add    %ecx,%eax
lea    0xe5a(%rip),%rdi
movzbl %al,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movzbl 0xe(%rax),%eax
shl    $0x8,%eax
mov    -0x10(%rbp),%rcx
movzbl 0xf(%rcx),%ecx
add    %ecx,%eax
lea    0xe5e(%rip),%rdi
movzbl %al,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movzbl 0x10(%rax),%eax
shl    $0x8,%eax
mov    -0x10(%rbp),%rcx
movzbl 0x11(%rcx),%ecx
add    %ecx,%eax
lea    0xe62(%rip),%rdi
movzbl %al,%esi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decode_power_condition>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x11,%esi
jg     1149 <decode_power_condition+0x29>
mov    %esi,%edx
mov    0x2eaf(%rip),%rax
mov    (%rax),%edi
lea    0xec6(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x61,%ebp
jmp    11f2 <decode_power_condition+0xd2>
mov    %rdi,%rbx
movzbl 0x4(%rdi),%edx
mov    %edx,%esi
shr    %esi
and    $0x1,%esi
and    $0x1,%edx
movzbl 0x5(%rdi),%r9d
mov    %r9d,%ecx
shr    $0x2,%ecx
and    $0x1,%ecx
mov    %r9d,%r8d
shr    %r8d
and    $0x1,%r8d
and    $0x1,%r9d
lea    0xeb1(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <printf@plt>
movzbl 0x7(%rbx),%esi
lea    0xed8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movzbl 0x9(%rbx),%esi
lea    0xef1(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movzbl 0xb(%rbx),%esi
lea    0xf0c(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movzbl 0xd(%rbx),%esi
lea    0xf27(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movzbl 0xf(%rbx),%esi
lea    0xf3f(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movzbl 0x11(%rbx),%esi
lea    0xf57(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [46 x i8] c"Power condition VPD page length too short=%d\0A\00"
@.str.1 = [59 x i8] c" Standby_y=%d Standby_z=%d Idle_c=%d Idle_b=%d Idle_a=%d\0A\00"
@.str.2 = [43 x i8] c" Stopped condition recovery time (ms) %d\0A\00"
@.str.3 = [45 x i8] c" Standby_z condition recovery time (ms) %d\0A\00"
@.str.4 = [45 x i8] c" Standby_y condition recovery time (ms) %d\0A\00"
@.str.5 = [42 x i8] c" Idle_a condition recovery time (ms) %d\0A\00"
@.str.6 = [42 x i8] c" Idle_b condition recovery time (ms) %d\0A\00"
@.str.7 = [42 x i8] c" Idle_c condition recovery time (ms) %d\0A\00"
define i32 @decode_power_condition(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
%7 = icmp slt i32 %6, 18
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i32, i32* %5
%11 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 %10)
store i32 97, i32* %3
br label %132
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = getelementptr inbounds i8, i8* %13, i64 4
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
%17 = and i32 %16, 2
%18 = icmp ne i32 %17, 0
%19 = xor i1 %18, true
%20 = xor i1 %19, true
%21 = zext i1 %20 to i32
%22 = trunc i32 %21 to i8
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i64 4
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = and i32 %26, 1
%28 = icmp ne i32 %27, 0
%29 = xor i1 %28, true
%30 = xor i1 %29, true
%31 = zext i1 %30 to i32
%32 = load i8*, i8** %4
%33 = getelementptr inbounds i8, i8* %32, i64 5
%34 = load i8, i8* %33
%35 = zext i8 %34 to i32
%36 = and i32 %35, 4
%37 = icmp ne i32 %36, 0
%38 = xor i1 %37, true
%39 = xor i1 %38, true
%40 = zext i1 %39 to i32
%41 = load i8*, i8** %4
%42 = getelementptr inbounds i8, i8* %41, i64 5
%43 = load i8, i8* %42
%44 = zext i8 %43 to i32
%45 = and i32 %44, 2
%46 = icmp ne i32 %45, 0
%47 = xor i1 %46, true
%48 = xor i1 %47, true
%49 = zext i1 %48 to i32
%50 = load i8*, i8** %4
%51 = getelementptr inbounds i8, i8* %50, i64 5
%52 = load i8, i8* %51
%53 = zext i8 %52 to i32
%54 = and i32 %53, 1
%55 = icmp ne i32 %54, 0
%56 = xor i1 %55, true
%57 = xor i1 %56, true
%58 = zext i1 %57 to i32
%59 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %22, i32 %31, i32 %40, i32 %49, i32 %58)
%60 = load i8*, i8** %4
%61 = getelementptr inbounds i8, i8* %60, i64 6
%62 = load i8, i8* %61
%63 = zext i8 %62 to i32
%64 = shl i32 %63, 8
%65 = load i8*, i8** %4
%66 = getelementptr inbounds i8, i8* %65, i64 7
%67 = load i8, i8* %66
%68 = zext i8 %67 to i32
%69 = add nsw i32 %64, %68
%70 = trunc i32 %69 to i8
%71 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %70)
%72 = load i8*, i8** %4
%73 = getelementptr inbounds i8, i8* %72, i64 8
%74 = load i8, i8* %73
%75 = zext i8 %74 to i32
%76 = shl i32 %75, 8
%77 = load i8*, i8** %4
%78 = getelementptr inbounds i8, i8* %77, i64 9
%79 = load i8, i8* %78
%80 = zext i8 %79 to i32
%81 = add nsw i32 %76, %80
%82 = trunc i32 %81 to i8
%83 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0), i8 zeroext %82)
%84 = load i8*, i8** %4
%85 = getelementptr inbounds i8, i8* %84, i64 10
%86 = load i8, i8* %85
%87 = zext i8 %86 to i32
%88 = shl i32 %87, 8
%89 = load i8*, i8** %4
%90 = getelementptr inbounds i8, i8* %89, i64 11
%91 = load i8, i8* %90
%92 = zext i8 %91 to i32
%93 = add nsw i32 %88, %92
%94 = trunc i32 %93 to i8
%95 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0), i8 zeroext %94)
%96 = load i8*, i8** %4
%97 = getelementptr inbounds i8, i8* %96, i64 12
%98 = load i8, i8* %97
%99 = zext i8 %98 to i32
%100 = shl i32 %99, 8
%101 = load i8*, i8** %4
%102 = getelementptr inbounds i8, i8* %101, i64 13
%103 = load i8, i8* %102
%104 = zext i8 %103 to i32
%105 = add nsw i32 %100, %104
%106 = trunc i32 %105 to i8
%107 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0), i8 zeroext %106)
%108 = load i8*, i8** %4
%109 = getelementptr inbounds i8, i8* %108, i64 14
%110 = load i8, i8* %109
%111 = zext i8 %110 to i32
%112 = shl i32 %111, 8
%113 = load i8*, i8** %4
%114 = getelementptr inbounds i8, i8* %113, i64 15
%115 = load i8, i8* %114
%116 = zext i8 %115 to i32
%117 = add nsw i32 %112, %116
%118 = trunc i32 %117 to i8
%119 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i64 0, i64 0), i8 zeroext %118)
%120 = load i8*, i8** %4
%121 = getelementptr inbounds i8, i8* %120, i64 16
%122 = load i8, i8* %121
%123 = zext i8 %122 to i32
%124 = shl i32 %123, 8
%125 = load i8*, i8** %4
%126 = getelementptr inbounds i8, i8* %125, i64 17
%127 = load i8, i8* %126
%128 = zext i8 %127 to i32
%129 = add nsw i32 %124, %128
%130 = trunc i32 %129 to i8
%131 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0), i8 zeroext %130)
store i32 0, i32* %3
br label %132
132: ; preds = %12, %8
%133 = load i32, i32* %3
ret i32 %133
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [46 x i8] c"Power condition VPD page length too short=%d\0A\00"
@.str.1 = [59 x i8] c" Standby_y=%d Standby_z=%d Idle_c=%d Idle_b=%d Idle_a=%d\0A\00"
@.str.2 = [43 x i8] c" Stopped condition recovery time (ms) %d\0A\00"
@.str.3 = [45 x i8] c" Standby_z condition recovery time (ms) %d\0A\00"
@.str.4 = [45 x i8] c" Standby_y condition recovery time (ms) %d\0A\00"
@.str.5 = [42 x i8] c" Idle_a condition recovery time (ms) %d\0A\00"
@.str.6 = [42 x i8] c" Idle_b condition recovery time (ms) %d\0A\00"
@.str.7 = [42 x i8] c" Idle_c condition recovery time (ms) %d\0A\00"
define i32 @decode_power_condition(i8* nocapture %0, i32 %1) {
%3 = icmp slt i32 %1, 18
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 %1)
br label %41
7: ; preds = %2
%8 = getelementptr inbounds i8, i8* %0, i64 4
%9 = load i8, i8* %8
%10 = lshr i8 %9, 1
%11 = and i8 %10, 1
%12 = and i8 %9, 1
%13 = zext i8 %12 to i32
%14 = getelementptr inbounds i8, i8* %0, i64 5
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
%17 = lshr i32 %16, 2
%18 = and i32 %17, 1
%19 = lshr i32 %16, 1
%20 = and i32 %19, 1
%21 = and i32 %16, 1
%22 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %11, i32 %13, i32 %18, i32 %20, i32 %21)
%23 = getelementptr inbounds i8, i8* %0, i64 7
%24 = load i8, i8* %23
%25 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %24)
%26 = getelementptr inbounds i8, i8* %0, i64 9
%27 = load i8, i8* %26
%28 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0), i8 zeroext %27)
%29 = getelementptr inbounds i8, i8* %0, i64 11
%30 = load i8, i8* %29
%31 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0), i8 zeroext %30)
%32 = getelementptr inbounds i8, i8* %0, i64 13
%33 = load i8, i8* %32
%34 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0), i8 zeroext %33)
%35 = getelementptr inbounds i8, i8* %0, i64 15
%36 = load i8, i8* %35
%37 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i64 0, i64 0), i8 zeroext %36)
%38 = getelementptr inbounds i8, i8* %0, i64 17
%39 = load i8, i8* %38
%40 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0), i8 zeroext %39)
br label %41
41: ; preds = %7, %4
%42 = phi i32 [ 97, %4 ], [ 0, %7 ]
ret i32 %42
}