#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ scanf(char *, char **);
int main() {
  int size = 10;
  char *p = (char *)malloc(sizeof(char) * size);
  char input[10];
  scanf("%s", &input);
  printf("%s", input);
  *p = 'a';
  *(p + 1) = 'b';
  int i;
  for (i = 0; i < size; i++) {
    *(p + i) = 'a';
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0x8(%rbp)
movslq -0x8(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
lea    -0x1a(%rbp),%rsi
lea    0xe9c(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x1a(%rbp),%rsi
lea    0xe8c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movb   $0x61,(%rax)
mov    -0x10(%rbp),%rax
movb   $0x62,0x1(%rax)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11b5 <main+0x85>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movb   $0x61,(%rax,%rcx,1)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    118f <main+0x5f>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    $0xa,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
lea    0xeb3(%rip),%r14
lea    0x6(%rsp),%r15
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <printf@plt>
movabs $0x6161616161616161,%rax
61 61 61
mov    %rax,(%rbx)
movw   $0x6161,0x8(%rbx)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [10 x i8]
%5 = alloca i32
store i32 0, i32* %1
store i32 10, i32* %2
%6 = load i32, i32* %2
%7 = sext i32 %6 to i64
%8 = mul i64 1, %7
%9 = trunc i64 %8 to i32
%10 = call i64 @malloc(i32 %9)
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %3
%12 = bitcast [10 x i8]* %4 to i8**
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %12)
%14 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%15 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = load i8*, i8** %3
store i8 97, i8* %16
%17 = load i8*, i8** %3
%18 = getelementptr inbounds i8, i8* %17, i64 1
store i8 98, i8* %18
store i32 0, i32* %5
br label %19
19: ; preds = %28, %0
%20 = load i32, i32* %5
%21 = load i32, i32* %2
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %31
23: ; preds = %19
%24 = load i8*, i8** %3
%25 = load i32, i32* %5
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
store i8 97, i8* %27
br label %28
28: ; preds = %23
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 1
store i32 %30, i32* %5
br label %19
31: ; preds = %19
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = tail call i64 @malloc(i32 10)
%3 = inttoptr i64 %2 to i8*
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%5 = bitcast [10 x i8]* %1 to i8**
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %5)
%7 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
ret i32 0
}