#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*/ EXIT_SUCCESS;
int asprintf(char **, char *, char *, ...);
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
scalar_t__ strcmp(char *, char *);
int main(void) {
  int result;
  char *s;
  result = asprintf(&s, "%s %d %c", "abc", 123, 'x');
  assert(result == 9);
  assert(strcmp("abc 123 x", s) == 0);
  free(s);
  char *long_string = "abcdefghijklmnopqrstuvwxyz";
  result = asprintf(&s, "%s %s %s %s", long_string, long_string, long_string,
                    long_string);
  assert(result == 107);
  assert(strcmp("abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz "
                "abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz",
                s) == 0);
  free(s);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x10(%rbp),%rdi
lea    0xe96(%rip),%rsi
lea    0xe98(%rip),%rdx
mov    $0x7b,%ecx
mov    $0x78,%r8d
mov    $0x0,%al
call   1060 <asprintf@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x9,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x10(%rbp),%rsi
lea    0xe6b(%rip),%rdi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
lea    0xeac(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    -0x18(%rbp),%r9
lea    -0x10(%rbp),%rdi
lea    0xe30(%rip),%rsi
mov    $0x0,%al
call   1060 <asprintf@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x6b,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x10(%rbp),%rsi
lea    0xe16(%rip),%rdi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    0x2dad(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xea4(%rip),%rsi
lea    0xea6(%rip),%rdx
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x7b,%ecx
mov    $0x78,%r8d
xor    %eax,%eax
call   1060 <asprintf@plt>
xor    %edi,%edi
cmp    $0x9,%eax
sete   %dil
call   1050 <assert@plt>
mov    0x8(%rsp),%rsi
lea    0xe76(%rip),%rdi
call   1040 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1050 <assert@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
lea    0xe5c(%rip),%rsi
lea    0xeb2(%rip),%rcx
mov    %rbx,%rdi
mov    %rcx,%rdx
mov    %rcx,%r8
mov    %rcx,%r9
xor    %eax,%eax
call   1060 <asprintf@plt>
xor    %edi,%edi
cmp    $0x6b,%eax
sete   %dil
call   1050 <assert@plt>
mov    0x8(%rsp),%rsi
lea    0xe34(%rip),%rdi
call   1040 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1050 <assert@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    0x2dcd(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"%s %d %c\00"
@.str.1 = [4 x i8] c"abc\00"
@.str.2 = [10 x i8] c"abc 123 x\00"
@.str.3 = [27 x i8] c"abcdefghijklmnopqrstuvwxyz\00"
@.str.4 = [12 x i8] c"%s %s %s %s\00"
@.str.5 = [108 x i8] c"abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
store i32 0, i32* %1
%5 = call i32 (i8**, i8*, i8*, ...) @asprintf(i8** %3, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 123, i32 120)
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = icmp eq i32 %6, 9
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
%10 = load i8*, i8** %3
%11 = call i64 @strcmp(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%12 = icmp eq i64 %11, 0
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = load i8*, i8** %3
%16 = call i32 @free(i8* %15)
store i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8** %4
%17 = load i8*, i8** %4
%18 = load i8*, i8** %4
%19 = load i8*, i8** %4
%20 = load i8*, i8** %4
%21 = call i32 (i8**, i8*, i8*, ...) @asprintf(i8** %3, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* %17, i8* %18, i8* %19, i8* %20)
store i32 %21, i32* %2
%22 = load i32, i32* %2
%23 = icmp eq i32 %22, 107
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
%26 = load i8*, i8** %3
%27 = call i64 @strcmp(i8* getelementptr inbounds ([108 x i8], [108 x i8]* @.str.5, i64 0, i64 0), i8* %26)
%28 = icmp eq i64 %27, 0
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
%31 = load i8*, i8** %3
%32 = call i32 @free(i8* %31)
%33 = load i32, i32* @EXIT_SUCCESS
%34 = call i32 @exit(i32 %33)
unreachable
}

LLVM IR (-O2):
@.str = [9 x i8] c"%s %d %c\00"
@.str.1 = [4 x i8] c"abc\00"
@.str.2 = [10 x i8] c"abc 123 x\00"
@.str.3 = [27 x i8] c"abcdefghijklmnopqrstuvwxyz\00"
@.str.4 = [12 x i8] c"%s %s %s %s\00"
@.str.5 = [108 x i8] c"abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i8*
%2 = bitcast i8** %1 to i8*
%3 = call i32 (i8**, i8*, i8*, ...) @asprintf(i8** %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 123, i32 120)
%4 = icmp eq i32 %3, 9
%5 = zext i1 %4 to i32
%6 = call i32 @assert(i32 %5)
%7 = load i8*, i8** %1
%8 = call i64 @strcmp(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%9 = icmp eq i64 %8, 0
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = load i8*, i8** %1
%13 = call i32 @free(i8* %12)
%14 = call i32 (i8**, i8*, i8*, ...) @asprintf(i8** %1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%15 = icmp eq i32 %14, 107
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = load i8*, i8** %1
%19 = call i64 @strcmp(i8* getelementptr inbounds ([108 x i8], [108 x i8]* @.str.5, i64 0, i64 0), i8* %18)
%20 = icmp eq i64 %19, 0
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = load i8*, i8** %1
%24 = call i32 @free(i8* %23)
%25 = load i32, i32* @EXIT_SUCCESS
%26 = call i32 @exit(i32 %25)
unreachable
}