#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*/ free(char *);
char *malloc(int);
int numlength(long);
int sprintf(char *, char *, int);
char *content_length_line(long number) {
  char *content_length;
  content_length = malloc((18 + numlength(number)) * sizeof(char));
  if (sprintf(content_length, "Content-Length:%d\n", (int)number) == -1) {
    free(content_length);
    return NULL;
  }
  return content_length;
}


x86 assembly (clang, -O0):
<content_length_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <numlength@plt>
add    $0x12,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    %eax,%edx
lea    0xe86(%rip),%rsi
call   1060 <sprintf@plt>
cmp    $0xffffffff,%eax
jne    119e <content_length_line+0x5e>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    11a6 <content_length_line+0x66>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<content_length_line>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1040 <numlength@plt>
lea    0x12(%rax),%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
lea    0xea2(%rip),%rsi
mov    %rax,%rdi
mov    %r14d,%edx
call   1060 <sprintf@plt>
cmp    $0xffffffff,%eax
jne    1178 <content_length_line+0x38>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Content-Length:%d\0A\00"
define i8* @content_length_line(i64 %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i8*
store i64 %0, i64* %3
%5 = load i64, i64* %3
%6 = call i32 @numlength(i64 %5)
%7 = add nsw i32 18, %6
%8 = sext i32 %7 to i64
%9 = mul i64 %8, 1
%10 = trunc i64 %9 to i32
%11 = call i8* @malloc(i32 %10)
store i8* %11, i8** %4
%12 = load i8*, i8** %4
%13 = load i64, i64* %3
%14 = trunc i64 %13 to i32
%15 = call i32 @sprintf(i8* %12, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %20
17: ; preds = %1
%18 = load i8*, i8** %4
%19 = call i32 @free(i8* %18)
store i8* null, i8** %2
br label %22
20: ; preds = %1
%21 = load i8*, i8** %4
store i8* %21, i8** %2
br label %22
22: ; preds = %20, %17
%23 = load i8*, i8** %2
ret i8* %23
}

LLVM IR (-O2):
@.str = [19 x i8] c"Content-Length:%d\0A\00"
define noalias i8* @content_length_line(i64 %0) {
%2 = tail call i32 @numlength(i64 %0)
%3 = add nsw i32 %2, 18
%4 = tail call i8* @malloc(i32 %3)
%5 = trunc i64 %0 to i32
%6 = tail call i32 @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = tail call i32 @free(i8* %4)
br label %10
10: ; preds = %1, %8
%11 = phi i8* [ null, %8 ], [ %4, %1 ]
ret i8* %11
}