#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*/ printf(char *, ...);
void dcmi_show_power_limit(unsigned char *cdata, int sdata, int rv) {
  unsigned long correction_time;
  char *pstr;
  correction_time = cdata[6];
  correction_time += (cdata[7] << 8);
  correction_time += (cdata[8] << 16);
  correction_time += (unsigned long)(cdata[9] << 24);
  if (rv == 0)
    pstr = "(active)";
  else if (rv == 0x80)
    pstr = "(inactive)";
  else
    pstr = "(error)";
  printf("  Exception Action:  ");
  if (cdata[3] & 0x01)
    printf("Hard Power off\n");
  else if ((cdata[3] & 0x11) == 0x11)
    printf("SEL logging\n");
  else
    printf("OEM defined\n");
  printf("  Power Limit:       %d Watts %s\n", cdata[4] + (cdata[5] << 8),
         pstr);
  printf("  Correction Time:   %d ms\n", correction_time);
  printf("  Sampling period:   %d sec\n", cdata[12] + (cdata[13] << 8));
}


x86 assembly (clang, -O0):
<dcmi_show_power_limit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movzbl 0x6(%rax),%eax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movzbl 0x7(%rax),%eax
shl    $0x8,%eax
cltq
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movzbl 0x8(%rax),%eax
shl    $0x10,%eax
cltq
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movzbl 0x9(%rax),%eax
shl    $0x18,%eax
cltq
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    1187 <dcmi_show_power_limit+0x77>
lea    0xe82(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11b4 <dcmi_show_power_limit+0xa4>
cmpl   $0x80,-0x10(%rbp)
jne    11a4 <dcmi_show_power_limit+0x94>
lea    0xe6e(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11af <dcmi_show_power_limit+0x9f>
lea    0xe69(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11b4 <dcmi_show_power_limit+0xa4>
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movzbl 0x3(%rax),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11e9 <dcmi_show_power_limit+0xd9>
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1223 <dcmi_show_power_limit+0x113>
mov    -0x8(%rbp),%rax
movzbl 0x3(%rax),%eax
and    $0x11,%eax
cmp    $0x11,%eax
jne    1210 <dcmi_show_power_limit+0x100>
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    121e <dcmi_show_power_limit+0x10e>
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1223 <dcmi_show_power_limit+0x113>
mov    -0x8(%rbp),%rax
movzbl 0x4(%rax),%esi
mov    -0x8(%rbp),%rax
movzbl 0x5(%rax),%eax
shl    $0x8,%eax
add    %eax,%esi
mov    -0x20(%rbp),%rdx
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movzbl 0xc(%rax),%esi
mov    -0x8(%rbp),%rax
movzbl 0xd(%rax),%eax
shl    $0x8,%eax
add    %eax,%esi
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dcmi_show_power_limit>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r15d
mov    %rdi,%r14
movzbl 0x8(%rdi),%ebx
movzwl 0x6(%rdi),%r12d
movzbl 0x9(%rdi),%ebp
lea    0xeda(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x3(%r14),%eax
mov    %eax,%ecx
not    %ecx
test   $0x11,%cl
lea    0xf3d(%rip),%rcx
lea    0xf2a(%rip),%rdx
cmove  %rcx,%rdx
test   $0x1,%al
lea    0xf35(%rip),%rdi
cmove  %rdx,%rdi
call   1030 <puts@plt>
cmp    $0x80,%r15d
lea    0xe82(%rip),%rax
lea    0xe86(%rip),%rcx
cmove  %rax,%rcx
test   %r15d,%r15d
lea    0xe64(%rip),%rdx
cmovne %rcx,%rdx
shl    $0x10,%rbx
or     %r12,%rbx
shl    $0x18,%ebp
movslq %ebp,%rbp
or     %rbx,%rbp
movzwl 0x4(%r14),%esi
lea    0xe76(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe8a(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
movzwl 0xc(%r14),%esi
lea    0xe90(%rip),%rdi
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"(active)\00"
@.str.1 = [11 x i8] c"(inactive)\00"
@.str.2 = [8 x i8] c"(error)\00"
@.str.3 = [22 x i8] c" Exception Action: \00"
@.str.4 = [16 x i8] c"Hard Power off\0A\00"
@.str.5 = [13 x i8] c"SEL logging\0A\00"
@.str.6 = [13 x i8] c"OEM defined\0A\00"
@.str.7 = [34 x i8] c" Power Limit: %d Watts %s\0A\00"
@.str.8 = [28 x i8] c" Correction Time: %d ms\0A\00"
@.str.9 = [29 x i8] c" Sampling period: %d sec\0A\00"
define void @dcmi_show_power_limit(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i64
%8 = alloca i8*
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%9 = load i8*, i8** %4
%10 = getelementptr inbounds i8, i8* %9, i64 6
%11 = load i8, i8* %10
%12 = zext i8 %11 to i64
store i64 %12, i64* %7
%13 = load i8*, i8** %4
%14 = getelementptr inbounds i8, i8* %13, i64 7
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
%17 = shl i32 %16, 8
%18 = sext i32 %17 to i64
%19 = load i64, i64* %7
%20 = add i64 %19, %18
store i64 %20, i64* %7
%21 = load i8*, i8** %4
%22 = getelementptr inbounds i8, i8* %21, i64 8
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = shl i32 %24, 16
%26 = sext i32 %25 to i64
%27 = load i64, i64* %7
%28 = add i64 %27, %26
store i64 %28, i64* %7
%29 = load i8*, i8** %4
%30 = getelementptr inbounds i8, i8* %29, i64 9
%31 = load i8, i8* %30
%32 = zext i8 %31 to i32
%33 = shl i32 %32, 24
%34 = sext i32 %33 to i64
%35 = load i64, i64* %7
%36 = add i64 %35, %34
store i64 %36, i64* %7
%37 = load i32, i32* %6
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %3
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8** %8
br label %46
40: ; preds = %3
%41 = load i32, i32* %6
%42 = icmp eq i32 %41, 128
br i1 %42, label %43, label %44
43: ; preds = %40
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8** %8
br label %45
44: ; preds = %40
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8** %8
br label %45
45: ; preds = %44, %43
br label %46
46: ; preds = %45, %39
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%48 = load i8*, i8** %4
%49 = getelementptr inbounds i8, i8* %48, i64 3
%50 = load i8, i8* %49
%51 = zext i8 %50 to i32
%52 = and i32 %51, 1
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %56
54: ; preds = %46
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
br label %68
56: ; preds = %46
%57 = load i8*, i8** %4
%58 = getelementptr inbounds i8, i8* %57, i64 3
%59 = load i8, i8* %58
%60 = zext i8 %59 to i32
%61 = and i32 %60, 17
%62 = icmp eq i32 %61, 17
br i1 %62, label %63, label %65
63: ; preds = %56
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
br label %67
65: ; preds = %56
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
br label %67
67: ; preds = %65, %63
br label %68
68: ; preds = %67, %54
%69 = load i8*, i8** %4
%70 = getelementptr inbounds i8, i8* %69, i64 4
%71 = load i8, i8* %70
%72 = zext i8 %71 to i32
%73 = load i8*, i8** %4
%74 = getelementptr inbounds i8, i8* %73, i64 5
%75 = load i8, i8* %74
%76 = zext i8 %75 to i32
%77 = shl i32 %76, 8
%78 = add nsw i32 %72, %77
%79 = load i8*, i8** %8
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0), i32 %78, i8* %79)
%81 = load i64, i64* %7
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0), i64 %81)
%83 = load i8*, i8** %4
%84 = getelementptr inbounds i8, i8* %83, i64 12
%85 = load i8, i8* %84
%86 = zext i8 %85 to i32
%87 = load i8*, i8** %4
%88 = getelementptr inbounds i8, i8* %87, i64 13
%89 = load i8, i8* %88
%90 = zext i8 %89 to i32
%91 = shl i32 %90, 8
%92 = add nsw i32 %86, %91
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0), i32 %92)
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"(active)\00"
@.str.1 = [11 x i8] c"(inactive)\00"
@.str.2 = [8 x i8] c"(error)\00"
@.str.3 = [22 x i8] c" Exception Action: \00"
@.str.7 = [34 x i8] c" Power Limit: %d Watts %s\0A\00"
@.str.8 = [28 x i8] c" Correction Time: %d ms\0A\00"
@.str.9 = [29 x i8] c" Sampling period: %d sec\0A\00"
@str = [12 x i8] c"OEM defined\00"
@str.10 = [12 x i8] c"SEL logging\00"
@str.11 = [15 x i8] c"Hard Power off\00"
define void @dcmi_show_power_limit(i8* nocapture %0, i32 %1, i32 %2) {
%4 = getelementptr inbounds i8, i8* %0, i64 6
%5 = load i8, i8* %4
%6 = getelementptr inbounds i8, i8* %0, i64 7
%7 = load i8, i8* %6
%8 = getelementptr inbounds i8, i8* %0, i64 8
%9 = load i8, i8* %8
%10 = getelementptr inbounds i8, i8* %0, i64 9
%11 = load i8, i8* %10
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%13 = getelementptr inbounds i8, i8* %0, i64 3
%14 = load i8, i8* %13
%15 = zext i8 %14 to i32
%16 = and i32 %15, 1
%17 = icmp eq i32 %16, 0
%18 = and i32 %15, 17
%19 = icmp eq i32 %18, 17
%20 = select i1 %19, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @str.10, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0)
%21 = select i1 %17, i8* %20, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @str.11, i64 0, i64 0)
%22 = tail call i32 @puts(i8* dereferenceable(1) %21)
%23 = icmp eq i32 %2, 0
%24 = icmp eq i32 %2, 128
%25 = select i1 %24, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0)
%26 = select i1 %23, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %25
%27 = zext i8 %7 to i64
%28 = shl nuw nsw i64 %27, 8
%29 = zext i8 %5 to i64
%30 = or i64 %28, %29
%31 = zext i8 %9 to i64
%32 = shl nuw nsw i64 %31, 16
%33 = or i64 %30, %32
%34 = zext i8 %11 to i32
%35 = shl nuw i32 %34, 24
%36 = sext i32 %35 to i64
%37 = or i64 %33, %36
%38 = getelementptr inbounds i8, i8* %0, i64 4
%39 = load i8, i8* %38
%40 = zext i8 %39 to i32
%41 = getelementptr inbounds i8, i8* %0, i64 5
%42 = load i8, i8* %41
%43 = zext i8 %42 to i32
%44 = shl nuw nsw i32 %43, 8
%45 = or i32 %44, %40
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0), i32 %45, i8* %26)
%47 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0), i64 %37)
%48 = getelementptr inbounds i8, i8* %0, i64 12
%49 = load i8, i8* %48
%50 = zext i8 %49 to i32
%51 = getelementptr inbounds i8, i8* %0, i64 13
%52 = load i8, i8* %51
%53 = zext i8 %52 to i32
%54 = shl nuw nsw i32 %53, 8
%55 = or i32 %54, %50
%56 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0), i32 %55)
ret void
}