#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 */
typedef int /*<<< orphan*/ time_t;
struct utimbuf {
  int /*<<< orphan*/ modtime;
  int /*<<< orphan*/ actime;
};
struct tm {
  int dummy;
};

/* Variables and functions */
scalar_t__ ENOENT;
scalar_t__ errno;
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ print_tm(struct tm *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int utime(char *, struct utimbuf *);
int main(void) {
  time_t t = time(NULL);
  struct utimbuf u = {.actime = t, .modtime = t};
  struct tm *p = localtime(&t);
  printf("utime(\"utime\\nfilename\", [");
  print_tm(p);
  printf(", ");
  print_tm(p);
  puts("]) = -1 ENOENT (No such file or directory)");
  puts("+++ exited with 0 +++");
  return utime("utime\nfilename", &u) == -1 && errno == ENOENT ? 0 : 77;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
lea    -0x8(%rbp),%rdi
call   1040 <localtime@plt>
mov    %rax,-0x18(%rbp)
lea    0xe65(%rip),%rdi
call   1060 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1070 <print_tm@plt>
lea    0xe6b(%rip),%rdi
call   1060 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1070 <print_tm@plt>
lea    0xe59(%rip),%rdi
call   1050 <puts@plt>
lea    0xe78(%rip),%rdi
call   1050 <puts@plt>
lea    0xe82(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1030 <utime@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xffffffff,%ecx
mov    %al,-0x19(%rbp)
jne    1210 <main+0xb0>
mov    0x2de3(%rip),%rax
mov    (%rax),%rax
mov    0x2dc9(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%dl
mov    $0x4d,%eax
xor    %ecx,%ecx
test   $0x1,%dl
cmovne %ecx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
xor    %r14d,%r14d
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,0xc(%rsp)
mov    %eax,0x10(%rsp)
mov    %eax,0x14(%rsp)
lea    0xc(%rsp),%rdi
call   1040 <localtime@plt>
mov    %rax,%rbx
lea    0xe6f(%rip),%rdi
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1070 <print_tm@plt>
lea    0xe76(%rip),%rdi
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1070 <print_tm@plt>
lea    0xe65(%rip),%rdi
call   1050 <puts@plt>
lea    0xe84(%rip),%rdi
call   1050 <puts@plt>
lea    0xe8e(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1030 <utime@plt>
mov    0x2dfe(%rip),%rcx
mov    (%rcx),%rcx
mov    0x2de4(%rip),%rdx
cmp    (%rdx),%rcx
mov    $0x4d,%ecx
cmovne %ecx,%r14d
cmp    $0xffffffff,%eax
cmovne %ecx,%r14d
mov    %r14d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.utimbuf = type { i32, i32 }
%struct.tm = type { i32 }
@.str = [27 x i8] c"utime(\22utime\\nfilename\22, [\00"
@.str.1 = [3 x i8] c", \00"
@.str.2 = [43 x i8] c"]) = -1 ENOENT (No such file or directory)\00"
@.str.3 = [22 x i8] c"+++ exited with 0 +++\00"
@.str.4 = [15 x i8] c"utime\0Afilename\00"
@errno = global i64 0
@ENOENT = global i64 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.utimbuf
%4 = alloca %struct.tm*
store i32 0, i32* %1
%5 = call i32 @time(i32* null)
store i32 %5, i32* %2
%6 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %3, i32 0, i32 0
%7 = load i32, i32* %2
store i32 %7, i32* %6
%8 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %3, i32 0, i32 1
%9 = load i32, i32* %2
store i32 %9, i32* %8
%10 = call %struct.tm* @localtime(i32* %2)
store %struct.tm* %10, %struct.tm** %4
%11 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%12 = load %struct.tm*, %struct.tm** %4
%13 = call i32 @print_tm(%struct.tm* %12)
%14 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%15 = load %struct.tm*, %struct.tm** %4
%16 = call i32 @print_tm(%struct.tm* %15)
%17 = call i32 @puts(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 @puts(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%19 = call i32 @utime(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), %struct.utimbuf* %3)
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %25
21: ; preds = %0
%22 = load i64, i64* @errno
%23 = load i64, i64* @ENOENT
%24 = icmp eq i64 %22, %23
br label %25
25: ; preds = %21, %0
%26 = phi i1 [ false, %0 ], [ %24, %21 ]
%27 = zext i1 %26 to i64
%28 = select i1 %26, i32 0, i32 77
ret i32 %28
}

LLVM IR (-O2):
%struct.utimbuf = type { i32, i32 }
%struct.tm = type { i32 }
@.str = [27 x i8] c"utime(\22utime\\nfilename\22, [\00"
@.str.1 = [3 x i8] c", \00"
@.str.2 = [43 x i8] c"]) = -1 ENOENT (No such file or directory)\00"
@.str.3 = [22 x i8] c"+++ exited with 0 +++\00"
@.str.4 = [15 x i8] c"utime\0Afilename\00"
@errno = global i64 0
@ENOENT = global i64 0
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.utimbuf
%3 = bitcast i32* %1 to i8*
%4 = tail call i32 @time(i32* null)
store i32 %4, i32* %1
%5 = bitcast %struct.utimbuf* %2 to i8*
%6 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %2, i64 0, i32 0
store i32 %4, i32* %6
%7 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %2, i64 0, i32 1
store i32 %4, i32* %7
%8 = call %struct.tm* @localtime(i32* %1)
%9 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @print_tm(%struct.tm* %8)
%11 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @print_tm(%struct.tm* %8)
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 @utime(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), %struct.utimbuf* %2)
%16 = icmp eq i32 %15, -1
%17 = load i64, i64* @errno
%18 = load i64, i64* @ENOENT
%19 = icmp eq i64 %17, %18
%20 = select i1 %16, i1 %19, i1 false
%21 = select i1 %20, i32 0, i32 77
ret i32 %21
}