#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(100) != NULL)
    if (cont++ == 2000) {
      putchar('.');
      cont = 0;
    }
  printf("\n Acabou a memoria");
  system("pause");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0x64,%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    $0x7d0,%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    0xe6a(%rip),%rdi
call   1040 <system@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x64,%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    $0x64,%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     1188 <main+0x48>
cmp    $0x7d0,%ebx
je     1160 <main+0x20>
add    $0x1,%ebx
jmp    116c <main+0x2c>
lea    0xe71(%rip),%rdi
call   1050 <printf@plt>
lea    0xe78(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [19 x i8] c"\0A Acabou a memoria\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 100)
%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, 2000
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 ([19 x i8], [19 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 = [19 x i8] c"\0A Acabou a memoria\00"
@.str.1 = [6 x i8] c"pause\00"
define i32 @main() {
%1 = tail call i32* @malloc(i32 100)
%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, 2000
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 100)
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %3
13: ; preds = %9, %0
%14 = tail call i32 @printf(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
}