#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 ide_sense_error(char *);
int /*<<< orphan*/ printf(char *);
int ide_get_sense_code() {
  char buf[10];
  int len = ide_sense_error(buf);
  if (len != 10) {
    printf("ERROR: Sense request failed!\n");
    return -1;
  }
  return ((int)buf[8] << 8) | buf[2];
}


x86 assembly (clang, -O0):
<ide_get_sense_code>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0xe(%rbp),%rdi
call   1040 <ide_sense_error@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
je     1156 <ide_get_sense_code+0x36>
lea    0xebb(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1166 <ide_get_sense_code+0x46>
movsbl -0x6(%rbp),%eax
shl    $0x8,%eax
movsbl -0xc(%rbp),%ecx
or     %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ide_get_sense_code>:
sub    $0x18,%rsp
lea    0xe(%rsp),%rdi
call   1040 <ide_sense_error@plt>
cmp    $0xa,%eax
jne    1147 <ide_get_sense_code+0x27>
movsbl 0x16(%rsp),%ecx
shl    $0x8,%ecx
movsbl 0x10(%rsp),%eax
or     %ecx,%eax
add    $0x18,%rsp
ret
lea    0xeb2(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"ERROR: Sense request failed!\0A\00"
define i32 @ide_get_sense_code() {
%1 = alloca i32
%2 = alloca [10 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%5 = call i32 @ide_sense_error(i8* %4)
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = icmp ne i32 %6, 10
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %1
br label %19
10: ; preds = %0
%11 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 8
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = shl i32 %13, 8
%15 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 2
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = or i32 %14, %17
store i32 %18, i32* %1
br label %19
19: ; preds = %10, %8
%20 = load i32, i32* %1
ret i32 %20
}

LLVM IR (-O2):
@str = [29 x i8] c"ERROR: Sense request failed!\00"
define i32 @ide_get_sense_code() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%3 = call i32 @ide_sense_error(i8* %2)
%4 = icmp eq i32 %3, 10
br i1 %4, label %7, label %5
5: ; preds = %0
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
br label %16
7: ; preds = %0
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 8
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = shl nsw i32 %10, 8
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 2
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = or i32 %11, %14
br label %16
16: ; preds = %7, %5
%17 = phi i32 [ -1, %5 ], [ %15, %7 ]
ret i32 %17
}