#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 */
typedef int /*<<< orphan*/ src;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcat_asm(char *, char *);
int /*<<< orphan*/ strcpy_asm(char *, char *);
int main(void) {
  char src[] = "hello, calling asm from c!";
  char dst[sizeof(src)] = {0};
  strcpy_asm(dst, src);
  printf("%s\n", dst);
  char dst2[100] = {0};
  strcat_asm(dst2, "hello, ");
  strcat_asm(dst2, "concatenation!");
  printf("%s\n", dst2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xea7(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xea4(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xea1(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xe9e(%rip),%ax
mov    %ax,-0x8(%rbp)
mov    0xe96(%rip),%al
mov    %al,-0x6(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x1b,%edx
call   1040 <memset@plt>
lea    -0x40(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1060 <strcpy_asm@plt>
lea    -0x40(%rbp),%rsi
lea    0xe6c(%rip),%rdi
call   1030 <printf@plt>
lea    -0xb0(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1040 <memset@plt>
lea    -0xb0(%rbp),%rdi
lea    0xe4a(%rip),%rsi
call   1050 <strcat_asm@plt>
lea    -0xb0(%rbp),%rdi
lea    0xe3f(%rip),%rsi
call   1050 <strcat_asm@plt>
lea    -0xb0(%rbp),%rsi
lea    0xe20(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xa8,%rsp
movups 0xeca(%rip),%xmm0
movups %xmm0,0x2b(%rsp)
movaps 0xeb3(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0xb(%rsp)
movaps %xmm0,(%rsp)
mov    %rsp,%rbx
lea    0x20(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <strcpy_asm@plt>
lea    0xea6(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movl   $0x0,0xa0(%rsp)
lea    0xe66(%rip),%rsi
lea    0x40(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strcat_asm@plt>
lea    0xe5a(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcat_asm@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xa8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.src = [27 x i8] c"hello, calling asm from c!\00"
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [8 x i8] c"hello, \00"
@.str.2 = [15 x i8] c"concatenation!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [27 x i8]
%3 = alloca [27 x i8]
%4 = alloca [100 x i8]
store i32 0, i32* %1
%5 = bitcast [27 x i8]* %2 to i8*
%6 = bitcast [27 x i8]* %3 to i8*
%7 = getelementptr inbounds [27 x i8], [27 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [27 x i8], [27 x i8]* %2, i64 0, i64 0
%9 = call i32 @strcpy_asm(i8* %7, i8* %8)
%10 = getelementptr inbounds [27 x i8], [27 x i8]* %3, i64 0, i64 0
%11 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = bitcast [100 x i8]* %4 to i8*
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%14 = call i32 @strcat_asm(i8* %13, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%16 = call i32 @strcat_asm(i8* %15, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %17)
ret i32 0
}

LLVM IR (-O2):
@__const.main.src = [27 x i8] c"hello, calling asm from c!\00"
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [8 x i8] c"hello, \00"
@.str.2 = [15 x i8] c"concatenation!\00"
define i32 @main() {
%1 = alloca [27 x i8]
%2 = alloca [27 x i8]
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [27 x i8], [27 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [27 x i8], [27 x i8]* %2, i64 0, i64 0
%6 = call i32 @strcpy_asm(i8* %5, i8* %4)
%7 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %5)
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%9 = call i32 @strcat_asm(i8* %8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @strcat_asm(i8* %8, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %8)
ret i32 0
}