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

/* Variables and functions */
int /*<<< orphan*/ exit(int);
long ftime(struct timeb *);
int /*<<< orphan*/ printf(char *, long);
int /*<<< orphan*/ test_end();
int /*<<< orphan*/ test_start();
int main(void) {
  struct timeb t;
  long i;
  unsigned long long v;
  i = ftime(&t);
  if (i < 0) {
    printf("error with ftime! (%li)\n", i);
    exit(1);
  } else {
  }
  test_start();
  for (i = 0; i < 500000000; i++) {
    ftime(&t);
  }
  test_end();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1070 <ftime@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jge    1191 <main+0x41>
mov    -0x10(%rbp),%rsi
lea    0xe7e(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
jmp    1196 <main+0x46>
mov    $0x0,%al
call   1040 <test_start@plt>
movq   $0x0,-0x10(%rbp)
cmpq   $0x1dcd6500,-0x10(%rbp)
1d
jge    11cd <main+0x7d>
lea    -0x8(%rbp),%rdi
call   1070 <ftime@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11a5 <main+0x55>
mov    $0x0,%al
call   1050 <test_end@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    %rsp,%rdi
call   1070 <ftime@plt>
test   %rax,%rax
js     118f <main+0x3f>
xor    %eax,%eax
call   1040 <test_start@plt>
mov    $0x1dcd6500,%ebx
mov    %rsp,%r14
mov    %r14,%rdi
call   1070 <ftime@plt>
add    $0xffffffffffffffff,%rbx
jne    1170 <main+0x20>
xor    %eax,%eax
call   1050 <test_end@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe6a(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.timeb = type { i32 }
@.str = [25 x i8] c"error with ftime! (%li)\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.timeb
%3 = alloca i64
%4 = alloca i64
store i32 0, i32* %1
%5 = call i64 @ftime(%struct.timeb* %2)
store i64 %5, i64* %3
%6 = load i64, i64* %3
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %0
%9 = load i64, i64* %3
%10 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i64 %9)
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %0
br label %13
13: ; preds = %12
%14 = call i32 (...) @test_start()
store i64 0, i64* %3
br label %15
15: ; preds = %20, %13
%16 = load i64, i64* %3
%17 = icmp slt i64 %16, 500000000
br i1 %17, label %18, label %23
18: ; preds = %15
%19 = call i64 @ftime(%struct.timeb* %2)
br label %20
20: ; preds = %18
%21 = load i64, i64* %3
%22 = add nsw i64 %21, 1
store i64 %22, i64* %3
br label %15
23: ; preds = %15
%24 = call i32 (...) @test_end()
ret i32 0
}

LLVM IR (-O2):
%struct.timeb = type { i32 }
@.str = [25 x i8] c"error with ftime! (%li)\0A\00"
define i32 @main() {
%1 = alloca %struct.timeb
%2 = bitcast %struct.timeb* %1 to i8*
%3 = call i64 @ftime(%struct.timeb* %1)
%4 = icmp slt i64 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i64 %3)
%7 = call i32 @exit(i32 1)
unreachable
8: ; preds = %0
%9 = call i32 (...) @test_start()
br label %10
10: ; preds = %8, %10
%11 = phi i64 [ 0, %8 ], [ %13, %10 ]
%12 = call i64 @ftime(%struct.timeb* %1)
%13 = add nuw nsw i64 %11, 1
%14 = icmp eq i64 %13, 500000000
br i1 %14, label %15, label %10
15: ; preds = %10
%16 = call i32 (...) @test_end()
ret i32 0
}