#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 {
  long tv_sec;
  long tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int select(int /*<<< orphan*/, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, struct timeval *);
int main(void) {
  int srv;
  long waittime = 4096;
  struct timeval tv;
  printf("Start\n");
  while ((waittime > 0) && (waittime < 3000000)) {
    printf("%d\n", waittime);
    tv.tv_sec = waittime / 1000000;
    tv.tv_usec = waittime % 1000000;
    waittime <<= 1;
    srv = select(0, NULL, NULL, NULL, &tv);
  }
  printf("End\n");
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x1000,-0x10(%rbp)
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x21(%rbp)
jle    1173 <main+0x43>
cmpq   $0x2dc6c0,-0x10(%rbp)
setl   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1183 <main+0x53>
jmp    11e2 <main+0xb2>
mov    -0x10(%rbp),%rsi
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    $0xf4240,%ecx
cqto
idiv   %rcx
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    $0xf4240,%ecx
cqto
idiv   %rcx
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
shl    $0x1,%rax
mov    %rax,-0x10(%rbp)
xor    %edi,%edi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x20(%rbp),%r8
mov    %rcx,%rsi
mov    %rcx,%rdx
call   1040 <select@plt>
mov    %eax,-0x8(%rbp)
jmp    1155 <main+0x25>
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xeb2(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1000,%ebx
lea    0xe9d(%rip),%r14
lea    0x8(%rsp),%r15
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%eax
imul   $0x431bde83,%rax,%rax
shr    $0x32,%rax
mov    %rax,0x8(%rsp)
imul   $0xf4240,%eax,%eax
mov    %ebx,%ecx
sub    %eax,%ecx
mov    %rcx,0x10(%rsp)
lea    (%rbx,%rbx,1),%r12
xor    %edi,%edi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %r15,%r8
call   1050 <select@plt>
lea    (%rbx,%rbx,1),%rax
add    $0xffffffffffffffff,%rax
mov    %r12,%rbx
cmp    $0x2dc6bf,%rax
jb     1170 <main+0x30>
lea    0xe3e(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
@.str = [7 x i8] c"Start\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [5 x i8] c"End\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i64
%4 = alloca %struct.timeval
store i32 0, i32* %1
store i64 4096, i64* %3
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %14, %0
%7 = load i64, i64* %3
%8 = icmp sgt i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = load i64, i64* %3
%11 = icmp slt i64 %10, 3000000
br label %12
12: ; preds = %9, %6
%13 = phi i1 [ false, %6 ], [ %11, %9 ]
br i1 %13, label %14, label %26
14: ; preds = %12
%15 = load i64, i64* %3
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %15)
%17 = load i64, i64* %3
%18 = sdiv i64 %17, 1000000
%19 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 0
store i64 %18, i64* %19
%20 = load i64, i64* %3
%21 = srem i64 %20, 1000000
%22 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 1
store i64 %21, i64* %22
%23 = load i64, i64* %3
%24 = shl i64 %23, 1
store i64 %24, i64* %3
%25 = call i32 @select(i32 0, i32* null, i32* null, i32* null, %struct.timeval* %4)
store i32 %25, i32* %2
br label %6
26: ; preds = %12
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%28 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
@.str.1 = [4 x i8] c"%d\0A\00"
@str = [6 x i8] c"Start\00"
@str.3 = [4 x i8] c"End\00"
define i32 @main() {
%1 = alloca %struct.timeval
%2 = bitcast %struct.timeval* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
%4 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%5 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
br label %6
6: ; preds = %0, %6
%7 = phi i64 [ 4096, %0 ], [ %14, %6 ]
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %7)
%9 = trunc i64 %7 to i32
%10 = udiv i32 %9, 1000000
%11 = zext i32 %10 to i64
store i64 %11, i64* %4
%12 = urem i32 %9, 1000000
%13 = zext i32 %12 to i64
store i64 %13, i64* %5
%14 = shl nuw nsw i64 %7, 1
%15 = call i32 @select(i32 0, i32* null, i32* null, i32* null, %struct.timeval* %1)
%16 = add nsw i64 %14, -1
%17 = icmp ult i64 %16, 2999999
br i1 %17, label %6, label %18
18: ; preds = %6
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.3, i64 0, i64 0))
%20 = call i32 @exit(i32 0)
unreachable
}