#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*/);
int fwrite(char *, int, int, int /*<<< orphan*/ *);
scalar_t__ get_sig_offset(int);
int /*<<< orphan*/ memmove(char *, char *, int);
int /*<<< orphan*/ memset(char *, char, int);
int clear_resume_block(FILE *dev, off_t offset) {
  char buf[21] = {
      0,
  };
  off_t location = offset + get_sig_offset(1);
  if (fseek(dev, location, SEEK_SET) < 0)
    return -1;
  if (fread(buf, sizeof(char), 20, dev) != 20)
    return -1;
  if (fseek(dev, location, SEEK_SET) < 0)
    return -1;
  memmove(buf + 10, buf, 10);
  memset(buf, '\0', 10);
  if (fwrite(buf, sizeof(char), 20, dev) != 20)
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<clear_resume_block>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x15,%edx
call   1040 <memset@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    $0x1,%edi
call   1060 <get_sig_offset@plt>
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    0x2e31(%rip),%rax
mov    (%rax),%edx
call   1050 <fseek@plt>
cmp    $0x0,%rax
jge    11cc <clear_resume_block+0x6c>
movl   $0xffffffff,-0x4(%rbp)
jmp    127d <clear_resume_block+0x11d>
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x14,%edx
call   1030 <fread@plt>
cmp    $0x14,%eax
je     11f8 <clear_resume_block+0x98>
movl   $0xffffffff,-0x4(%rbp)
jmp    127d <clear_resume_block+0x11d>
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    0x2dd9(%rip),%rax
mov    (%rax),%edx
call   1050 <fseek@plt>
cmp    $0x0,%rax
jge    1224 <clear_resume_block+0xc4>
movl   $0xffffffff,-0x4(%rbp)
jmp    127d <clear_resume_block+0x11d>
lea    -0x30(%rbp),%rdi
add    $0xa,%rdi
lea    -0x30(%rbp),%rsi
mov    $0xa,%edx
call   1070 <memmove@plt>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <memset@plt>
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x14,%edx
call   1080 <fwrite@plt>
cmp    $0x14,%eax
je     1276 <clear_resume_block+0x116>
movl   $0xffffffff,-0x4(%rbp)
jmp    127d <clear_resume_block+0x11d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clear_resume_block>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movq   $0x0,0xd(%rsp)
mov    $0x1,%edi
call   1060 <get_sig_offset@plt>
add    %rax,%rbx
mov    0x2e4c(%rip),%r15
mov    (%r15),%edx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <fseek@plt>
mov    $0xffffffff,%ebp
test   %rax,%rax
js     121d <clear_resume_block+0xbd>
mov    %rsp,%rdi
mov    $0x1,%esi
mov    $0x14,%edx
mov    %r14,%rcx
call   1030 <fread@plt>
cmp    $0x14,%eax
jne    121d <clear_resume_block+0xbd>
mov    (%r15),%edx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <fseek@plt>
test   %rax,%rax
js     121d <clear_resume_block+0xbd>
lea    0xa(%rsp),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
mov    $0xa,%edx
call   1070 <memmove@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <memset@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x14,%edx
mov    %r14,%rcx
call   1080 <fwrite@plt>
xor    %ebp,%ebp
cmp    $0x14,%eax
setne  %bpl
neg    %ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
define i32 @clear_resume_block(i32* %0, i64 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i64
%6 = alloca [21 x i8]
%7 = alloca i64
store i32* %0, i32** %4
store i64 %1, i64* %5
%8 = bitcast [21 x i8]* %6 to i8*
%9 = load i64, i64* %5
%10 = call i64 @get_sig_offset(i32 1)
%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 %44
18: ; preds = %2
%19 = getelementptr inbounds [21 x i8], [21 x i8]* %6, i64 0, i64 0
%20 = load i32*, i32** %4
%21 = call i32 @fread(i8* %19, i32 1, i32 20, i32* %20)
%22 = icmp ne i32 %21, 20
br i1 %22, label %23, label %24
23: ; preds = %18
store i32 -1, i32* %3
br label %44
24: ; preds = %18
%25 = load i32*, i32** %4
%26 = load i64, i64* %7
%27 = load i32, i32* @SEEK_SET
%28 = call i64 @fseek(i32* %25, i64 %26, i32 %27)
%29 = icmp slt i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %24
store i32 -1, i32* %3
br label %44
31: ; preds = %24
%32 = getelementptr inbounds [21 x i8], [21 x i8]* %6, i64 0, i64 0
%33 = getelementptr inbounds i8, i8* %32, i64 10
%34 = getelementptr inbounds [21 x i8], [21 x i8]* %6, i64 0, i64 0
%35 = call i32 @memmove(i8* %33, i8* %34, i32 10)
%36 = getelementptr inbounds [21 x i8], [21 x i8]* %6, i64 0, i64 0
%37 = call i32 @memset(i8* %36, i8 signext 0, i32 10)
%38 = getelementptr inbounds [21 x i8], [21 x i8]* %6, i64 0, i64 0
%39 = load i32*, i32** %4
%40 = call i32 @fwrite(i8* %38, i32 1, i32 20, i32* %39)
%41 = icmp ne i32 %40, 20
br i1 %41, label %42, label %43
42: ; preds = %31
store i32 -1, i32* %3
br label %44
43: ; preds = %31
store i32 0, i32* %3
br label %44
44: ; preds = %43, %42, %30, %23, %17
%45 = load i32, i32* %3
ret i32 %45
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
define i32 @clear_resume_block(i32* nocapture %0, i64 %1) {
%3 = alloca [21 x i8]
%4 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 0
%5 = tail call i64 @get_sig_offset(i32 1)
%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 %24, label %10
10: ; preds = %2
%11 = call i32 @fread(i8* %4, i32 1, i32 20, i32* %0)
%12 = icmp eq i32 %11, 20
br i1 %12, label %13, label %24
13: ; preds = %10
%14 = load i32, i32* @SEEK_SET
%15 = tail call i64 @fseek(i32* %0, i64 %6, i32 %14)
%16 = icmp slt i64 %15, 0
br i1 %16, label %24, label %17
17: ; preds = %13
%18 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 10
%19 = call i32 @memmove(i8* %18, i8* %4, i32 10)
%20 = call i32 @memset(i8* %4, i8 signext 0, i32 10)
%21 = call i32 @fwrite(i8* %4, i32 1, i32 20, i32* %0)
%22 = icmp ne i32 %21, 20
%23 = sext i1 %22 to i32
br label %24
24: ; preds = %17, %13, %10, %2
%25 = phi i32 [ -1, %2 ], [ -1, %10 ], [ -1, %13 ], [ %23, %17 ]
ret i32 %25
}