#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*/ abort();
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *);
char *realpath(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ stdout;
int main() {
  int i;
  for (i = 0; i < (int)2e9; i++) {
    char *path = realpath("/etc/passwd", NULL);
    if (path == NULL) {
      abort();
    } else {
      free(path);
    }
    if (i % (int)1e6 == 0) {
      printf(".");
      fflush(stdout);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x77359400,-0x8(%rbp)
jge    11e3 <main+0x93>
lea    0xe86(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <realpath@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1199 <main+0x49>
mov    $0x0,%al
call   1040 <abort@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%eax
mov    $0xf4240,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11d0 <main+0x80>
lea    0xe4f(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e17(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
jmp    11d5 <main+0x85>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1166 <main+0x16>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %ebx,%ebx
lea    0xe9f(%rip),%r14
mov    0x2e78(%rip),%r15
xor    %ebp,%ebp
jmp    117e <main+0x2e>
nopl   0x0(%rax)
add    $0x1,%ebp
add    $0xffffffff,%ebx
cmp    $0x88ca6c00,%ebx
je     11c2 <main+0x72>
mov    %r14,%rdi
xor    %esi,%esi
call   1060 <realpath@plt>
test   %rax,%rax
je     11cd <main+0x7d>
mov    %ebp,%ecx
imul   $0x431bde83,%rcx,%rcx
shr    $0x32,%rcx
imul   $0xfff0bdc0,%ecx,%r12d
mov    %rax,%rdi
call   1030 <free@plt>
cmp    %ebx,%r12d
jne    1170 <main+0x20>
mov    $0x2e,%edi
call   1040 <putchar@plt>
mov    (%r15),%edi
call   1070 <fflush@plt>
jmp    1170 <main+0x20>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   1050 <abort@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"/etc/passwd\00"
@.str.1 = [2 x i8] c".\00"
@stdout = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
store i32 0, i32* %1
store i32 0, i32* %2
br label %4
4: ; preds = %25, %0
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 2000000000
br i1 %6, label %7, label %28
7: ; preds = %4
%8 = call i8* @realpath(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32* null)
store i8* %8, i8** %3
%9 = load i8*, i8** %3
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = call i32 (...) @abort()
unreachable
13: ; preds = %7
%14 = load i8*, i8** %3
%15 = call i32 @free(i8* %14)
br label %16
16: ; preds = %13
%17 = load i32, i32* %2
%18 = srem i32 %17, 1000000
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%22 = load i32, i32* @stdout
%23 = call i32 @fflush(i32 %22)
br label %24
24: ; preds = %20, %16
br label %25
25: ; preds = %24
%26 = load i32, i32* %2
%27 = add nsw i32 %26, 1
store i32 %27, i32* %2
br label %4
28: ; preds = %4
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"/etc/passwd\00"
@stdout = global i32 0
define i32 @main() {
br label %1
1: ; preds = %0, %15
%2 = phi i32 [ 0, %0 ], [ %16, %15 ]
%3 = tail call i8* @realpath(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32* null)
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call i32 (...) @abort()
unreachable
7: ; preds = %1
%8 = tail call i32 @free(i8* %3)
%9 = urem i32 %2, 1000000
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %7
%12 = tail call i32 @putchar(i32 46)
%13 = load i32, i32* @stdout
%14 = tail call i32 @fflush(i32 %13)
br label %15
15: ; preds = %11, %7
%16 = add nuw nsw i32 %2, 1
%17 = icmp eq i32 %16, 2000000000
br i1 %17, label %18, label %1
18: ; preds = %15
ret i32 0
}