#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;
  int /*<<< orphan*/ modes;
  scalar_t__ freq;
  scalar_t__ offset;
};

/* Variables and functions */
int /*<<< orphan*/ ADJ_FREQUENCY;
int /*<<< orphan*/ ADJ_OFFSET;
int /*<<< orphan*/ ADJ_STATUS;
int adjtimex(struct timex *);
void clear_ntp_state(void) {
  struct timex tx;
  int ret;
  tx.modes = ADJ_OFFSET;
  tx.offset = 0;
  ret = adjtimex(&tx);
  tx.modes = ADJ_FREQUENCY;
  tx.freq = 0;
  ret = adjtimex(&tx);
  tx.modes = ADJ_STATUS;
  tx.status = 0;
  ret = adjtimex(&tx);
}


x86 assembly (clang, -O0):
<clear_ntp_state>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x2eb9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
movq   $0x0,-0x8(%rbp)
lea    -0x20(%rbp),%rdi
call   1030 <adjtimex@plt>
mov    %eax,-0x24(%rbp)
mov    0x2e91(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
movq   $0x0,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
call   1030 <adjtimex@plt>
mov    %eax,-0x24(%rbp)
mov    0x2e89(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
lea    -0x20(%rbp),%rdi
call   1030 <adjtimex@plt>
mov    %eax,-0x24(%rbp)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clear_ntp_state>:
push   %rbx
sub    $0x20,%rsp
mov    0x2ebc(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%rsp)
movq   $0x0,0x18(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <adjtimex@plt>
mov    0x2e93(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%rsp)
movq   $0x0,0x10(%rsp)
mov    %rbx,%rdi
call   1030 <adjtimex@plt>
mov    0x2e8d(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%rsp)
movq   $0x0,(%rsp)
mov    %rbx,%rdi
call   1030 <adjtimex@plt>
add    $0x20,%rsp
pop    %rbx
ret

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

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