#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*/ assert(int);
int /*<<< orphan*/ timespec_from_ms(struct timespec *, int);
void test_ms_timespec(void) {
  struct timespec a;
  timespec_from_ms(&a, 1000);
  assert(a.tv_sec == 1);
  assert(a.tv_nsec == 0);
  ;
  timespec_from_ms(&a, 1);
  assert(a.tv_sec == 0);
  assert(a.tv_nsec == 1000000);
  ;
  timespec_from_ms(&a, 99999);
  assert(a.tv_sec == 99);
  assert(a.tv_nsec == 999000000);
  ;
}


x86 assembly (clang, -O0):
<test_ms_timespec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x8(%rbp),%rdi
mov    $0x3e8,%esi
call   1040 <timespec_from_ms@plt>
cmpl   $0x1,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x0,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    -0x8(%rbp),%rdi
mov    $0x1,%esi
call   1040 <timespec_from_ms@plt>
cmpl   $0x0,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0xf4240,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    -0x8(%rbp),%rdi
mov    $0x1869f,%esi
call   1040 <timespec_from_ms@plt>
cmpl   $0x63,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x3b8b87c0,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_ms_timespec>:
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x3e8,%esi
call   1040 <timespec_from_ms@plt>
xor    %edi,%edi
cmpl   $0x1,0x8(%rsp)
sete   %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmpl   $0x0,0xc(%rsp)
sete   %dil
call   1030 <assert@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1040 <timespec_from_ms@plt>
xor    %edi,%edi
cmpl   $0x0,0x8(%rsp)
sete   %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmpl   $0xf4240,0xc(%rsp)
sete   %dil
call   1030 <assert@plt>
mov    %rbx,%rdi
mov    $0x1869f,%esi
call   1040 <timespec_from_ms@plt>
xor    %edi,%edi
cmpl   $0x63,0x8(%rsp)
sete   %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmpl   $0x3b8b87c0,0xc(%rsp)
3b
sete   %dil
call   1030 <assert@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timespec = type { i32, i32 }
define void @test_ms_timespec() {
%1 = alloca %struct.timespec
%2 = call i32 @timespec_from_ms(%struct.timespec* %1, i32 1000)
%3 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 0
%4 = load i32, i32* %3
%5 = icmp eq i32 %4, 1
%6 = zext i1 %5 to i32
%7 = call i32 @assert(i32 %6)
%8 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 1
%9 = load i32, i32* %8
%10 = icmp eq i32 %9, 0
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = call i32 @timespec_from_ms(%struct.timespec* %1, i32 1)
%14 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 0
%15 = load i32, i32* %14
%16 = icmp eq i32 %15, 0
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 1
%20 = load i32, i32* %19
%21 = icmp eq i32 %20, 1000000
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = call i32 @timespec_from_ms(%struct.timespec* %1, i32 99999)
%25 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 0
%26 = load i32, i32* %25
%27 = icmp eq i32 %26, 99
%28 = zext i1 %27 to i32
%29 = call i32 @assert(i32 %28)
%30 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 1
%31 = load i32, i32* %30
%32 = icmp eq i32 %31, 999000000
%33 = zext i1 %32 to i32
%34 = call i32 @assert(i32 %33)
ret void
}

LLVM IR (-O2):
%struct.timespec = type { i32, i32 }
define void @test_ms_timespec() {
%1 = alloca %struct.timespec
%2 = bitcast %struct.timespec* %1 to i8*
%3 = call i32 @timespec_from_ms(%struct.timespec* %1, i32 1000)
%4 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 0
%5 = load i32, i32* %4
%6 = icmp eq i32 %5, 1
%7 = zext i1 %6 to i32
%8 = call i32 @assert(i32 %7)
%9 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 1
%10 = load i32, i32* %9
%11 = icmp eq i32 %10, 0
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = call i32 @timespec_from_ms(%struct.timespec* %1, i32 1)
%15 = load i32, i32* %4
%16 = icmp eq i32 %15, 0
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = load i32, i32* %9
%20 = icmp eq i32 %19, 1000000
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = call i32 @timespec_from_ms(%struct.timespec* %1, i32 99999)
%24 = load i32, i32* %4
%25 = icmp eq i32 %24, 99
%26 = zext i1 %25 to i32
%27 = call i32 @assert(i32 %26)
%28 = load i32, i32* %9
%29 = icmp eq i32 %28, 999000000
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
ret void
}