#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 */
struct string {
  int dummy;
};

/* Variables and functions */
struct string *alloc_str();
int /*<<< orphan*/ assert_string_equals(char *, int, struct string *);
int /*<<< orphan*/ free_str(struct string *);
int /*<<< orphan*/ str_printf(struct string *, char *, char *, char *);
void test_should_print_formatted_string_to_value(void) {
  struct string *str = alloc_str();
  str_printf(str, "%s, %s!", "Hello", "World");
  assert_string_equals("Hello, World!", 13, str);
  free_str(str);
}


x86 assembly (clang, -O0):
<test_should_print_formatted_string_to_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <alloc_str@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea2(%rip),%rsi
lea    0xea3(%rip),%rdx
lea    0xea2(%rip),%rcx
call   1060 <str_printf@plt>
mov    -0x8(%rbp),%rdx
lea    0xe98(%rip),%rdi
mov    $0xd,%esi
call   1040 <assert_string_equals@plt>
mov    -0x8(%rbp),%rdi
call   1050 <free_str@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_should_print_formatted_string_to_value>:
push   %rbx
xor    %eax,%eax
call   1030 <alloc_str@plt>
mov    %rax,%rbx
lea    0xeae(%rip),%rsi
lea    0xeaf(%rip),%rdx
lea    0xeae(%rip),%rcx
mov    %rax,%rdi
call   1060 <str_printf@plt>
lea    0xea5(%rip),%rdi
mov    $0xd,%esi
mov    %rbx,%rdx
call   1040 <assert_string_equals@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1050 <free_str@plt>

LLVM IR (-O0):
%struct.string = type { i32 }
@.str = [8 x i8] c"%s, %s!\00"
@.str.1 = [6 x i8] c"Hello\00"
@.str.2 = [6 x i8] c"World\00"
@.str.3 = [14 x i8] c"Hello, World!\00"
define void @test_should_print_formatted_string_to_value() {
%1 = alloca %struct.string*
%2 = call %struct.string* (...) @alloc_str()
store %struct.string* %2, %struct.string** %1
%3 = load %struct.string*, %struct.string** %1
%4 = call i32 @str_printf(%struct.string* %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%5 = load %struct.string*, %struct.string** %1
%6 = call i32 @assert_string_equals(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 13, %struct.string* %5)
%7 = load %struct.string*, %struct.string** %1
%8 = call i32 @free_str(%struct.string* %7)
ret void
}

LLVM IR (-O2):
%struct.string = type { i32 }
@.str = [8 x i8] c"%s, %s!\00"
@.str.1 = [6 x i8] c"Hello\00"
@.str.2 = [6 x i8] c"World\00"
@.str.3 = [14 x i8] c"Hello, World!\00"
define void @test_should_print_formatted_string_to_value() {
%1 = tail call %struct.string* (...) @alloc_str()
%2 = tail call i32 @str_printf(%struct.string* %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%3 = tail call i32 @assert_string_equals(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 13, %struct.string* %1)
%4 = tail call i32 @free_str(%struct.string* %1)
ret void
}