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

/* Variables and functions */
int /*<<< orphan*/ ADJ_FREQUENCY;
int adjtimex(struct timex *);
int /*<<< orphan*/ printf(char *);
int system(char *);
int change_skew_test(int ppm) {
  struct timex tx;
  int ret;
  tx.modes = ADJ_FREQUENCY;
  tx.freq = ppm << 16;
  ret = adjtimex(&tx);
  if (ret < 0) {
    printf("Error adjusting freq\n");
    return ret;
  }
  ret = system("./raw_skew");
  ret |= system("./inconsistency-check");
  ret |= system("./nanosleep");
  return ret;
}


x86 assembly (clang, -O0):
<change_skew_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    0x2e9e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
shl    $0x10,%eax
mov    %eax,-0x10(%rbp)
lea    -0x10(%rbp),%rdi
call   1050 <adjtimex@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    117d <change_skew_test+0x4d>
lea    0xe93(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11b6 <change_skew_test+0x86>
lea    0xe92(%rip),%rdi
call   1030 <system@plt>
mov    %eax,-0x14(%rbp)
lea    0xe8e(%rip),%rdi
call   1030 <system@plt>
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
lea    0xe92(%rip),%rdi
call   1030 <system@plt>
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<change_skew_test>:
push   %rbp
push   %rbx
push   %rax
mov    0x2ea6(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%rsp)
shl    $0x10,%edi
mov    %edi,(%rsp)
mov    %rsp,%rdi
call   1050 <adjtimex@plt>
test   %eax,%eax
js     1182 <change_skew_test+0x52>
lea    0xea7(%rip),%rdi
call   1040 <system@plt>
mov    %eax,%ebx
lea    0xea4(%rip),%rdi
call   1040 <system@plt>
mov    %eax,%ebp
or     %ebx,%ebp
lea    0xeaa(%rip),%rdi
call   1040 <system@plt>
mov    %eax,%ebx
or     %ebp,%ebx
jmp    1190 <change_skew_test+0x60>
mov    %eax,%ebx
lea    0xea2(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.timex = type { i32, i32 }
@ADJ_FREQUENCY = global i32 0
@.str = [22 x i8] c"Error adjusting freq\0A\00"
@.str.1 = [11 x i8] c"./raw_skew\00"
@.str.2 = [22 x i8] c"./inconsistency-check\00"
@.str.3 = [12 x i8] c"./nanosleep\00"
define i32 @change_skew_test(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.timex
%5 = alloca i32
store i32 %0, i32* %3
%6 = load i32, i32* @ADJ_FREQUENCY
%7 = getelementptr inbounds %struct.timex, %struct.timex* %4, i32 0, i32 1
store i32 %6, i32* %7
%8 = load i32, i32* %3
%9 = shl i32 %8, 16
%10 = getelementptr inbounds %struct.timex, %struct.timex* %4, i32 0, i32 0
store i32 %9, i32* %10
%11 = call i32 @adjtimex(%struct.timex* %4)
store i32 %11, i32* %5
%12 = load i32, i32* %5
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %1
%15 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%16 = load i32, i32* %5
store i32 %16, i32* %2
br label %26
17: ; preds = %1
%18 = call i32 @system(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
store i32 %18, i32* %5
%19 = call i32 @system(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%20 = load i32, i32* %5
%21 = or i32 %20, %19
store i32 %21, i32* %5
%22 = call i32 @system(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%23 = load i32, i32* %5
%24 = or i32 %23, %22
store i32 %24, i32* %5
%25 = load i32, i32* %5
store i32 %25, i32* %2
br label %26
26: ; preds = %17, %14
%27 = load i32, i32* %2
ret i32 %27
}

LLVM IR (-O2):
%struct.timex = type { i32, i32 }
@ADJ_FREQUENCY = global i32 0
@.str.1 = [11 x i8] c"./raw_skew\00"
@.str.2 = [22 x i8] c"./inconsistency-check\00"
@.str.3 = [12 x i8] c"./nanosleep\00"
@str = [21 x i8] c"Error adjusting freq\00"
define i32 @change_skew_test(i32 %0) {
%2 = alloca %struct.timex
%3 = bitcast %struct.timex* %2 to i8*
%4 = load i32, i32* @ADJ_FREQUENCY
%5 = getelementptr inbounds %struct.timex, %struct.timex* %2, i64 0, i32 1
store i32 %4, i32* %5
%6 = shl i32 %0, 16
%7 = getelementptr inbounds %struct.timex, %struct.timex* %2, i64 0, i32 0
store i32 %6, i32* %7
%8 = call i32 @adjtimex(%struct.timex* %2)
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
br label %18
12: ; preds = %1
%13 = call i32 @system(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @system(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%15 = or i32 %14, %13
%16 = call i32 @system(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%17 = or i32 %15, %16
br label %18
18: ; preds = %12, %10
%19 = phi i32 [ %8, %10 ], [ %17, %12 ]
ret i32 %19
}