#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*/ dStrHex(char const *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
void decode_softw_inf_id(unsigned char *buff, int len, int do_hex) {
  int k;
  if (do_hex) {
    dStrHex((const char *)buff, len, 0);
    return;
  }
  len -= 4;
  buff += 4;
  for (; len > 5; len -= 6, buff += 6) {
    printf("    ");
    for (k = 0; k < 6; ++k)
      printf("%02x", (unsigned int)buff[k]);
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<decode_softw_inf_id>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     114f <decode_softw_inf_id+0x2f>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
xor    %edx,%edx
call   1030 <dStrHex@plt>
jmp    11dd <decode_softw_inf_id+0xbd>
mov    -0xc(%rbp),%eax
sub    $0x4,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x8(%rbp)
cmpl   $0x5,-0xc(%rbp)
jle    11dd <decode_softw_inf_id+0xbd>
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x6,-0x14(%rbp)
jge    11b5 <decode_softw_inf_id+0x95>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1183 <decode_softw_inf_id+0x63>
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
sub    $0x6,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
add    $0x6,%rax
mov    %rax,-0x8(%rbp)
jmp    1164 <decode_softw_inf_id+0x44>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decode_softw_inf_id>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
test   %edx,%edx
je     1156 <decode_softw_inf_id+0x26>
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %edx,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <dStrHex@plt>
cmp    $0xa,%ebp
jl     11f3 <decode_softw_inf_id+0xc3>
add    $0x4,%rbx
add    $0x2,%ebp
lea    0xe93(%rip),%r14
lea    0xe91(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl (%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl 0x1(%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl 0x2(%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl 0x3(%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl 0x4(%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl 0x5(%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0xfffffffa,%ebp
add    $0x6,%rbx
cmp    $0xb,%ebp
ja     1180 <decode_softw_inf_id+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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