#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*/ SEEK_SET;
int /*<<< orphan*/ free_aligned(char *, int);
int /*<<< orphan*/ lseek(int, int, int /*<<< orphan*/);
char *malloc_aligned(int);
int read(int, char *, int);
scalar_t__ strcmp(char *, char *);
int is_photoframe(int f) {
  int y, res;
  char id[] = "SITRONIX CORP.";
  char *buff;
  buff = malloc_aligned(0x200);
  lseek(f, 0x0, SEEK_SET);
  y = read(f, buff, 0x200);
  if (y != 0x200)
    return 0;
  buff[15] = 0;
  res = strcmp(buff, id) == 0 ? 1 : 0;
  free_aligned(buff, 0x200);
  return res;
}


x86 assembly (clang, -O0):
<is_photoframe>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    0xe9e(%rip),%rax
mov    %rax,-0x1f(%rbp)
mov    0xe9c(%rip),%eax
mov    %eax,-0x17(%rbp)
mov    0xe96(%rip),%ax
mov    %ax,-0x13(%rbp)
mov    0xe8e(%rip),%al
mov    %al,-0x11(%rbp)
mov    $0x200,%edi
call   1030 <malloc_aligned@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2e45(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1040 <lseek@plt>
mov    -0x8(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    $0x200,%edx
call   1050 <read@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x200,-0xc(%rbp)
je     11d1 <is_photoframe+0x81>
movl   $0x0,-0x4(%rbp)
jmp    120e <is_photoframe+0xbe>
mov    -0x28(%rbp),%rax
movb   $0x0,0xf(%rax)
mov    -0x28(%rbp),%rdi
lea    -0x1f(%rbp),%rsi
call   1060 <strcmp@plt>
mov    %rax,%rdx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x0,%rdx
cmove  %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x28(%rbp),%rdi
mov    $0x200,%esi
call   1070 <free_aligned@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_photoframe>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
movabs $0x2e50524f432058,%rax
mov    %rax,0x7(%rsp)
movabs $0x58494e4f52544953,%rax
4e 49 58
mov    %rax,(%rsp)
mov    $0x200,%edi
call   1030 <malloc_aligned@plt>
mov    %rax,%r14
mov    0x2e55(%rip),%rax
mov    (%rax),%edx
xor    %ebp,%ebp
mov    %ebx,%edi
xor    %esi,%esi
call   1040 <lseek@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x200,%edx
call   1050 <read@plt>
cmp    $0x200,%eax
jne    11d4 <is_photoframe+0x84>
movb   $0x0,0xf(%r14)
mov    %rsp,%rsi
mov    %r14,%rdi
call   1060 <strcmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
sete   %bpl
mov    %r14,%rdi
mov    $0x200,%esi
call   1070 <free_aligned@plt>
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@__const.is_photoframe.id = [15 x i8] c"SITRONIX CORP.\00"
@SEEK_SET = global i32 0
define i32 @is_photoframe(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [15 x i8]
%7 = alloca i8*
store i32 %0, i32* %3
%8 = bitcast [15 x i8]* %6 to i8*
%9 = call i8* @malloc_aligned(i32 512)
store i8* %9, i8** %7
%10 = load i32, i32* %3
%11 = load i32, i32* @SEEK_SET
%12 = call i32 @lseek(i32 %10, i32 0, i32 %11)
%13 = load i32, i32* %3
%14 = load i8*, i8** %7
%15 = call i32 @read(i32 %13, i8* %14, i32 512)
store i32 %15, i32* %4
%16 = load i32, i32* %4
%17 = icmp ne i32 %16, 512
br i1 %17, label %18, label %19
18: ; preds = %1
store i32 0, i32* %2
br label %31
19: ; preds = %1
%20 = load i8*, i8** %7
%21 = getelementptr inbounds i8, i8* %20, i64 15
store i8 0, i8* %21
%22 = load i8*, i8** %7
%23 = getelementptr inbounds [15 x i8], [15 x i8]* %6, i64 0, i64 0
%24 = call i64 @strcmp(i8* %22, i8* %23)
%25 = icmp eq i64 %24, 0
%26 = zext i1 %25 to i64
%27 = select i1 %25, i32 1, i32 0
store i32 %27, i32* %5
%28 = load i8*, i8** %7
%29 = call i32 @free_aligned(i8* %28, i32 512)
%30 = load i32, i32* %5
store i32 %30, i32* %2
br label %31
31: ; preds = %19, %18
%32 = load i32, i32* %2
ret i32 %32
}

LLVM IR (-O2):
@__const.is_photoframe.id = [15 x i8] c"SITRONIX CORP.\00"
@SEEK_SET = global i32 0
define i32 @is_photoframe(i32 %0) {
%2 = alloca [15 x i8]
%3 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%4 = tail call i8* @malloc_aligned(i32 512)
%5 = load i32, i32* @SEEK_SET
%6 = tail call i32 @lseek(i32 %0, i32 0, i32 %5)
%7 = tail call i32 @read(i32 %0, i8* %4, i32 512)
%8 = icmp eq i32 %7, 512
br i1 %8, label %9, label %15
9: ; preds = %1
%10 = getelementptr inbounds i8, i8* %4, i64 15
store i8 0, i8* %10
%11 = call i64 @strcmp(i8* %4, i8* %3)
%12 = icmp eq i64 %11, 0
%13 = zext i1 %12 to i32
%14 = call i32 @free_aligned(i8* %4, i32 512)
br label %15
15: ; preds = %1, %9
%16 = phi i32 [ %13, %9 ], [ 0, %1 ]
ret i32 %16
}