#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_normalize(struct timespec *);
void test_normalize_timespec() {
  struct timespec a;
  a.tv_sec = 11;
  a.tv_nsec = 123456789;
  ;
  timespec_normalize(&a);
  assert(a.tv_sec == 11);
  assert(a.tv_nsec == 123456789);
  ;
  a.tv_sec = 10;
  a.tv_nsec = 1000000000;
  ;
  timespec_normalize(&a);
  assert(a.tv_sec == 11);
  assert(a.tv_nsec == 0);
  ;
  a.tv_sec = 10;
  a.tv_nsec = 2147483647;
  ;
  timespec_normalize(&a);
  assert(a.tv_sec == 12);
  assert(a.tv_nsec == 147483647);
  ;
  a.tv_sec = 10;
  a.tv_nsec = -1;
  ;
  timespec_normalize(&a);
  assert(a.tv_sec == 9);
  assert(a.tv_nsec == 999999999);
  ;
  a.tv_sec = 10;
  a.tv_nsec = -999999999;
  ;
  timespec_normalize(&a);
  assert(a.tv_sec == 9);
  assert(a.tv_nsec == 1);
  ;
  a.tv_sec = 10;
  a.tv_nsec = -2147483647;
  ;
  timespec_normalize(&a);
  assert(a.tv_sec == 7);
  assert(a.tv_nsec == 852516353);
  ;
}


x86 assembly (clang, -O0):
<test_normalize_timespec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0xb,-0x8(%rbp)
movl   $0x75bcd15,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1030 <timespec_normalize@plt>
cmpl   $0xb,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpl   $0x75bcd15,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movl   $0xa,-0x8(%rbp)
movl   $0x3b9aca00,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1030 <timespec_normalize@plt>
cmpl   $0xb,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpl   $0x0,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movl   $0xa,-0x8(%rbp)
movl   $0x7fffffff,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1030 <timespec_normalize@plt>
cmpl   $0xc,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpl   $0x8ca6bff,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movl   $0xa,-0x8(%rbp)
movl   $0xffffffff,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1030 <timespec_normalize@plt>
cmpl   $0x9,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpl   $0x3b9ac9ff,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movl   $0xa,-0x8(%rbp)
movl   $0xc4653601,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1030 <timespec_normalize@plt>
cmpl   $0x9,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpl   $0x1,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movl   $0xa,-0x8(%rbp)
movl   $0x80000001,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1030 <timespec_normalize@plt>
cmpl   $0x7,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpl   $0x32d05e01,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_normalize_timespec>:
push   %rbx
sub    $0x10,%rsp
movabs $0x75bcd150000000b,%rax
cd 5b 07
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <timespec_normalize@plt>
xor    %edi,%edi
cmpl   $0xb,0x8(%rsp)
sete   %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmpl   $0x75bcd15,0xc(%rsp)
07
sete   %dil
call   1040 <assert@plt>
movabs $0x3b9aca000000000a,%rax
ca 9a 3b
mov    %rax,0x8(%rsp)
mov    %rbx,%rdi
call   1030 <timespec_normalize@plt>
xor    %edi,%edi
cmpl   $0xb,0x8(%rsp)
sete   %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmpl   $0x0,0xc(%rsp)
sete   %dil
call   1040 <assert@plt>
movabs $0x7fffffff0000000a,%rax
ff ff 7f
mov    %rax,0x8(%rsp)
mov    %rbx,%rdi
call   1030 <timespec_normalize@plt>
xor    %edi,%edi
cmpl   $0xc,0x8(%rsp)
sete   %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmpl   $0x8ca6bff,0xc(%rsp)
08
sete   %dil
call   1040 <assert@plt>
movabs $0xffffffff0000000a,%rax
ff ff ff
mov    %rax,0x8(%rsp)
mov    %rbx,%rdi
call   1030 <timespec_normalize@plt>
xor    %edi,%edi
cmpl   $0x9,0x8(%rsp)
sete   %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmpl   $0x3b9ac9ff,0xc(%rsp)
3b
sete   %dil
call   1040 <assert@plt>
movabs $0xc46536010000000a,%rax
36 65 c4
mov    %rax,0x8(%rsp)
mov    %rbx,%rdi
call   1030 <timespec_normalize@plt>
xor    %edi,%edi
cmpl   $0x9,0x8(%rsp)
sete   %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmpl   $0x1,0xc(%rsp)
sete   %dil
call   1040 <assert@plt>
movabs $0x800000010000000a,%rax
mov    %rax,0x8(%rsp)
mov    %rbx,%rdi
call   1030 <timespec_normalize@plt>
xor    %edi,%edi
cmpl   $0x7,0x8(%rsp)
sete   %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmpl   $0x32d05e01,0xc(%rsp)
32
sete   %dil
call   1040 <assert@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timespec = type { i32, i32 }
define void @test_normalize_timespec() {
%1 = alloca %struct.timespec
%2 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 0
store i32 11, i32* %2
%3 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 1
store i32 123456789, i32* %3
%4 = call i32 @timespec_normalize(%struct.timespec* %1)
%5 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 0
%6 = load i32, i32* %5
%7 = icmp eq i32 %6, 11
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
%10 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 1
%11 = load i32, i32* %10
%12 = icmp eq i32 %11, 123456789
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 0
store i32 10, i32* %15
%16 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 1
store i32 1000000000, i32* %16
%17 = call i32 @timespec_normalize(%struct.timespec* %1)
%18 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 0
%19 = load i32, i32* %18
%20 = icmp eq i32 %19, 11
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 1
%24 = load i32, i32* %23
%25 = icmp eq i32 %24, 0
%26 = zext i1 %25 to i32
%27 = call i32 @assert(i32 %26)
%28 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 0
store i32 10, i32* %28
%29 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 1
store i32 2147483647, i32* %29
%30 = call i32 @timespec_normalize(%struct.timespec* %1)
%31 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 0
%32 = load i32, i32* %31
%33 = icmp eq i32 %32, 12
%34 = zext i1 %33 to i32
%35 = call i32 @assert(i32 %34)
%36 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 1
%37 = load i32, i32* %36
%38 = icmp eq i32 %37, 147483647
%39 = zext i1 %38 to i32
%40 = call i32 @assert(i32 %39)
%41 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 0
store i32 10, i32* %41
%42 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 1
store i32 -1, i32* %42
%43 = call i32 @timespec_normalize(%struct.timespec* %1)
%44 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 0
%45 = load i32, i32* %44
%46 = icmp eq i32 %45, 9
%47 = zext i1 %46 to i32
%48 = call i32 @assert(i32 %47)
%49 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 1
%50 = load i32, i32* %49
%51 = icmp eq i32 %50, 999999999
%52 = zext i1 %51 to i32
%53 = call i32 @assert(i32 %52)
%54 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 0
store i32 10, i32* %54
%55 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 1
store i32 -999999999, i32* %55
%56 = call i32 @timespec_normalize(%struct.timespec* %1)
%57 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 0
%58 = load i32, i32* %57
%59 = icmp eq i32 %58, 9
%60 = zext i1 %59 to i32
%61 = call i32 @assert(i32 %60)
%62 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 1
%63 = load i32, i32* %62
%64 = icmp eq i32 %63, 1
%65 = zext i1 %64 to i32
%66 = call i32 @assert(i32 %65)
%67 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 0
store i32 10, i32* %67
%68 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 1
store i32 -2147483647, i32* %68
%69 = call i32 @timespec_normalize(%struct.timespec* %1)
%70 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 0
%71 = load i32, i32* %70
%72 = icmp eq i32 %71, 7
%73 = zext i1 %72 to i32
%74 = call i32 @assert(i32 %73)
%75 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 1
%76 = load i32, i32* %75
%77 = icmp eq i32 %76, 852516353
%78 = zext i1 %77 to i32
%79 = call i32 @assert(i32 %78)
ret void
}

