#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
unsigned int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int FileIsDucked(FILE *fptr_in) {
  unsigned int signatures[4] = {0x0A, 0xA0, 0x5A, 0x95};
  int i;
  for (i = 0; i < 4; i++) {
    if (fgetc(fptr_in) != signatures[i]) {
      fseek(fptr_in, 0, SEEK_SET);
      return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<FileIsDucked>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    0xecd(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x4,-0x24(%rbp)
jge    119d <FileIsDucked+0x7d>
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
movslq -0x24(%rbp),%rcx
cmp    -0x20(%rbp,%rcx,4),%eax
je     118a <FileIsDucked+0x6a>
mov    -0x10(%rbp),%rdi
mov    0x2e6b(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1040 <fseek@plt>
movl   $0x0,-0x4(%rbp)
jmp    11a4 <FileIsDucked+0x84>
jmp    118f <FileIsDucked+0x6f>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1149 <FileIsDucked+0x29>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FileIsDucked>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <fgetc@plt>
cmp    $0xa,%eax
jne    1160 <FileIsDucked+0x40>
mov    %rbx,%rdi
call   1030 <fgetc@plt>
cmp    $0xa0,%eax
jne    1160 <FileIsDucked+0x40>
mov    %rbx,%rdi
call   1030 <fgetc@plt>
cmp    $0x5a,%eax
jne    1160 <FileIsDucked+0x40>
mov    %rbx,%rdi
call   1030 <fgetc@plt>
mov    $0x1,%ebp
cmp    $0x95,%eax
je     1175 <FileIsDucked+0x55>
mov    0x2e79(%rip),%rax
mov    (%rax),%edx
xor    %ebp,%ebp
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <fseek@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@__const.FileIsDucked.signatures = [4 x i32] [i32 10, i32 160, i32 90, i32 149]
@SEEK_SET = global i32 0
define i32 @FileIsDucked(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca [4 x i32]
%5 = alloca i32
store i32* %0, i32** %3
%6 = bitcast [4 x i32]* %4 to i8*
store i32 0, i32* %5
br label %7
7: ; preds = %23, %1
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 4
br i1 %9, label %10, label %26
10: ; preds = %7
%11 = load i32*, i32** %3
%12 = call i32 @fgetc(i32* %11)
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 %14
%16 = load i32, i32* %15
%17 = icmp ne i32 %12, %16
br i1 %17, label %18, label %22
18: ; preds = %10
%19 = load i32*, i32** %3
%20 = load i32, i32* @SEEK_SET
%21 = call i32 @fseek(i32* %19, i32 0, i32 %20)
store i32 0, i32* %2
br label %27
22: ; preds = %10
br label %23
23: ; preds = %22
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
br label %7
26: ; preds = %7
store i32 1, i32* %2
br label %27
27: ; preds = %26, %18
%28 = load i32, i32* %2
ret i32 %28
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
define i32 @FileIsDucked(i32* nocapture %0) {
%2 = tail call i32 @fgetc(i32* %0)
%3 = icmp eq i32 %2, 10
br i1 %3, label %4, label %13
4: ; preds = %1
%5 = tail call i32 @fgetc(i32* %0)
%6 = icmp eq i32 %5, 160
br i1 %6, label %7, label %13
7: ; preds = %4
%8 = tail call i32 @fgetc(i32* %0)
%9 = icmp eq i32 %8, 90
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = tail call i32 @fgetc(i32* %0)
%12 = icmp eq i32 %11, 149
br i1 %12, label %16, label %13
13: ; preds = %10, %7, %4, %1
%14 = load i32, i32* @SEEK_SET
%15 = tail call i32 @fseek(i32* %0, i32 0, i32 %14)
br label %16
16: ; preds = %10, %13
%17 = phi i32 [ 0, %13 ], [ 1, %10 ]
ret i32 %17
}