#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 tm {
  int dummy;
};
struct timeval {
  int /*<<< orphan*/ tv_usec;
  int /*<<< orphan*/ tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ mktime(struct tm *);
int utimes(char const *, struct timeval *);
int touch(const char *filename, struct tm *tm) {
  time_t ut = mktime(tm);
  struct timeval tv[2] = {{.tv_sec = ut, .tv_usec = 0},
                          {.tv_sec = ut, .tv_usec = 0}};
  return utimes(filename, tv);
}


x86 assembly (clang, -O0):
<touch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <mktime@plt>
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x2c(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1030 <utimes@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<touch>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1040 <mktime@plt>
movl   $0x0,(%rsp)
mov    %eax,0x4(%rsp)
movl   $0x0,0x8(%rsp)
mov    %eax,0xc(%rsp)
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1030 <utimes@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
%struct.timeval = type { i32, i32 }
define i32 @touch(i8* %0, %struct.tm* %1) {
%3 = alloca i8*
%4 = alloca %struct.tm*
%5 = alloca i32
%6 = alloca [2 x %struct.timeval]
store i8* %0, i8** %3
store %struct.tm* %1, %struct.tm** %4
%7 = load %struct.tm*, %struct.tm** %4
%8 = call i32 @mktime(%struct.tm* %7)
store i32 %8, i32* %5
%9 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %6, i64 0, i64 0
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i32 0, i32 0
store i32 0, i32* %10
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i32 0, i32 1
%12 = load i32, i32* %5
store i32 %12, i32* %11
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i64 1
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 0
store i32 0, i32* %14
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 1
%16 = load i32, i32* %5
store i32 %16, i32* %15
%17 = load i8*, i8** %3
%18 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %6, i64 0, i64 0
%19 = call i32 @utimes(i8* %17, %struct.timeval* %18)
ret i32 %19
}

LLVM IR (-O2):
%struct.tm = type { i32 }
%struct.timeval = type { i32, i32 }
define i32 @touch(i8* nocapture %0, %struct.tm* nocapture %1) {
%3 = alloca [2 x %struct.timeval]
%4 = tail call i32 @mktime(%struct.tm* %1)
%5 = bitcast [2 x %struct.timeval]* %3 to i8*
%6 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %3, i64 0, i64 0
%7 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %3, i64 0, i64 0, i32 0
store i32 0, i32* %7
%8 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %3, i64 0, i64 0, i32 1
store i32 %4, i32* %8
%9 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %3, i64 0, i64 1, i32 0
store i32 0, i32* %9
%10 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %3, i64 0, i64 1, i32 1
store i32 %4, i32* %10
%11 = call i32 @utimes(i8* %0, %struct.timeval* %6)
ret i32 %11
}