#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*/ *malloc(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ system(char *);
int main(void) {
  int cont = 0;
  while (malloc(1000) != NULL)
    if (cont++ == 20000) {
      putchar('.');
      cont = 0;
    }
  printf("\nAcabou a memoria!\n");
  system("pause");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0x3e8,%edi
call   1060 <malloc@plt>
cmp    $0x0,%rax
je     1196 <main+0x56>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x4e20,%eax
jne    1191 <main+0x51>
mov    $0x2e,%edi
call   1030 <putchar@plt>
movl   $0x0,-0x8(%rbp)
jmp    1156 <main+0x16>
lea    0xe63(%rip),%rdi
call   1050 <printf@plt>
lea    0xe6b(%rip),%rdi
call   1040 <system@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x3e8,%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     1188 <main+0x48>
xor    %ebx,%ebx
jmp    117b <main+0x3b>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x2e,%edi
call   1030 <putchar@plt>
xor    %ebx,%ebx
mov    $0x3e8,%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     1188 <main+0x48>
cmp    $0x4e20,%ebx
je     1160 <main+0x20>
add    $0x1,%ebx
jmp    116c <main+0x2c>
lea    0xe77(%rip),%rdi
call   1040 <puts@plt>
lea    0xe65(%rip),%rdi
call   1050 <system@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [20 x i8] c"\0AAcabou a memoria!\0A\00"
@.str.1 = [6 x i8] c"pause\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
br label %3
3: ; preds = %12, %0
%4 = call i32* @malloc(i32 1000)
%5 = icmp ne i32* %4, null
br i1 %5, label %6, label %13
6: ; preds = %3
%7 = load i32, i32* %2
%8 = add nsw i32 %7, 1
store i32 %8, i32* %2
%9 = icmp eq i32 %7, 20000
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = call i32 @putchar(i8 signext 46)
store i32 0, i32* %2
br label %12
12: ; preds = %10, %6
br label %3
13: ; preds = %3
%14 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32, i32* %1
ret i32 %16
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"pause\00"
@str = [19 x i8] c"\0AAcabou a memoria!\00"
define i32 @main() {
%1 = tail call i32* @malloc(i32 1000)
%2 = icmp eq i32* %1, null
br i1 %2, label %13, label %3
3: ; preds = %0, %9
%4 = phi i32 [ %10, %9 ], [ 0, %0 ]
%5 = add nsw i32 %4, 1
%6 = icmp eq i32 %4, 20000
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call i32 @putchar(i8 signext 46)
br label %9
9: ; preds = %7, %3
%10 = phi i32 [ 0, %7 ], [ %5, %3 ]
%11 = tail call i32* @malloc(i32 1000)
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %3
13: ; preds = %9, %0
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%15 = tail call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}