#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 */
struct timeval {
  int tv_sec;
  int tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/);
int /*<<< orphan*/ log2mem_append_int(void *, int);
int /*<<< orphan*/ log2mem_append_long(void *, long);
int /*<<< orphan*/ log2mem_append_str(void *, char const *);
int /*<<< orphan*/ log2mem_counter_incr(int /*<<< orphan*/);
void *log2mem_get_row(char *, int);
int /*<<< orphan*/ log2mem_var_double_set(int, float);
int /*<<< orphan*/ log2mem_write(char *, char *, int);
int /*<<< orphan*/ sleep(int);
void loop(const char *s) {
  log2mem_write("starting loop",
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/darrenjs/log2mem/refs/heads/"
                "master/examples/interact/example.c",
                54);
  float f = 1.1;
  int i = 0;
  int iterations = 0;
  for (i = 0; i < 50; ++i) {
    f += 1.12;
    struct timeval tv;
    gettimeofday(&tv, 0);
    long l = tv.tv_sec * 1000000 + tv.tv_usec;
    void *rowptr =
        log2mem_get_row("/scratch/repos/new/home/jordi_armengol_estape/"
                        "c-scraper/outputs/2022-01-22/02-19-57/repos/darrenjs/"
                        "log2mem/refs/heads/master/examples/interact/example.c",
                        73);
    log2mem_append_long(rowptr, l);
    log2mem_var_double_set(i & 0x7, f);
    log2mem_counter_incr(0);
    iterations++;
  }
  log2mem_write("ending loop",
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/darrenjs/log2mem/refs/heads/"
                "master/examples/interact/example.c",
                82);
  sleep(4);
  void *rowptr =
      log2mem_get_row("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                      "outputs/2022-01-22/02-19-57/repos/darrenjs/log2mem/refs/"
                      "heads/master/examples/interact/example.c",
                      86);
  log2mem_append_str(rowptr, "loop name:");
  log2mem_append_str(rowptr, s);
  log2mem_append_str(rowptr, "completed after");
  log2mem_append_int(rowptr, iterations);
  log2mem_append_str(rowptr, "iterations");
}


