#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, char *, ...);
int main(int argc, char *argv[]) {
  char *buf = (char *)malloc(30);
  char ii[] = "yours";
  char *pp = "love";
  char a = 'c';
  printf("%s,%s,%c\n", buf, pp, a);
  pp = "Who am I? Please told me!";
  sprintf(buf, "%s,%c", pp, a);
  printf("%s\n", buf);
  pp = "hi";
  ii[0] = 'i';
  sprintf(buf, "%s", pp);
  printf("%s\t%s\n", buf, ii);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x1e,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    0xea6(%rip),%eax
mov    %eax,-0x1e(%rbp)
mov    0xea0(%rip),%ax
mov    %ax,-0x1a(%rbp)
lea    0xe97(%rip),%rax
mov    %rax,-0x28(%rbp)
movb   $0x63,-0x29(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
movsbl -0x29(%rbp),%ecx
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7d(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rdx
movsbl -0x29(%rbp),%ecx
lea    0xe80(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe66(%rip),%rax
mov    %rax,-0x28(%rbp)
movb   $0x69,-0x1e(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xe52(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
mov    -0x18(%rbp),%rsi
lea    -0x1e(%rbp),%rdx
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    $0x1e,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
movw   $0x73,0xc(%rsp)
movl   $0x72756f79,0x8(%rsp)
72
lea    0xeb3(%rip),%rdi
lea    0xea7(%rip),%rdx
mov    %rax,%rsi
mov    $0x63,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeba(%rip),%rsi
lea    0xe99(%rip),%rdx
mov    %rbx,%rdi
mov    $0x63,%ecx
xor    %eax,%eax
call   1050 <sprintf@plt>
lea    0xea9(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
movb   $0x69,0x8(%rsp)
movw   $0x6968,(%rbx)
movb   $0x0,0x2(%rbx)
lea    0xe87(%rip),%rdi
lea    0x8(%rsp),%rdx
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.ii = [6 x i8] c"yours\00"
@.str = [5 x i8] c"love\00"
@.str.1 = [10 x i8] c"%s,%s,%c\0A\00"
@.str.2 = [26 x i8] c"Who am I? Please told me!\00"
@.str.3 = [6 x i8] c"%s,%c\00"
@.str.4 = [4 x i8] c"%s\0A\00"
@.str.5 = [3 x i8] c"hi\00"
@.str.6 = [3 x i8] c"%s\00"
@.str.7 = [7 x i8] c"%s\09%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca [6 x i8]
%8 = alloca i8*
%9 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i64 @malloc(i32 30)
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %6
%12 = bitcast [6 x i8]* %7 to i8*
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %8
store i8 99, i8* %9
%13 = load i8*, i8** %6
%14 = load i8*, i8** %8
%15 = load i8, i8* %9
%16 = sext i8 %15 to i32
%17 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %13, i8* %14, i32 %16)
store i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8** %8
%18 = load i8*, i8** %6
%19 = load i8*, i8** %8
%20 = load i8, i8* %9
%21 = sext i8 %20 to i32
%22 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %18, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %19, i32 %21)
%23 = load i8*, i8** %6
%24 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %23)
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8** %8
%25 = getelementptr inbounds [6 x i8], [6 x i8]* %7, i64 0, i64 0
store i8 105, i8* %25
%26 = load i8*, i8** %6
%27 = load i8*, i8** %8
%28 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %27)
%29 = load i8*, i8** %6
%30 = getelementptr inbounds [6 x i8], [6 x i8]* %7, i64 0, i64 0
%31 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* %29, i8* %30)
ret i32 0
}

LLVM IR (-O2):
@__const.main.ii = [6 x i8] c"yours\00"
@.str = [5 x i8] c"love\00"
@.str.1 = [10 x i8] c"%s,%s,%c\0A\00"
@.str.2 = [26 x i8] c"Who am I? Please told me!\00"
@.str.3 = [6 x i8] c"%s,%c\00"
@.str.4 = [4 x i8] c"%s\0A\00"
@.str.5 = [3 x i8] c"hi\00"
@.str.7 = [7 x i8] c"%s\09%s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [6 x i8]
%4 = tail call i64 @malloc(i32 30)
%5 = inttoptr i64 %4 to i8*
%6 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%7 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 99)
%8 = tail call i32 (i8*, i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %5, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 99)
%9 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %5)
store i8 105, i8* %6
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(3) %5, i8* align 1 dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i64 3, i1 false)
%10 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* %5, i8* %6)
ret i32 0
}