#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 {
  unsigned long tv_sec;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ err(int, char *);
int /*<<< orphan*/ errx(int, char *);
scalar_t__ fclose(int /*<<< orphan*/ *);
scalar_t__ fflush(int /*<<< orphan*/ *);
int fileno(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int futimes(int, struct timeval *);
int fwrite(char *, int, int, int /*<<< orphan*/ *);
int gettimeofday(struct timeval *, int /*<<< orphan*/);
unsigned long strtol(char *, int /*<<< orphan*/, int);
int main(int argc, char *argv[]) {
  struct timeval t[2];
  FILE *fp;
  unsigned long size = 0;
  unsigned long age;
  int fd;
  if (argc < 3)
    errx(2, "usage: file age [size]");
  age = strtol(argv[2], 0, 10);
  if (!age)
    errx(2, "age must be numeric");
  if (argc > 3) {
    size = strtol(argv[2], 0, 10);
  }
  fp = fopen(argv[1], "wb");
  if (!fp)
    err(2, "fopen");
  fd = fileno(fp);
  if (argc > 3) {
    for (;;) {
      if (!size)
        break;
      if (fwrite("\x0", 1, 1, fp) < 1)
        err(2, "fwrite");
      --size;
    }
    if (fflush(fp) != 0)
      err(2, "fflush");
  }
  if (gettimeofday(&t[0], 0) == -1)
    err(2, "gettimeofday");
  t[0].tv_sec -= age;
  t[1] = t[0];
  if (futimes(fd, t) == -1)
    err(2, "futimes");
  if (fclose(fp) != 0)
    err(2, "fclose");
  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)
movq   $0x0,-0x30(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11d9 <main+0x39>
mov    $0x2,%edi
lea    0xe2c(%rip),%rsi
call   1050 <errx@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1070 <strtol@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    120d <main+0x6d>
mov    $0x2,%edi
lea    0xe0f(%rip),%rsi
call   1050 <errx@plt>
cmpl   $0x3,-0x8(%rbp)
jle    122f <main+0x8f>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1070 <strtol@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xded(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1263 <main+0xc3>
mov    $0x2,%edi
lea    0xdd0(%rip),%rsi
call   1090 <err@plt>
mov    -0x28(%rbp),%rdi
call   1080 <fileno@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x3,-0x8(%rbp)
jle    12f9 <main+0x159>
jmp    127e <main+0xde>
cmpq   $0x0,-0x30(%rbp)
jne    128e <main+0xee>
jmp    12d0 <main+0x130>
mov    -0x28(%rbp),%rcx
lea    0xdc5(%rip),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   10c0 <fwrite@plt>
cmp    $0x1,%eax
jge    12bf <main+0x11f>
mov    $0x2,%edi
lea    0xd7a(%rip),%rsi
call   1090 <err@plt>
mov    -0x30(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x30(%rbp)
jmp    127e <main+0xde>
mov    -0x28(%rbp),%rdi
call   10a0 <fflush@plt>
cmp    $0x0,%rax
je     12f4 <main+0x154>
mov    $0x2,%edi
lea    0xd4c(%rip),%rsi
call   1090 <err@plt>
jmp    12f9 <main+0x159>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
cmp    $0xffffffff,%eax
jne    131e <main+0x17e>
mov    $0x2,%edi
lea    0xd29(%rip),%rsi
call   1090 <err@plt>
mov    -0x38(%rbp),%rcx
mov    -0x20(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x3c(%rbp),%edi
lea    -0x20(%rbp),%rsi
call   1040 <futimes@plt>
cmp    $0xffffffff,%eax
jne    135b <main+0x1bb>
mov    $0x2,%edi
lea    0xcf9(%rip),%rsi
call   1090 <err@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
cmp    $0x0,%rax
je     137f <main+0x1df>
mov    $0x2,%edi
lea    0xcdd(%rip),%rsi
call   1090 <err@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %edi,%r12d
cmp    $0x2,%edi
jg     11ca <main+0x2a>
lea    0xe40(%rip),%rsi
mov    $0x2,%edi
call   1050 <errx@plt>
mov    0x10(%rbx),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1070 <strtol@plt>
mov    %rax,%r14
test   %rax,%rax
je     11fd <main+0x5d>
cmp    $0x4,%r12d
jl     1214 <main+0x74>
mov    0x10(%rbx),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1070 <strtol@plt>
mov    %rax,%rbp
jmp    1216 <main+0x76>
lea    0xe13(%rip),%rsi
mov    $0x2,%edi
call   1050 <errx@plt>
cmp    $0x4,%r12d
jge    11e8 <main+0x48>
xor    %ebp,%ebp
mov    0x8(%rbx),%rdi
lea    0xe0a(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    123f <main+0x9f>
lea    0xdf9(%rip),%rsi
mov    $0x2,%edi
call   1090 <err@plt>
mov    %rbx,%rdi
call   1080 <fileno@plt>
mov    %eax,%r15d
cmp    $0x4,%r12d
jl     12bc <main+0x11c>
test   %rbp,%rbp
je     129e <main+0xfe>
lea    0xe02(%rip),%r12
lea    0xdd1(%rip),%r13
jmp    1276 <main+0xd6>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0xffffffffffffffff,%rbp
je     129e <main+0xfe>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10c0 <fwrite@plt>
test   %eax,%eax
jg     1270 <main+0xd0>
mov    $0x2,%edi
mov    %r13,%rsi
call   1090 <err@plt>
jmp    1270 <main+0xd0>
mov    %rbx,%rdi
call   10a0 <fflush@plt>
test   %rax,%rax
je     12bc <main+0x11c>
lea    0xd89(%rip),%rsi
mov    $0x2,%edi
call   1090 <err@plt>
mov    %rsp,%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
cmp    $0xffffffff,%eax
jne    12dc <main+0x13c>
lea    0xd70(%rip),%rsi
mov    $0x2,%edi
call   1090 <err@plt>
mov    (%rsp),%rax
sub    %r14,%rax
mov    %rax,(%rsp)
mov    %rax,0x8(%rsp)
mov    %rsp,%rsi
mov    %r15d,%edi
call   1040 <futimes@plt>
cmp    $0xffffffff,%eax
jne    130d <main+0x16d>
lea    0xd4c(%rip),%rsi
mov    $0x2,%edi
call   1090 <err@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
test   %rax,%rax
je     132b <main+0x18b>
lea    0xd36(%rip),%rsi
mov    $0x2,%edi
call   1090 <err@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i64 }
@.str = [23 x i8] c"usage: file age [size]\00"
@.str.1 = [20 x i8] c"age must be numeric\00"
@.str.2 = [3 x i8] c"wb\00"
@.str.3 = [6 x i8] c"fopen\00"
@.str.4 = [2 x i8] zeroinitializer
@.str.5 = [7 x i8] c"fwrite\00"
@.str.6 = [7 x i8] c"fflush\00"
@.str.7 = [13 x i8] c"gettimeofday\00"
@.str.8 = [8 x i8] c"futimes\00"
@.str.9 = [7 x i8] c"fclose\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [2 x %struct.timeval]
%7 = alloca i32*
%8 = alloca i64
%9 = alloca i64
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %8
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 3
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 @errx(i32 2, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %13, %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 2
%18 = load i8*, i8** %17
%19 = call i64 @strtol(i8* %18, i32 0, i32 10)
store i64 %19, i64* %9
%20 = load i64, i64* %9
%21 = icmp ne i64 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %15
%23 = call i32 @errx(i32 2, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %22, %15
%25 = load i32, i32* %4
%26 = icmp sgt i32 %25, 3
br i1 %26, label %27, label %32
27: ; preds = %24
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 2
%30 = load i8*, i8** %29
%31 = call i64 @strtol(i8* %30, i32 0, i32 10)
store i64 %31, i64* %8
br label %32
32: ; preds = %27, %24
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = call i32* @fopen(i8* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %36, i32** %7
%37 = load i32*, i32** %7
%38 = icmp ne i32* %37, null
br i1 %38, label %41, label %39
39: ; preds = %32
%40 = call i32 @err(i32 2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %41
41: ; preds = %39, %32
%42 = load i32*, i32** %7
%43 = call i32 @fileno(i32* %42)
store i32 %43, i32* %10
%44 = load i32, i32* %4
%45 = icmp sgt i32 %44, 3
br i1 %45, label %46, label %67
46: ; preds = %41
br label %47
47: ; preds = %57, %46
%48 = load i64, i64* %8
%49 = icmp ne i64 %48, 0
br i1 %49, label %51, label %50
50: ; preds = %47
br label %60
51: ; preds = %47
%52 = load i32*, i32** %7
%53 = call i32 @fwrite(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 1, i32 1, i32* %52)
%54 = icmp slt i32 %53, 1
br i1 %54, label %55, label %57
55: ; preds = %51
%56 = call i32 @err(i32 2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %57
57: ; preds = %55, %51
%58 = load i64, i64* %8
%59 = add i64 %58, -1
store i64 %59, i64* %8
br label %47
60: ; preds = %50
%61 = load i32*, i32** %7
%62 = call i64 @fflush(i32* %61)
%63 = icmp ne i64 %62, 0
br i1 %63, label %64, label %66
64: ; preds = %60
%65 = call i32 @err(i32 2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %66
66: ; preds = %64, %60
br label %67
67: ; preds = %66, %41
%68 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %6, i64 0, i64 0
%69 = call i32 @gettimeofday(%struct.timeval* %68, i32 0)
%70 = icmp eq i32 %69, -1
br i1 %70, label %71, label %73
71: ; preds = %67
%72 = call i32 @err(i32 2, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
br label %73
73: ; preds = %71, %67
%74 = load i64, i64* %9
%75 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %6, i64 0, i64 0
%76 = getelementptr inbounds %struct.timeval, %struct.timeval* %75, i32 0, i32 0
%77 = load i64, i64* %76
%78 = sub i64 %77, %74
store i64 %78, i64* %76
%79 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %6, i64 0, i64 1
%80 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %6, i64 0, i64 0
%81 = bitcast %struct.timeval* %79 to i8*
%82 = bitcast %struct.timeval* %80 to i8*
%83 = load i32, i32* %10
%84 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %6, i64 0, i64 0
%85 = call i32 @futimes(i32 %83, %struct.timeval* %84)
%86 = icmp eq i32 %85, -1
br i1 %86, label %87, label %89
87: ; preds = %73
%88 = call i32 @err(i32 2, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
br label %89
89: ; preds = %87, %73
%90 = load i32*, i32** %7
%91 = call i64 @fclose(i32* %90)
%92 = icmp ne i64 %91, 0
br i1 %92, label %93, label %95
93: ; preds = %89
%94 = call i32 @err(i32 2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0))
br label %95
95: ; preds = %93, %89
ret i32 0
}

LLVM IR (-O2):
%struct.timeval = type { i64 }
@.str = [23 x i8] c"usage: file age [size]\00"
@.str.1 = [20 x i8] c"age must be numeric\00"
@.str.2 = [3 x i8] c"wb\00"
@.str.3 = [6 x i8] c"fopen\00"
@.str.4 = [2 x i8] zeroinitializer
@.str.5 = [7 x i8] c"fwrite\00"
@.str.6 = [7 x i8] c"fflush\00"
@.str.7 = [13 x i8] c"gettimeofday\00"
@.str.8 = [8 x i8] c"futimes\00"
@.str.9 = [7 x i8] c"fclose\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [2 x %struct.timeval]
%4 = bitcast [2 x %struct.timeval]* %3 to i8*
%5 = icmp slt i32 %0, 3
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @errx(i32 2, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %6, %2
%9 = getelementptr inbounds i8*, i8** %1, i64 2
%10 = load i8*, i8** %9
%11 = tail call i64 @strtol(i8* %10, i32 0, i32 10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %8
%14 = tail call i32 @errx(i32 2, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %13, %8
%16 = icmp sgt i32 %0, 3
br i1 %16, label %17, label %20
17: ; preds = %15
%18 = load i8*, i8** %9
%19 = tail call i64 @strtol(i8* %18, i32 0, i32 10)
br label %20
20: ; preds = %17, %15
%21 = phi i64 [ %19, %17 ], [ 0, %15 ]
%22 = getelementptr inbounds i8*, i8** %1, i64 1
%23 = load i8*, i8** %22
%24 = tail call i32* @fopen(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %28
26: ; preds = %20
%27 = tail call i32 @err(i32 2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %28
28: ; preds = %26, %20
%29 = tail call i32 @fileno(i32* %24)
br i1 %16, label %30, label %46
30: ; preds = %28
%31 = icmp eq i64 %21, 0
br i1 %31, label %41, label %32
32: ; preds = %30, %38
%33 = phi i64 [ %39, %38 ], [ %21, %30 ]
%34 = tail call i32 @fwrite(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 1, i32 1, i32* %24)
%35 = icmp slt i32 %34, 1
br i1 %35, label %36, label %38
36: ; preds = %32
%37 = tail call i32 @err(i32 2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %38
38: ; preds = %36, %32
%39 = add i64 %33, -1
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %32
41: ; preds = %38, %30
%42 = tail call i64 @fflush(i32* %24)
%43 = icmp eq i64 %42, 0
br i1 %43, label %46, label %44
44: ; preds = %41
%45 = tail call i32 @err(i32 2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %46
46: ; preds = %41, %44, %28
%47 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %3, i64 0, i64 0
%48 = call i32 @gettimeofday(%struct.timeval* %47, i32 0)
%49 = icmp eq i32 %48, -1
br i1 %49, label %50, label %52
50: ; preds = %46
%51 = call i32 @err(i32 2, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
br label %52
52: ; preds = %50, %46
%53 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %3, i64 0, i64 0, i32 0
%54 = load i64, i64* %53
%55 = sub i64 %54, %11
store i64 %55, i64* %53
%56 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %3, i64 0, i64 1, i32 0
store i64 %55, i64* %56
%57 = call i32 @futimes(i32 %29, %struct.timeval* %47)
%58 = icmp eq i32 %57, -1
br i1 %58, label %59, label %61
59: ; preds = %52
%60 = call i32 @err(i32 2, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
br label %61
61: ; preds = %59, %52
%62 = call i64 @fclose(i32* %24)
%63 = icmp eq i64 %62, 0
br i1 %63, label %66, label %64
64: ; preds = %61
%65 = call i32 @err(i32 2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0))
br label %66
66: ; preds = %64, %61
ret i32 0
}