#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 */
scalar_t__ memory_allocation(int);
int /*<<< orphan*/ memset(char *, int, int);
int /*<<< orphan*/ snprintf(char *, int, char *, ...);
int strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, int);
char *GetId3v1(char *titre, char *artiste, char *radioName) {
  char *chunk;
  char *relativePointer;
  int padding = 0;
  chunk = (char *)memory_allocation(128);
  strncat(chunk, "TAG", 3);
  relativePointer = chunk + 3;
  if (titre) {
    padding = (30 - strlen(titre));
    if (padding < 0) {
      snprintf(relativePointer + 3, 31, "%s", titre);
    } else {
      snprintf(relativePointer, 128 - 3, "%s", titre);
      memset(relativePointer + (30 - padding), 0, padding);
    }
  } else {
    memset(relativePointer, 0, 30);
  }
  relativePointer = relativePointer + 30;
  if (artiste) {
    padding = (30 - strlen(artiste));
    if (padding < 0) {
      snprintf(relativePointer, 31, "%s", artiste);
    } else {
      snprintf(relativePointer, 128 - 33, "%s", artiste);
      memset(relativePointer + (30 - padding), 0, padding);
    }
  } else {
    memset(relativePointer, 0, 30);
  }
  relativePointer = relativePointer + 30;
  if (radioName != NULL) {
    padding = (30 - strlen(radioName));
    if (padding < 0) {
      snprintf(relativePointer, 31, "%s", radioName);
    } else {
      snprintf(relativePointer, 128 - 63, "%s", radioName);
      memset(relativePointer + (30 - padding), 0, padding);
    }
  } else {
    memset(relativePointer, 0, 30);
  }
  relativePointer = relativePointer + 30;
  memset(relativePointer, 0, 4);
  relativePointer = relativePointer + 4;
  snprintf(relativePointer, 31, "by cPige http://ed.zehome.com/");
  relativePointer = relativePointer + 30;
  memset(relativePointer, 1, 1);
  return chunk;
}


