#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*/ asprintf(char **, char *, ...);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, char *argv[]) {
  char *s;
  asprintf(&s, "Hello, %s.", "-Reader-");
  printf("%s\n", s);
  free(s);
  asprintf(&s, "%c", '\0');
  printf("blank string: [%s]\n", s);
  free(s);
  int i = 0;
  asprintf(&s, "%i", i++);
  printf("Zero: %s\n", s);
  free(s);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
lea    0xeb6(%rip),%rsi
lea    0xeba(%rip),%rdx
mov    $0x0,%al
call   1050 <asprintf@plt>
mov    -0x18(%rbp),%rsi
lea    0xed1(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
lea    -0x18(%rbp),%rdi
lea    0xe98(%rip),%rsi
xor    %edx,%edx
mov    $0x0,%al
call   1050 <asprintf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe87(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%edx
mov    %edx,%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
lea    -0x18(%rbp),%rdi
lea    0xe70(%rip),%rsi
mov    $0x0,%al
call   1050 <asprintf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe61(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xec4(%rip),%rsi
lea    0xec8(%rip),%rdx
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <asprintf@plt>
mov    0x8(%rsp),%rsi
lea    0xed6(%rip),%rdi
call   1040 <printf@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
lea    0xea0(%rip),%rsi
mov    %rbx,%rdi
xor    %edx,%edx
xor    %eax,%eax
call   1050 <asprintf@plt>
mov    0x8(%rsp),%rsi
lea    0xe8b(%rip),%rdi
call   1040 <printf@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
lea    0xe89(%rip),%rsi
mov    %rbx,%rdi
xor    %edx,%edx
xor    %eax,%eax
call   1050 <asprintf@plt>
mov    0x8(%rsp),%rsi
lea    0xe74(%rip),%rdi
call   1040 <printf@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [11 x i8] c"Hello, %s.\00"
@.str.1 = [9 x i8] c"-Reader-\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [3 x i8] c"%c\00"
@.str.4 = [20 x i8] c"blank string: [%s]\0A\00"
@.str.5 = [3 x i8] c"%i\00"
@.str.6 = [10 x i8] c"Zero: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%7 = call i32 (i8**, i8*, ...) @asprintf(i8** %5, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%8 = load i8*, i8** %5
%9 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%10 = load i8*, i8** %5
%11 = call i32 @free(i8* %10)
%12 = call i32 (i8**, i8*, ...) @asprintf(i8** %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 0)
%13 = load i8*, i8** %5
%14 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %13)
%15 = load i8*, i8** %5
%16 = call i32 @free(i8* %15)
store i32 0, i32* %6
%17 = load i32, i32* %6
%18 = add nsw i32 %17, 1
store i32 %18, i32* %6
%19 = call i32 (i8**, i8*, ...) @asprintf(i8** %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %17)
%20 = load i8*, i8** %5
%21 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* %20)
%22 = load i8*, i8** %5
%23 = call i32 @free(i8* %22)
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"Hello, %s.\00"
@.str.1 = [9 x i8] c"-Reader-\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [3 x i8] c"%c\00"
@.str.4 = [20 x i8] c"blank string: [%s]\0A\00"
@.str.5 = [3 x i8] c"%i\00"
@.str.6 = [10 x i8] c"Zero: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = call i32 (i8**, i8*, ...) @asprintf(i8** %3, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%6 = load i8*, i8** %3
%7 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%8 = load i8*, i8** %3
%9 = call i32 @free(i8* %8)
%10 = call i32 (i8**, i8*, ...) @asprintf(i8** %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 0)
%11 = load i8*, i8** %3
%12 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %11)
%13 = load i8*, i8** %3
%14 = call i32 @free(i8* %13)
%15 = call i32 (i8**, i8*, ...) @asprintf(i8** %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 0)
%16 = load i8*, i8** %3
%17 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* %16)
%18 = load i8*, i8** %3
%19 = call i32 @free(i8* %18)
ret i32 0
}