#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*/ O_RDWR;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ ftruncate(int, long);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ print_error(char *, char *);
int id3_strip_tag(long sizelesstag, char *fn) {
  int fd;
  fd = open(fn, O_RDWR);
  if (fd == -1) {
    print_error("strip_tag: Error opening %s", fn);
    return 0;
  }
  ftruncate(fd, sizelesstag);
  close(fd);
  return 1;
}


x86 assembly (clang, -O0):
<id3_strip_tag>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2e8d(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    118b <id3_strip_tag+0x4b>
mov    -0x18(%rbp),%rsi
lea    0xe86(%rip),%rdi
call   1030 <print_error@plt>
movl   $0x0,-0x4(%rbp)
jmp    11a6 <id3_strip_tag+0x66>
mov    -0x1c(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <ftruncate@plt>
mov    -0x1c(%rbp),%edi
call   1050 <close@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<id3_strip_tag>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
mov    0x2e97(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1060 <open@plt>
cmp    $0xffffffff,%eax
je     117a <id3_strip_tag+0x3a>
mov    %eax,%ebp
mov    %eax,%edi
mov    %r14,%rsi
call   1040 <ftruncate@plt>
mov    %ebp,%edi
call   1050 <close@plt>
mov    $0x1,%eax
jmp    118b <id3_strip_tag+0x4b>
lea    0xe7f(%rip),%rdi
mov    %rbx,%rsi
call   1030 <print_error@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@O_RDWR = global i32 0
@.str = [28 x i8] c"strip_tag: Error opening %s\00"
define i32 @id3_strip_tag(i64 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i32
store i64 %0, i64* %4
store i8* %1, i8** %5
%7 = load i8*, i8** %5
%8 = load i32, i32* @O_RDWR
%9 = call i32 @open(i8* %7, i32 %8)
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = load i8*, i8** %5
%14 = call i32 @print_error(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %13)
store i32 0, i32* %3
br label %21
15: ; preds = %2
%16 = load i32, i32* %6
%17 = load i64, i64* %4
%18 = call i32 @ftruncate(i32 %16, i64 %17)
%19 = load i32, i32* %6
%20 = call i32 @close(i32 %19)
store i32 1, i32* %3
br label %21
21: ; preds = %15, %12
%22 = load i32, i32* %3
ret i32 %22
}

LLVM IR (-O2):
@O_RDWR = global i32 0
@.str = [28 x i8] c"strip_tag: Error opening %s\00"
define i32 @id3_strip_tag(i64 %0, i8* %1) {
%3 = load i32, i32* @O_RDWR
%4 = tail call i32 @open(i8* %1, i32 %3)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @print_error(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %1)
br label %11
8: ; preds = %2
%9 = tail call i32 @ftruncate(i32 %4, i64 %0)
%10 = tail call i32 @close(i32 %4)
br label %11
11: ; preds = %8, %6
%12 = phi i32 [ 0, %6 ], [ 1, %8 ]
ret i32 %12
}