#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_usec;
  scalar_t__ tv_sec;
};

/* Variables and functions */
int score_lvl();
void calculate_speed(struct timeval *v) {
  v->tv_sec = 0 - score_lvl() * 0;
  v->tv_usec = 500000 - score_lvl() * 100000;
  if (v->tv_sec < 0)
    v->tv_sec = 0;
  if (v->tv_usec < 100000)
    v->tv_usec = 100000;
}


x86 assembly (clang, -O0):
<calculate_speed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1030 <score_lvl@plt>
imul   $0x0,%eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
movslq %eax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    $0x0,%al
call   1030 <score_lvl@plt>
imul   $0x186a0,%eax,%eax
mov    $0x7a120,%ecx
sub    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
cmpq   $0x0,0x8(%rax)
jge    116a <calculate_speed+0x5a>
mov    -0x8(%rbp),%rax
movq   $0x0,0x8(%rax)
mov    -0x8(%rbp),%rax
cmpl   $0x186a0,(%rax)
jge    1184 <calculate_speed+0x74>
mov    -0x8(%rbp),%rax
movl   $0x186a0,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calculate_speed>:
push   %rbx
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <score_lvl@plt>
movq   $0x0,0x8(%rbx)
xor    %eax,%eax
call   1030 <score_lvl@plt>
imul   $0xfffe7960,%eax,%eax
add    $0x7a120,%eax
mov    %eax,(%rbx)
cmpq   $0x0,0x8(%rbx)
js     1147 <calculate_speed+0x37>
cmp    $0x1869f,%eax
jle    1156 <calculate_speed+0x46>
pop    %rbx
ret
movq   $0x0,0x8(%rbx)
cmp    $0x1869f,%eax
jg     1145 <calculate_speed+0x35>
movl   $0x186a0,(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i64 }
define void @calculate_speed(%struct.timeval* %0) {
%2 = alloca %struct.timeval*
store %struct.timeval* %0, %struct.timeval** %2
%3 = call i32 (...) @score_lvl()
%4 = mul nsw i32 %3, 0
%5 = sub nsw i32 0, %4
%6 = sext i32 %5 to i64
%7 = load %struct.timeval*, %struct.timeval** %2
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 1
store i64 %6, i64* %8
%9 = call i32 (...) @score_lvl()
%10 = mul nsw i32 %9, 100000
%11 = sub nsw i32 500000, %10
%12 = load %struct.timeval*, %struct.timeval** %2
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 0
store i32 %11, i32* %13
%14 = load %struct.timeval*, %struct.timeval** %2
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 1
%16 = load i64, i64* %15
%17 = icmp slt i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %1
%19 = load %struct.timeval*, %struct.timeval** %2
%20 = getelementptr inbounds %struct.timeval, %struct.timeval* %19, i32 0, i32 1
store i64 0, i64* %20
br label %21
21: ; preds = %18, %1
%22 = load %struct.timeval*, %struct.timeval** %2
%23 = getelementptr inbounds %struct.timeval, %struct.timeval* %22, i32 0, i32 0
%24 = load i32, i32* %23
%25 = icmp slt i32 %24, 100000
br i1 %25, label %26, label %29
26: ; preds = %21
%27 = load %struct.timeval*, %struct.timeval** %2
%28 = getelementptr inbounds %struct.timeval, %struct.timeval* %27, i32 0, i32 0
store i32 100000, i32* %28
br label %29
29: ; preds = %26, %21
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i32, i64 }
define void @calculate_speed(%struct.timeval* nocapture %0) {
%2 = tail call i32 (...) @score_lvl()
%3 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 1
store i64 0, i64* %3
%4 = tail call i32 (...) @score_lvl()
%5 = mul i32 %4, -100000
%6 = add i32 %5, 500000
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 0
store i32 %6, i32* %7
%8 = load i64, i64* %3
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %1
store i64 0, i64* %3
br label %11
11: ; preds = %10, %1
%12 = icmp slt i32 %6, 100000
br i1 %12, label %13, label %14
13: ; preds = %11
store i32 100000, i32* %7
br label %14
14: ; preds = %13, %11
ret void
}