#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*/ printf(char *, ...);
void pmecc_print_header(const uint32_t word) {
  int val;
  printf("PMECC header:\n");
  printf("\t\t====================\n");
  val = (word >> 18) & 0x1ff;
  printf("\t\teccOffset: %9i\n", val);
  val = (((word >> 16) & 0x3) == 0) ? 512 : 1024;
  printf("\t\tsectorSize: %8i\n", val);
  if (((word >> 13) & 0x7) <= 2)
    val = (2 << ((word >> 13) & 0x7));
  else
    val = (12 << (((word >> 13) & 0x7) - 3));
  printf("\t\teccBitReq: %9i\n", val);
  val = (word >> 4) & 0x1ff;
  printf("\t\tspareSize: %9i\n", val);
  val = (1 << ((word >> 1) & 0x3));
  printf("\t\tnbSectorPerPage: %3i\n", val);
  printf("\t\tusePmecc: %10i\n", word & 0x1);
  printf("\t\t====================\n");
}


x86 assembly (clang, -O0):
<pmecc_print_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0xede(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
sar    $0x12,%eax
and    $0x1ff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xed8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%edx
sar    $0x10,%edx
and    $0x3,%edx
mov    $0x400,%eax
mov    $0x200,%ecx
cmp    $0x0,%edx
cmove  %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
sar    $0xd,%eax
and    $0x7,%eax
cmp    $0x2,%eax
jg     11ad <pmecc_print_header+0x9d>
mov    -0x4(%rbp),%ecx
sar    $0xd,%ecx
and    $0x7,%ecx
mov    $0x2,%eax
shl    %cl,%eax
mov    %eax,-0x8(%rbp)
jmp    11c3 <pmecc_print_header+0xb3>
mov    -0x4(%rbp),%ecx
sar    $0xd,%ecx
and    $0x7,%ecx
sub    $0x3,%ecx
mov    $0xc,%eax
shl    %cl,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
sar    $0x4,%eax
and    $0x1ff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%ecx
sar    $0x1,%ecx
and    $0x3,%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%esi
and    $0x1,%esi
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xddd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pmecc_print_header>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
mov    %edi,%eax
shr    $0xd,%eax
and    $0x7,%eax
lea    -0x3(%rax),%edx
mov    $0x2,%esi
mov    %eax,%ecx
shl    %cl,%esi
mov    $0xc,%ebp
mov    %edx,%ecx
shl    %cl,%ebp
cmp    $0x3,%eax
lea    0xf23(%rip),%rdi
lea    0xf2a(%rip),%r14
lea    0xea2(%rip),%r15
cmovb  %esi,%ebp
call   1030 <puts@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %ebx,%esi
shr    $0x12,%esi
and    $0x1ff,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %esi,%esi
test   $0x30000,%ebx
setne  %sil
lea    0xe7c(%rip),%rdi
shl    $0x9,%esi
add    $0x200,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe78(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%esi
shr    $0x4,%esi
and    $0x1ff,%esi
lea    0xe6f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%ecx
shr    %cl
and    $0x3,%cl
mov    $0x1,%esi
shl    %cl,%esi
lea    0xe65(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
and    $0x1,%ebx
lea    0xe6c(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"PMECC header:\0A\00"
@.str.1 = [24 x i8] c"\09\09====================\0A\00"
@.str.2 = [18 x i8] c"\09\09eccOffset: %9i\0A\00"
@.str.3 = [19 x i8] c"\09\09sectorSize: %8i\0A\00"
@.str.4 = [18 x i8] c"\09\09eccBitReq: %9i\0A\00"
@.str.5 = [18 x i8] c"\09\09spareSize: %9i\0A\00"
@.str.6 = [24 x i8] c"\09\09nbSectorPerPage: %3i\0A\00"
@.str.7 = [18 x i8] c"\09\09usePmecc: %10i\0A\00"
define void @pmecc_print_header(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%6 = load i32, i32* %2
%7 = ashr i32 %6, 18
%8 = and i32 %7, 511
store i32 %8, i32* %3
%9 = load i32, i32* %3
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = load i32, i32* %2
%12 = ashr i32 %11, 16
%13 = and i32 %12, 3
%14 = icmp eq i32 %13, 0
%15 = zext i1 %14 to i64
%16 = select i1 %14, i32 512, i32 1024
store i32 %16, i32* %3
%17 = load i32, i32* %3
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %2
%20 = ashr i32 %19, 13
%21 = and i32 %20, 7
%22 = icmp sle i32 %21, 2
br i1 %22, label %23, label %28
23: ; preds = %1
%24 = load i32, i32* %2
%25 = ashr i32 %24, 13
%26 = and i32 %25, 7
%27 = shl i32 2, %26
store i32 %27, i32* %3
br label %34
28: ; preds = %1
%29 = load i32, i32* %2
%30 = ashr i32 %29, 13
%31 = and i32 %30, 7
%32 = sub nsw i32 %31, 3
%33 = shl i32 12, %32
store i32 %33, i32* %3
br label %34
34: ; preds = %28, %23
%35 = load i32, i32* %3
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %35)
%37 = load i32, i32* %2
%38 = ashr i32 %37, 4
%39 = and i32 %38, 511
store i32 %39, i32* %3
%40 = load i32, i32* %3
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %40)
%42 = load i32, i32* %2
%43 = ashr i32 %42, 1
%44 = and i32 %43, 3
%45 = shl i32 1, %44
store i32 %45, i32* %3
%46 = load i32, i32* %3
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i32 %46)
%48 = load i32, i32* %2
%49 = and i32 %48, 1
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i32 %49)
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.2 = [18 x i8] c"\09\09eccOffset: %9i\0A\00"
@.str.3 = [19 x i8] c"\09\09sectorSize: %8i\0A\00"
@.str.4 = [18 x i8] c"\09\09eccBitReq: %9i\0A\00"
@.str.5 = [18 x i8] c"\09\09spareSize: %9i\0A\00"
@.str.6 = [24 x i8] c"\09\09nbSectorPerPage: %3i\0A\00"
@.str.7 = [18 x i8] c"\09\09usePmecc: %10i\0A\00"
@str = [14 x i8] c"PMECC header:\00"
@str.9 = [23 x i8] c"\09\09====================\00"
define void @pmecc_print_header(i32 %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.9, i64 0, i64 0))
%4 = lshr i32 %0, 18
%5 = and i32 %4, 511
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %5)
%7 = and i32 %0, 196608
%8 = icmp eq i32 %7, 0
%9 = select i1 %8, i32 512, i32 1024
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %9)
%11 = lshr i32 %0, 13
%12 = and i32 %11, 7
%13 = icmp ult i32 %12, 3
%14 = shl nuw nsw i32 2, %12
%15 = add nsw i32 %12, -3
%16 = shl nuw nsw i32 12, %15
%17 = select i1 %13, i32 %14, i32 %16
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %17)
%19 = lshr i32 %0, 4
%20 = and i32 %19, 511
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %20)
%22 = lshr i32 %0, 1
%23 = and i32 %22, 3
%24 = shl nuw nsw i32 1, %23
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i32 %24)
%26 = and i32 %0, 1
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i32 %26)
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.9, i64 0, i64 0))
ret void
}