#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 EXIT_SUCCESS;
char *calloc(int, int);
int /*<<< orphan*/ free(char *);
char *malloc(int);
char *realloc(char *, int);
int main(int argc, char *argv[]) {
  char *string1 = malloc(256 * sizeof(char));
  char *string2 = calloc(256, sizeof(char));
  char *string3;
  int i;
  for (i = 0; i < 256; i++) {
    string1[i] = 'q';
  }
  for (i = 0; i < 256; i++) {
    string2[i] = string1[i];
  }
  string3 = realloc(string2, 200);
  for (i = 0; i < 200; i++) {
    string3[i] = 'b';
  }
  free(string1);
  free(string3);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x100,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    $0x100,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x100,-0x2c(%rbp)
jge    11a5 <main+0x65>
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movb   $0x71,(%rax,%rcx,1)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    117e <main+0x3e>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x100,-0x2c(%rbp)
jge    11dd <main+0x9d>
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11ac <main+0x6c>
mov    -0x20(%rbp),%rdi
mov    $0xc8,%esi
call   1060 <realloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0xc8,-0x2c(%rbp)
jge    121d <main+0xdd>
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movb   $0x62,(%rax,%rcx,1)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11f6 <main+0xb6>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    0x2daa(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x100,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
mov    $0x100,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
movaps 0xe99(%rip),%xmm0
movups %xmm0,(%r14)
movups %xmm0,0x10(%r14)
movups %xmm0,0x20(%r14)
movups %xmm0,0x30(%r14)
movups %xmm0,0x40(%r14)
movups %xmm0,0x50(%r14)
movups %xmm0,0x60(%r14)
movups %xmm0,0x70(%r14)
movups %xmm0,0x80(%r14)
movups %xmm0,0x90(%r14)
movups %xmm0,0xa0(%r14)
movups %xmm0,0xb0(%r14)
movups %xmm0,0xc0(%r14)
movups %xmm0,0xd0(%r14)
movups %xmm0,0xe0(%r14)
movups %xmm0,0xf0(%r14)
movups %xmm0,0xf0(%rax)
movups %xmm0,0xe0(%rax)
movups %xmm0,0xd0(%rax)
movups %xmm0,0xc0(%rax)
movups %xmm0,0xb0(%rax)
movups %xmm0,0xa0(%rax)
movups %xmm0,0x90(%rax)
movups %xmm0,0x80(%rax)
movups %xmm0,0x70(%rax)
movups %xmm0,0x60(%rax)
movups %xmm0,0x50(%rax)
movups %xmm0,0x40(%rax)
movups %xmm0,0x30(%rax)
movups %xmm0,0x20(%rax)
movups %xmm0,0x10(%rax)
movups %xmm0,(%rax)
mov    %rax,%rdi
mov    $0xc8,%esi
call   1060 <realloc@plt>
mov    %rax,%rbx
movaps 0xdd4(%rip),%xmm0
movups %xmm0,(%rax)
movups %xmm0,0x10(%rax)
movups %xmm0,0x20(%rax)
movups %xmm0,0x30(%rax)
movups %xmm0,0x40(%rax)
movups %xmm0,0x50(%rax)
movups %xmm0,0x60(%rax)
movups %xmm0,0x70(%rax)
movups %xmm0,0x80(%rax)
movups %xmm0,0x90(%rax)
movups %xmm0,0xa0(%rax)
movups %xmm0,0xb0(%rax)
movabs $0x6262626262626262,%rax
62 62 62
mov    %rax,0xc0(%rbx)
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x2d41(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i8* @malloc(i32 256)
store i8* %10, i8** %6
%11 = call i8* @calloc(i32 256, i32 1)
store i8* %11, i8** %7
store i32 0, i32* %9
br label %12
12: ; preds = %20, %2
%13 = load i32, i32* %9
%14 = icmp slt i32 %13, 256
br i1 %14, label %15, label %23
15: ; preds = %12
%16 = load i8*, i8** %6
%17 = load i32, i32* %9
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
store i8 113, i8* %19
br label %20
20: ; preds = %15
%21 = load i32, i32* %9
%22 = add nsw i32 %21, 1
store i32 %22, i32* %9
br label %12
23: ; preds = %12
store i32 0, i32* %9
br label %24
24: ; preds = %37, %23
%25 = load i32, i32* %9
%26 = icmp slt i32 %25, 256
br i1 %26, label %27, label %40
27: ; preds = %24
%28 = load i8*, i8** %6
%29 = load i32, i32* %9
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
%32 = load i8, i8* %31
%33 = load i8*, i8** %7
%34 = load i32, i32* %9
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
store i8 %32, i8* %36
br label %37
37: ; preds = %27
%38 = load i32, i32* %9
%39 = add nsw i32 %38, 1
store i32 %39, i32* %9
br label %24
40: ; preds = %24
%41 = load i8*, i8** %7
%42 = call i8* @realloc(i8* %41, i32 200)
store i8* %42, i8** %8
store i32 0, i32* %9
br label %43
43: ; preds = %51, %40
%44 = load i32, i32* %9
%45 = icmp slt i32 %44, 200
br i1 %45, label %46, label %54
46: ; preds = %43
%47 = load i8*, i8** %8
%48 = load i32, i32* %9
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %47, i64 %49
store i8 98, i8* %50
br label %51
51: ; preds = %46
%52 = load i32, i32* %9
%53 = add nsw i32 %52, 1
store i32 %53, i32* %9
br label %43
54: ; preds = %43
%55 = load i8*, i8** %6
%56 = call i32 @free(i8* %55)
%57 = load i8*, i8** %8
%58 = call i32 @free(i8* %57)
%59 = load i32, i32* @EXIT_SUCCESS
ret i32 %59
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call dereferenceable_or_null(256) i8* @malloc(i32 256)
%4 = tail call dereferenceable_or_null(256) i8* @calloc(i32 256, i32 1)
%5 = tail call i8* @realloc(i8* %4, i32 200)
%6 = tail call i32 @free(i8* %3)
%7 = tail call i32 @free(i8* %5)
%8 = load i32, i32* @EXIT_SUCCESS
ret i32 %8
}