#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 */

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ display(int, int, int);
int /*<<< orphan*/ measure(int, int, int);
int /*<<< orphan*/ printf(char *);
int main(int argc, char **argv) {
  int adj = 0;
  int slp = 10;
  int utm = 0;
  if (argc != 4) {
    printf("usage:\r\n\tdrift [adj] [duration] [mode]\r\n");
    printf("\t\t[adj]:      adjustment in ppm (default 0ppm)\r\n");
    printf(
        "\t\t[duration]: duration of measurement in seconds (default 10s)\r\n");
    printf("\t\t[mode]:\r\n");
    printf("\t\t            0: use frequency adjustemnt only\r\n");
    printf(
        "\t\t            1: use frequency adjustemnt and tick adjustment\r\n");
    printf("\t\t            2: use tick adjustment only\r\n");
    printf("\r\n");
  }
  if (argc > 1) {
    adj = atoi(argv[1]);
  }
  if (argc > 2) {
    slp = atoi(argv[2]);
  }
  if (argc > 3) {
    utm = atoi(argv[3]);
  }
  measure(adj, slp, utm);
  display(adj, slp, utm);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0xa,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     11d5 <main+0x95>
lea    0xe84(%rip),%rdi
call   1040 <printf@plt>
lea    0xea1(%rip),%rdi
call   1040 <printf@plt>
lea    0xec6(%rip),%rdi
call   1040 <printf@plt>
lea    0xefb(%rip),%rdi
call   1040 <printf@plt>
lea    0xefb(%rip),%rdi
call   1040 <printf@plt>
lea    0xf20(%rip),%rdi
call   1040 <printf@plt>
lea    0xf54(%rip),%rdi
call   1040 <printf@plt>
lea    0xe87(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x1,-0x8(%rbp)
jle    11ef <main+0xaf>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    1209 <main+0xc9>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x3,-0x8(%rbp)
jle    1223 <main+0xe3>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1050 <measure@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1030 <display@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
cmp    $0x4,%edi
jne    1177 <main+0x37>
mov    0x8(%r14),%rdi
call   1060 <atoi@plt>
mov    %eax,%r12d
mov    0x10(%r14),%rdi
call   1060 <atoi@plt>
mov    %eax,%ebp
mov    0x18(%r14),%rdi
call   1060 <atoi@plt>
mov    %eax,%ebx
jmp    1213 <main+0xd3>
mov    %edi,%r15d
lea    0xe7f(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9b(%rip),%rdi
call   1030 <puts@plt>
lea    0xebf(%rip),%rdi
call   1030 <puts@plt>
lea    0xef3(%rip),%rdi
call   1030 <puts@plt>
lea    0xef2(%rip),%rdi
call   1030 <puts@plt>
lea    0xf16(%rip),%rdi
call   1030 <puts@plt>
lea    0xf49(%rip),%rdi
call   1030 <puts@plt>
lea    0xe81(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
mov    $0xa,%ebp
cmp    $0x2,%r15d
jl     1210 <main+0xd0>
mov    0x8(%r14),%rdi
call   1060 <atoi@plt>
mov    %eax,%r12d
cmp    $0x2,%r15d
je     1213 <main+0xd3>
mov    0x10(%r14),%rdi
call   1060 <atoi@plt>
mov    %eax,%ebp
cmp    $0x4,%r15d
jae    1167 <main+0x27>
jmp    1213 <main+0xd3>
xor    %r12d,%r12d
mov    %r12d,%edi
mov    %ebp,%esi
mov    %ebx,%edx
call   1050 <measure@plt>
mov    %r12d,%edi
mov    %ebp,%esi
mov    %ebx,%edx
call   1040 <display@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [41 x i8] c"usage:\0D\0A\09drift [adj] [duration] [mode]\0D\0A\00"
@.str.1 = [49 x i8] c"\09\09[adj]: adjustment in ppm (default 0ppm)\0D\0A\00"
@.str.2 = [65 x i8] c"\09\09[duration]: duration of measurement in seconds (default 10s)\0D\0A\00"
@.str.3 = [12 x i8] c"\09\09[mode]:\0D\0A\00"
@.str.4 = [49 x i8] c"\09\09 0: use frequency adjustemnt only\0D\0A\00"
@.str.5 = [64 x i8] c"\09\09 1: use frequency adjustemnt and tick adjustment\0D\0A\00"
@.str.6 = [44 x i8] c"\09\09 2: use tick adjustment only\0D\0A\00"
@.str.7 = [3 x i8] c"\0D\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 10, i32* %7
store i32 0, i32* %8
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 4
br i1 %10, label %11, label %20
11: ; preds = %2
%12 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%16 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0))
%17 = call i32 @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.5, i64 0, i64 0))
%18 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0))
%19 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
br label %20
20: ; preds = %11, %2
%21 = load i32, i32* %4
%22 = icmp sgt i32 %21, 1
br i1 %22, label %23, label %28
23: ; preds = %20
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32 @atoi(i8* %26)
store i32 %27, i32* %6
br label %28
28: ; preds = %23, %20
%29 = load i32, i32* %4
%30 = icmp sgt i32 %29, 2
br i1 %30, label %31, label %36
31: ; preds = %28
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 2
%34 = load i8*, i8** %33
%35 = call i32 @atoi(i8* %34)
store i32 %35, i32* %7
br label %36
36: ; preds = %31, %28
%37 = load i32, i32* %4
%38 = icmp sgt i32 %37, 3
br i1 %38, label %39, label %44
39: ; preds = %36
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 3
%42 = load i8*, i8** %41
%43 = call i32 @atoi(i8* %42)
store i32 %43, i32* %8
br label %44
44: ; preds = %39, %36
%45 = load i32, i32* %6
%46 = load i32, i32* %7
%47 = load i32, i32* %8
%48 = call i32 @measure(i32 %45, i32 %46, i32 %47)
%49 = load i32, i32* %6
%50 = load i32, i32* %7
%51 = load i32, i32* %8
%52 = call i32 @display(i32 %49, i32 %50, i32 %51)
ret i32 0
}

