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

/* Variables and functions */
int gettimeofday(struct timeval *, int /*<<< orphan*/);
void now(struct timeval *t) {
  int timeout = 0;
  t->tv_sec = -1;
  t->tv_usec = 0;
  while (gettimeofday(t, 0) == -1 && timeout < 10)
    timeout++;
}


x86 assembly (clang, -O0):
<now>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movl   $0xffffffff,(%rax)
mov    -0x8(%rbp),%rax
movq   $0x0,0x8(%rax)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xffffffff,%ecx
mov    %al,-0xd(%rbp)
jne    115e <now+0x4e>
cmpl   $0xa,-0xc(%rbp)
setl   %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    116e <now+0x5e>
jmp    117c <now+0x6c>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1139 <now+0x29>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<now>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
movl   $0xffffffff,(%rdi)
movq   $0x0,0x8(%rdi)
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
cmp    $0xffffffff,%eax
jne    1149 <now+0x39>
lea    0x1(%rbx),%eax
cmp    $0xa,%ebx
mov    %eax,%ebx
jb     1130 <now+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i64 }
define void @now(%struct.timeval* %0) {
%2 = alloca %struct.timeval*
%3 = alloca i32
store %struct.timeval* %0, %struct.timeval** %2
store i32 0, i32* %3
%4 = load %struct.timeval*, %struct.timeval** %2
%5 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 0
store i32 -1, i32* %5
%6 = load %struct.timeval*, %struct.timeval** %2
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
store i64 0, i64* %7
br label %8
8: ; preds = %17, %1
%9 = load %struct.timeval*, %struct.timeval** %2
%10 = call i32 @gettimeofday(%struct.timeval* %9, i32 0)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %15
12: ; preds = %8
%13 = load i32, i32* %3
%14 = icmp slt i32 %13, 10
br label %15
15: ; preds = %12, %8
%16 = phi i1 [ false, %8 ], [ %14, %12 ]
br i1 %16, label %17, label %20
17: ; preds = %15
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
store i32 %19, i32* %3
br label %8
20: ; preds = %15
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i32, i64 }
define void @now(%struct.timeval* %0) {
%2 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 0
store i32 -1, i32* %2
%3 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 1
store i64 0, i64* %3
br label %4
4: ; preds = %4, %1
%5 = phi i32 [ 0, %1 ], [ %10, %4 ]
%6 = tail call i32 @gettimeofday(%struct.timeval* %0, i32 0)
%7 = icmp eq i32 %6, -1
%8 = icmp ult i32 %5, 10
%9 = select i1 %7, i1 %8, i1 false
%10 = add nuw nsw i32 %5, 1
br i1 %9, label %4, label %11
11: ; preds = %4
ret void
}