#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);
  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,-0x4(%rbp)
mov    0xe9e(%rip),%rax
mov    %rax,-0x1b(%rbp)
mov    0xe9c(%rip),%eax
mov    %eax,-0x13(%rbp)
mov    0xe96(%rip),%ax
mov    %ax,-0xf(%rbp)
mov    0xe8e(%rip),%al
mov    %al,-0xd(%rbp)
mov    $0x200,%edi
call   1030 <malloc_aligned@plt>
mov    %rax,-0x28(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e45(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1040 <lseek@plt>
mov    -0x4(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    $0x200,%edx
call   1050 <read@plt>
mov    %eax,-0x8(%rbp)
mov    -0x28(%rbp),%rax
movb   $0x0,0xf(%rax)
mov    -0x28(%rbp),%rdi
lea    -0x1b(%rbp),%rsi
call   1060 <strcmp@plt>
mov    %rax,%rdx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x0,%rdx
cmove  %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x28(%rbp),%rdi
mov    $0x200,%esi
call   1070 <free_aligned@plt>
mov    -0xc(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_photoframe>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ebp
movabs $0x2e50524f432058,%rax
mov    %rax,0xf(%rsp)
movabs $0x58494e4f52544953,%rax
4e 49 58
mov    %rax,0x8(%rsp)
mov    $0x200,%edi
call   1030 <malloc_aligned@plt>
mov    %rax,%rbx
mov    0x2e56(%rip),%rax
mov    (%rax),%edx
mov    %ebp,%edi
xor    %esi,%esi
call   1040 <lseek@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x200,%edx
call   1050 <read@plt>
movb   $0x0,0xf(%rbx)
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
sete   %bpl
mov    %rbx,%rdi
mov    $0x200,%esi
call   1070 <free_aligned@plt>
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
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 [15 x i8]
%6 = alloca i8*
store i32 %0, i32* %2
%7 = bitcast [15 x i8]* %5 to i8*
%8 = call i8* @malloc_aligned(i32 512)
store i8* %8, i8** %6
%9 = load i32, i32* %2
%10 = load i32, i32* @SEEK_SET
%11 = call i32 @lseek(i32 %9, i32 0, i32 %10)
%12 = load i32, i32* %2
%13 = load i8*, i8** %6
%14 = call i32 @read(i32 %12, i8* %13, i32 512)
store i32 %14, i32* %3
%15 = load i8*, i8** %6
%16 = getelementptr inbounds i8, i8* %15, i64 15
store i8 0, i8* %16
%17 = load i8*, i8** %6
%18 = getelementptr inbounds [15 x i8], [15 x i8]* %5, i64 0, i64 0
%19 = call i64 @strcmp(i8* %17, i8* %18)
%20 = icmp eq i64 %19, 0
%21 = zext i1 %20 to i64
%22 = select i1 %20, i32 1, i32 0
store i32 %22, i32* %4
%23 = load i8*, i8** %6
%24 = call i32 @free_aligned(i8* %23, i32 512)
%25 = load i32, i32* %4
ret i32 %25
}

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 = getelementptr inbounds i8, i8* %4, i64 15
store i8 0, i8* %8
%9 = call i64 @strcmp(i8* %4, i8* %3)
%10 = icmp eq i64 %9, 0
%11 = zext i1 %10 to i32
%12 = call i32 @free_aligned(i8* %4, i32 512)
ret i32 %11
}