#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 */
typedef scalar_t__ off_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
int fread(char *, int, int, int /*<<< orphan*/ *);
scalar_t__ fseek(int /*<<< orphan*/ *, scalar_t__, int /*<<< orphan*/);
scalar_t__ get_sig_offset(int /*<<< orphan*/);
int /*<<< orphan*/ strncmp(char *, char *, int);
int check_resume_block(FILE *dev, off_t offset) {
  char buf[11] = {
      0,
  };
  off_t location = offset + get_sig_offset(0);
  if (fseek(dev, location, SEEK_SET) < 0)
    return -1;
  if (fread(buf, sizeof(char), 10, dev) != 10)
    return -1;
  if (!strncmp(buf, "S1SUSPEND", 9) || !strncmp(buf, "ULSUSPEND", 9))
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<check_resume_block>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x23(%rbp),%rdi
xor    %esi,%esi
mov    $0xb,%edx
call   1050 <memset@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
xor    %edi,%edi
call   1070 <get_sig_offset@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    0x2e44(%rip),%rax
mov    (%rax),%edx
call   1060 <fseek@plt>
cmp    $0x0,%rax
jge    11b9 <check_resume_block+0x69>
movl   $0xffffffff,-0x4(%rbp)
jmp    1234 <check_resume_block+0xe4>
lea    -0x23(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0xa,%edx
call   1040 <fread@plt>
cmp    $0xa,%eax
je     11e5 <check_resume_block+0x95>
movl   $0xffffffff,-0x4(%rbp)
jmp    1234 <check_resume_block+0xe4>
lea    -0x23(%rbp),%rdi
lea    0xe10(%rip),%rsi
mov    $0x9,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
je     1221 <check_resume_block+0xd1>
lea    -0x23(%rbp),%rdi
lea    0xdfc(%rip),%rsi
mov    $0x9,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    122d <check_resume_block+0xdd>
movl   $0x1,-0x4(%rbp)
jmp    1234 <check_resume_block+0xe4>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_resume_block>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
movl   $0x0,0xf(%rsp)
movq   $0x0,0x8(%rsp)
xor    %edi,%edi
call   1060 <get_sig_offset@plt>
add    %rax,%rbx
mov    0x2e71(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <fseek@plt>
mov    $0xffffffff,%ebx
test   %rax,%rax
js     11de <check_resume_block+0x9e>
lea    0x8(%rsp),%rdi
mov    $0x1,%esi
mov    $0xa,%edx
mov    %r14,%rcx
call   1040 <fread@plt>
cmp    $0xa,%eax
jne    11de <check_resume_block+0x9e>
lea    0xe57(%rip),%rsi
lea    0x8(%rsp),%rdi
mov    $0x9,%edx
call   1030 <strncmp@plt>
mov    $0x1,%ebx
test   %eax,%eax
je     11de <check_resume_block+0x9e>
lea    0xe42(%rip),%rsi
lea    0x8(%rsp),%rdi
mov    $0x9,%edx
call   1030 <strncmp@plt>
xor    %ebx,%ebx
test   %eax,%eax
sete   %bl
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
@.str = [10 x i8] c"S1SUSPEND\00"
@.str.1 = [10 x i8] c"ULSUSPEND\00"
define i32 @check_resume_block(i32* %0, i64 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i64
%6 = alloca [11 x i8]
%7 = alloca i64
store i32* %0, i32** %4
store i64 %1, i64* %5
%8 = bitcast [11 x i8]* %6 to i8*
%9 = load i64, i64* %5
%10 = call i64 @get_sig_offset(i32 0)
%11 = add nsw i64 %9, %10
store i64 %11, i64* %7
%12 = load i32*, i32** %4
%13 = load i64, i64* %7
%14 = load i32, i32* @SEEK_SET
%15 = call i64 @fseek(i32* %12, i64 %13, i32 %14)
%16 = icmp slt i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %2
store i32 -1, i32* %3
br label %34
18: ; preds = %2
%19 = getelementptr inbounds [11 x i8], [11 x i8]* %6, i64 0, i64 0
%20 = load i32*, i32** %4
%21 = call i32 @fread(i8* %19, i32 1, i32 10, i32* %20)
%22 = icmp ne i32 %21, 10
br i1 %22, label %23, label %24
23: ; preds = %18
store i32 -1, i32* %3
br label %34
24: ; preds = %18
%25 = getelementptr inbounds [11 x i8], [11 x i8]* %6, i64 0, i64 0
%26 = call i32 @strncmp(i8* %25, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 9)
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %24
%29 = getelementptr inbounds [11 x i8], [11 x i8]* %6, i64 0, i64 0
%30 = call i32 @strncmp(i8* %29, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 9)
%31 = icmp ne i32 %30, 0
br i1 %31, label %33, label %32
32: ; preds = %28, %24
store i32 1, i32* %3
br label %34
33: ; preds = %28
store i32 0, i32* %3
br label %34
34: ; preds = %33, %32, %23, %17
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
@.str = [10 x i8] c"S1SUSPEND\00"
@.str.1 = [10 x i8] c"ULSUSPEND\00"
define i32 @check_resume_block(i32* nocapture %0, i64 %1) {
%3 = alloca [11 x i8]
%4 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
%5 = tail call i64 @get_sig_offset(i32 0)
%6 = add nsw i64 %5, %1
%7 = load i32, i32* @SEEK_SET
%8 = tail call i64 @fseek(i32* %0, i64 %6, i32 %7)
%9 = icmp slt i64 %8, 0
br i1 %9, label %20, label %10
10: ; preds = %2
%11 = call i32 @fread(i8* %4, i32 1, i32 10, i32* %0)
%12 = icmp eq i32 %11, 10
br i1 %12, label %13, label %20
13: ; preds = %10
%14 = call i32 @strncmp(i8* %4, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 9)
%15 = icmp eq i32 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %13
%17 = call i32 @strncmp(i8* %4, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 9)
%18 = icmp eq i32 %17, 0
%19 = zext i1 %18 to i32
br label %20
20: ; preds = %16, %13, %10, %2
%21 = phi i32 [ -1, %2 ], [ -1, %10 ], [ 1, %13 ], [ %19, %16 ]
ret i32 %21
}