LLVM IR (-O2):
%struct.timespec = type { i32, i32 }
define void @test_normalize_timespec() {
%1 = alloca %struct.timespec
%2 = bitcast %struct.timespec* %1 to i8*
%3 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 0
store i32 11, i32* %3
%4 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 1
store i32 123456789, i32* %4
%5 = call i32 @timespec_normalize(%struct.timespec* %1)
%6 = load i32, i32* %3
%7 = icmp eq i32 %6, 11
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 123456789
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
store i32 10, i32* %3
store i32 1000000000, i32* %4
%14 = call i32 @timespec_normalize(%struct.timespec* %1)
%15 = load i32, i32* %3
%16 = icmp eq i32 %15, 11
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = load i32, i32* %4
%20 = icmp eq i32 %19, 0
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
store i32 10, i32* %3
store i32 2147483647, i32* %4
%23 = call i32 @timespec_normalize(%struct.timespec* %1)
%24 = load i32, i32* %3
%25 = icmp eq i32 %24, 12
%26 = zext i1 %25 to i32
%27 = call i32 @assert(i32 %26)
%28 = load i32, i32* %4
%29 = icmp eq i32 %28, 147483647
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
store i32 10, i32* %3
store i32 -1, i32* %4
%32 = call i32 @timespec_normalize(%struct.timespec* %1)
%33 = load i32, i32* %3
%34 = icmp eq i32 %33, 9
%35 = zext i1 %34 to i32
%36 = call i32 @assert(i32 %35)
%37 = load i32, i32* %4
%38 = icmp eq i32 %37, 999999999
%39 = zext i1 %38 to i32
%40 = call i32 @assert(i32 %39)
store i32 10, i32* %3
store i32 -999999999, i32* %4
%41 = call i32 @timespec_normalize(%struct.timespec* %1)
%42 = load i32, i32* %3
%43 = icmp eq i32 %42, 9
%44 = zext i1 %43 to i32
%45 = call i32 @assert(i32 %44)
%46 = load i32, i32* %4
%47 = icmp eq i32 %46, 1
%48 = zext i1 %47 to i32
%49 = call i32 @assert(i32 %48)
store i32 10, i32* %3
store i32 -2147483647, i32* %4
%50 = call i32 @timespec_normalize(%struct.timespec* %1)
%51 = load i32, i32* %3
%52 = icmp eq i32 %51, 7
%53 = zext i1 %52 to i32
%54 = call i32 @assert(i32 %53)
%55 = load i32, i32* %4
%56 = icmp eq i32 %55, 852516353
%57 = zext i1 %56 to i32
%58 = call i32 @assert(i32 %57)
ret void
}