#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 timespec {
  int tv_sec;
  int tv_nsec;
};

/* Variables and functions */
int /*<<< orphan*/ CLOCK_REALTIME;
int clock_gettime(int /*<<< orphan*/, struct timespec *);
long long flu_gets(char level) {
  struct timespec ts;
  int r = clock_gettime(CLOCK_REALTIME, &ts);
  if (r != 0)
    return 0;
  if (level == 'n')
    return ts.tv_sec * 1000000000 + ts.tv_nsec;
  if (level == 'u')
    return ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
  if (level == 'm')
    return ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
  return ts.tv_sec;
}


x86 assembly (clang, -O0):
<flu_gets>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dil,%al
mov    %al,-0x9(%rbp)
mov    0x2ebb(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
call   1030 <clock_gettime@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     114a <flu_gets+0x3a>
movq   $0x0,-0x8(%rbp)
jmp    11dc <flu_gets+0xcc>
movsbl -0x9(%rbp),%eax
cmp    $0x6e,%eax
jne    116c <flu_gets+0x5c>
imul   $0x3b9aca00,-0x18(%rbp),%eax
add    -0x14(%rbp),%eax
cltq
mov    %rax,-0x8(%rbp)
jmp    11dc <flu_gets+0xcc>
movsbl -0x9(%rbp),%eax
cmp    $0x75,%eax
jne    11a0 <flu_gets+0x90>
imul   $0xf4240,-0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
add    %ecx,%eax
cltq
mov    %rax,-0x8(%rbp)
jmp    11dc <flu_gets+0xcc>
movsbl -0x9(%rbp),%eax
cmp    $0x6d,%eax
jne    11d4 <flu_gets+0xc4>
imul   $0x3e8,-0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%eax
mov    $0xf4240,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
add    %ecx,%eax
cltq
mov    %rax,-0x8(%rbp)
jmp    11dc <flu_gets+0xcc>
movslq -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<flu_gets>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
mov    0x2ec2(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
call   1030 <clock_gettime@plt>
test   %eax,%eax
je     1132 <flu_gets+0x22>
xor    %eax,%eax
jmp    11ad <flu_gets+0x9d>
cmp    $0x6d,%bl
je     1157 <flu_gets+0x47>
cmp    $0x75,%bl
je     117c <flu_gets+0x6c>
cmp    $0x6e,%bl
jne    11a8 <flu_gets+0x98>
movslq 0x8(%rsp),%rax
imul   $0x3b9aca00,%rax,%rcx
movslq 0xc(%rsp),%rax
add    %rcx,%rax
jmp    11ad <flu_gets+0x9d>
movslq 0x8(%rsp),%rax
imul   $0x3e8,%rax,%rcx
movslq 0xc(%rsp),%rax
imul   $0x431bde83,%rax,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x32,%rax
jmp    119f <flu_gets+0x8f>
movslq 0x8(%rsp),%rax
imul   $0xf4240,%rax,%rcx
movslq 0xc(%rsp),%rax
imul   $0x10624dd3,%rax,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rax
add    %edx,%eax
cltq
add    %rcx,%rax
jmp    11ad <flu_gets+0x9d>
movslq 0x8(%rsp),%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timespec = type { i32, i32 }
@CLOCK_REALTIME = global i32 0
define i64 @flu_gets(i8 signext %0) {
%2 = alloca i64
%3 = alloca i8
%4 = alloca %struct.timespec
%5 = alloca i32
store i8 %0, i8* %3
%6 = load i32, i32* @CLOCK_REALTIME
%7 = call i32 @clock_gettime(i32 %6, %struct.timespec* %4)
store i32 %7, i32* %5
%8 = load i32, i32* %5
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %1
store i64 0, i64* %2
br label %53
11: ; preds = %1
%12 = load i8, i8* %3
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 110
br i1 %14, label %15, label %23
15: ; preds = %11
%16 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i32 0, i32 0
%17 = load i32, i32* %16
%18 = mul nsw i32 %17, 1000000000
%19 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i32 0, i32 1
%20 = load i32, i32* %19
%21 = add nsw i32 %18, %20
%22 = sext i32 %21 to i64
store i64 %22, i64* %2
br label %53
23: ; preds = %11
%24 = load i8, i8* %3
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 117
br i1 %26, label %27, label %36
27: ; preds = %23
%28 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i32 0, i32 0
%29 = load i32, i32* %28
%30 = mul nsw i32 %29, 1000000
%31 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i32 0, i32 1
%32 = load i32, i32* %31
%33 = sdiv i32 %32, 1000
%34 = add nsw i32 %30, %33
%35 = sext i32 %34 to i64
store i64 %35, i64* %2
br label %53
36: ; preds = %23
%37 = load i8, i8* %3
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 109
br i1 %39, label %40, label %49
40: ; preds = %36
%41 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i32 0, i32 0
%42 = load i32, i32* %41
%43 = mul nsw i32 %42, 1000
%44 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i32 0, i32 1
%45 = load i32, i32* %44
%46 = sdiv i32 %45, 1000000
%47 = add nsw i32 %43, %46
%48 = sext i32 %47 to i64
store i64 %48, i64* %2
br label %53
49: ; preds = %36
%50 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i32 0, i32 0
%51 = load i32, i32* %50
%52 = sext i32 %51 to i64
store i64 %52, i64* %2
br label %53
53: ; preds = %49, %40, %27, %15, %10
%54 = load i64, i64* %2
ret i64 %54
}

LLVM IR (-O2):
%struct.timespec = type { i32, i32 }
@CLOCK_REALTIME = global i32 0
define i64 @flu_gets(i8 signext %0) {
%2 = alloca %struct.timespec
%3 = bitcast %struct.timespec* %2 to i8*
%4 = load i32, i32* @CLOCK_REALTIME
%5 = call i32 @clock_gettime(i32 %4, %struct.timespec* %2)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %38
7: ; preds = %1
switch i8 %0, label %34 [
i8 110, label %8
i8 117, label %16
i8 109, label %25
]
8: ; preds = %7
%9 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 0
%10 = load i32, i32* %9
%11 = mul nsw i32 %10, 1000000000
%12 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 1
%13 = load i32, i32* %12
%14 = add nsw i32 %11, %13
%15 = sext i32 %14 to i64
br label %38
16: ; preds = %7
%17 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 0
%18 = load i32, i32* %17
%19 = mul nsw i32 %18, 1000000
%20 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 1
%21 = load i32, i32* %20
%22 = sdiv i32 %21, 1000
%23 = add nsw i32 %22, %19
%24 = sext i32 %23 to i64
br label %38
25: ; preds = %7
%26 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 0
%27 = load i32, i32* %26
%28 = mul nsw i32 %27, 1000
%29 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 1
%30 = load i32, i32* %29
%31 = sdiv i32 %30, 1000000
%32 = add nsw i32 %31, %28
%33 = sext i32 %32 to i64
br label %38
34: ; preds = %7
%35 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 0
%36 = load i32, i32* %35
%37 = sext i32 %36 to i64
br label %38
38: ; preds = %1, %34, %25, %16, %8
%39 = phi i64 [ %15, %8 ], [ %24, %16 ], [ %33, %25 ], [ %37, %34 ], [ 0, %1 ]
ret i64 %39
}