int main() {
  char buf[100] = {"helloworld"};
  int n;
  char msg[100] = {0};
  makeAMsg(msg, buf, 1001);
  printf("msg[%s]\n", msg);
  memset(buf, 0x00, sizeof(buf));
  parseAMsg(msg, buf, &n);
  printf("n[%d],msg[%s]\n", n, buf);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x70(%rbp),%rdi
lea    0xe93(%rip),%rsi
mov    $0x64,%edx
call   1050 <memcpy@plt>
lea    -0xe0(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1040 <memset@plt>
lea    -0xe0(%rbp),%rdi
lea    -0x70(%rbp),%rsi
mov    $0x3e9,%edx
mov    $0x0,%al
call   1070 <makeAMsg@plt>
lea    -0xe0(%rbp),%rsi
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1040 <memset@plt>
lea    -0xe0(%rbp),%rdi
lea    -0x70(%rbp),%rsi
lea    -0x74(%rbp),%rdx
mov    $0x0,%al
call   1060 <parseAMsg@plt>
mov    -0x74(%rbp),%esi
lea    -0x70(%rbp),%rdx
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xe8,%rsp
movaps 0xf0f(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xef3(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xed7(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xebb(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xe9f(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe83(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movl   $0x0,0x70(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movl   $0x0,0xe0(%rsp)
lea    0x80(%rsp),%rbx
lea    0x10(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x3e9,%edx
xor    %eax,%eax
call   1050 <makeAMsg@plt>
lea    0xe7c(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x60(%rsp)
movl   $0x0,0x70(%rsp)
lea    0xc(%rsp),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <parseAMsg@plt>
mov    0xc(%rsp),%esi
lea    0xe26(%rip),%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xe8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.buf = [100 x i8] c"helloworld\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [9 x i8] c"msg[%s]\0A\00"
@.str.1 = [15 x i8] c"n[%d],msg[%s]\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca i32
%4 = alloca [100 x i8]
store i32 0, i32* %1
%5 = bitcast [100 x i8]* %2 to i8*
%6 = bitcast [100 x i8]* %4 to i8*
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%9 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @makeAMsg to i32 (i8*, i8*, i32, ...)*)(i8* %7, i8* %8, i32 1001)
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%15 = call i32 (i8*, i8*, i32*, ...) bitcast (i32 (...)* @parseAMsg to i32 (i8*, i8*, i32*, ...)*)(i8* %13, i8* %14, i32* %3)
%16 = load i32, i32* %3
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %16, i8* %17)
ret i32 0
}

LLVM IR (-O2):
@__const.main.buf = [100 x i8] c"helloworld\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [9 x i8] c"msg[%s]\0A\00"
@.str.1 = [15 x i8] c"n[%d],msg[%s]\0A\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca i32
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%5 = bitcast i32* %2 to i8*
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%7 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @makeAMsg to i32 (i8*, i8*, i32, ...)*)(i8* %6, i8* %4, i32 1001)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %6)
%9 = call i32 (i8*, i8*, i32*, ...) bitcast (i32 (...)* @parseAMsg to i32 (i8*, i8*, i32*, ...)*)(i8* %6, i8* %4, i32* %2)
%10 = load i32, i32* %2
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %10, i8* %4)
ret i32 0
}