#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ stderr;
void updatetime(int t) {
  FILE *tfile;
  tfile = fopen("/usr/spool/at/lasttimedone", "w");
  if (tfile == NULL) {
    fprintf(stderr, "can't write lastfile\n");
    exit(1);
  }
  fprintf(tfile, "%04d\n", t);
}


x86 assembly (clang, -O0):
<updatetime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0xebe(%rip),%rdi
lea    0xed2(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    117f <updatetime+0x4f>
mov    0x2e7c(%rip),%rax
movslq (%rax),%rdi
lea    0xeaf(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xea6(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<updatetime>:
push   %rbx
mov    %edi,%ebx
lea    0xeb6(%rip),%rdi
lea    0xeca(%rip),%rsi
call   1040 <fopen@plt>
test   %rax,%rax
je     116f <updatetime+0x2f>
lea    0xed1(%rip),%rsi
mov    %rax,%rdi
mov    %ebx,%edx
xor    %eax,%eax
pop    %rbx
jmp    1030 <fprintf@plt>
mov    0x2e6a(%rip),%rax
movslq (%rax),%rcx
lea    0xe9d(%rip),%rdi
mov    $0x15,%esi
mov    $0x1,%edx
call   1060 <fwrite@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [27 x i8] c"/usr/spool/at/lasttimedone\00"
@.str.1 = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.2 = [22 x i8] c"can't write lastfile\0A\00"
@.str.3 = [6 x i8] c"%04d\0A\00"
define void @updatetime(i32 %0) {
%2 = alloca i32
%3 = alloca i32*
store i32 %0, i32* %2
%4 = call i32* @fopen(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %4, i32** %3
%5 = load i32*, i32** %3
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %13
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = sext i32 %8 to i64
%10 = inttoptr i64 %9 to i32*
%11 = call i32 (i32*, i8*, ...) @fprintf(i32* %10, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %1
%14 = load i32*, i32** %3
%15 = load i32, i32* %2
%16 = call i32 (i32*, i8*, ...) @fprintf(i32* %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %15)
ret void
}

LLVM IR (-O2):
@.str = [27 x i8] c"/usr/spool/at/lasttimedone\00"
@.str.1 = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.2 = [22 x i8] c"can't write lastfile\0A\00"
@.str.3 = [6 x i8] c"%04d\0A\00"
define void @updatetime(i32 %0) {
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %10
4: ; preds = %1
%5 = load i32, i32* @stderr
%6 = sext i32 %5 to i64
%7 = inttoptr i64 %6 to i32*
%8 = tail call i64 @fwrite(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i64 21, i64 1, i32* %7)
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %1
%11 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %0)
ret void
}