#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*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ sprintf(char *, char *, unsigned long long);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ tar_fill_ustar_magic(char *);
int tar_fill_longlink_header(char b[512], int link_length, char ext) {
  memset(b, 0, 512);
  strcpy(b, "././@LongLink");
  sprintf(b + 100, "%07o", 0);
  sprintf(b + 108, "%07o", 0);
  sprintf(b + 116, "%07o", 0);
  sprintf(b + 124, "%011o", link_length + 1);
  sprintf(b + 136, "%011llo", (unsigned long long)0);
  tar_fill_ustar_magic(b);
  b[156] = ext;
  return 0;
}


x86 assembly (clang, -O0):
<tar_fill_longlink_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dl,%al
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %al,-0xd(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1040 <memset@plt>
mov    -0x8(%rbp),%rdi
lea    0xe91(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
add    $0x64,%rdi
lea    0xe8b(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1060 <sprintf@plt>
mov    -0x8(%rbp),%rdi
add    $0x6c,%rdi
lea    0xe73(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1060 <sprintf@plt>
mov    -0x8(%rbp),%rdi
add    $0x74,%rdi
lea    0xe5b(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1060 <sprintf@plt>
mov    -0x8(%rbp),%rdi
add    $0x7c,%rdi
mov    -0xc(%rbp),%eax
add    $0x1,%eax
movslq %eax,%rdx
lea    0xe3f(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x8(%rbp),%rdi
add    $0x88,%rdi
lea    0xe2e(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1060 <sprintf@plt>
mov    -0x8(%rbp),%rdi
call   1050 <tar_fill_ustar_magic@plt>
mov    -0xd(%rbp),%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x9c(%rax)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tar_fill_longlink_header>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%rbx
xor    %esi,%esi
mov    $0x200,%edx
call   1040 <memset@plt>
lea    0xe9e(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0x64(%rbx),%rdi
lea    0xe99(%rip),%r15
mov    %r15,%rsi
xor    %edx,%edx
call   1060 <sprintf@plt>
lea    0x6c(%rbx),%rdi
mov    %r15,%rsi
xor    %edx,%edx
call   1060 <sprintf@plt>
lea    0x74(%rbx),%rdi
mov    %r15,%rsi
xor    %edx,%edx
call   1060 <sprintf@plt>
lea    0x7c(%rbx),%rdi
add    $0x1,%ebp
movslq %ebp,%rdx
lea    0xe67(%rip),%rsi
call   1060 <sprintf@plt>
lea    0x88(%rbx),%rdi
lea    0xe5a(%rip),%rsi
xor    %edx,%edx
call   1060 <sprintf@plt>
mov    %rbx,%rdi
call   1050 <tar_fill_ustar_magic@plt>
mov    %r14b,0x9c(%rbx)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"././@LongLink\00"
@.str.1 = [5 x i8] c"%07o\00"
@.str.2 = [6 x i8] c"%011o\00"
@.str.3 = [8 x i8] c"%011llo\00"
define i32 @tar_fill_longlink_header(i8* %0, i32 %1, i8 signext %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8
store i8* %0, i8** %4
store i32 %1, i32* %5
store i8 %2, i8* %6
%7 = load i8*, i8** %4
%8 = call i32 @memset(i8* %7, i32 0, i32 512)
%9 = load i8*, i8** %4
%10 = call i32 @strcpy(i8* %9, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%11 = load i8*, i8** %4
%12 = getelementptr inbounds i8, i8* %11, i64 100
%13 = call i32 @sprintf(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 0)
%14 = load i8*, i8** %4
%15 = getelementptr inbounds i8, i8* %14, i64 108
%16 = call i32 @sprintf(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 0)
%17 = load i8*, i8** %4
%18 = getelementptr inbounds i8, i8* %17, i64 116
%19 = call i32 @sprintf(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 0)
%20 = load i8*, i8** %4
%21 = getelementptr inbounds i8, i8* %20, i64 124
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 1
%24 = sext i32 %23 to i64
%25 = call i32 @sprintf(i8* %21, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 %24)
%26 = load i8*, i8** %4
%27 = getelementptr inbounds i8, i8* %26, i64 136
%28 = call i32 @sprintf(i8* %27, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i64 0)
%29 = load i8*, i8** %4
%30 = call i32 @tar_fill_ustar_magic(i8* %29)
%31 = load i8, i8* %6
%32 = load i8*, i8** %4
%33 = getelementptr inbounds i8, i8* %32, i64 156
store i8 %31, i8* %33
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"././@LongLink\00"
@.str.1 = [5 x i8] c"%07o\00"
@.str.2 = [6 x i8] c"%011o\00"
@.str.3 = [8 x i8] c"%011llo\00"
define i32 @tar_fill_longlink_header(i8* %0, i32 %1, i8 signext %2) {
%4 = tail call i32 @memset(i8* %0, i32 0, i32 512)
%5 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds i8, i8* %0, i64 100
%7 = tail call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 0)
%8 = getelementptr inbounds i8, i8* %0, i64 108
%9 = tail call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 0)
%10 = getelementptr inbounds i8, i8* %0, i64 116
%11 = tail call i32 @sprintf(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 0)
%12 = getelementptr inbounds i8, i8* %0, i64 124
%13 = add nsw i32 %1, 1
%14 = sext i32 %13 to i64
%15 = tail call i32 @sprintf(i8* %12, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 %14)
%16 = getelementptr inbounds i8, i8* %0, i64 136
%17 = tail call i32 @sprintf(i8* %16, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i64 0)
%18 = tail call i32 @tar_fill_ustar_magic(i8* %0)
%19 = getelementptr inbounds i8, i8* %0, i64 156
store i8 %2, i8* %19
ret i32 0
}