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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fwrite(int /*<<< orphan*/ *, int /*<<< orphan*/,
                          int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
scalar_t__ stat(char *, struct stat *);
void *time(int /*<<< orphan*/ *);
scalar_t__ utime(char *, struct utimbuf *);
int main(int argc, char **argv) {
  struct stat f;
  if (stat(argv[1], &f) < 0) {
    FILE *newfile;
    newfile = fopen(argv[1], "a");
    fwrite(NULL, 0, 0, newfile);
    fclose(newfile);
  } else {
    char *filename = argv[1];
    struct utimbuf newtime;
    newtime.actime = time(NULL);
    newtime.modtime = time(NULL);
    if (utime(filename, &newtime) < 0) {
      perror(filename);
      return 1;
    }
  }
  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    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <stat@plt>
cmp    $0x0,%rax
jge    11d8 <main+0x68>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe50(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%edi
xor    %edx,%edx
mov    %edx,%esi
call   1090 <fwrite@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
jmp    122f <main+0xbf>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %rax,-0x30(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1030 <utime@plt>
cmp    $0x0,%rax
jge    122a <main+0xba>
mov    -0x28(%rbp),%rdi
call   1080 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1236 <main+0xc6>
jmp    122f <main+0xbf>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
mov    %rsp,%rsi
call   1050 <stat@plt>
mov    0x8(%rbx),%r14
test   %rax,%rax
js     11ba <main+0x5a>
xor    %ebx,%ebx
xor    %edi,%edi
call   1060 <time@plt>
mov    %rax,0x10(%rsp)
xor    %edi,%edi
call   1060 <time@plt>
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rsi
mov    %r14,%rdi
call   1030 <utime@plt>
test   %rax,%rax
jns    11d3 <main+0x73>
mov    %r14,%rdi
call   1080 <perror@plt>
mov    $0x1,%ebx
jmp    11d3 <main+0x73>
lea    0xe3f(%rip),%rsi
mov    %r14,%rdi
call   1070 <fopen@plt>
mov    %rax,%rdi
call   1040 <fclose@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
%struct.utimbuf = type { i8*, i8* }
@.str = [2 x i8] c"a\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.stat
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca %struct.utimbuf
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i64 @stat(i8* %12, %struct.stat* %6)
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %24
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %19, i32** %7
%20 = load i32*, i32** %7
%21 = call i32 @fwrite(i32* null, i32 0, i32 0, i32* %20)
%22 = load i32*, i32** %7
%23 = call i32 @fclose(i32* %22)
br label %39
24: ; preds = %2
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
store i8* %27, i8** %8
%28 = call i8* @time(i32* null)
%29 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %9, i32 0, i32 1
store i8* %28, i8** %29
%30 = call i8* @time(i32* null)
%31 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %9, i32 0, i32 0
store i8* %30, i8** %31
%32 = load i8*, i8** %8
%33 = call i64 @utime(i8* %32, %struct.utimbuf* %9)
%34 = icmp slt i64 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %24
%36 = load i8*, i8** %8
%37 = call i32 @perror(i8* %36)
store i32 1, i32* %3
br label %40
38: ; preds = %24
br label %39
39: ; preds = %38, %15
store i32 0, i32* %3
br label %40
40: ; preds = %39, %35
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
%struct.stat = type { i32 }
%struct.utimbuf = type { i8*, i8* }
@.str = [2 x i8] c"a\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = alloca %struct.utimbuf
%5 = bitcast %struct.stat* %3 to i8*
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = call i64 @stat(i8* %7, %struct.stat* %3)
%9 = icmp slt i64 %8, 0
%10 = load i8*, i8** %6
br i1 %9, label %11, label %14
11: ; preds = %2
%12 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @fclose(i32* %12)
br label %25
14: ; preds = %2
%15 = bitcast %struct.utimbuf* %4 to i8*
%16 = call i8* @time(i32* null)
%17 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %4, i64 0, i32 1
store i8* %16, i8** %17
%18 = call i8* @time(i32* null)
%19 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %4, i64 0, i32 0
store i8* %18, i8** %19
%20 = call i64 @utime(i8* %10, %struct.utimbuf* %4)
%21 = icmp slt i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %14
%23 = call i32 @perror(i8* %10)
br label %25
24: ; preds = %14
br label %25
25: ; preds = %11, %24, %22
%26 = phi i32 [ 1, %22 ], [ 0, %24 ], [ 0, %11 ]
ret i32 %26
}