#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*/ line_buffer;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ memcpy(char *, char *, int);
int snprintf(char *, int, char *, int, int);
int /*<<< orphan*/ stderr;
void build_content(char *p, int n) {
  char line_buffer[80];
  int k;
  int i = 0;
  while (n > 0) {
    k = snprintf(
        line_buffer, sizeof(line_buffer),
        "%04d_ABCDEFGHIJKL_This_line_is_64_bytes_long_ABCDEFGHIJKL_%04d\r\n", i,
        i);
    if (k != 64) {
      fprintf(stderr, "snprintf() returned %d in build_content()\n", k);
    }
    ++i;
    if (n >= 64) {
      memcpy(p, line_buffer, 64);
      p += 64;
      n -= 64;
    } else {
      memcpy(p, line_buffer, n);
      p += n;
      n = 0;
    }
  }
}


x86 assembly (clang, -O0):
<build_content>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x68(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    11fd <build_content+0xcd>
lea    -0x60(%rbp),%rdi
mov    -0x68(%rbp),%ecx
mov    -0x68(%rbp),%r8d
mov    $0x50,%esi
lea    0xe99(%rip),%rdx
call   1030 <snprintf@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0x40,-0x64(%rbp)
je     1191 <build_content+0x61>
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
mov    -0x64(%rbp),%edx
lea    0xeb5(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
cmpl   $0x40,-0xc(%rbp)
jl     11d0 <build_content+0xa0>
mov    -0x8(%rbp),%rdi
lea    -0x60(%rbp),%rsi
mov    $0x40,%edx
call   1050 <memcpy@plt>
mov    -0x8(%rbp),%rax
add    $0x40,%rax
mov    %rax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x40,%eax
mov    %eax,-0xc(%rbp)
jmp    11f8 <build_content+0xc8>
mov    -0x8(%rbp),%rdi
lea    -0x60(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1050 <memcpy@plt>
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
jmp    1146 <build_content+0x16>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<build_content>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
test   %esi,%esi
jle    11c7 <build_content+0x97>
mov    %esi,%r14d
mov    %rdi,%rbx
xor    %ebp,%ebp
lea    0xeab(%rip),%r15
mov    %rsp,%r12
lea    0xee2(%rip),%r13
nop
mov    %r12,%rdi
mov    $0x50,%esi
mov    %r15,%rdx
mov    %ebp,%ecx
mov    %ebp,%r8d
call   1030 <snprintf@plt>
cmp    $0x40,%eax
je     118d <build_content+0x5d>
mov    0x2e5f(%rip),%rcx
mov    (%rcx),%edi
mov    %r13,%rsi
mov    %eax,%edx
call   1040 <fprintf@plt>
cmp    $0x3f,%r14d
jbe    11b9 <build_content+0x89>
add    $0x1,%ebp
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x40,%edx
call   1050 <memcpy@plt>
add    $0x40,%rbx
lea    -0x40(%r14),%eax
cmp    $0x40,%r14d
mov    %eax,%r14d
jg     1160 <build_content+0x30>
jmp    11c7 <build_content+0x97>
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    %r14d,%edx
call   1050 <memcpy@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [65 x i8] c"%04d_ABCDEFGHIJKL_This_line_is_64_bytes_long_ABCDEFGHIJKL_%04d\0D\0A\00"
@stderr = global i32 0
@.str.1 = [43 x i8] c"snprintf() returned %d in build_content()\0A\00"
define void @build_content(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [80 x i8]
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %7
br label %8
8: ; preds = %44, %2
%9 = load i32, i32* %4
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %45
11: ; preds = %8
%12 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%13 = load i32, i32* %7
%14 = load i32, i32* %7
%15 = call i32 @snprintf(i8* %12, i32 80, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %14)
store i32 %15, i32* %6
%16 = load i32, i32* %6
%17 = icmp ne i32 %16, 64
br i1 %17, label %18, label %22
18: ; preds = %11
%19 = load i32, i32* @stderr
%20 = load i32, i32* %6
%21 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %18, %11
%23 = load i32, i32* %7
%24 = add nsw i32 %23, 1
store i32 %24, i32* %7
%25 = load i32, i32* %4
%26 = icmp sge i32 %25, 64
br i1 %26, label %27, label %35
27: ; preds = %22
%28 = load i8*, i8** %3
%29 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%30 = call i32 @memcpy(i8* %28, i8* %29, i32 64)
%31 = load i8*, i8** %3
%32 = getelementptr inbounds i8, i8* %31, i64 64
store i8* %32, i8** %3
%33 = load i32, i32* %4
%34 = sub nsw i32 %33, 64
store i32 %34, i32* %4
br label %44
35: ; preds = %22
%36 = load i8*, i8** %3
%37 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%38 = load i32, i32* %4
%39 = call i32 @memcpy(i8* %36, i8* %37, i32 %38)
%40 = load i32, i32* %4
%41 = load i8*, i8** %3
%42 = sext i32 %40 to i64
%43 = getelementptr inbounds i8, i8* %41, i64 %42
store i8* %43, i8** %3
store i32 0, i32* %4
br label %44
44: ; preds = %35, %27
br label %8
45: ; preds = %8
ret void
}

LLVM IR (-O2):
@.str = [65 x i8] c"%04d_ABCDEFGHIJKL_This_line_is_64_bytes_long_ABCDEFGHIJKL_%04d\0D\0A\00"
@stderr = global i32 0
@.str.1 = [43 x i8] c"snprintf() returned %d in build_content()\0A\00"
define void @build_content(i8* %0, i32 %1) {
%3 = alloca [80 x i8]
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %25
6: ; preds = %2, %19
%7 = phi i32 [ %20, %19 ], [ 0, %2 ]
%8 = phi i8* [ %22, %19 ], [ %0, %2 ]
%9 = phi i32 [ %23, %19 ], [ %1, %2 ]
%10 = call i32 @snprintf(i8* %4, i32 80, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %7)
%11 = icmp eq i32 %10, 64
br i1 %11, label %15, label %12
12: ; preds = %6
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i32 %10)
br label %15
15: ; preds = %12, %6
%16 = icmp ugt i32 %9, 63
br i1 %16, label %19, label %17
17: ; preds = %15
%18 = call i32 @memcpy(i8* %8, i8* %4, i32 %9)
br label %25
19: ; preds = %15
%20 = add nuw nsw i32 %7, 1
%21 = call i32 @memcpy(i8* %8, i8* %4, i32 64)
%22 = getelementptr inbounds i8, i8* %8, i64 64
%23 = add nsw i32 %9, -64
%24 = icmp sgt i32 %9, 64
br i1 %24, label %6, label %25
25: ; preds = %19, %17, %2
ret void
}