#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 {
  int tv_sec;
  int tv_usec;
};

/* Variables and functions */
int errno;
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int handle_zng(int);
int /*<<< orphan*/ printf(char *, ...);
int utimes(char *, struct timeval *);
int utimes_test(char *filename, struct timeval tvp[2]) {
  int ret, save_errno;
  int passed;
  printf("utimes(): filename=%s, tvp=0x%p\n",
         (((filename) == NULL) ? "(null)" : (filename)), tvp);
  fflush(NULL);
  passed = handle_zng(ret = utimes(filename, tvp));
  save_errno = errno;
  switch (passed) {
  case -1:
    printf("\t\tret = %d\n", ret);
    printf("\tSucceeded Phase 1\n");
    fflush(NULL);
    break;
  case 0:
    printf("\t\ttvp[0].tv_sec = %ld\n", tvp[0].tv_sec);
    printf("\t\ttvp[0].tv_usec = %ld\n", tvp[0].tv_usec);
    printf("\t\ttvp[1].tv_sec = %ld\n", tvp[1].tv_sec);
    printf("\t\ttvp[1].tv_usec = %ld\n", tvp[1].tv_usec);
    printf("\t\tret = %d\n", ret);
    printf("\tSucceeded Phase 1\n");
    fflush(NULL);
    break;
  case -2:
    printf("\tFailed Phase 1: returned undefined value! "
           "ret = %d\n",
           ret);
    fflush(NULL);
    break;
  default:
    printf("Internal syscalltester error: passed = %d\n", passed);
    fflush(NULL);
    break;
  }
  errno = save_errno;
  return ret;
}