x86 assembly (clang, -O0):
<loop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe6d(%rip),%rdi
lea    0xe74(%rip),%rsi
mov    $0x36,%edx
call   1080 <log2mem_write@plt>
movss  0xe44(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x32,-0x10(%rbp)
jge    1269 <loop+0xd9>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe17(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
imul   $0xf4240,-0x20(%rbp),%eax
add    -0x1c(%rbp),%eax
cltq
mov    %rax,-0x28(%rbp)
lea    0xdfe(%rip),%rdi
mov    $0x49,%esi
call   1090 <log2mem_get_row@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <log2mem_append_long@plt>
mov    -0x10(%rbp),%edi
and    $0x7,%edi
movss  -0xc(%rbp),%xmm0
call   10a0 <log2mem_var_double_set@plt>
xor    %edi,%edi
call   1070 <log2mem_counter_incr@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11d6 <loop+0x46>
lea    0xe47(%rip),%rdi
lea    0xda7(%rip),%rsi
mov    $0x52,%edx
call   1080 <log2mem_write@plt>
mov    $0x4,%edi
call   10b0 <sleep@plt>
lea    0xd8c(%rip),%rdi
mov    $0x56,%esi
call   1090 <log2mem_get_row@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
lea    0xe18(%rip),%rsi
call   1050 <log2mem_append_str@plt>
mov    -0x38(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1050 <log2mem_append_str@plt>
mov    -0x38(%rbp),%rdi
lea    0xe06(%rip),%rsi
call   1050 <log2mem_append_str@plt>
mov    -0x38(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <log2mem_append_int@plt>
mov    -0x38(%rbp),%rdi
lea    0xdfa(%rip),%rsi
call   1050 <log2mem_append_str@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<loop>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
lea    0xe6a(%rip),%rdi
lea    0xe71(%rip),%r15
mov    %r15,%rsi
mov    $0x36,%edx
call   1080 <log2mem_write@plt>
xor    %ebp,%ebp
movss  0xe3c(%rip),%xmm0
lea    0x8(%rsp),%r12
nopl   0x0(%rax)
cvtss2sd %xmm0,%xmm0
addsd  0xe2c(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
mov    %r12,%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
movslq 0x8(%rsp),%rax
imul   $0xf4240,%rax,%rax
movslq 0xc(%rsp),%rbx
add    %rax,%rbx
mov    %r15,%rdi
mov    $0x49,%esi
call   1090 <log2mem_get_row@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
call   1040 <log2mem_append_long@plt>
mov    %ebp,%edi
and    $0x7,%edi
movss  0x4(%rsp),%xmm0
call   10a0 <log2mem_var_double_set@plt>
xor    %edi,%edi
call   1070 <log2mem_counter_incr@plt>
movss  0x4(%rsp),%xmm0
add    $0x1,%ebp
cmp    $0x32,%ebp
jne    11d0 <loop+0x40>
lea    0xe6f(%rip),%rdi
lea    0xdcf(%rip),%rbx
mov    %rbx,%rsi
mov    $0x52,%edx
call   1080 <log2mem_write@plt>
mov    $0x4,%edi
call   10b0 <sleep@plt>
mov    %rbx,%rdi
mov    $0x56,%esi
call   1090 <log2mem_get_row@plt>
mov    %rax,%rbx
lea    0xe46(%rip),%rsi
mov    %rax,%rdi
call   1050 <log2mem_append_str@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <log2mem_append_str@plt>
lea    0xe37(%rip),%rsi
mov    %rbx,%rdi
call   1050 <log2mem_append_str@plt>
mov    %rbx,%rdi
mov    $0x32,%esi
call   1030 <log2mem_append_int@plt>
lea    0xe2b(%rip),%rsi
mov    %rbx,%rdi
call   1050 <log2mem_append_str@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
@.str = [14 x i8] c"starting loop\00"
@.str.1 = [153 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/darrenjs/log2mem/refs/heads/master/examples/interact/example.c\00"
@.str.2 = [12 x i8] c"ending loop\00"
@.str.3 = [11 x i8] c"loop name:\00"
@.str.4 = [16 x i8] c"completed after\00"
@.str.5 = [11 x i8] c"iterations\00"
define void @loop(i8* %0) {
%2 = alloca i8*
%3 = alloca float
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.timeval
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i8*
store i8* %0, i8** %2
%10 = call i32 @log2mem_write(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([153 x i8], [153 x i8]* @.str.1, i64 0, i64 0), i32 54)
store float 0x3FF19999A0000000, float* %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %4
br label %11
11: ; preds = %38, %1
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 50
br i1 %13, label %14, label %41
14: ; preds = %11
%15 = load float, float* %3
%16 = fpext float %15 to double
%17 = fadd double %16, 1.120000e+00
%18 = fptrunc double %17 to float
store float %18, float* %3
%19 = call i32 @gettimeofday(%struct.timeval* %6, i32 0)
%20 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%21 = load i32, i32* %20
%22 = mul nsw i32 %21, 1000000
%23 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
%24 = load i32, i32* %23
%25 = add nsw i32 %22, %24
%26 = sext i32 %25 to i64
store i64 %26, i64* %7
%27 = call i8* @log2mem_get_row(i8* getelementptr inbounds ([153 x i8], [153 x i8]* @.str.1, i64 0, i64 0), i32 73)
store i8* %27, i8** %8
%28 = load i8*, i8** %8
%29 = load i64, i64* %7
%30 = call i32 @log2mem_append_long(i8* %28, i64 %29)
%31 = load i32, i32* %4
%32 = and i32 %31, 7
%33 = load float, float* %3
%34 = call i32 @log2mem_var_double_set(i32 %32, float %33)
%35 = call i32 @log2mem_counter_incr(i32 0)
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
store i32 %37, i32* %5
br label %38
38: ; preds = %14
%39 = load i32, i32* %4
%40 = add nsw i32 %39, 1
store i32 %40, i32* %4
br label %11
41: ; preds = %11
%42 = call i32 @log2mem_write(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([153 x i8], [153 x i8]* @.str.1, i64 0, i64 0), i32 82)
%43 = call i32 @sleep(i32 4)
%44 = call i8* @log2mem_get_row(i8* getelementptr inbounds ([153 x i8], [153 x i8]* @.str.1, i64 0, i64 0), i32 86)
store i8* %44, i8** %9
%45 = load i8*, i8** %9
%46 = call i32 @log2mem_append_str(i8* %45, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%47 = load i8*, i8** %9
%48 = load i8*, i8** %2
%49 = call i32 @log2mem_append_str(i8* %47, i8* %48)
%50 = load i8*, i8** %9
%51 = call i32 @log2mem_append_str(i8* %50, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%52 = load i8*, i8** %9
%53 = load i32, i32* %5
%54 = call i32 @log2mem_append_int(i8* %52, i32 %53)
%55 = load i8*, i8** %9
%56 = call i32 @log2mem_append_str(i8* %55, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
@.str = [14 x i8] c"starting loop\00"
@.str.1 = [153 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/darrenjs/log2mem/refs/heads/master/examples/interact/example.c\00"
@.str.2 = [12 x i8] c"ending loop\00"
@.str.3 = [11 x i8] c"loop name:\00"
@.str.4 = [16 x i8] c"completed after\00"
@.str.5 = [11 x i8] c"iterations\00"
define void @loop(i8* %0) {
%2 = alloca %struct.timeval
%3 = tail call i32 @log2mem_write(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([153 x i8], [153 x i8]* @.str.1, i64 0, i64 0), i32 54)
%4 = bitcast %struct.timeval* %2 to i8*
%5 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 1
br label %7
7: ; preds = %1, %7
%8 = phi float [ 0x3FF19999A0000000, %1 ], [ %12, %7 ]
%9 = phi i32 [ 0, %1 ], [ %24, %7 ]
%10 = fpext float %8 to double
%11 = fadd double %10, 1.120000e+00
%12 = fptrunc double %11 to float
%13 = call i32 @gettimeofday(%struct.timeval* %2, i32 0)
%14 = load i32, i32* %5
%15 = mul nsw i32 %14, 1000000
%16 = load i32, i32* %6
%17 = add nsw i32 %15, %16
%18 = sext i32 %17 to i64
%19 = call i8* @log2mem_get_row(i8* getelementptr inbounds ([153 x i8], [153 x i8]* @.str.1, i64 0, i64 0), i32 73)
%20 = call i32 @log2mem_append_long(i8* %19, i64 %18)
%21 = and i32 %9, 7
%22 = call i32 @log2mem_var_double_set(i32 %21, float %12)
%23 = call i32 @log2mem_counter_incr(i32 0)
%24 = add nuw nsw i32 %9, 1
%25 = icmp eq i32 %24, 50
br i1 %25, label %26, label %7
26: ; preds = %7
%27 = call i32 @log2mem_write(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([153 x i8], [153 x i8]* @.str.1, i64 0, i64 0), i32 82)
%28 = call i32 @sleep(i32 4)
%29 = call i8* @log2mem_get_row(i8* getelementptr inbounds ([153 x i8], [153 x i8]* @.str.1, i64 0, i64 0), i32 86)
%30 = call i32 @log2mem_append_str(i8* %29, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%31 = call i32 @log2mem_append_str(i8* %29, i8* %0)
%32 = call i32 @log2mem_append_str(i8* %29, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%33 = call i32 @log2mem_append_int(i8* %29, i32 50)
%34 = call i32 @log2mem_append_str(i8* %29, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
ret void
}