#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*/ stderr;
int /*<<< orphan*/ swab4(char *, int);
int testByte(char *hd) {
  int ver = *((int *)(hd + 304));
  if (ver < 1 || ver > 6) {
    swab4((char *)&ver, 4);
    if (ver < 1 || ver > 6) {
      fprintf(stderr, "****** not in sac format, version = %d\n", ver);
    }
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<testByte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x130(%rax),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jl     114d <testByte+0x2d>
cmpl   $0x6,-0x14(%rbp)
jle    1193 <testByte+0x73>
lea    -0x14(%rbp),%rdi
mov    $0x4,%esi
call   1030 <swab4@plt>
cmpl   $0x1,-0x14(%rbp)
jl     116f <testByte+0x4f>
cmpl   $0x6,-0x14(%rbp)
jle    1187 <testByte+0x67>
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xe7e(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    119a <testByte+0x7a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testByte>:
push   %rbx
sub    $0x10,%rsp
mov    0x130(%rdi),%eax
mov    %eax,0xc(%rsp)
add    $0xfffffff9,%eax
xor    %ebx,%ebx
cmp    $0xfffffff9,%eax
ja     116e <testByte+0x4e>
lea    0xc(%rsp),%rdi
mov    $0x4,%esi
call   1030 <swab4@plt>
mov    0xc(%rsp),%edx
lea    -0x7(%rdx),%eax
mov    $0x1,%ebx
cmp    $0xfffffff9,%eax
ja     116e <testByte+0x4e>
mov    0x2e80(%rip),%rax
mov    (%rax),%edi
lea    0xe97(%rip),%rsi
call   1040 <fprintf@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [40 x i8] c"****** not in sac format, version = %d\0A\00"
define i32 @testByte(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = getelementptr inbounds i8, i8* %5, i64 304
%7 = bitcast i8* %6 to i32*
%8 = load i32, i32* %7
store i32 %8, i32* %4
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 1
br i1 %10, label %14, label %11
11: ; preds = %1
%12 = load i32, i32* %4
%13 = icmp sgt i32 %12, 6
br i1 %13, label %14, label %27
14: ; preds = %11, %1
%15 = bitcast i32* %4 to i8*
%16 = call i32 @swab4(i8* %15, i32 4)
%17 = load i32, i32* %4
%18 = icmp slt i32 %17, 1
br i1 %18, label %22, label %19
19: ; preds = %14
%20 = load i32, i32* %4
%21 = icmp sgt i32 %20, 6
br i1 %21, label %22, label %26
22: ; preds = %19, %14
%23 = load i32, i32* @stderr
%24 = load i32, i32* %4
%25 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %22, %19
store i32 1, i32* %2
br label %28
27: ; preds = %11
store i32 0, i32* %2
br label %28
28: ; preds = %27, %26
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [40 x i8] c"****** not in sac format, version = %d\0A\00"
define i32 @testByte(i8* nocapture %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = getelementptr inbounds i8, i8* %0, i64 304
%5 = bitcast i8* %4 to i32*
%6 = load i32, i32* %5
store i32 %6, i32* %2
%7 = add i32 %6, -7
%8 = icmp ult i32 %7, -6
br i1 %8, label %9, label %17
9: ; preds = %1
%10 = call i32 @swab4(i8* %3, i32 4)
%11 = load i32, i32* %2
%12 = add i32 %11, -7
%13 = icmp ult i32 %12, -6
br i1 %13, label %14, label %17
14: ; preds = %9
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %11)
br label %17
17: ; preds = %1, %14, %9
%18 = phi i32 [ 1, %9 ], [ 1, %14 ], [ 0, %1 ]
ret i32 %18
}