#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 errno;
int /*<<< orphan*/ printf(char *, int);
int sprintf(char *, char *, char *, int, int, int, int);
int write(int, char *, int);
void output_link(int f, char *target, int location) {
  static int index = 1024;
  char image[272];
  int bytes, written;
  index--;
  bytes = sprintf(image,
                  "\n-%s:[%4.4X]\n"
                  "$21:%6.6X\n"
                  "[%4.4X]06-:000000 "
                  "[%4.4X:000000000000/*06]30:000000000000\n",
                  target, index, location + 1, index, index);
  written = write(f, image, bytes);
  if (written < 0)
    printf("label write error %d\n", errno);
}


x86 assembly (clang, -O0):
<output_link>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    0x2eed(%rip),%eax
add    $0xffffffff,%eax
mov    %eax,0x2ee4(%rip)
lea    -0x130(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    0x2ed3(%rip),%ecx
mov    -0x14(%rbp),%r8d
add    $0x1,%r8d
mov    0x2ec4(%rip),%r9d
mov    0x2ebe(%rip),%eax
lea    0xe7f(%rip),%rsi
mov    %eax,(%rsp)
call   1050 <sprintf@plt>
mov    %eax,-0x134(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x130(%rbp),%rsi
mov    -0x134(%rbp),%edx
call   1030 <write@plt>
mov    %eax,-0x138(%rbp)
cmpl   $0x0,-0x138(%rbp)
jge    11cc <output_link+0x9c>
mov    0x2e22(%rip),%rax
mov    (%rax),%esi
lea    0xe8b(%rip),%rdi
call   1040 <printf@plt>
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_link>:
push   %r14
push   %rbx
sub    $0x128,%rsp
mov    %rsi,%rax
mov    %edi,%ebx
mov    0x2ef3(%rip),%ecx
add    $0xffffffff,%ecx
mov    %ecx,0x2eea(%rip)
lea    0x1(%rdx),%r8d
mov    %ecx,(%rsp)
lea    0xea4(%rip),%rsi
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    %rax,%rdx
mov    %ecx,%r9d
call   1050 <sprintf@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write@plt>
test   %eax,%eax
js     118a <output_link+0x5a>
add    $0x128,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e4f(%rip),%rax
mov    (%rax),%esi
lea    0xeb8(%rip),%rdi
add    $0x128,%rsp
pop    %rbx
pop    %r14
jmp    1040 <printf@plt>

LLVM IR (-O0):
@output_link.index = internal global i32 1024
@.str = [82 x i8] c"\0A-%s:[%4.4X]\0A$21:%6.6X\0A[%4.4X]06-:000000 [%4.4X:000000000000/*06]30:000000000000\0A\00"
@.str.1 = [22 x i8] c"label write error %d\0A\00"
@errno = global i32 0
define void @output_link(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca [272 x i8]
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%10 = load i32, i32* @output_link.index
%11 = add nsw i32 %10, -1
store i32 %11, i32* @output_link.index
%12 = getelementptr inbounds [272 x i8], [272 x i8]* %7, i64 0, i64 0
%13 = load i8*, i8** %5
%14 = load i32, i32* @output_link.index
%15 = load i32, i32* %6
%16 = add nsw i32 %15, 1
%17 = load i32, i32* @output_link.index
%18 = load i32, i32* @output_link.index
%19 = call i32 @sprintf(i8* %12, i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str, i64 0, i64 0), i8* %13, i32 %14, i32 %16, i32 %17, i32 %18)
store i32 %19, i32* %8
%20 = load i32, i32* %4
%21 = getelementptr inbounds [272 x i8], [272 x i8]* %7, i64 0, i64 0
%22 = load i32, i32* %8
%23 = call i32 @write(i32 %20, i8* %21, i32 %22)
store i32 %23, i32* %9
%24 = load i32, i32* %9
%25 = icmp slt i32 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %3
%27 = load i32, i32* @errno
%28 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %26, %3
ret void
}

LLVM IR (-O2):
@output_link.index = internal unnamed_addr global i32 1024
@.str = [82 x i8] c"\0A-%s:[%4.4X]\0A$21:%6.6X\0A[%4.4X]06-:000000 [%4.4X:000000000000/*06]30:000000000000\0A\00"
@.str.1 = [22 x i8] c"label write error %d\0A\00"
@errno = global i32 0
define void @output_link(i32 %0, i8* %1, i32 %2) {
%4 = alloca [272 x i8]
%5 = getelementptr inbounds [272 x i8], [272 x i8]* %4, i64 0, i64 0
%6 = load i32, i32* @output_link.index
%7 = add nsw i32 %6, -1
store i32 %7, i32* @output_link.index
%8 = add nsw i32 %2, 1
%9 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([82 x i8], [82 x i8]* @.str, i64 0, i64 0), i8* %1, i32 %7, i32 %8, i32 %7, i32 %7)
%10 = call i32 @write(i32 %0, i8* %5, i32 %9)
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %3
%13 = load i32, i32* @errno
%14 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %13)
br label %15
15: ; preds = %12, %3
ret void
}