#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*/ printf(char *, char *);
scalar_t__ read(int, char *, int /*<<< orphan*/);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strlen(char *);
int CheckMagicBytes(int tfd) {
  char fmagic[16];
  if (read(tfd, fmagic, strlen("Name515635200")) > 0) {
    if (!strcmp(fmagic, "Name515635200")) {
      printf("Backup-Type: %s\n", "Name515635200");
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<CheckMagicBytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x2c(%rbp)
lea    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    0xea0(%rip),%rdi
call   1030 <strlen@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
call   1050 <read@plt>
cmp    $0x0,%rax
jle    11ba <CheckMagicBytes+0x7a>
lea    -0x20(%rbp),%rdi
lea    0xe78(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    11b5 <CheckMagicBytes+0x75>
lea    0xe71(%rip),%rdi
lea    0xe5c(%rip),%rsi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11c1 <CheckMagicBytes+0x81>
jmp    11ba <CheckMagicBytes+0x7a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CheckMagicBytes>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
lea    0xec2(%rip),%rdi
call   1030 <strlen@plt>
mov    %rsp,%rsi
mov    %ebx,%edi
mov    %eax,%edx
call   1050 <read@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jle    1193 <CheckMagicBytes+0x63>
movabs $0x36353135656d614e,%rcx
31 35 36
xor    (%rsp),%rcx
movabs $0x30303235333635,%rdx
xor    0x6(%rsp),%rdx
or     %rcx,%rdx
jne    1193 <CheckMagicBytes+0x63>
lea    0xe8c(%rip),%rdi
lea    0xe77(%rip),%rsi
call   1040 <printf@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Name515635200\00"
@.str.1 = [17 x i8] c"Backup-Type: %s\0A\00"
define i32 @CheckMagicBytes(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [16 x i8]
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%7 = call i32 @strlen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%8 = call i64 @read(i32 %5, i8* %6, i32 %7)
%9 = icmp sgt i64 %8, 0
br i1 %9, label %10, label %17
10: ; preds = %1
%11 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%12 = call i32 @strcmp(i8* %11, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%13 = icmp ne i32 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %10
%15 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %2
br label %18
16: ; preds = %10
br label %17
17: ; preds = %16, %1
store i32 0, i32* %2
br label %18
18: ; preds = %17, %14
%19 = load i32, i32* %2
ret i32 %19
}

LLVM IR (-O2):
@.str = [14 x i8] c"Name515635200\00"
@.str.1 = [17 x i8] c"Backup-Type: %s\0A\00"
define i32 @CheckMagicBytes(i32 %0) {
%2 = alloca [16 x i8]
%3 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @strlen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%5 = call i64 @read(i32 %0, i8* %3, i32 %4)
%6 = icmp sgt i64 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %1
%8 = call i32 @bcmp(i8* dereferenceable(14) %3, i8* dereferenceable(14) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i64 14)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %1, %7, %10
%13 = phi i32 [ 1, %10 ], [ 0, %7 ], [ 0, %1 ]
ret i32 %13
}