#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*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ stderr;
int decode_tape_dev_caps_vpd(unsigned char *buff, int len) {
  if (len < 6) {
    fprintf(stderr,
            "Sequential access device capabilities VPD page "
            "length too short=%d\n",
            len);
    return 97;
  }
  printf("  Worm: %d\n", !!(buff[4] & 0x1));
  return 0;
}


x86 assembly (clang, -O0):
<decode_tape_dev_caps_vpd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpl   $0x6,-0x14(%rbp)
jge    115d <decode_tape_dev_caps_vpd+0x3d>
mov    0x2ea0(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xeb4(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x61,-0x4(%rbp)
jmp    118a <decode_tape_dev_caps_vpd+0x6a>
mov    -0x10(%rbp),%rax
movzbl 0x4(%rax),%eax
and    $0x1,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%esi
lea    0xec6(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decode_tape_dev_caps_vpd>:
push   %rax
cmp    $0x5,%esi
jg     1144 <decode_tape_dev_caps_vpd+0x24>
mov    %esi,%edx
mov    0x2eb1(%rip),%rax
mov    (%rax),%edi
lea    0xec8(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x61,%eax
pop    %rcx
ret
movzbl 0x4(%rdi),%esi
and    $0x1,%esi
lea    0xef2(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [68 x i8] c"Sequential access device capabilities VPD page length too short=%d\0A\00"
@.str.1 = [12 x i8] c" Worm: %d\0A\00"
define i32 @decode_tape_dev_caps_vpd(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
%7 = icmp slt i32 %6, 6
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i32, i32* %5
%11 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0), i32 %10)
store i32 97, i32* %3
br label %23
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = getelementptr inbounds i8, i8* %13, i64 4
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
%17 = and i32 %16, 1
%18 = icmp ne i32 %17, 0
%19 = xor i1 %18, true
%20 = xor i1 %19, true
%21 = zext i1 %20 to i32
%22 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %21)
store i32 0, i32* %3
br label %23
23: ; preds = %12, %8
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [68 x i8] c"Sequential access device capabilities VPD page length too short=%d\0A\00"
@.str.1 = [12 x i8] c" Worm: %d\0A\00"
define i32 @decode_tape_dev_caps_vpd(i8* nocapture %0, i32 %1) {
%3 = icmp slt i32 %1, 6
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0), i32 %1)
br label %13
7: ; preds = %2
%8 = getelementptr inbounds i8, i8* %0, i64 4
%9 = load i8, i8* %8
%10 = and i8 %9, 1
%11 = zext i8 %10 to i32
%12 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %11)
br label %13
13: ; preds = %7, %4
%14 = phi i32 [ 97, %4 ], [ 0, %7 ]
ret i32 %14
}