#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*/ scanf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ system(char *);
int main(void) {
  printf("What is your name? \n");
  char str[10] = {0};
  scanf("%s", str);
  char result[30] = {0};
  sprintf(result, "say Hello %s", str);
  system(result);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
call   1040 <printf@plt>
lea    -0xe(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <memset@plt>
lea    -0xe(%rbp),%rsi
lea    0xe99(%rip),%rdi
call   1060 <scanf@plt>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x1e,%edx
call   1050 <memset@plt>
lea    -0x30(%rbp),%rdi
lea    -0xe(%rbp),%rdx
lea    0xe6b(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x30(%rbp),%rdi
call   1030 <system@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x38,%rsp
lea    0xebf(%rip),%rdi
call   1030 <puts@plt>
movw   $0x0,0x8(%rsp)
movq   $0x0,(%rsp)
lea    0xea1(%rip),%rdi
mov    %rsp,%r14
mov    %r14,%rsi
call   1050 <scanf@plt>
xorps  %xmm0,%xmm0
movups %xmm0,0x1e(%rsp)
movaps %xmm0,0x10(%rsp)
lea    0xe78(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rdx
call   1060 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [21 x i8] c"What is your name? \0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [13 x i8] c"say Hello %s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i8]
%3 = alloca [30 x i8]
store i32 0, i32* %1
%4 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%5 = bitcast [10 x i8]* %2 to i8*
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%8 = bitcast [30 x i8]* %3 to i8*
%9 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%11 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%12 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%13 = call i32 @system(i8* %12)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [13 x i8] c"say Hello %s\00"
@str = [20 x i8] c"What is your name? \00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = alloca [30 x i8]
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%6 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%7 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%8 = call i32 @system(i8* %6)
ret i32 0
}