#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 timeval {
  void *tv_usec;
  void *tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ adjtime(struct timeval *, struct timeval *);
void *atoi(char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  struct timeval delta, olddelta;
  switch (argc) {
  case 1:
    adjtime(0, &olddelta);
    printf("Old delta: %d sec %d usec \n\r", (int)olddelta.tv_sec,
           (int)olddelta.tv_usec);
    break;
  case 3:
    delta.tv_sec = atoi(argv[1]);
    delta.tv_usec = atoi(argv[2]);
    printf("Delta: %d sec %d usec\n\r", (int)delta.tv_sec, (int)delta.tv_usec);
    adjtime(&delta, &olddelta);
    printf("Old delta: %d sec %d usec\n\r", (int)olddelta.tv_sec,
           (int)olddelta.tv_usec);
    break;
  default:
    printf("Usage: uadjtime [<delta in sec> <delta in usec>]\n\r");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x34(%rbp)
sub    $0x1,%eax
je     116b <main+0x3b>
jmp    115a <main+0x2a>
mov    -0x34(%rbp),%eax
sub    $0x3,%eax
je     1197 <main+0x67>
jmp    11ff <main+0xcf>
xor    %eax,%eax
mov    %eax,%edi
lea    -0x30(%rbp),%rsi
call   1040 <adjtime@plt>
mov    -0x28(%rbp),%rax
mov    %eax,%esi
mov    -0x30(%rbp),%rax
mov    %eax,%edx
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    120d <main+0xdd>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <atoi@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %eax,%esi
mov    -0x20(%rbp),%rax
mov    %eax,%edx
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1040 <adjtime@plt>
mov    -0x28(%rbp),%rax
mov    %eax,%esi
mov    -0x30(%rbp),%rax
mov    %eax,%edx
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    120d <main+0xdd>
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
cmp    $0x3,%edi
je     115e <main+0x2e>
cmp    $0x1,%edi
jne    11ba <main+0x8a>
lea    0x8(%rsp),%rsi
xor    %edi,%edi
call   1040 <adjtime@plt>
mov    0x8(%rsp),%edx
mov    0x10(%rsp),%esi
lea    0xea4(%rip),%rdi
jmp    11b1 <main+0x81>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
mov    %rax,%r14
mov    %rax,0x20(%rsp)
mov    0x10(%rbx),%rdi
call   1050 <atoi@plt>
mov    %rax,0x18(%rsp)
lea    0xe96(%rip),%rdi
mov    %r14d,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x18(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1040 <adjtime@plt>
mov    0x8(%rsp),%edx
mov    0x10(%rsp),%esi
lea    0xe84(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11c8 <main+0x98>
lea    0xe90(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.timeval = type { i8*, i8* }
@.str = [29 x i8] c"Old delta: %d sec %d usec \0A\0D\00"
@.str.1 = [24 x i8] c"Delta: %d sec %d usec\0A\0D\00"
@.str.2 = [28 x i8] c"Old delta: %d sec %d usec\0A\0D\00"
@.str.3 = [51 x i8] c"Usage: uadjtime [<delta in sec> <delta in usec>]\0A\0D\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.timeval
%7 = alloca %struct.timeval
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
switch i32 %8, label %44 [
i32 1, label %9
i32 3, label %18
]
9: ; preds = %2
%10 = call i32 @adjtime(%struct.timeval* null, %struct.timeval* %7)
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 1
%12 = load i8*, i8** %11
%13 = ptrtoint i8* %12 to i32
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%15 = load i8*, i8** %14
%16 = ptrtoint i8* %15 to i32
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %16)
br label %46
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i8* @atoi(i8* %21)
%23 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
store i8* %22, i8** %23
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = call i8* @atoi(i8* %26)
%28 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
store i8* %27, i8** %28
%29 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
%30 = load i8*, i8** %29
%31 = ptrtoint i8* %30 to i32
%32 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%33 = load i8*, i8** %32
%34 = ptrtoint i8* %33 to i32
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %31, i32 %34)
%36 = call i32 @adjtime(%struct.timeval* %6, %struct.timeval* %7)
%37 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 1
%38 = load i8*, i8** %37
%39 = ptrtoint i8* %38 to i32
%40 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%41 = load i8*, i8** %40
%42 = ptrtoint i8* %41 to i32
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %39, i32 %42)
br label %46
44: ; preds = %2
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0))
br label %46
46: ; preds = %44, %18, %9
ret i32 0
}

LLVM IR (-O2):
%struct.timeval = type { i8*, i8* }
@.str = [29 x i8] c"Old delta: %d sec %d usec \0A\0D\00"
@.str.1 = [24 x i8] c"Delta: %d sec %d usec\0A\0D\00"
@.str.2 = [28 x i8] c"Old delta: %d sec %d usec\0A\0D\00"
@.str.3 = [51 x i8] c"Usage: uadjtime [<delta in sec> <delta in usec>]\0A\0D\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.timeval
%4 = alloca %struct.timeval
%5 = bitcast %struct.timeval* %3 to i8*
%6 = bitcast %struct.timeval* %4 to i8*
switch i32 %0, label %42 [
i32 1, label %7
i32 3, label %18
]
7: ; preds = %2
%8 = call i32 @adjtime(%struct.timeval* null, %struct.timeval* %4)
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
%10 = load i8*, i8** %9
%11 = ptrtoint i8* %10 to i64
%12 = trunc i64 %11 to i32
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
%14 = load i8*, i8** %13
%15 = ptrtoint i8* %14 to i64
%16 = trunc i64 %15 to i32
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %16)
br label %44
18: ; preds = %2
%19 = getelementptr inbounds i8*, i8** %1, i64 1
%20 = load i8*, i8** %19
%21 = tail call i8* @atoi(i8* %20)
%22 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
store i8* %21, i8** %22
%23 = getelementptr inbounds i8*, i8** %1, i64 2
%24 = load i8*, i8** %23
%25 = tail call i8* @atoi(i8* %24)
%26 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
store i8* %25, i8** %26
%27 = ptrtoint i8* %21 to i64
%28 = trunc i64 %27 to i32
%29 = ptrtoint i8* %25 to i64
%30 = trunc i64 %29 to i32
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %28, i32 %30)
%32 = call i32 @adjtime(%struct.timeval* %3, %struct.timeval* %4)
%33 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
%34 = load i8*, i8** %33
%35 = ptrtoint i8* %34 to i64
%36 = trunc i64 %35 to i32
%37 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
%38 = load i8*, i8** %37
%39 = ptrtoint i8* %38 to i64
%40 = trunc i64 %39 to i32
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %36, i32 %40)
br label %44
42: ; preds = %2
%43 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0))
br label %44
44: ; preds = %42, %18, %7
ret i32 0
}