int si475x_getPartInformation(int size, char *buf) {
  char revision;
  unsigned char partNumber;
  char partMajor;
  char partMinor;
  char partBuild;
  unsigned char romID;
  unsigned char rsp[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
  unsigned char cmd[1] = {0};
  cmd[0] = 0x02;
  si475x_command(1, cmd, 9, rsp);
  revision = (char)rsp[1];
  partNumber = rsp[2];
  partMajor = (char)rsp[3];
  partMinor = (char)rsp[4];
  partBuild = (char)rsp[5];
  romID = rsp[8];
  printf("------>[%s]:[%d.%d.%d.%d.%d.%d] \n", __func__, revision, partNumber,
         partMajor, partMinor, partBuild, romID);
  if (0 == revision && 0 == partNumber && 0 == partMajor && 0 == partMinor &&
      0 == partBuild && 0 == romID)
    return -1;
  if (size >= 9) {
    memcpy(buf, rsp, 9);
  } else {
    memcpy(buf, rsp, size);
  }
  return 0;
}


x86 assembly (clang, -O0):
<si475x_getPartInformation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x1f(%rbp),%rdi
xor    %esi,%esi
mov    $0x9,%edx
call   1050 <memset@plt>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <memset@plt>
movb   $0x2,-0x20(%rbp)
lea    -0x20(%rbp),%rsi
lea    -0x1f(%rbp),%rcx
mov    $0x1,%edi
mov    $0x9,%edx
mov    $0x0,%al
call   1040 <si475x_command@plt>
mov    -0x1e(%rbp),%al
mov    %al,-0x11(%rbp)
mov    -0x1d(%rbp),%al
mov    %al,-0x12(%rbp)
mov    -0x1c(%rbp),%al
mov    %al,-0x13(%rbp)
mov    -0x1b(%rbp),%al
mov    %al,-0x14(%rbp)
mov    -0x1a(%rbp),%al
mov    %al,-0x15(%rbp)
mov    -0x17(%rbp),%al
mov    %al,-0x16(%rbp)
movsbl -0x11(%rbp),%edx
movzbl -0x12(%rbp),%ecx
movsbl -0x13(%rbp),%r8d
movsbl -0x14(%rbp),%r9d
movsbl -0x15(%rbp),%r10d
movzbl -0x16(%rbp),%eax
lea    0xe2e(%rip),%rdi
lea    0xe49(%rip),%rsi
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
movsbl -0x11(%rbp),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
jne    1248 <si475x_getPartInformation+0x108>
movzbl -0x12(%rbp),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
jne    1248 <si475x_getPartInformation+0x108>
movsbl -0x13(%rbp),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
jne    1248 <si475x_getPartInformation+0x108>
movsbl -0x14(%rbp),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
jne    1248 <si475x_getPartInformation+0x108>
movsbl -0x15(%rbp),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
jne    1248 <si475x_getPartInformation+0x108>
movzbl -0x16(%rbp),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
jne    1248 <si475x_getPartInformation+0x108>
movl   $0xffffffff,-0x4(%rbp)
jmp    1280 <si475x_getPartInformation+0x140>
cmpl   $0x9,-0x8(%rbp)
jl     1268 <si475x_getPartInformation+0x128>
mov    -0x10(%rbp),%rax
mov    -0x1f(%rbp),%rcx
mov    %rcx,(%rax)
mov    -0x17(%rbp),%cl
mov    %cl,0x8(%rax)
jmp    1279 <si475x_getPartInformation+0x139>
mov    -0x10(%rbp),%rdi
lea    -0x1f(%rbp),%rsi
movslq -0x8(%rbp),%rdx
call   1060 <memcpy@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<si475x_getPartInformation>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,0x20(%rsp)
mov    %edi,0x1c(%rsp)
movb   $0x0,0x18(%rsp)
movq   $0x0,0x10(%rsp)
movb   $0x2,0xf(%rsp)
lea    0xf(%rsp),%rsi
lea    0x10(%rsp),%rcx
mov    $0x1,%edi
mov    $0x9,%edx
xor    %eax,%eax
call   1040 <si475x_command@plt>
movsbl 0x11(%rsp),%ebx
mov    0x12(%rsp),%r15b
mov    0x13(%rsp),%r14b
mov    0x14(%rsp),%r13b
movsbl 0x15(%rsp),%ebp
movzbl 0x18(%rsp),%r12d
movzbl %r15b,%ecx
movsbl %r14b,%r8d
movsbl %r13b,%r9d
lea    0xe59(%rip),%rdi
lea    0xe74(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
push   %r12
push   %rbp
call   1030 <printf@plt>
add    $0x10,%rsp
test   %ebx,%ebx
jne    11e0 <si475x_getPartInformation+0xb0>
test   %r15b,%r15b
jne    11e0 <si475x_getPartInformation+0xb0>
test   %r14b,%r14b
jne    11e0 <si475x_getPartInformation+0xb0>
test   %r13b,%r13b
jne    11e0 <si475x_getPartInformation+0xb0>
test   %bpl,%bpl
jne    11e0 <si475x_getPartInformation+0xb0>
mov    $0xffffffff,%eax
test   %r12b,%r12b
je     120e <si475x_getPartInformation+0xde>
mov    0x1c(%rsp),%eax
cmp    $0x9,%eax
mov    0x20(%rsp),%rdi
jl     11ff <si475x_getPartInformation+0xcf>
mov    0x18(%rsp),%al
mov    %al,0x8(%rdi)
mov    0x10(%rsp),%rax
mov    %rax,(%rdi)
jmp    120c <si475x_getPartInformation+0xdc>
movslq %eax,%rdx
lea    0x10(%rsp),%rsi
call   1050 <memcpy@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"------>[%s]:[%d.%d.%d.%d.%d.%d] \0A\00"
@__func__.si475x_getPartInformation = [26 x i8] c"si475x_getPartInformation\00"
define i32 @si475x_getPartInformation(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8
%7 = alloca i8
%8 = alloca i8
%9 = alloca i8
%10 = alloca i8
%11 = alloca i8
%12 = alloca [9 x i8]
%13 = alloca [1 x i8]
store i32 %0, i32* %4
store i8* %1, i8** %5
%14 = bitcast [9 x i8]* %12 to i8*
%15 = bitcast [1 x i8]* %13 to i8*
%16 = getelementptr inbounds [1 x i8], [1 x i8]* %13, i64 0, i64 0
store i8 2, i8* %16
%17 = getelementptr inbounds [1 x i8], [1 x i8]* %13, i64 0, i64 0
%18 = getelementptr inbounds [9 x i8], [9 x i8]* %12, i64 0, i64 0
%19 = call i32 (i32, i8*, i32, i8*, ...) bitcast (i32 (...)* @si475x_command to i32 (i32, i8*, i32, i8*, ...)*)(i32 1, i8* %17, i32 9, i8* %18)
%20 = getelementptr inbounds [9 x i8], [9 x i8]* %12, i64 0, i64 1
%21 = load i8, i8* %20
store i8 %21, i8* %6
%22 = getelementptr inbounds [9 x i8], [9 x i8]* %12, i64 0, i64 2
%23 = load i8, i8* %22
store i8 %23, i8* %7
%24 = getelementptr inbounds [9 x i8], [9 x i8]* %12, i64 0, i64 3
%25 = load i8, i8* %24
store i8 %25, i8* %8
%26 = getelementptr inbounds [9 x i8], [9 x i8]* %12, i64 0, i64 4
%27 = load i8, i8* %26
store i8 %27, i8* %9
%28 = getelementptr inbounds [9 x i8], [9 x i8]* %12, i64 0, i64 5
%29 = load i8, i8* %28
store i8 %29, i8* %10
%30 = getelementptr inbounds [9 x i8], [9 x i8]* %12, i64 0, i64 8
%31 = load i8, i8* %30
store i8 %31, i8* %11
%32 = load i8, i8* %6
%33 = sext i8 %32 to i32
%34 = load i8, i8* %7
%35 = zext i8 %34 to i32
%36 = load i8, i8* %8
%37 = sext i8 %36 to i32
%38 = load i8, i8* %9
%39 = sext i8 %38 to i32
%40 = load i8, i8* %10
%41 = sext i8 %40 to i32
%42 = load i8, i8* %11
%43 = zext i8 %42 to i32
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @__func__.si475x_getPartInformation, i64 0, i64 0), i32 %33, i32 %35, i32 %37, i32 %39, i32 %41, i32 %43)
%45 = load i8, i8* %6
%46 = sext i8 %45 to i32
%47 = icmp eq i32 0, %46
br i1 %47, label %48, label %69
48: ; preds = %2
%49 = load i8, i8* %7
%50 = zext i8 %49 to i32
%51 = icmp eq i32 0, %50
br i1 %51, label %52, label %69
52: ; preds = %48
%53 = load i8, i8* %8
%54 = sext i8 %53 to i32
%55 = icmp eq i32 0, %54
br i1 %55, label %56, label %69
56: ; preds = %52
%57 = load i8, i8* %9
%58 = sext i8 %57 to i32
%59 = icmp eq i32 0, %58
br i1 %59, label %60, label %69
60: ; preds = %56
%61 = load i8, i8* %10
%62 = sext i8 %61 to i32
%63 = icmp eq i32 0, %62
br i1 %63, label %64, label %69
64: ; preds = %60
%65 = load i8, i8* %11
%66 = zext i8 %65 to i32
%67 = icmp eq i32 0, %66
br i1 %67, label %68, label %69
68: ; preds = %64
store i32 -1, i32* %3
br label %81
69: ; preds = %64, %60, %56, %52, %48, %2
%70 = load i32, i32* %4
%71 = icmp sge i32 %70, 9
br i1 %71, label %72, label %75
72: ; preds = %69
%73 = load i8*, i8** %5
%74 = getelementptr inbounds [9 x i8], [9 x i8]* %12, i64 0, i64 0
br label %80
75: ; preds = %69
%76 = load i8*, i8** %5
%77 = getelementptr inbounds [9 x i8], [9 x i8]* %12, i64 0, i64 0
%78 = load i32, i32* %4
%79 = sext i32 %78 to i64
br label %80
80: ; preds = %75, %72
store i32 0, i32* %3
br label %81
81: ; preds = %80, %68
%82 = load i32, i32* %3
ret i32 %82
}

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