#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*/ CopyTags_APE(int /*<<< orphan*/ *);
int /*<<< orphan*/ CopyTags_ID3(int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
scalar_t__ strncmp(char const *, char *, int);
int CopyTags(const char *filename) {
  FILE *fp;
  if (0 == strncmp(filename, "/dev/", 5))
    return 0;
  fp = fopen(filename, "rb");
  if (fp == NULL)
    return -1;
  CopyTags_APE(fp);
  CopyTags_ID3(fp);
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<CopyTags>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe99(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    118b <CopyTags+0x3b>
movl   $0x0,-0x4(%rbp)
jmp    11d8 <CopyTags+0x88>
mov    -0x10(%rbp),%rdi
lea    0xe70(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11b6 <CopyTags+0x66>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d8 <CopyTags+0x88>
mov    -0x18(%rbp),%rdi
call   1050 <CopyTags_APE@plt>
mov    -0x18(%rbp),%rdi
call   1070 <CopyTags_ID3@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CopyTags>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xea3(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     11a4 <CopyTags+0x54>
lea    0xe91(%rip),%rsi
mov    %rbx,%rdi
call   1060 <fopen@plt>
test   %rax,%rax
je     119f <CopyTags+0x4f>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <CopyTags_APE@plt>
mov    %rbx,%rdi
call   1070 <CopyTags_ID3@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
jmp    11a4 <CopyTags+0x54>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"/dev/\00"
@.str.1 = [3 x i8] c"rb\00"
define i32 @CopyTags(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i64 @strncmp(i8* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%7 = icmp eq i64 0, %6
br i1 %7, label %8, label %9
8: ; preds = %1
store i32 0, i32* %2
br label %22
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %11, i32** %4
%12 = load i32*, i32** %4
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %15
14: ; preds = %9
store i32 -1, i32* %2
br label %22
15: ; preds = %9
%16 = load i32*, i32** %4
%17 = call i32 @CopyTags_APE(i32* %16)
%18 = load i32*, i32** %4
%19 = call i32 @CopyTags_ID3(i32* %18)
%20 = load i32*, i32** %4
%21 = call i32 @fclose(i32* %20)
store i32 0, i32* %2
br label %22
22: ; preds = %15, %14, %8
%23 = load i32, i32* %2
ret i32 %23
}

LLVM IR (-O2):
@.str = [6 x i8] c"/dev/\00"
@.str.1 = [3 x i8] c"rb\00"
define i32 @CopyTags(i8* %0) {
%2 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%3 = icmp eq i64 %2, 0
br i1 %3, label %11, label %4
4: ; preds = %1
%5 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %11, label %7
7: ; preds = %4
%8 = tail call i32 @CopyTags_APE(i32* %5)
%9 = tail call i32 @CopyTags_ID3(i32* %5)
%10 = tail call i32 @fclose(i32* %5)
br label %11
11: ; preds = %4, %1, %7
%12 = phi i32 [ 0, %7 ], [ 0, %1 ], [ -1, %4 ]
ret i32 %12
}