LLVM IR (-O2):
@str = [40 x i8] c"usage:\0D\0A\09drift [adj] [duration] [mode]\0D\00"
@str.8 = [48 x i8] c"\09\09[adj]: adjustment in ppm (default 0ppm)\0D\00"
@str.9 = [64 x i8] c"\09\09[duration]: duration of measurement in seconds (default 10s)\0D\00"
@str.10 = [11 x i8] c"\09\09[mode]:\0D\00"
@str.11 = [48 x i8] c"\09\09 0: use frequency adjustemnt only\0D\00"
@str.12 = [63 x i8] c"\09\09 1: use frequency adjustemnt and tick adjustment\0D\00"
@str.13 = [43 x i8] c"\09\09 2: use tick adjustment only\0D\00"
@str.14 = [2 x i8] c"\0D\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %4, label %11
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
%8 = getelementptr inbounds i8*, i8** %1, i64 2
%9 = load i8*, i8** %8
%10 = tail call i32 @atoi(i8* %9)
br label %31
11: ; preds = %2
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.8, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @str.9, i64 0, i64 0))
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.10, i64 0, i64 0))
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.11, i64 0, i64 0))
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @str.12, i64 0, i64 0))
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.13, i64 0, i64 0))
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.14, i64 0, i64 0))
%20 = icmp sgt i32 %0, 1
br i1 %20, label %21, label %37
21: ; preds = %11
%22 = getelementptr inbounds i8*, i8** %1, i64 1
%23 = load i8*, i8** %22
%24 = tail call i32 @atoi(i8* %23)
%25 = icmp eq i32 %0, 2
br i1 %25, label %37, label %26
26: ; preds = %21
%27 = getelementptr inbounds i8*, i8** %1, i64 2
%28 = load i8*, i8** %27
%29 = tail call i32 @atoi(i8* %28)
%30 = icmp ugt i32 %0, 3
br i1 %30, label %31, label %37
31: ; preds = %4, %26
%32 = phi i32 [ %10, %4 ], [ %29, %26 ]
%33 = phi i32 [ %7, %4 ], [ %24, %26 ]
%34 = getelementptr inbounds i8*, i8** %1, i64 3
%35 = load i8*, i8** %34
%36 = tail call i32 @atoi(i8* %35)
br label %37
37: ; preds = %11, %21, %31, %26
%38 = phi i32 [ %32, %31 ], [ %29, %26 ], [ 10, %21 ], [ 10, %11 ]
%39 = phi i32 [ %33, %31 ], [ %24, %26 ], [ %24, %21 ], [ 0, %11 ]
%40 = phi i32 [ %36, %31 ], [ 0, %26 ], [ 0, %21 ], [ 0, %11 ]
%41 = tail call i32 @measure(i32 %39, i32 %38, i32 %40)
%42 = tail call i32 @display(i32 %39, i32 %38, i32 %40)
ret i32 0
}