#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 */
struct string {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ string_append(struct string *, char const *, size_t);
int /*<<< orphan*/ string_char_append(struct string *, char, int);
int /*<<< orphan*/ string_init(struct string *);
int /*<<< orphan*/ string_set(struct string *, char *);
void __aosc_code_init(struct string *code, const char *src, size_t size) {
  string_init(code);
  string_set(code, "AAAA");
  string_append(code, src, size);
  string_char_append(code, 'A', ((4) - ((size) % (4))));
}


x86 assembly (clang, -O0):
<__aosc_code_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <string_init@plt>
mov    -0x8(%rbp),%rdi
lea    0xe98(%rip),%rsi
call   1040 <string_set@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1060 <string_append@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rcx
and    $0x3,%rcx
mov    $0x4,%eax
sub    %rcx,%rax
mov    %eax,%edx
mov    $0x41,%esi
call   1030 <string_char_append@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__aosc_code_init>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1050 <string_init@plt>
lea    0xea6(%rip),%rsi
mov    %r15,%rdi
call   1040 <string_set@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1060 <string_append@plt>
and    $0x3,%ebx
mov    $0x4,%edx
sub    %ebx,%edx
mov    %r15,%rdi
mov    $0x41,%esi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <string_char_append@plt>

LLVM IR (-O0):
%struct.string = type { i32 }
@.str = [5 x i8] c"AAAA\00"
define void @__aosc_code_init(%struct.string* %0, i8* %1, i64 %2) {
%4 = alloca %struct.string*
%5 = alloca i8*
%6 = alloca i64
store %struct.string* %0, %struct.string** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%7 = load %struct.string*, %struct.string** %4
%8 = call i32 @string_init(%struct.string* %7)
%9 = load %struct.string*, %struct.string** %4
%10 = call i32 @string_set(%struct.string* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%11 = load %struct.string*, %struct.string** %4
%12 = load i8*, i8** %5
%13 = load i64, i64* %6
%14 = call i32 @string_append(%struct.string* %11, i8* %12, i64 %13)
%15 = load %struct.string*, %struct.string** %4
%16 = load i64, i64* %6
%17 = urem i64 %16, 4
%18 = sub i64 4, %17
%19 = trunc i64 %18 to i32
%20 = call i32 @string_char_append(%struct.string* %15, i8 signext 65, i32 %19)
ret void
}

LLVM IR (-O2):
%struct.string = type { i32 }
@.str = [5 x i8] c"AAAA\00"
define void @__aosc_code_init(%struct.string* %0, i8* %1, i64 %2) {
%4 = tail call i32 @string_init(%struct.string* %0)
%5 = tail call i32 @string_set(%struct.string* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @string_append(%struct.string* %0, i8* %1, i64 %2)
%7 = trunc i64 %2 to i32
%8 = and i32 %7, 3
%9 = sub nuw nsw i32 4, %8
%10 = tail call i32 @string_char_append(%struct.string* %0, i8 signext 65, i32 %9)
ret void
}