#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 timeval {
  int tv_sec;
  int tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ timeval_normalize(struct timeval *);
void test_normalize_timeval() {
  struct timeval a;
  a.tv_sec = 11;
  a.tv_usec = 123456;
  ;
  timeval_normalize(&a);
  assert(a.tv_sec == 11);
  assert(a.tv_usec == 123456);
  ;
  a.tv_sec = 10;
  a.tv_usec = 1000000;
  ;
  timeval_normalize(&a);
  assert(a.tv_sec == 11);
  assert(a.tv_usec == 0);
  ;
  a.tv_sec = 10;
  a.tv_usec = 2147483647;
  ;
  timeval_normalize(&a);
  assert(a.tv_sec == 2157);
  assert(a.tv_usec == 483647);
  ;
  a.tv_sec = 10;
  a.tv_usec = -1;
  ;
  timeval_normalize(&a);
  assert(a.tv_sec == 9);
  assert(a.tv_usec == 999999);
  ;
  a.tv_sec = 10;
  a.tv_usec = -999999;
  ;
  timeval_normalize(&a);
  assert(a.tv_sec == 9);
  assert(a.tv_usec == 1);
  ;
  a.tv_sec = 3000;
  a.tv_usec = -2147483647;
  ;
  timeval_normalize(&a);
  assert(a.tv_sec == 852);
  assert(a.tv_usec == 516353);
  ;
}


