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

/* Variables and functions */
int /*<<< orphan*/ SEEK_CUR;
int /*<<< orphan*/ alignFilePointer(int /*<<< orphan*/ *, int);
int fread(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/ *);
scalar_t__ fseek(int /*<<< orphan*/ *, size_t, int /*<<< orphan*/);
size_t getSigSize(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int skipSignature(FILE *f) {
  uint32_t sigType;
  size_t size;
  if (fread(&sigType, sizeof(sigType), 1, f) != 1) {
    perror("skipSignature: error reading signature type");
    return -1;
  }
  size = getSigSize(sigType);
  if (fseek(f, size, SEEK_CUR)) {
    perror("skipSignature: error seeking");
    return -1;
  }
  if (!alignFilePointer(f, 64)) {
    perror("skipSignature: error aligning file pointer");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<skipSignature>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x1,%eax
je     1194 <skipSignature+0x44>
lea    0xe7d(%rip),%rdi
call   1070 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    120e <skipSignature+0xbe>
mov    -0x14(%rbp),%edi
call   1060 <getSigSize@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    0x2e39(%rip),%rax
mov    (%rax),%edx
call   1050 <fseek@plt>
cmp    $0x0,%rax
je     11d8 <skipSignature+0x88>
lea    0xe65(%rip),%rdi
call   1070 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    120e <skipSignature+0xbe>
mov    -0x10(%rbp),%rdi
mov    $0x40,%esi
call   1040 <alignFilePointer@plt>
cmp    $0x0,%eax
jne    1207 <skipSignature+0xb7>
lea    0xe53(%rip),%rdi
call   1070 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    120e <skipSignature+0xbe>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<skipSignature>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xc(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
cmp    $0x1,%eax
jne    11b1 <skipSignature+0x61>
mov    0xc(%rsp),%edi
call   1060 <getSigSize@plt>
mov    0x2e64(%rip),%rcx
mov    (%rcx),%edx
mov    %rbx,%rdi
mov    %rax,%rsi
call   1050 <fseek@plt>
test   %rax,%rax
jne    11ba <skipSignature+0x6a>
mov    %rbx,%rdi
mov    $0x40,%esi
call   1040 <alignFilePointer@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
je     11c3 <skipSignature+0x73>
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe48(%rip),%rdi
jmp    11ca <skipSignature+0x7a>
lea    0xe6b(%rip),%rdi
jmp    11ca <skipSignature+0x7a>
lea    0xe7f(%rip),%rdi
call   1070 <perror@plt>
mov    $0xffffffff,%eax
jmp    11ab <skipSignature+0x5b>

LLVM IR (-O0):
@.str = [44 x i8] c"skipSignature: error reading signature type\00"
@SEEK_CUR = global i32 0
@.str.1 = [29 x i8] c"skipSignature: error seeking\00"
@.str.2 = [43 x i8] c"skipSignature: error aligning file pointer\00"
define i32 @skipSignature(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i64
store i32* %0, i32** %3
%6 = load i32*, i32** %3
%7 = call i32 @fread(i32* %4, i32 4, i32 1, i32* %6)
%8 = icmp ne i32 %7, 1
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = call i32 @perror(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %2
br label %28
11: ; preds = %1
%12 = load i32, i32* %4
%13 = call i64 @getSigSize(i32 %12)
store i64 %13, i64* %5
%14 = load i32*, i32** %3
%15 = load i64, i64* %5
%16 = load i32, i32* @SEEK_CUR
%17 = call i64 @fseek(i32* %14, i64 %15, i32 %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %11
%20 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %2
br label %28
21: ; preds = %11
%22 = load i32*, i32** %3
%23 = call i32 @alignFilePointer(i32* %22, i32 64)
%24 = icmp ne i32 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %21
%26 = call i32 @perror(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %2
br label %28
27: ; preds = %21
store i32 0, i32* %2
br label %28
28: ; preds = %27, %25, %19, %9
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
@.str = [44 x i8] c"skipSignature: error reading signature type\00"
@SEEK_CUR = global i32 0
@.str.1 = [29 x i8] c"skipSignature: error seeking\00"
@.str.2 = [43 x i8] c"skipSignature: error aligning file pointer\00"
define i32 @skipSignature(i32* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = call i32 @fread(i32* %2, i32 4, i32 1, i32* %0)
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %15
6: ; preds = %1
%7 = load i32, i32* %2
%8 = tail call i64 @getSigSize(i32 %7)
%9 = load i32, i32* @SEEK_CUR
%10 = tail call i64 @fseek(i32* %0, i64 %8, i32 %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %6
%13 = tail call i32 @alignFilePointer(i32* %0, i32 64)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %12, %6, %1
%16 = phi i8* [ getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), %6 ], [ getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), %12 ]
%17 = tail call i32 @perror(i8* %16)
br label %18
18: ; preds = %15, %12
%19 = phi i32 [ 0, %12 ], [ -1, %15 ]
ret i32 %19
}