#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 tm_year;
  int tm_mon;
  int tm_mday;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, int, int);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ *stdout;
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  time_t ltime;
  struct tm *today;
  FILE *of;
  if (argc != 2) {
    of = stdout;
  } else {
    of = fopen(argv[1], "w");
    if (!of)
      return 3;
  }
  time(&ltime);
  today = localtime(&ltime);
  if (!today)
    return 1;
  fprintf(of, "%d.%02d.%02d", (today->tm_year + 1900), (today->tm_mon + 1),
          today->tm_mday);
  if (of != stdout)
    fclose(of);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1183 <main+0x33>
mov    0x2e69(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    11b7 <main+0x67>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe6e(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11b2 <main+0x62>
movl   $0x3,-0x4(%rbp)
jmp    1236 <main+0xe6>
jmp    11b7 <main+0x67>
lea    -0x14(%rbp),%rdi
call   1060 <time@plt>
lea    -0x14(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11e4 <main+0x94>
movl   $0x1,-0x4(%rbp)
jmp    1236 <main+0xe6>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%edx
add    $0x76c,%edx
mov    -0x20(%rbp),%rax
mov    0x4(%rax),%ecx
add    $0x1,%ecx
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%r8d
lea    0xdf5(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x28(%rbp),%rax
mov    0x2dc3(%rip),%rcx
cmp    (%rcx),%rax
je     122f <main+0xdf>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    1177 <main+0x27>
mov    0x8(%rsi),%rdi
lea    0xe9d(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1181 <main+0x31>
mov    $0x3,%ebp
jmp    11d8 <main+0x88>
mov    0x2e62(%rip),%rax
mov    (%rax),%rbx
lea    0x4(%rsp),%rbp
mov    %rbp,%rdi
call   1060 <time@plt>
mov    %rbp,%rdi
call   1030 <localtime@plt>
test   %rax,%rax
je     11d3 <main+0x83>
mov    $0x76c,%edx
add    (%rax),%edx
mov    0x4(%rax),%ecx
mov    0x8(%rax),%r8d
add    $0x1,%ecx
lea    0xe4f(%rip),%rsi
mov    %rbx,%rdi
call   1050 <fprintf@plt>
mov    0x2e1e(%rip),%rax
xor    %ebp,%ebp
cmp    (%rax),%rbx
je     11d8 <main+0x88>
mov    %rbx,%rdi
call   1040 <fclose@plt>
jmp    11d8 <main+0x88>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32 }
@stdout = global i32* null
@.str = [2 x i8] c"w\00"
@.str.1 = [13 x i8] c"%d.%02d.%02d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.tm*
%8 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = load i32*, i32** @stdout
store i32* %12, i32** %8
br label %22
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %17, i32** %8
%18 = load i32*, i32** %8
%19 = icmp ne i32* %18, null
br i1 %19, label %21, label %20
20: ; preds = %13
store i32 3, i32* %3
br label %49
21: ; preds = %13
br label %22
22: ; preds = %21, %11
%23 = call i32 @time(i32* %6)
%24 = call %struct.tm* @localtime(i32* %6)
store %struct.tm* %24, %struct.tm** %7
%25 = load %struct.tm*, %struct.tm** %7
%26 = icmp ne %struct.tm* %25, null
br i1 %26, label %28, label %27
27: ; preds = %22
store i32 1, i32* %3
br label %49
28: ; preds = %22
%29 = load i32*, i32** %8
%30 = load %struct.tm*, %struct.tm** %7
%31 = getelementptr inbounds %struct.tm, %struct.tm* %30, i32 0, i32 0
%32 = load i32, i32* %31
%33 = add nsw i32 %32, 1900
%34 = load %struct.tm*, %struct.tm** %7
%35 = getelementptr inbounds %struct.tm, %struct.tm* %34, i32 0, i32 1
%36 = load i32, i32* %35
%37 = add nsw i32 %36, 1
%38 = load %struct.tm*, %struct.tm** %7
%39 = getelementptr inbounds %struct.tm, %struct.tm* %38, i32 0, i32 2
%40 = load i32, i32* %39
%41 = call i32 @fprintf(i32* %29, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %33, i32 %37, i32 %40)
%42 = load i32*, i32** %8
%43 = load i32*, i32** @stdout
%44 = icmp ne i32* %42, %43
br i1 %44, label %45, label %48
45: ; preds = %28
%46 = load i32*, i32** %8
%47 = call i32 @fclose(i32* %46)
br label %48
48: ; preds = %45, %28
store i32 0, i32* %3
br label %49
49: ; preds = %48, %27, %20
%50 = load i32, i32* %3
ret i32 %50
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32 }
@stdout = global i32* null
@.str = [2 x i8] c"w\00"
@.str.1 = [13 x i8] c"%d.%02d.%02d\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = icmp eq i32 %0, 2
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = load i32*, i32** @stdout
br label %13
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %32, label %13
13: ; preds = %8, %6
%14 = phi i32* [ %7, %6 ], [ %11, %8 ]
%15 = call i32 @time(i32* %3)
%16 = call %struct.tm* @localtime(i32* %3)
%17 = icmp eq %struct.tm* %16, null
br i1 %17, label %32, label %18
18: ; preds = %13
%19 = getelementptr inbounds %struct.tm, %struct.tm* %16, i64 0, i32 0
%20 = load i32, i32* %19
%21 = add nsw i32 %20, 1900
%22 = getelementptr inbounds %struct.tm, %struct.tm* %16, i64 0, i32 1
%23 = load i32, i32* %22
%24 = add nsw i32 %23, 1
%25 = getelementptr inbounds %struct.tm, %struct.tm* %16, i64 0, i32 2
%26 = load i32, i32* %25
%27 = call i32 @fprintf(i32* %14, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %21, i32 %24, i32 %26)
%28 = load i32*, i32** @stdout
%29 = icmp eq i32* %14, %28
br i1 %29, label %32, label %30
30: ; preds = %18
%31 = call i32 @fclose(i32* %14)
br label %32
32: ; preds = %18, %30, %13, %8
%33 = phi i32 [ 3, %8 ], [ 1, %13 ], [ 0, %30 ], [ 0, %18 ]
ret i32 %33
}