#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 show_oemsdr_hp(unsigned char *sdr) {
  int len, i;
  len = sdr[4] + 5;
  if (sdr[8] == 0x02)
    len = 18;
  printf("HP: ");
  for (i = 8; i < len; i++)
    printf("%02x ", sdr[i]);
  if (sdr[8] == 0x02)
    printf("%s", &sdr[18]);
  printf("\n");
  return;
}


x86 assembly (clang, -O0):
<show_oemsdr_hp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movzbl 0x4(%rax),%eax
add    $0x5,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movzbl 0x8(%rax),%eax
cmp    $0x2,%eax
jne    1142 <show_oemsdr_hp+0x32>
movl   $0x12,-0xc(%rbp)
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x8,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    118b <show_oemsdr_hp+0x7b>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1157 <show_oemsdr_hp+0x47>
mov    -0x8(%rbp),%rax
movzbl 0x8(%rax),%eax
cmp    $0x2,%eax
jne    11b2 <show_oemsdr_hp+0xa2>
mov    -0x8(%rbp),%rsi
add    $0x12,%rsi
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_oemsdr_hp>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
movzbl 0x4(%rdi),%eax
add    $0x5,%eax
cmpb   $0x2,0x8(%rdi)
mov    $0x12,%ebx
cmovne %eax,%ebx
lea    0xebb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x9,%ebx
jb     1178 <show_oemsdr_hp+0x58>
mov    %ebx,%r12d
mov    $0x8,%ebx
lea    0xea5(%rip),%r14
movzbl (%r15,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1160 <show_oemsdr_hp+0x40>
cmpb   $0x2,0x8(%r15)
jne    1194 <show_oemsdr_hp+0x74>
add    $0x12,%r15
lea    0xe81(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"HP: \00"
@.str.1 = [6 x i8] c"%02x \00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [2 x i8] c"\0A\00"
define void @show_oemsdr_hp(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = getelementptr inbounds i8, i8* %5, i64 4
%7 = load i8, i8* %6
%8 = zext i8 %7 to i32
%9 = add nsw i32 %8, 5
store i32 %9, i32* %3
%10 = load i8*, i8** %2
%11 = getelementptr inbounds i8, i8* %10, i64 8
%12 = load i8, i8* %11
%13 = zext i8 %12 to i32
%14 = icmp eq i32 %13, 2
br i1 %14, label %15, label %16
15: ; preds = %1
store i32 18, i32* %3
br label %16
16: ; preds = %15, %1
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 8, i32* %4
br label %18
18: ; preds = %30, %16
%19 = load i32, i32* %4
%20 = load i32, i32* %3
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %33
22: ; preds = %18
%23 = load i8*, i8** %2
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = zext i8 %27 to i32
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %22
%31 = load i32, i32* %4
%32 = add nsw i32 %31, 1
store i32 %32, i32* %4
br label %18
33: ; preds = %18
%34 = load i8*, i8** %2
%35 = getelementptr inbounds i8, i8* %34, i64 8
%36 = load i8, i8* %35
%37 = zext i8 %36 to i32
%38 = icmp eq i32 %37, 2
br i1 %38, label %39, label %43
39: ; preds = %33
%40 = load i8*, i8** %2
%41 = getelementptr inbounds i8, i8* %40, i64 18
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %41)
br label %43
43: ; preds = %39, %33
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"HP: \00"
@.str.1 = [6 x i8] c"%02x \00"
@.str.2 = [3 x i8] c"%s\00"
define void @show_oemsdr_hp(i8* %0) {
%2 = getelementptr inbounds i8, i8* %0, i64 4
%3 = load i8, i8* %2
%4 = zext i8 %3 to i32
%5 = add nuw nsw i32 %4, 5
%6 = getelementptr inbounds i8, i8* %0, i64 8
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 2
%9 = select i1 %8, i32 18, i32 %5
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%11 = icmp ugt i32 %9, 8
br i1 %11, label %12, label %22
12: ; preds = %1
%13 = zext i32 %9 to i64
br label %14
14: ; preds = %12, %14
%15 = phi i64 [ 8, %12 ], [ %20, %14 ]
%16 = getelementptr inbounds i8, i8* %0, i64 %15
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = add nuw nsw i64 %15, 1
%21 = icmp eq i64 %20, %13
br i1 %21, label %22, label %14
22: ; preds = %14, %1
%23 = load i8, i8* %6
%24 = icmp eq i8 %23, 2
br i1 %24, label %25, label %28
25: ; preds = %22
%26 = getelementptr inbounds i8, i8* %0, i64 18
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %26)
br label %28
28: ; preds = %25, %22
%29 = tail call i32 @putchar(i32 10)
ret void
}