#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 _atoi(char *, int);
char *getenv(char *);
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/, int /*<<< orphan*/,
                          int /*<<< orphan*/, ...);
int /*<<< orphan*/ rand();
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  char *_entries = getenv("ENTRIES");
  char *_r_typea = getenv("R_TYPEA");
  char *_r_typeb = getenv("R_TYPEB");
  char *_r_typec = getenv("R_TYPEC");
  int entries = _atoi(_entries, 10);
  int r_typea = _atoi(_r_typea, 1);
  int r_typeb = _atoi(_r_typeb, 1);
  int r_typec = _atoi(_r_typec, 1);
  for (int i = 0; i < entries; i++) {
    if ((r_typea > 0) && (i % r_typea == 0)) {
      printf("{type: 'A', timestamp: %lu, metric_a: %u, metric_b: %u}\n",
             time(NULL), rand(), rand());
    }
    if ((r_typeb > 0) && (i % r_typeb == 0)) {
      printf("{type: 'B', timestamp: %lu, metric_a: %u, metric_c: %u, extra: "
             "{cnt: %u, metric_d: %u}}\n",
             time(NULL), rand(), rand(), i, rand());
    }
    if ((r_typec > 0) && (i % r_typec == 0)) {
      printf("{type: 'C', timestamp: %lu, metric_a: %u, metric_e: %u, "
             "metric_f: %u}\n",
             time(NULL), rand(), rand(), rand());
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
lea    0xe92(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x18(%rbp)
lea    0xe8a(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x20(%rbp)
lea    0xe82(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0xa,%esi
call   1040 <_atoi@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x1,%esi
call   1040 <_atoi@plt>
mov    %eax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x1,%esi
call   1040 <_atoi@plt>
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%rdi
mov    $0x1,%esi
call   1040 <_atoi@plt>
mov    %eax,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    1316 <main+0x1c6>
cmpl   $0x0,-0x30(%rbp)
jle    1243 <main+0xf3>
mov    -0x3c(%rbp),%eax
cltd
idivl  -0x30(%rbp)
cmp    $0x0,%edx
jne    1243 <main+0xf3>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,-0x44(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
mov    %eax,-0x40(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
mov    -0x44(%rbp),%esi
mov    -0x40(%rbp),%edx
mov    %eax,%ecx
lea    0xde4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x0,-0x34(%rbp)
jle    12a8 <main+0x158>
mov    -0x3c(%rbp),%eax
cltd
idivl  -0x34(%rbp)
cmp    $0x0,%edx
jne    12a8 <main+0x158>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,-0x54(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
mov    %eax,-0x50(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x3c(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
mov    -0x54(%rbp),%esi
mov    -0x50(%rbp),%edx
mov    -0x4c(%rbp),%ecx
mov    -0x48(%rbp),%r8d
mov    %eax,%r9d
lea    0xdb8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x0,-0x38(%rbp)
jle    1303 <main+0x1b3>
mov    -0x3c(%rbp),%eax
cltd
idivl  -0x38(%rbp)
cmp    $0x0,%edx
jne    1303 <main+0x1b3>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,-0x60(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
mov    %eax,-0x5c(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
mov    %eax,-0x58(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
mov    -0x60(%rbp),%esi
mov    -0x5c(%rbp),%edx
mov    -0x58(%rbp),%ecx
mov    %eax,%r8d
lea    0xdb6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1308 <main+0x1b8>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11ea <main+0x9a>
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe9e(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rbx
lea    0xe97(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rbp
lea    0xe90(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%r12
lea    0xe89(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%r13
mov    %rbx,%rdi
mov    $0xa,%esi
call   1040 <_atoi@plt>
mov    %eax,%ebx
mov    %rbp,%rdi
mov    $0x1,%esi
call   1040 <_atoi@plt>
mov    %eax,%ebp
mov    %r12,%rdi
mov    %ebx,%r12d
mov    $0x1,%esi
call   1040 <_atoi@plt>
mov    %eax,%ebx
mov    %r13,%rdi
mov    $0x1,%esi
call   1040 <_atoi@plt>
test   %r12d,%r12d
jle    131f <main+0x1cf>
mov    %eax,%r15d
xor    %r13d,%r13d
mov    %ebp,0x4(%rsp)
mov    %ebx,(%rsp)
jmp    11fd <main+0xad>
nopl   0x0(%rax)
add    $0x1,%r13d
cmp    %r13d,%r12d
je     131f <main+0x1cf>
test   %ebp,%ebp
jle    120b <main+0xbb>
mov    %r13d,%eax
cltd
idiv   %ebp
test   %edx,%edx
je     1270 <main+0x120>
test   %ebx,%ebx
jle    12c0 <main+0x170>
mov    %r13d,%eax
cltd
idiv   %ebx
test   %edx,%edx
jne    12c0 <main+0x170>
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%r14d
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1070 <rand@plt>
lea    0xe0e(%rip),%rdi
mov    %r14d,%esi
mov    %ebp,%edx
mov    0x4(%rsp),%ebp
mov    %ebx,%ecx
mov    (%rsp),%ebx
mov    %r13d,%r8d
mov    %eax,%r9d
xor    %eax,%eax
call   1050 <printf@plt>
jmp    12c0 <main+0x170>
nopl   0x0(%rax,%rax,1)
xor    %edi,%edi
call   1060 <time@plt>
mov    %r12d,%ebx
mov    %eax,%r12d
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%r14d
xor    %eax,%eax
call   1070 <rand@plt>
lea    0xd8b(%rip),%rdi
mov    %r12d,%esi
mov    %ebx,%r12d
mov    (%rsp),%ebx
mov    %r14d,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
test   %ebx,%ebx
jg     1213 <main+0xc3>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
test   %r15d,%r15d
jle    11f0 <main+0xa0>
mov    %r13d,%eax
cltd
idiv   %r15d
test   %edx,%edx
jne    11f0 <main+0xa0>
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%r14d
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1070 <rand@plt>
lea    0xdb0(%rip),%rdi
mov    %r14d,%esi
mov    %ebp,%edx
mov    0x4(%rsp),%ebp
mov    %ebx,%ecx
mov    (%rsp),%ebx
mov    %eax,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11f0 <main+0xa0>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"ENTRIES\00"
@.str.1 = [8 x i8] c"R_TYPEA\00"
@.str.2 = [8 x i8] c"R_TYPEB\00"
@.str.3 = [8 x i8] c"R_TYPEC\00"
@.str.4 = [57 x i8] c"{type: 'A', timestamp: %lu, metric_a: %u, metric_b: %u}\0A\00"
@.str.5 = [89 x i8] c"{type: 'B', timestamp: %lu, metric_a: %u, metric_c: %u, extra: {cnt: %u, metric_d: %u}}\0A\00"
@.str.6 = [71 x i8] c"{type: 'C', timestamp: %lu, metric_a: %u, metric_e: %u, metric_f: %u}\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %1
%11 = call i8* @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i8* %11, i8** %2
%12 = call i8* @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
store i8* %12, i8** %3
%13 = call i8* @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
store i8* %13, i8** %4
%14 = call i8* @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
store i8* %14, i8** %5
%15 = load i8*, i8** %2
%16 = call i32 @_atoi(i8* %15, i32 10)
store i32 %16, i32* %6
%17 = load i8*, i8** %3
%18 = call i32 @_atoi(i8* %17, i32 1)
store i32 %18, i32* %7
%19 = load i8*, i8** %4
%20 = call i32 @_atoi(i8* %19, i32 1)
store i32 %20, i32* %8
%21 = load i8*, i8** %5
%22 = call i32 @_atoi(i8* %21, i32 1)
store i32 %22, i32* %9
store i32 0, i32* %10
br label %23
23: ; preds = %70, %0
%24 = load i32, i32* %10
%25 = load i32, i32* %6
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %73
27: ; preds = %23
%28 = load i32, i32* %7
%29 = icmp sgt i32 %28, 0
br i1 %29, label %30, label %40
30: ; preds = %27
%31 = load i32, i32* %10
%32 = load i32, i32* %7
%33 = srem i32 %31, %32
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %40
35: ; preds = %30
%36 = call i32 @time(i32* null)
%37 = call i32 (...) @rand()
%38 = call i32 (...) @rand()
%39 = call i32 (i8*, i32, i32, i32, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.4, i64 0, i64 0), i32 %36, i32 %37, i32 %38)
br label %40
40: ; preds = %35, %30, %27
%41 = load i32, i32* %8
%42 = icmp sgt i32 %41, 0
br i1 %42, label %43, label %55
43: ; preds = %40
%44 = load i32, i32* %10
%45 = load i32, i32* %8
%46 = srem i32 %44, %45
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %55
48: ; preds = %43
%49 = call i32 @time(i32* null)
%50 = call i32 (...) @rand()
%51 = call i32 (...) @rand()
%52 = load i32, i32* %10
%53 = call i32 (...) @rand()
%54 = call i32 (i8*, i32, i32, i32, ...) @printf(i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str.5, i64 0, i64 0), i32 %49, i32 %50, i32 %51, i32 %52, i32 %53)
br label %55
55: ; preds = %48, %43, %40
%56 = load i32, i32* %9
%57 = icmp sgt i32 %56, 0
br i1 %57, label %58, label %69
58: ; preds = %55
%59 = load i32, i32* %10
%60 = load i32, i32* %9
%61 = srem i32 %59, %60
%62 = icmp eq i32 %61, 0
br i1 %62, label %63, label %69
63: ; preds = %58
%64 = call i32 @time(i32* null)
%65 = call i32 (...) @rand()
%66 = call i32 (...) @rand()
%67 = call i32 (...) @rand()
%68 = call i32 (i8*, i32, i32, i32, ...) @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.6, i64 0, i64 0), i32 %64, i32 %65, i32 %66, i32 %67)
br label %69
69: ; preds = %63, %58, %55
br label %70
70: ; preds = %69
%71 = load i32, i32* %10
%72 = add nsw i32 %71, 1
store i32 %72, i32* %10
br label %23
73: ; preds = %23
%74 = load i32, i32* %1
ret i32 %74
}

LLVM IR (-O2):
@.str = [8 x i8] c"ENTRIES\00"
@.str.1 = [8 x i8] c"R_TYPEA\00"
@.str.2 = [8 x i8] c"R_TYPEB\00"
@.str.3 = [8 x i8] c"R_TYPEC\00"
@.str.4 = [57 x i8] c"{type: 'A', timestamp: %lu, metric_a: %u, metric_b: %u}\0A\00"
@.str.5 = [89 x i8] c"{type: 'B', timestamp: %lu, metric_a: %u, metric_c: %u, extra: {cnt: %u, metric_d: %u}}\0A\00"
@.str.6 = [71 x i8] c"{type: 'C', timestamp: %lu, metric_a: %u, metric_e: %u, metric_f: %u}\0A\00"
define i32 @main() {
%1 = tail call i8* @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%2 = tail call i8* @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i8* @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%4 = tail call i8* @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%5 = tail call i32 @_atoi(i8* %1, i32 10)
%6 = tail call i32 @_atoi(i8* %2, i32 1)
%7 = tail call i32 @_atoi(i8* %3, i32 1)
%8 = tail call i32 @_atoi(i8* %4, i32 1)
%9 = icmp sgt i32 %5, 0
br i1 %9, label %10, label %14
10: ; preds = %0
%11 = icmp sgt i32 %6, 0
%12 = icmp sgt i32 %7, 0
%13 = icmp sgt i32 %8, 0
br label %15
14: ; preds = %45, %0
ret i32 0
15: ; preds = %10, %45
%16 = phi i32 [ 0, %10 ], [ %46, %45 ]
br i1 %11, label %17, label %25
17: ; preds = %15
%18 = srem i32 %16, %6
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %17
%21 = tail call i32 @time(i32* null)
%22 = tail call i32 (...) @rand()
%23 = tail call i32 (...) @rand()
%24 = tail call i32 (i8*, i32, i32, i32, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.4, i64 0, i64 0), i32 %21, i32 %22, i32 %23)
br label %25
25: ; preds = %20, %17, %15
br i1 %12, label %26, label %35
26: ; preds = %25
%27 = srem i32 %16, %7
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %35
29: ; preds = %26
%30 = tail call i32 @time(i32* null)
%31 = tail call i32 (...) @rand()
%32 = tail call i32 (...) @rand()
%33 = tail call i32 (...) @rand()
%34 = tail call i32 (i8*, i32, i32, i32, ...) @printf(i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str.5, i64 0, i64 0), i32 %30, i32 %31, i32 %32, i32 %16, i32 %33)
br label %35
35: ; preds = %29, %26, %25
br i1 %13, label %36, label %45
36: ; preds = %35
%37 = srem i32 %16, %8
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %45
39: ; preds = %36
%40 = tail call i32 @time(i32* null)
%41 = tail call i32 (...) @rand()
%42 = tail call i32 (...) @rand()
%43 = tail call i32 (...) @rand()
%44 = tail call i32 (i8*, i32, i32, i32, ...) @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.6, i64 0, i64 0), i32 %40, i32 %41, i32 %42, i32 %43)
br label %45
45: ; preds = %35, %36, %39
%46 = add nuw nsw i32 %16, 1
%47 = icmp eq i32 %46, %5
br i1 %47, label %14, label %15
}