x86 assembly (clang, -O0):
<utimes_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    116b <utimes_test+0x2b>
lea    0xebf(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    1173 <utimes_test+0x33>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe7e(%rip),%rdi
xor    %eax,%eax
mov    %eax,-0x30(%rbp)
call   1040 <printf@plt>
mov    -0x30(%rbp),%eax
mov    %eax,%edi
call   1060 <fflush@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <utimes@plt>
mov    %eax,%edi
mov    %edi,-0x14(%rbp)
call   1030 <handle_zng@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2e29(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
sub    $0xfffffffe,%eax
je     129e <utimes_test+0x15e>
jmp    11d0 <utimes_test+0x90>
mov    -0x2c(%rbp),%eax
sub    $0xffffffff,%eax
je     11f1 <utimes_test+0xb1>
jmp    11e1 <utimes_test+0xa1>
mov    -0x2c(%rbp),%eax
test   %eax,%eax
je     121e <utimes_test+0xde>
jmp    12bd <utimes_test+0x17d>
mov    -0x14(%rbp),%esi
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <fflush@plt>
jmp    12d7 <utimes_test+0x197>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%esi
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%esi
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%esi
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xdad(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdab(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <fflush@plt>
jmp    12d7 <utimes_test+0x197>
mov    -0x14(%rbp),%esi
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <fflush@plt>
jmp    12d7 <utimes_test+0x197>
mov    -0x1c(%rbp),%esi
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <fflush@plt>
mov    -0x18(%rbp),%ecx
mov    0x2cff(%rip),%rax
mov    %ecx,(%rax)
mov    -0x14(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<utimes_test>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%rbp
test   %rdi,%rdi
lea    0xeba(%rip),%rsi
cmovne %rdi,%rsi
lea    0xe8e(%rip),%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
call   1070 <fflush@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1060 <utimes@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1040 <handle_zng@plt>
mov    0x2e42(%rip),%r14
mov    (%r14),%r15d
cmp    $0xfffffffe,%eax
je     11ba <utimes_test+0x6a>
test   %eax,%eax
je     11cc <utimes_test+0x7c>
cmp    $0xffffffff,%eax
je     120f <utimes_test+0xbf>
lea    0xf11(%rip),%rdi
mov    %eax,%esi
jmp    11c3 <utimes_test+0x73>
lea    0xed1(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    122b <utimes_test+0xdb>
mov    (%rbx),%esi
lea    0xe5f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rbx),%esi
lea    0xe65(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rbx),%esi
lea    0xe6c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rbx),%esi
lea    0xe72(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe12(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xecc(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1070 <fflush@plt>
mov    %r15d,(%r14)
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
@.str = [33 x i8] c"utimes(): filename=%s, tvp=0x%p\0A\00"
@.str.1 = [7 x i8] c"(null)\00"
@errno = global i32 0
@.str.2 = [12 x i8] c"\09\09ret = %d\0A\00"
@.str.3 = [20 x i8] c"\09Succeeded Phase 1\0A\00"
@.str.4 = [23 x i8] c"\09\09tvp[0].tv_sec = %ld\0A\00"
@.str.5 = [24 x i8] c"\09\09tvp[0].tv_usec = %ld\0A\00"
@.str.6 = [23 x i8] c"\09\09tvp[1].tv_sec = %ld\0A\00"
@.str.7 = [24 x i8] c"\09\09tvp[1].tv_usec = %ld\0A\00"
@.str.8 = [53 x i8] c"\09Failed Phase 1: returned undefined value! ret = %d\0A\00"
@.str.9 = [43 x i8] c"Internal syscalltester error: passed = %d\0A\00"
define i32 @utimes_test(i8* %0, %struct.timeval* %1) {
%3 = alloca i8*
%4 = alloca %struct.timeval*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store %struct.timeval* %1, %struct.timeval** %4
%8 = load i8*, i8** %3
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %11
10: ; preds = %2
br label %13
11: ; preds = %2
%12 = load i8*, i8** %3
br label %13
13: ; preds = %11, %10
%14 = phi i8* [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), %10 ], [ %12, %11 ]
%15 = load %struct.timeval*, %struct.timeval** %4
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %14, %struct.timeval* %15)
%17 = call i32 @fflush(i32* null)
%18 = load i8*, i8** %3
%19 = load %struct.timeval*, %struct.timeval** %4
%20 = call i32 @utimes(i8* %18, %struct.timeval* %19)
store i32 %20, i32* %5
%21 = call i32 @handle_zng(i32 %20)
store i32 %21, i32* %7
%22 = load i32, i32* @errno
store i32 %22, i32* %6
%23 = load i32, i32* %7
switch i32 %23, label %58 [
i32 -1, label %24
i32 0, label %29
i32 -2, label %54
]
24: ; preds = %13
%25 = load i32, i32* %5
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %25)
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%28 = call i32 @fflush(i32* null)
br label %62
29: ; preds = %13
%30 = load %struct.timeval*, %struct.timeval** %4
%31 = getelementptr inbounds %struct.timeval, %struct.timeval* %30, i64 0
%32 = getelementptr inbounds %struct.timeval, %struct.timeval* %31, i32 0, i32 0
%33 = load i32, i32* %32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %33)
%35 = load %struct.timeval*, %struct.timeval** %4
%36 = getelementptr inbounds %struct.timeval, %struct.timeval* %35, i64 0
%37 = getelementptr inbounds %struct.timeval, %struct.timeval* %36, i32 0, i32 1
%38 = load i32, i32* %37
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i32 %38)
%40 = load %struct.timeval*, %struct.timeval** %4
%41 = getelementptr inbounds %struct.timeval, %struct.timeval* %40, i64 1
%42 = getelementptr inbounds %struct.timeval, %struct.timeval* %41, i32 0, i32 0
%43 = load i32, i32* %42
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i32 %43)
%45 = load %struct.timeval*, %struct.timeval** %4
%46 = getelementptr inbounds %struct.timeval, %struct.timeval* %45, i64 1
%47 = getelementptr inbounds %struct.timeval, %struct.timeval* %46, i32 0, i32 1
%48 = load i32, i32* %47
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i32 %48)
%50 = load i32, i32* %5
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %50)
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%53 = call i32 @fflush(i32* null)
br label %62
54: ; preds = %13
%55 = load i32, i32* %5
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.8, i64 0, i64 0), i32 %55)
%57 = call i32 @fflush(i32* null)
br label %62
58: ; preds = %13
%59 = load i32, i32* %7
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.9, i64 0, i64 0), i32 %59)
%61 = call i32 @fflush(i32* null)
br label %62
62: ; preds = %58, %54, %29, %24
%63 = load i32, i32* %6
store i32 %63, i32* @errno
%64 = load i32, i32* %5
ret i32 %64
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
@.str = [33 x i8] c"utimes(): filename=%s, tvp=0x%p\0A\00"
@.str.1 = [7 x i8] c"(null)\00"
@errno = global i32 0
@.str.2 = [12 x i8] c"\09\09ret = %d\0A\00"
@.str.4 = [23 x i8] c"\09\09tvp[0].tv_sec = %ld\0A\00"
@.str.5 = [24 x i8] c"\09\09tvp[0].tv_usec = %ld\0A\00"
@.str.6 = [23 x i8] c"\09\09tvp[1].tv_sec = %ld\0A\00"
@.str.7 = [24 x i8] c"\09\09tvp[1].tv_usec = %ld\0A\00"
@.str.8 = [53 x i8] c"\09Failed Phase 1: returned undefined value! ret = %d\0A\00"
@.str.9 = [43 x i8] c"Internal syscalltester error: passed = %d\0A\00"
@str.10 = [19 x i8] c"\09Succeeded Phase 1\00"
define i32 @utimes_test(i8* %0, %struct.timeval* %1) {
%3 = icmp eq i8* %0, null
%4 = select i1 %3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %4, %struct.timeval* %1)
%6 = tail call i32 @fflush(i32* null)
%7 = tail call i32 @utimes(i8* %0, %struct.timeval* %1)
%8 = tail call i32 @handle_zng(i32 %7)
%9 = load i32, i32* @errno
switch i32 %8, label %30 [
i32 -1, label %10
i32 0, label %13
i32 -2, label %28
]
10: ; preds = %2
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.10, i64 0, i64 0))
br label %32
13: ; preds = %2
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%15 = load i32, i32* %14
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%18 = load i32, i32* %17
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i32 %18)
%20 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 1, i32 0
%21 = load i32, i32* %20
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 1, i32 1
%24 = load i32, i32* %23
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i32 %24)
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.10, i64 0, i64 0))
br label %32
28: ; preds = %2
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.8, i64 0, i64 0), i32 %7)
br label %32
30: ; preds = %2
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.9, i64 0, i64 0), i32 %8)
br label %32
32: ; preds = %30, %28, %13, %10
%33 = tail call i32 @fflush(i32* null)
store i32 %9, i32* @errno
ret i32 %7
}