#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 /*<<< orphan*/ free(char *);
int /*<<< orphan*/ gets(char *);
scalar_t__ malloc(scalar_t__);
int /*<<< orphan*/ memmove(char *, char *, int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strlen(char *);
int main() {
  char cumle[256];
  printf("Bir cumle giriniz.\n");
  gets(cumle);
  char *p;
  if (p == NULL) {
    printf("Bellek ayrilamiyor!\n");
    return -1;
  }
  p = (char *)malloc(strlen(cumle) + 1);
  memmove(cumle + 2, cumle, 5);
  printf("cumle: %s\n", cumle);
  free(p);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x110(%rbp),%rdi
call   1060 <gets@plt>
cmpq   $0x0,-0x118(%rbp)
jne    11b4 <main+0x54>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1217 <main+0xb7>
lea    -0x110(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1070 <malloc@plt>
mov    %rax,-0x118(%rbp)
lea    -0x110(%rbp),%rdi
add    $0x2,%rdi
lea    -0x110(%rbp),%rsi
mov    $0x5,%edx
call   1080 <memmove@plt>
lea    -0x110(%rbp),%rsi
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x118(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x108,%rsp
lea    0xe8a(%rip),%rdi
call   1040 <puts@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1070 <gets@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%rdi
call   1080 <malloc@plt>
mov    %rax,%r14
lea    0x2(%rsp),%rdi
mov    %rbx,%rsi
mov    $0x5,%edx
call   1090 <memmove@plt>
lea    0xe42(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Bir cumle giriniz.\0A\00"
@.str.1 = [21 x i8] c"Bellek ayrilamiyor!\0A\00"
@.str.2 = [11 x i8] c"cumle: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [256 x i8]
%3 = alloca i8*
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%6 = call i32 @gets(i8* %5)
%7 = load i8*, i8** %3
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %25
11: ; preds = %0
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%13 = call i64 @strlen(i8* %12)
%14 = add nsw i64 %13, 1
%15 = call i64 @malloc(i64 %14)
%16 = inttoptr i64 %15 to i8*
store i8* %16, i8** %3
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%18 = getelementptr inbounds i8, i8* %17, i64 2
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%20 = call i32 @memmove(i8* %18, i8* %19, i32 5)
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %21)
%23 = load i8*, i8** %3
%24 = call i32 @free(i8* %23)
store i32 0, i32* %1
br label %25
25: ; preds = %11, %9
%26 = load i32, i32* %1
ret i32 %26
}

LLVM IR (-O2):
@.str.2 = [11 x i8] c"cumle: %s\0A\00"
@str = [19 x i8] c"Bir cumle giriniz.\00"
define i32 @main() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%4 = call i32 @gets(i8* %2)
%5 = call i64 @strlen(i8* %2)
%6 = add nsw i64 %5, 1
%7 = call i64 @malloc(i64 %6)
%8 = inttoptr i64 %7 to i8*
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 2
%10 = call i32 @memmove(i8* %9, i8* %2, i32 5)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%12 = call i32 @free(i8* %8)
ret i32 0
}