#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 timex {
  scalar_t__ status;
  void *modes;
  scalar_t__ maxerror;
};

/* Variables and functions */
void *ADJ_MAXERROR;
void *ADJ_STATUS;
scalar_t__ STA_PLL;
int adjtimex(struct timex *);
void clear_time_state(void) {
  struct timex tx;
  int ret;
  tx.modes = ADJ_STATUS;
  tx.status = STA_PLL;
  ret = adjtimex(&tx);
  tx.modes = ADJ_MAXERROR;
  tx.maxerror = 0;
  ret = adjtimex(&tx);
  tx.modes = ADJ_STATUS;
  tx.status = 0;
  ret = adjtimex(&tx);
}


x86 assembly (clang, -O0):
<clear_time_state>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0x2eb9(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
mov    0x2eb3(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
lea    -0x18(%rbp),%rdi
call   1030 <adjtimex@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2ea9(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x8(%rbp)
lea    -0x18(%rbp),%rdi
call   1030 <adjtimex@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2e6f(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
lea    -0x18(%rbp),%rdi
call   1030 <adjtimex@plt>
mov    %eax,-0x1c(%rbp)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clear_time_state>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    0x2eba(%rip),%r14
mov    (%r14),%rax
mov    %rax,0x8(%rsp)
mov    0x2eb3(%rip),%rax
mov    (%rax),%rax
mov    %rax,(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <adjtimex@plt>
mov    0x2eaa(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x8(%rsp)
movq   $0x0,0x10(%rsp)
mov    %rbx,%rdi
call   1030 <adjtimex@plt>
mov    (%r14),%rax
mov    %rax,0x8(%rsp)
movq   $0x0,(%rsp)
mov    %rbx,%rdi
call   1030 <adjtimex@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.timex = type { i64, i8*, i64 }
@ADJ_STATUS = global i8* null
@STA_PLL = global i64 0
@ADJ_MAXERROR = global i8* null
define void @clear_time_state() {
%1 = alloca %struct.timex
%2 = alloca i32
%3 = load i8*, i8** @ADJ_STATUS
%4 = getelementptr inbounds %struct.timex, %struct.timex* %1, i32 0, i32 1
store i8* %3, i8** %4
%5 = load i64, i64* @STA_PLL
%6 = getelementptr inbounds %struct.timex, %struct.timex* %1, i32 0, i32 0
store i64 %5, i64* %6
%7 = call i32 @adjtimex(%struct.timex* %1)
store i32 %7, i32* %2
%8 = load i8*, i8** @ADJ_MAXERROR
%9 = getelementptr inbounds %struct.timex, %struct.timex* %1, i32 0, i32 1
store i8* %8, i8** %9
%10 = getelementptr inbounds %struct.timex, %struct.timex* %1, i32 0, i32 2
store i64 0, i64* %10
%11 = call i32 @adjtimex(%struct.timex* %1)
store i32 %11, i32* %2
%12 = load i8*, i8** @ADJ_STATUS
%13 = getelementptr inbounds %struct.timex, %struct.timex* %1, i32 0, i32 1
store i8* %12, i8** %13
%14 = getelementptr inbounds %struct.timex, %struct.timex* %1, i32 0, i32 0
store i64 0, i64* %14
%15 = call i32 @adjtimex(%struct.timex* %1)
store i32 %15, i32* %2
ret void
}

LLVM IR (-O2):
%struct.timex = type { i64, i8*, i64 }
@ADJ_STATUS = global i8* null
@STA_PLL = global i64 0
@ADJ_MAXERROR = global i8* null
define void @clear_time_state() {
%1 = alloca %struct.timex
%2 = bitcast %struct.timex* %1 to i8*
%3 = load i8*, i8** @ADJ_STATUS
%4 = getelementptr inbounds %struct.timex, %struct.timex* %1, i64 0, i32 1
store i8* %3, i8** %4
%5 = load i64, i64* @STA_PLL
%6 = getelementptr inbounds %struct.timex, %struct.timex* %1, i64 0, i32 0
store i64 %5, i64* %6
%7 = call i32 @adjtimex(%struct.timex* %1)
%8 = load i8*, i8** @ADJ_MAXERROR
store i8* %8, i8** %4
%9 = getelementptr inbounds %struct.timex, %struct.timex* %1, i64 0, i32 2
store i64 0, i64* %9
%10 = call i32 @adjtimex(%struct.timex* %1)
%11 = load i8*, i8** @ADJ_STATUS
store i8* %11, i8** %4
store i64 0, i64* %6
%12 = call i32 @adjtimex(%struct.timex* %1)
ret void
}