#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 {
  int /*<<< orphan*/ esterror;
  int /*<<< orphan*/ maxerror;
  int /*<<< orphan*/ time;
  scalar_t__ modes;
};
struct ntptimeval {
  int /*<<< orphan*/ esterror;
  int /*<<< orphan*/ maxerror;
  int /*<<< orphan*/ time;
};

/* Variables and functions */
int adjtimex(struct timex *);
int ntp_gettime(struct ntptimeval *ntv) {
  struct timex tntx;
  int result;
  tntx.modes = 0;
  result = adjtimex(&tntx);
  ntv->time = tntx.time;
  ntv->maxerror = tntx.maxerror;
  ntv->esterror = tntx.esterror;
  return result;
}


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

x86 assembly (clang, -O2):
<ntp_gettime>:
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
movq   $0x0,0x18(%rsp)
lea    0x8(%rsp),%rdi
call   1030 <adjtimex@plt>
mov    0x10(%rsp),%ecx
mov    %ecx,0x8(%rbx)
mov    0xc(%rsp),%ecx
mov    %ecx,0x4(%rbx)
mov    0x8(%rsp),%ecx
mov    %ecx,(%rbx)
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.ntptimeval = type { i32, i32, i32 }
%struct.timex = type { i32, i32, i32, i64 }
define i32 @ntp_gettime(%struct.ntptimeval* %0) {
%2 = alloca %struct.ntptimeval*
%3 = alloca %struct.timex
%4 = alloca i32
store %struct.ntptimeval* %0, %struct.ntptimeval** %2
%5 = getelementptr inbounds %struct.timex, %struct.timex* %3, i32 0, i32 3
store i64 0, i64* %5
%6 = call i32 @adjtimex(%struct.timex* %3)
store i32 %6, i32* %4
%7 = getelementptr inbounds %struct.timex, %struct.timex* %3, i32 0, i32 2
%8 = load i32, i32* %7
%9 = load %struct.ntptimeval*, %struct.ntptimeval** %2
%10 = getelementptr inbounds %struct.ntptimeval, %struct.ntptimeval* %9, i32 0, i32 2
store i32 %8, i32* %10
%11 = getelementptr inbounds %struct.timex, %struct.timex* %3, i32 0, i32 1
%12 = load i32, i32* %11
%13 = load %struct.ntptimeval*, %struct.ntptimeval** %2
%14 = getelementptr inbounds %struct.ntptimeval, %struct.ntptimeval* %13, i32 0, i32 1
store i32 %12, i32* %14
%15 = getelementptr inbounds %struct.timex, %struct.timex* %3, i32 0, i32 0
%16 = load i32, i32* %15
%17 = load %struct.ntptimeval*, %struct.ntptimeval** %2
%18 = getelementptr inbounds %struct.ntptimeval, %struct.ntptimeval* %17, i32 0, i32 0
store i32 %16, i32* %18
%19 = load i32, i32* %4
ret i32 %19
}

LLVM IR (-O2):
%struct.ntptimeval = type { i32, i32, i32 }
%struct.timex = type { i32, i32, i32, i64 }
define i32 @ntp_gettime(%struct.ntptimeval* nocapture writeonly %0) {
%2 = alloca %struct.timex
%3 = bitcast %struct.timex* %2 to i8*
%4 = getelementptr inbounds %struct.timex, %struct.timex* %2, i64 0, i32 3
store i64 0, i64* %4
%5 = call i32 @adjtimex(%struct.timex* %2)
%6 = getelementptr inbounds %struct.timex, %struct.timex* %2, i64 0, i32 2
%7 = load i32, i32* %6
%8 = getelementptr inbounds %struct.ntptimeval, %struct.ntptimeval* %0, i64 0, i32 2
store i32 %7, i32* %8
%9 = getelementptr inbounds %struct.timex, %struct.timex* %2, i64 0, i32 1
%10 = load i32, i32* %9
%11 = getelementptr inbounds %struct.ntptimeval, %struct.ntptimeval* %0, i64 0, i32 1
store i32 %10, i32* %11
%12 = getelementptr inbounds %struct.timex, %struct.timex* %2, i64 0, i32 0
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.ntptimeval, %struct.ntptimeval* %0, i64 0, i32 0
store i32 %13, i32* %14
ret i32 %5
}