x86 assembly (clang, -O0):
<GetId3v1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    $0x80,%edi
call   1030 <memory_allocation@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe7c(%rip),%rsi
mov    $0x3,%edx
call   1070 <strncat@plt>
mov    -0x20(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1223 <GetId3v1+0xd3>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    $0x1e,%eax
sub    %ecx,%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    11e8 <GetId3v1+0x98>
mov    -0x28(%rbp),%rdi
add    $0x3,%rdi
mov    -0x8(%rbp),%rcx
mov    $0x1f,%esi
lea    0xe28(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
jmp    121e <GetId3v1+0xce>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x7d,%esi
lea    0xe08(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
mov    -0x28(%rbp),%rdi
mov    $0x1e,%eax
sub    -0x2c(%rbp),%eax
cltq
add    %rax,%rdi
mov    -0x2c(%rbp),%edx
xor    %esi,%esi
call   1060 <memset@plt>
jmp    1233 <GetId3v1+0xe3>
mov    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x1e,%edx
call   1060 <memset@plt>
mov    -0x28(%rbp),%rax
add    $0x1e,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     12c4 <GetId3v1+0x174>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    $0x1e,%eax
sub    %ecx,%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    1289 <GetId3v1+0x139>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1f,%esi
lea    0xd87(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
jmp    12bf <GetId3v1+0x16f>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x5f,%esi
lea    0xd67(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
mov    -0x28(%rbp),%rdi
mov    $0x1e,%eax
sub    -0x2c(%rbp),%eax
cltq
add    %rax,%rdi
mov    -0x2c(%rbp),%edx
xor    %esi,%esi
call   1060 <memset@plt>
jmp    12d4 <GetId3v1+0x184>
mov    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x1e,%edx
call   1060 <memset@plt>
mov    -0x28(%rbp),%rax
add    $0x1e,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1365 <GetId3v1+0x215>
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    $0x1e,%eax
sub    %ecx,%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    132a <GetId3v1+0x1da>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x1f,%esi
lea    0xce6(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
jmp    1360 <GetId3v1+0x210>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x41,%esi
lea    0xcc6(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
mov    -0x28(%rbp),%rdi
mov    $0x1e,%eax
sub    -0x2c(%rbp),%eax
cltq
add    %rax,%rdi
mov    -0x2c(%rbp),%edx
xor    %esi,%esi
call   1060 <memset@plt>
jmp    1375 <GetId3v1+0x225>
mov    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x1e,%edx
call   1060 <memset@plt>
mov    -0x28(%rbp),%rax
add    $0x1e,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1060 <memset@plt>
mov    -0x28(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    $0x1f,%esi
lea    0xc5a(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
mov    -0x28(%rbp),%rax
add    $0x1e,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1060 <memset@plt>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetId3v1>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    $0x80,%edi
call   1030 <memory_allocation@plt>
mov    %rax,%r12
lea    0xe88(%rip),%rsi
mov    %rax,%rdi
mov    $0x3,%edx
call   1070 <strncat@plt>
lea    0x3(%r12),%r13
test   %rbx,%rbx
je     11b9 <GetId3v1+0x69>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    $0x1f,%eax
jl     11c5 <GetId3v1+0x75>
lea    0x6(%r12),%rdi
lea    0xe5c(%rip),%rdx
mov    $0x1f,%esi
mov    %rbx,%rcx
xor    %eax,%eax
call   1050 <snprintf@plt>
jmp    1201 <GetId3v1+0xb1>
mov    %r13,%rdi
xor    %esi,%esi
mov    $0x1e,%edx
jmp    11fc <GetId3v1+0xac>
mov    %eax,%ebp
mov    %r14,(%rsp)
mov    $0x1e,%r14d
sub    %eax,%r14d
lea    0xe29(%rip),%rdx
mov    %r13,%rdi
mov    $0x7d,%esi
mov    %rbx,%rcx
xor    %eax,%eax
call   1050 <snprintf@plt>
movslq %ebp,%rdi
add    %r13,%rdi
xor    %esi,%esi
mov    %r14d,%edx
mov    (%rsp),%r14
call   1060 <memset@plt>
lea    0x21(%r12),%rbx
test   %r15,%r15
je     1233 <GetId3v1+0xe3>
mov    %r15,%rdi
call   1040 <strlen@plt>
cmp    $0x1f,%eax
jl     123f <GetId3v1+0xef>
lea    0xde5(%rip),%rdx
mov    %rbx,%rdi
mov    $0x1f,%esi
mov    %r15,%rcx
xor    %eax,%eax
call   1050 <snprintf@plt>
jmp    1279 <GetId3v1+0x129>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1e,%edx
jmp    1274 <GetId3v1+0x124>
mov    %eax,%ebp
mov    %r14,%r13
mov    $0x1e,%r14d
sub    %eax,%r14d
lea    0xdb0(%rip),%rdx
mov    %rbx,%rdi
mov    $0x5f,%esi
mov    %r15,%rcx
xor    %eax,%eax
call   1050 <snprintf@plt>
movslq %ebp,%rdi
add    %rbx,%rdi
xor    %esi,%esi
mov    %r14d,%edx
mov    %r13,%r14
call   1060 <memset@plt>
lea    0x3f(%r12),%rbx
test   %r14,%r14
je     12ab <GetId3v1+0x15b>
mov    %r14,%rdi
call   1040 <strlen@plt>
cmp    $0x1f,%eax
jl     12b7 <GetId3v1+0x167>
lea    0xd6d(%rip),%rdx
mov    %rbx,%rdi
mov    $0x1f,%esi
mov    %r14,%rcx
xor    %eax,%eax
call   1050 <snprintf@plt>
jmp    12eb <GetId3v1+0x19b>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1e,%edx
jmp    12e6 <GetId3v1+0x196>
mov    %eax,%ebp
mov    %r14,%rcx
mov    $0x1e,%r14d
sub    %eax,%r14d
lea    0xd38(%rip),%rdx
mov    %rbx,%rdi
mov    $0x41,%esi
xor    %eax,%eax
call   1050 <snprintf@plt>
movslq %ebp,%rdi
add    %rbx,%rdi
xor    %esi,%esi
mov    %r14d,%edx
call   1060 <memset@plt>
lea    0x5d(%r12),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1060 <memset@plt>
lea    0x61(%r12),%rdi
lea    0xcff(%rip),%rdx
mov    $0x1f,%esi
xor    %eax,%eax
call   1050 <snprintf@plt>
mov    %r12,%rdi
add    $0x7f,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
call   1060 <memset@plt>
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"TAG\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [31 x i8] c"by cPige http://ed.zehome.com/\00"
define i8* @GetId3v1(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i32 0, i32* %9
%10 = call i64 @memory_allocation(i32 128)
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %7
%12 = load i8*, i8** %7
%13 = call i32 @strncat(i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%14 = load i8*, i8** %7
%15 = getelementptr inbounds i8, i8* %14, i64 3
store i8* %15, i8** %8
%16 = load i8*, i8** %4
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %41
18: ; preds = %3
%19 = load i8*, i8** %4
%20 = call i32 @strlen(i8* %19)
%21 = sub nsw i32 30, %20
store i32 %21, i32* %9
%22 = load i32, i32* %9
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %29
24: ; preds = %18
%25 = load i8*, i8** %8
%26 = getelementptr inbounds i8, i8* %25, i64 3
%27 = load i8*, i8** %4
%28 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %26, i32 31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %27)
br label %40
29: ; preds = %18
%30 = load i8*, i8** %8
%31 = load i8*, i8** %4
%32 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %30, i32 125, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %31)
%33 = load i8*, i8** %8
%34 = load i32, i32* %9
%35 = sub nsw i32 30, %34
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %33, i64 %36
%38 = load i32, i32* %9
%39 = call i32 @memset(i8* %37, i32 0, i32 %38)
br label %40
40: ; preds = %29, %24
br label %44
41: ; preds = %3
%42 = load i8*, i8** %8
%43 = call i32 @memset(i8* %42, i32 0, i32 30)
br label %44
44: ; preds = %41, %40
%45 = load i8*, i8** %8
%46 = getelementptr inbounds i8, i8* %45, i64 30
store i8* %46, i8** %8
%47 = load i8*, i8** %5
%48 = icmp ne i8* %47, null
br i1 %48, label %49, label %71
49: ; preds = %44
%50 = load i8*, i8** %5
%51 = call i32 @strlen(i8* %50)
%52 = sub nsw i32 30, %51
store i32 %52, i32* %9
%53 = load i32, i32* %9
%54 = icmp slt i32 %53, 0
br i1 %54, label %55, label %59
55: ; preds = %49
%56 = load i8*, i8** %8
%57 = load i8*, i8** %5
%58 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %56, i32 31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %57)
br label %70
59: ; preds = %49
%60 = load i8*, i8** %8
%61 = load i8*, i8** %5
%62 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %60, i32 95, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %61)
%63 = load i8*, i8** %8
%64 = load i32, i32* %9
%65 = sub nsw i32 30, %64
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i8, i8* %63, i64 %66
%68 = load i32, i32* %9
%69 = call i32 @memset(i8* %67, i32 0, i32 %68)
br label %70
70: ; preds = %59, %55
br label %74
71: ; preds = %44
%72 = load i8*, i8** %8
%73 = call i32 @memset(i8* %72, i32 0, i32 30)
br label %74
74: ; preds = %71, %70
%75 = load i8*, i8** %8
%76 = getelementptr inbounds i8, i8* %75, i64 30
store i8* %76, i8** %8
%77 = load i8*, i8** %6
%78 = icmp ne i8* %77, null
br i1 %78, label %79, label %101
79: ; preds = %74
%80 = load i8*, i8** %6
%81 = call i32 @strlen(i8* %80)
%82 = sub nsw i32 30, %81
store i32 %82, i32* %9
%83 = load i32, i32* %9
%84 = icmp slt i32 %83, 0
br i1 %84, label %85, label %89
85: ; preds = %79
%86 = load i8*, i8** %8
%87 = load i8*, i8** %6
%88 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %86, i32 31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %87)
br label %100
89: ; preds = %79
%90 = load i8*, i8** %8
%91 = load i8*, i8** %6
%92 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %90, i32 65, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %91)
%93 = load i8*, i8** %8
%94 = load i32, i32* %9
%95 = sub nsw i32 30, %94
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds i8, i8* %93, i64 %96
%98 = load i32, i32* %9
%99 = call i32 @memset(i8* %97, i32 0, i32 %98)
br label %100
100: ; preds = %89, %85
br label %104
101: ; preds = %74
%102 = load i8*, i8** %8
%103 = call i32 @memset(i8* %102, i32 0, i32 30)
br label %104
104: ; preds = %101, %100
%105 = load i8*, i8** %8
%106 = getelementptr inbounds i8, i8* %105, i64 30
store i8* %106, i8** %8
%107 = load i8*, i8** %8
%108 = call i32 @memset(i8* %107, i32 0, i32 4)
%109 = load i8*, i8** %8
%110 = getelementptr inbounds i8, i8* %109, i64 4
store i8* %110, i8** %8
%111 = load i8*, i8** %8
%112 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %111, i32 31, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%113 = load i8*, i8** %8
%114 = getelementptr inbounds i8, i8* %113, i64 30
store i8* %114, i8** %8
%115 = load i8*, i8** %8
%116 = call i32 @memset(i8* %115, i32 1, i32 1)
%117 = load i8*, i8** %7
ret i8* %117
}

LLVM IR (-O2):
@.str = [4 x i8] c"TAG\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [31 x i8] c"by cPige http://ed.zehome.com/\00"
define i8* @GetId3v1(i8* %0, i8* %1, i8* %2) {
%4 = tail call i64 @memory_allocation(i32 128)
%5 = inttoptr i64 %4 to i8*
%6 = tail call i32 @strncat(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%7 = getelementptr inbounds i8, i8* %5, i64 3
%8 = icmp eq i8* %0, null
br i1 %8, label %21, label %9
9: ; preds = %3
%10 = tail call i32 @strlen(i8* %0)
%11 = icmp sgt i32 %10, 30
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = getelementptr inbounds i8, i8* %5, i64 6
%14 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %13, i32 31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %23
15: ; preds = %9
%16 = sub nsw i32 30, %10
%17 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %7, i32 125, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%18 = sext i32 %10 to i64
%19 = getelementptr inbounds i8, i8* %7, i64 %18
%20 = tail call i32 @memset(i8* %19, i32 0, i32 %16)
br label %23
21: ; preds = %3
%22 = tail call i32 @memset(i8* %7, i32 0, i32 30)
br label %23
23: ; preds = %12, %15, %21
%24 = getelementptr inbounds i8, i8* %5, i64 33
%25 = icmp eq i8* %1, null
br i1 %25, label %37, label %26
26: ; preds = %23
%27 = tail call i32 @strlen(i8* %1)
%28 = icmp sgt i32 %27, 30
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %24, i32 31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
br label %39
31: ; preds = %26
%32 = sub nsw i32 30, %27
%33 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %24, i32 95, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%34 = sext i32 %27 to i64
%35 = getelementptr inbounds i8, i8* %24, i64 %34
%36 = tail call i32 @memset(i8* %35, i32 0, i32 %32)
br label %39
37: ; preds = %23
%38 = tail call i32 @memset(i8* %24, i32 0, i32 30)
br label %39
39: ; preds = %29, %31, %37
%40 = getelementptr inbounds i8, i8* %5, i64 63
%41 = icmp eq i8* %2, null
br i1 %41, label %53, label %42
42: ; preds = %39
%43 = tail call i32 @strlen(i8* %2)
%44 = icmp sgt i32 %43, 30
br i1 %44, label %45, label %47
45: ; preds = %42
%46 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %40, i32 31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
br label %55
47: ; preds = %42
%48 = sub nsw i32 30, %43
%49 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %40, i32 65, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%50 = sext i32 %43 to i64
%51 = getelementptr inbounds i8, i8* %40, i64 %50
%52 = tail call i32 @memset(i8* %51, i32 0, i32 %48)
br label %55
53: ; preds = %39
%54 = tail call i32 @memset(i8* %40, i32 0, i32 30)
br label %55
55: ; preds = %45, %47, %53
%56 = getelementptr inbounds i8, i8* %5, i64 93
%57 = tail call i32 @memset(i8* %56, i32 0, i32 4)
%58 = getelementptr inbounds i8, i8* %5, i64 97
%59 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %58, i32 31, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%60 = getelementptr inbounds i8, i8* %5, i64 127
%61 = tail call i32 @memset(i8* %60, i32 1, i32 1)
ret i8* %5
}