#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*/ printf(char *);
int /*<<< orphan*/ tc_printf(int, char *, ...);
void test_tc_printf(void) {
  tc_printf(0x0000000000004L | 0x0000200000000L,
            "~~ ORIGINAL MESSAGE: This is test..."
            "int: %d & str %s ~~",
            99, "STRING");
  printf("\n");
  tc_printf(0x0000000000002L | 0x0100000000000L, "Black On White!");
  printf("\n");
  tc_printf(0x0000000010000L | 0x0000020000000L, "Yellow On Blue!");
  printf("\n");
  printf("back to normal printf\n");
}


x86 assembly (clang, -O0):
<test_tc_printf>:
push   %rbp
mov    %rsp,%rbp
mov    $0x4,%edi
lea    0xed0(%rip),%rsi
mov    $0x63,%edx
lea    0xefc(%rip),%rcx
mov    $0x0,%al
call   1040 <tc_printf@plt>
lea    0xf2a(%rip),%rdi
call   1030 <printf@plt>
mov    $0x2,%edi
lea    0xee4(%rip),%rsi
mov    $0x0,%al
call   1040 <tc_printf@plt>
lea    0xf0b(%rip),%rdi
call   1030 <printf@plt>
mov    $0x20010000,%edi
lea    0xed5(%rip),%rsi
mov    $0x0,%al
call   1040 <tc_printf@plt>
lea    0xeec(%rip),%rdi
call   1030 <printf@plt>
lea    0xecb(%rip),%rdi
call   1030 <printf@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_tc_printf>:
push   %rax
lea    0xec8(%rip),%rsi
lea    0xef9(%rip),%rcx
mov    $0x4,%edi
mov    $0x63,%edx
xor    %eax,%eax
call   1050 <tc_printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xede(%rip),%rsi
mov    $0x2,%edi
xor    %eax,%eax
call   1050 <tc_printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xed1(%rip),%rsi
mov    $0x20010000,%edi
xor    %eax,%eax
call   1050 <tc_printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xec4(%rip),%rdi
pop    %rax
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [56 x i8] c"~~ ORIGINAL MESSAGE: This is test...int: %d & str %s ~~\00"
@.str.1 = [7 x i8] c"STRING\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [16 x i8] c"Black On White!\00"
@.str.4 = [16 x i8] c"Yellow On Blue!\00"
@.str.5 = [23 x i8] c"back to normal printf\0A\00"
define void @test_tc_printf() {
%1 = call i32 (i32, i8*, ...) @tc_printf(i32 4, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i32 99, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%2 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%3 = call i32 (i32, i8*, ...) @tc_printf(i32 2, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%5 = call i32 (i32, i8*, ...) @tc_printf(i32 536936448, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [56 x i8] c"~~ ORIGINAL MESSAGE: This is test...int: %d & str %s ~~\00"
@.str.1 = [7 x i8] c"STRING\00"
@.str.3 = [16 x i8] c"Black On White!\00"
@.str.4 = [16 x i8] c"Yellow On Blue!\00"
@str = [22 x i8] c"back to normal printf\00"
define void @test_tc_printf() {
%1 = tail call i32 (i32, i8*, ...) @tc_printf(i32 4, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i32 99, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i32 @putchar(i32 10)
%3 = tail call i32 (i32, i8*, ...) @tc_printf(i32 2, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%4 = tail call i32 @putchar(i32 10)
%5 = tail call i32 (i32, i8*, ...) @tc_printf(i32 536936448, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%6 = tail call i32 @putchar(i32 10)
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
ret void
}