#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
char *getNext();
int /*<<< orphan*/ printf(char *, unsigned long long, ...);
void test_getNext() {
  unsigned long long int counta = 0;
  char *ip = getNext();
  while (ip != NULL) {
    counta++;
    free(ip);
    ip = getNext();
    if (counta % 10000000 == 0) {
      printf("num %llu  ip   %s\n", counta, ip);
    }
  }
  printf("%llu", counta);
  exit(0);
}


x86 assembly (clang, -O0):
<test_getNext>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movq   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1060 <getNext@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11b9 <test_getNext+0x79>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    $0x0,%al
call   1060 <getNext@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x989680,%ecx
xor    %edx,%edx
div    %rcx
cmp    $0x0,%rdx
jne    11b4 <test_getNext+0x74>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    115b <test_getNext+0x1b>
mov    -0x8(%rbp),%rsi
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<test_getNext>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %r14d,%r14d
xor    %eax,%eax
call   1060 <getNext@plt>
test   %rax,%rax
jne    1172 <test_getNext+0x32>
lea    0xeb2(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>
mov    %rax,%r15
mov    $0x1,%ebx
movabs $0xd6bf94d5e57a42bd,%r13
94 bf d6
xor    %r14d,%r14d
jmp    1199 <test_getNext+0x59>
nopl   0x0(%rax)
add    $0x1,%rbx
test   %r15,%r15
je     115a <test_getNext+0x1a>
mov    %r14,%rbp
mov    %rbx,%rax
mul    %r13
add    $0x1,%r14
shr    $0x17,%rdx
imul   $0x989680,%rdx,%r12
add    $0xffffffffffffffff,%r12
mov    %r15,%rdi
call   1030 <free@plt>
xor    %eax,%eax
call   1060 <getNext@plt>
mov    %rax,%r15
cmp    %rbp,%r12
jne    1190 <test_getNext+0x50>
lea    0xe2d(%rip),%rdi
mov    %r14,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1190 <test_getNext+0x50>

LLVM IR (-O0):
@.str = [19 x i8] c"num %llu ip %s\0A\00"
@.str.1 = [5 x i8] c"%llu\00"
define void @test_getNext() {
%1 = alloca i64
%2 = alloca i8*
store i64 0, i64* %1
%3 = call i8* (...) @getNext()
store i8* %3, i8** %2
br label %4
4: ; preds = %20, %0
%5 = load i8*, i8** %2
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %21
7: ; preds = %4
%8 = load i64, i64* %1
%9 = add i64 %8, 1
store i64 %9, i64* %1
%10 = load i8*, i8** %2
%11 = call i32 @free(i8* %10)
%12 = call i8* (...) @getNext()
store i8* %12, i8** %2
%13 = load i64, i64* %1
%14 = urem i64 %13, 10000000
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %7
%17 = load i64, i64* %1
%18 = load i8*, i8** %2
%19 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i64 %17, i8* %18)
br label %20
20: ; preds = %16, %7
br label %4
21: ; preds = %4
%22 = load i64, i64* %1
%23 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %22)
%24 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [19 x i8] c"num %llu ip %s\0A\00"
@.str.1 = [5 x i8] c"%llu\00"
define void @test_getNext() {
%1 = tail call i8* (...) @getNext()
%2 = icmp eq i8* %1, null
br i1 %2, label %15, label %3
3: ; preds = %0, %13
%4 = phi i8* [ %8, %13 ], [ %1, %0 ]
%5 = phi i64 [ %6, %13 ], [ 0, %0 ]
%6 = add i64 %5, 1
%7 = tail call i32 @free(i8* %4)
%8 = tail call i8* (...) @getNext()
%9 = urem i64 %6, 10000000
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %3
%12 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i64 %6, i8* %8)
br label %13
13: ; preds = %11, %3
%14 = icmp eq i8* %8, null
br i1 %14, label %15, label %3
15: ; preds = %13, %0
%16 = phi i64 [ 0, %0 ], [ %6, %13 ]
%17 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %16)
%18 = tail call i32 @exit(i32 0)
unreachable
}