x86 assembly (clang, -O0):
<test_normalize_timeval>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0xb,-0x8(%rbp)
movl   $0x1e240,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1040 <timeval_normalize@plt>
cmpl   $0xb,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x1e240,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movl   $0xa,-0x8(%rbp)
movl   $0xf4240,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1040 <timeval_normalize@plt>
cmpl   $0xb,-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>
movl   $0xa,-0x8(%rbp)
movl   $0x7fffffff,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1040 <timeval_normalize@plt>
cmpl   $0x86d,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x7613f,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movl   $0xa,-0x8(%rbp)
movl   $0xffffffff,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1040 <timeval_normalize@plt>
cmpl   $0x9,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0xf423f,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movl   $0xa,-0x8(%rbp)
movl   $0xfff0bdc1,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1040 <timeval_normalize@plt>
cmpl   $0x9,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x1,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movl   $0xbb8,-0x8(%rbp)
movl   $0x80000001,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1040 <timeval_normalize@plt>
cmpl   $0x354,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x7e101,-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_normalize_timeval>:
push   %rbx
sub    $0x10,%rsp
movabs $0x1e2400000000b,%rax
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <timeval_normalize@plt>
xor    %edi,%edi
cmpl   $0xb,0x8(%rsp)
sete   %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmpl   $0x1e240,0xc(%rsp)
sete   %dil
call   1030 <assert@plt>
movabs $0xf42400000000a,%rax
mov    %rax,0x8(%rsp)
mov    %rbx,%rdi
call   1040 <timeval_normalize@plt>
xor    %edi,%edi
cmpl   $0xb,0x8(%rsp)
sete   %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmpl   $0x0,0xc(%rsp)
sete   %dil
call   1030 <assert@plt>
movabs $0x7fffffff0000000a,%rax
ff ff 7f
mov    %rax,0x8(%rsp)
mov    %rbx,%rdi
call   1040 <timeval_normalize@plt>
xor    %edi,%edi
cmpl   $0x86d,0x8(%rsp)
sete   %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmpl   $0x7613f,0xc(%rsp)
sete   %dil
call   1030 <assert@plt>
movabs $0xffffffff0000000a,%rax
ff ff ff
mov    %rax,0x8(%rsp)
mov    %rbx,%rdi
call   1040 <timeval_normalize@plt>
xor    %edi,%edi
cmpl   $0x9,0x8(%rsp)
sete   %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmpl   $0xf423f,0xc(%rsp)
sete   %dil
call   1030 <assert@plt>
movabs $0xfff0bdc10000000a,%rax
bd f0 ff
mov    %rax,0x8(%rsp)
mov    %rbx,%rdi
call   1040 <timeval_normalize@plt>
xor    %edi,%edi
cmpl   $0x9,0x8(%rsp)
sete   %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmpl   $0x1,0xc(%rsp)
sete   %dil
call   1030 <assert@plt>
movabs $0x8000000100000bb8,%rax
mov    %rax,0x8(%rsp)
mov    %rbx,%rdi
call   1040 <timeval_normalize@plt>
xor    %edi,%edi
cmpl   $0x354,0x8(%rsp)
sete   %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmpl   $0x7e101,0xc(%rsp)
sete   %dil
call   1030 <assert@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
define void @test_normalize_timeval() {
%1 = alloca %struct.timeval
%2 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
store i32 11, i32* %2
%3 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
store i32 123456, i32* %3
%4 = call i32 @timeval_normalize(%struct.timeval* %1)
%5 = getelementptr inbounds %struct.timeval, %struct.timeval* %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.timeval, %struct.timeval* %1, i32 0, i32 1
%11 = load i32, i32* %10
%12 = icmp eq i32 %11, 123456
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
store i32 10, i32* %15
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
store i32 1000000, i32* %16
%17 = call i32 @timeval_normalize(%struct.timeval* %1)
%18 = getelementptr inbounds %struct.timeval, %struct.timeval* %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.timeval, %struct.timeval* %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.timeval, %struct.timeval* %1, i32 0, i32 0
store i32 10, i32* %28
%29 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
store i32 2147483647, i32* %29
%30 = call i32 @timeval_normalize(%struct.timeval* %1)
%31 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
%32 = load i32, i32* %31
%33 = icmp eq i32 %32, 2157
%34 = zext i1 %33 to i32
%35 = call i32 @assert(i32 %34)
%36 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
%37 = load i32, i32* %36
%38 = icmp eq i32 %37, 483647
%39 = zext i1 %38 to i32
%40 = call i32 @assert(i32 %39)
%41 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
store i32 10, i32* %41
%42 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
store i32 -1, i32* %42
%43 = call i32 @timeval_normalize(%struct.timeval* %1)
%44 = getelementptr inbounds %struct.timeval, %struct.timeval* %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.timeval, %struct.timeval* %1, i32 0, i32 1
%50 = load i32, i32* %49
%51 = icmp eq i32 %50, 999999
%52 = zext i1 %51 to i32
%53 = call i32 @assert(i32 %52)
%54 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
store i32 10, i32* %54
%55 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
store i32 -999999, i32* %55
%56 = call i32 @timeval_normalize(%struct.timeval* %1)
%57 = getelementptr inbounds %struct.timeval, %struct.timeval* %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.timeval, %struct.timeval* %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.timeval, %struct.timeval* %1, i32 0, i32 0
store i32 3000, i32* %67
%68 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
store i32 -2147483647, i32* %68
%69 = call i32 @timeval_normalize(%struct.timeval* %1)
%70 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
%71 = load i32, i32* %70
%72 = icmp eq i32 %71, 852
%73 = zext i1 %72 to i32
%74 = call i32 @assert(i32 %73)
%75 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
%76 = load i32, i32* %75
%77 = icmp eq i32 %76, 516353
%78 = zext i1 %77 to i32
%79 = call i32 @assert(i32 %78)
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
define void @test_normalize_timeval() {
%1 = alloca %struct.timeval
%2 = bitcast %struct.timeval* %1 to i8*
%3 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
store i32 11, i32* %3
%4 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
store i32 123456, i32* %4
%5 = call i32 @timeval_normalize(%struct.timeval* %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, 123456
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
store i32 10, i32* %3
store i32 1000000, i32* %4
%14 = call i32 @timeval_normalize(%struct.timeval* %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 @timeval_normalize(%struct.timeval* %1)
%24 = load i32, i32* %3
%25 = icmp eq i32 %24, 2157
%26 = zext i1 %25 to i32
%27 = call i32 @assert(i32 %26)
%28 = load i32, i32* %4
%29 = icmp eq i32 %28, 483647
%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 @timeval_normalize(%struct.timeval* %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, 999999
%39 = zext i1 %38 to i32
%40 = call i32 @assert(i32 %39)
store i32 10, i32* %3
store i32 -999999, i32* %4
%41 = call i32 @timeval_normalize(%struct.timeval* %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 3000, i32* %3
store i32 -2147483647, i32* %4
%50 = call i32 @timeval_normalize(%struct.timeval* %1)
%51 = load i32, i32* %3
%52 = icmp eq i32 %51, 852
%53 = zext i1 %52 to i32
%54 = call i32 @assert(i32 %53)
%55 = load i32, i32* %4
%56 = icmp eq i32 %55, 516353
%57 = zext i1 %56 to i32
%58 = call i32 @assert(i32 %57)
ret void
}