#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 dummy;
};

/* Variables and functions */
int /*<<< orphan*/ auto_run_process();
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
long msec_passed(struct timeval *, struct timeval *);
int /*<<< orphan*/ sleep(int);
void *timer_loop(void *arg) {
  struct timeval previous_time_loop, current_time_loop;
  long msec_elapsed;
  while (1) {
    gettimeofday(&previous_time_loop, NULL);
    sleep(1);
    gettimeofday(&current_time_loop, NULL);
    msec_elapsed = msec_passed(&previous_time_loop, &current_time_loop);
    if (msec_elapsed > (1 * 1000 + 300))
      auto_run_process();
  }
}


x86 assembly (clang, -O0):
<timer_loop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
lea    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <msec_passed@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x514,-0x20(%rbp)
jle    1196 <timer_loop+0x56>
mov    $0x0,%al
call   1050 <auto_run_process@plt>
jmp    114c <timer_loop+0xc>

x86 assembly (clang, -O2):
<timer_loop>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0x10(%rsp),%r14
lea    0x8(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <msec_passed@plt>
cmp    $0x515,%rax
jl     1160 <timer_loop+0x20>
xor    %eax,%eax
call   1050 <auto_run_process@plt>
jmp    1160 <timer_loop+0x20>

LLVM IR (-O0):
%struct.timeval = type { i32 }
define i8* @timer_loop(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.timeval
%4 = alloca %struct.timeval
%5 = alloca i64
store i8* %0, i8** %2
br label %6
6: ; preds = %1, %15
%7 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%8 = call i32 @sleep(i32 1)
%9 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%10 = call i64 @msec_passed(%struct.timeval* %3, %struct.timeval* %4)
store i64 %10, i64* %5
%11 = load i64, i64* %5
%12 = icmp sgt i64 %11, 1300
br i1 %12, label %13, label %15
13: ; preds = %6
%14 = call i32 (...) @auto_run_process()
br label %15
15: ; preds = %13, %6
br label %6
}

LLVM IR (-O2):
%struct.timeval = type { i32 }
define noalias i8* @timer_loop(i8* nocapture readnone %0) {
%2 = alloca %struct.timeval
%3 = alloca %struct.timeval
%4 = bitcast %struct.timeval* %2 to i8*
%5 = bitcast %struct.timeval* %3 to i8*
br label %6
6: ; preds = %14, %1
%7 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%8 = call i32 @sleep(i32 1)
%9 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%10 = call i64 @msec_passed(%struct.timeval* %2, %struct.timeval* %3)
%11 = icmp sgt i64 %10, 1300
br i1 %11, label %12, label %14
12: ; preds = %6
%13 = call i32 (...) @auto_run_process()
br label %14
14: ; preds = %12, %6
br label %6
}