#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 status;
  scalar_t__ modes;
};

/* Variables and functions */
int STA_DEL;
int STA_INS;
int adjtimex(struct timex *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
void pstatus() {
  struct timex tx;
  tx.modes = 0;
  if (adjtimex(&tx) == -1) {
    perror("adjtimex(4)");
    exit(1);
  }
  printf("Kernel leap second flag: ");
  if (tx.status & STA_INS)
    printf("add\n");
  else if (tx.status & STA_DEL)
    printf("delete\n");
  else
    printf("not set\n");
}


x86 assembly (clang, -O0):
<pstatus>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movq   $0x0,-0x8(%rbp)
lea    -0x10(%rbp),%rdi
call   1060 <adjtimex@plt>
cmp    $0xffffffff,%eax
jne    1178 <pstatus+0x38>
lea    0xe97(%rip),%rdi
call   1040 <perror@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
lea    0xe8d(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
mov    0x2e52(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11aa <pstatus+0x6a>
lea    0xe86(%rip),%rdi
call   1030 <printf@plt>
jmp    11e1 <pstatus+0xa1>
mov    -0x10(%rbp),%eax
mov    0x2e24(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11d0 <pstatus+0x90>
lea    0xe65(%rip),%rdi
call   1030 <printf@plt>
jmp    11dc <pstatus+0x9c>
lea    0xe5c(%rip),%rdi
call   1030 <printf@plt>
jmp    11e1 <pstatus+0xa1>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pstatus>:
sub    $0x18,%rsp
movq   $0x0,0x10(%rsp)
lea    0x8(%rsp),%rdi
call   1070 <adjtimex@plt>
cmp    $0xffffffff,%eax
je     11b9 <pstatus+0x69>
lea    0xe99(%rip),%rdi
call   1040 <printf@plt>
mov    0x8(%rsp),%eax
mov    0x2e5d(%rip),%rcx
mov    (%rcx),%ecx
and    %eax,%ecx
mov    0x2e4a(%rip),%rdx
and    (%rdx),%eax
lea    0xe8f(%rip),%rax
lea    0xe90(%rip),%rdx
cmove  %rax,%rdx
test   %ecx,%ecx
lea    0xe8a(%rip),%rdi
cmove  %rdx,%rdi
call   1030 <puts@plt>
add    $0x18,%rsp
ret
lea    0xe40(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.timex = type { i32, i64 }
@.str = [12 x i8] c"adjtimex(4)\00"
@.str.1 = [26 x i8] c"Kernel leap second flag: \00"
@STA_INS = global i32 0
@.str.2 = [5 x i8] c"add\0A\00"
@STA_DEL = global i32 0
@.str.3 = [8 x i8] c"delete\0A\00"
@.str.4 = [9 x i8] c"not set\0A\00"
define void @pstatus() {
%1 = alloca %struct.timex
%2 = getelementptr inbounds %struct.timex, %struct.timex* %1, i32 0, i32 1
store i64 0, i64* %2
%3 = call i32 @adjtimex(%struct.timex* %1)
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @exit(i32 1)
unreachable
8: ; preds = %0
%9 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%10 = getelementptr inbounds %struct.timex, %struct.timex* %1, i32 0, i32 0
%11 = load i32, i32* %10
%12 = load i32, i32* @STA_INS
%13 = and i32 %11, %12
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %8
%16 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %28
17: ; preds = %8
%18 = getelementptr inbounds %struct.timex, %struct.timex* %1, i32 0, i32 0
%19 = load i32, i32* %18
%20 = load i32, i32* @STA_DEL
%21 = and i32 %19, %20
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %17
%24 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %27
25: ; preds = %17
%26 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
br label %27
27: ; preds = %25, %23
br label %28
28: ; preds = %27, %15
ret void
}

LLVM IR (-O2):
%struct.timex = type { i32, i64 }
@.str = [12 x i8] c"adjtimex(4)\00"
@.str.1 = [26 x i8] c"Kernel leap second flag: \00"
@STA_INS = global i32 0
@STA_DEL = global i32 0
@str = [8 x i8] c"not set\00"
@str.5 = [7 x i8] c"delete\00"
@str.6 = [4 x i8] c"add\00"
define void @pstatus() {
%1 = alloca %struct.timex
%2 = bitcast %struct.timex* %1 to i8*
%3 = getelementptr inbounds %struct.timex, %struct.timex* %1, i64 0, i32 1
store i64 0, i64* %3
%4 = call i32 @adjtimex(%struct.timex* %1)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @exit(i32 1)
unreachable
9: ; preds = %0
%10 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%11 = getelementptr inbounds %struct.timex, %struct.timex* %1, i64 0, i32 0
%12 = load i32, i32* %11
%13 = load i32, i32* @STA_INS
%14 = and i32 %13, %12
%15 = icmp eq i32 %14, 0
%16 = load i32, i32* @STA_DEL
%17 = and i32 %16, %12
%18 = icmp eq i32 %17, 0
%19 = select i1 %18, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str.5, i64 0, i64 0)
%20 = select i1 %15, i8* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @str.6, i64 0, i64 0)
%21 = call i32 @puts(i8* dereferenceable(1) %20)
ret void
}