#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*/ generate_seg(unsigned long long *, unsigned long *);
int /*<<< orphan*/ insert_seg(unsigned long long, unsigned long);
int /*<<< orphan*/ print_map();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  int i;
  unsigned long long size = 0;
  srand(time(NULL));
  while (1) {
    unsigned long long offset;
    unsigned long len;
    generate_seg(&offset, &len);
    printf("%llu,%lu\n", offset, len);
    insert_seg(offset, len);
    print_map();
    printf("\n");
    size += len;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
lea    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1030 <generate_seg@plt>
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1040 <insert_seg@plt>
mov    $0x0,%al
call   1080 <print_map@plt>
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x30(%rbp),%rax
add    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    %rax,-0x20(%rbp)
jmp    118e <main+0x2e>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
lea    0x8(%rsp),%r14
mov    %rsp,%r15
lea    0xe6a(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <generate_seg@plt>
mov    0x8(%rsp),%rsi
mov    (%rsp),%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x8(%rsp),%rdi
mov    (%rsp),%rsi
call   1050 <insert_seg@plt>
xor    %eax,%eax
call   1090 <print_map@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11a0 <main+0x30>

LLVM IR (-O0):
@.str = [10 x i8] c"%llu,%lu\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %7
%10 = call i32 @time(i32* null)
%11 = call i32 @srand(i32 %10)
br label %12
12: ; preds = %2, %12
%13 = call i32 @generate_seg(i64* %8, i64* %9)
%14 = load i64, i64* %8
%15 = load i64, i64* %9
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 %14, i64 %15)
%17 = load i64, i64* %8
%18 = load i64, i64* %9
%19 = call i32 @insert_seg(i64 %17, i64 %18)
%20 = call i32 (...) @print_map()
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%22 = load i64, i64* %9
%23 = load i64, i64* %7
%24 = add i64 %23, %22
store i64 %24, i64* %7
br label %12
}

LLVM IR (-O2):
@.str = [10 x i8] c"%llu,%lu\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i64
%4 = alloca i64
%5 = tail call i32 @time(i32* null)
%6 = tail call i32 @srand(i32 %5)
%7 = bitcast i64* %3 to i8*
%8 = bitcast i64* %4 to i8*
br label %9
9: ; preds = %9, %2
%10 = call i32 @generate_seg(i64* %3, i64* %4)
%11 = load i64, i64* %3
%12 = load i64, i64* %4
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 %11, i64 %12)
%14 = load i64, i64* %3
%15 = load i64, i64* %4
%16 = call i32 @insert_seg(i64 %14, i64 %15)
%17 = call i32 (...) @print_map()
%18 = call i32 @putchar(i32 10)
br label %9
}