#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 add(int, int);
int /*<<< orphan*/ printf(char *, ...);
int value_convert(int);
int main() {
  printf("GCC ARM Inline Assembler CookBook Demo!\n");
  int x = 3, y = 2;
  printf("call func value_convert with input x = %d,output : %d\n", x,
         value_convert(x));
  printf("call func add           with input x = %d, y = %d, output : %d\n", x,
         y, add(x, y));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x3,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <value_convert@plt>
mov    -0x18(%rbp),%esi
mov    %eax,%edx
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <add@plt>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    %eax,%ecx
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xf2f(%rip),%rdi
call   1040 <puts@plt>
mov    $0x3,%edi
call   1060 <value_convert@plt>
lea    0xea2(%rip),%rdi
mov    $0x3,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x3,%edi
mov    $0x2,%esi
call   1030 <add@plt>
lea    0xeb5(%rip),%rdi
mov    $0x3,%esi
mov    $0x2,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [41 x i8] c"GCC ARM Inline Assembler CookBook Demo!\0A\00"
@.str.1 = [55 x i8] c"call func value_convert with input x = %d,output : %d\0A\00"
@.str.2 = [64 x i8] c"call func add with input x = %d, y = %d, output : %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
store i32 3, i32* %2
store i32 2, i32* %3
%5 = load i32, i32* %2
%6 = load i32, i32* %2
%7 = call i32 @value_convert(i32 %6)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0), i32 %5, i32 %7)
%9 = load i32, i32* %2
%10 = load i32, i32* %3
%11 = load i32, i32* %2
%12 = load i32, i32* %3
%13 = call i32 @add(i32 %11, i32 %12)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.2, i64 0, i64 0), i32 %9, i32 %10, i32 %13)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [55 x i8] c"call func value_convert with input x = %d,output : %d\0A\00"
@.str.2 = [64 x i8] c"call func add with input x = %d, y = %d, output : %d\0A\00"
@str = [40 x i8] c"GCC ARM Inline Assembler CookBook Demo!\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @value_convert(i32 3)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0), i32 3, i32 %2)
%4 = tail call i32 @add(i32 3, i32 2)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @.str.2, i64 0, i64 0), i32 3, i32 2, i32 %4)
ret i32 0
}