#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 */
typedef void *time_t;
struct timeb {
  scalar_t__ dstflag;
  scalar_t__ timezone;
  void *millitm;
  void *time;
};

/* Variables and functions */
int /*<<< orphan*/ os_freakout();
int os_system_time(void **, void **, int *);
int ftime(struct timeb *fb) {
  int rc;
  time_t sec;
  time_t milli;
  if (os_system_time(&sec, &milli, &rc) == -1)
    os_freakout();
  if (rc != 0)
    return -1;
  fb->time = sec;
  fb->millitm = milli;
  fb->timezone = 0;
  fb->dstflag = 0;
  return 0;
}


x86 assembly (clang, -O0):
<ftime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1030 <os_system_time@plt>
cmp    $0xffffffff,%eax
jne    114d <ftime+0x2d>
mov    $0x0,%al
call   1040 <os_freakout@plt>
cmpl   $0x0,-0x14(%rbp)
je     1163 <ftime+0x43>
movl   $0xffffffff,-0x4(%rbp)
jmp    1199 <ftime+0x79>
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x18(%rax)
mov    -0x28(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x10(%rax)
mov    -0x10(%rbp),%rax
movq   $0x0,0x8(%rax)
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ftime>:
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
lea    0x18(%rsp),%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   1030 <os_system_time@plt>
cmp    $0xffffffff,%eax
jne    1148 <ftime+0x28>
xor    %eax,%eax
call   1040 <os_freakout@plt>
mov    $0xffffffff,%eax
cmpl   $0x0,0xc(%rsp)
jne    116e <ftime+0x4e>
mov    0x18(%rsp),%rax
mov    %rax,0x18(%rbx)
mov    0x10(%rsp),%rax
mov    %rax,0x10(%rbx)
xorps  %xmm0,%xmm0
movups %xmm0,(%rbx)
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timeb = type { i64, i64, i8*, i8* }
define i32 @ftime(%struct.timeb* %0) {
%2 = alloca i32
%3 = alloca %struct.timeb*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
store %struct.timeb* %0, %struct.timeb** %3
%7 = call i32 @os_system_time(i8** %5, i8** %6, i32* %4)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = call i32 (...) @os_freakout()
br label %11
11: ; preds = %9, %1
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %11
store i32 -1, i32* %2
br label %26
15: ; preds = %11
%16 = load i8*, i8** %5
%17 = load %struct.timeb*, %struct.timeb** %3
%18 = getelementptr inbounds %struct.timeb, %struct.timeb* %17, i32 0, i32 3
store i8* %16, i8** %18
%19 = load i8*, i8** %6
%20 = load %struct.timeb*, %struct.timeb** %3
%21 = getelementptr inbounds %struct.timeb, %struct.timeb* %20, i32 0, i32 2
store i8* %19, i8** %21
%22 = load %struct.timeb*, %struct.timeb** %3
%23 = getelementptr inbounds %struct.timeb, %struct.timeb* %22, i32 0, i32 1
store i64 0, i64* %23
%24 = load %struct.timeb*, %struct.timeb** %3
%25 = getelementptr inbounds %struct.timeb, %struct.timeb* %24, i32 0, i32 0
store i64 0, i64* %25
store i32 0, i32* %2
br label %26
26: ; preds = %15, %14
%27 = load i32, i32* %2
ret i32 %27
}

LLVM IR (-O2):
%struct.timeb = type { i64, i64, i8*, i8* }
define i32 @ftime(%struct.timeb* nocapture writeonly %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i8** %3 to i8*
%7 = bitcast i8** %4 to i8*
%8 = call i32 @os_system_time(i8** %3, i8** %4, i32* %2)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = call i32 (...) @os_freakout()
br label %12
12: ; preds = %10, %1
%13 = load i32, i32* %2
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %21
15: ; preds = %12
%16 = load i8*, i8** %3
%17 = getelementptr inbounds %struct.timeb, %struct.timeb* %0, i64 0, i32 3
store i8* %16, i8** %17
%18 = load i8*, i8** %4
%19 = getelementptr inbounds %struct.timeb, %struct.timeb* %0, i64 0, i32 2
store i8* %18, i8** %19
%20 = bitcast %struct.timeb* %0 to i8*
br label %21
21: ; preds = %12, %15
%22 = phi i32 [ 0, %15 ], [ -1, %12 ]
ret i32 %22
}