#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;
};

/* Variables and functions */
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
struct tm *gmtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  char tmbuf[256];
  time_t t = time(NULL);
  struct tm *gmt = gmtime(&t);
  if (argc > 1)
    strftime(tmbuf, 256, "%Y-%m-%dT%H:%M:%S+0000", gmt);
  else
    strftime(tmbuf, 256, "%Y-%m-%d", gmt);
  ;
  fputs(tmbuf, stdout);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,-0x114(%rbp)
lea    -0x114(%rbp),%rdi
call   1060 <gmtime@plt>
mov    %rax,-0x120(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11a9 <main+0x69>
lea    -0x110(%rbp),%rdi
mov    -0x120(%rbp),%rcx
mov    $0x100,%esi
lea    0xe61(%rip),%rdx
call   1050 <strftime@plt>
jmp    11c8 <main+0x88>
lea    -0x110(%rbp),%rdi
mov    -0x120(%rbp),%rcx
mov    $0x100,%esi
lea    0xe54(%rip),%rdx
call   1050 <strftime@plt>
lea    -0x110(%rbp),%rdi
mov    0x2e0a(%rip),%rax
mov    (%rax),%esi
call   1030 <fputs@plt>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x110,%rsp
mov    %edi,%ebx
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1060 <gmtime@plt>
cmp    $0x2,%ebx
lea    0xe97(%rip),%rcx
lea    0xea7(%rip),%rdx
cmovge %rcx,%rdx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %rax,%rcx
call   1050 <strftime@plt>
mov    0x2e50(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1030 <fputs@plt>
xor    %eax,%eax
add    $0x110,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [23 x i8] c"%Y-%m-%dT%H:%M:%S+0000\00"
@.str.1 = [9 x i8] c"%Y-%m-%d\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [256 x i8]
%7 = alloca i32
%8 = alloca %struct.tm*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 @time(i32* null)
store i32 %9, i32* %7
%10 = call %struct.tm* @gmtime(i32* %7)
store %struct.tm* %10, %struct.tm** %8
%11 = load i32, i32* %4
%12 = icmp sgt i32 %11, 1
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%15 = load %struct.tm*, %struct.tm** %8
%16 = call i32 @strftime(i8* %14, i32 256, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), %struct.tm* %15)
br label %21
17: ; preds = %2
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%19 = load %struct.tm*, %struct.tm** %8
%20 = call i32 @strftime(i8* %18, i32 256, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %19)
br label %21
21: ; preds = %17, %13
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%23 = load i32, i32* @stdout
%24 = call i32 @fputs(i8* %22, i32 %23)
ret i32 0
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [23 x i8] c"%Y-%m-%dT%H:%M:%S+0000\00"
@.str.1 = [9 x i8] c"%Y-%m-%d\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [256 x i8]
%4 = alloca i32
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = bitcast i32* %4 to i8*
%7 = tail call i32 @time(i32* null)
store i32 %7, i32* %4
%8 = call %struct.tm* @gmtime(i32* %4)
%9 = icmp sgt i32 %0, 1
%10 = select i1 %9, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0)
%11 = call i32 @strftime(i8* %5, i32 256, i8* %10, %struct.tm* %8)
%12 = load i32, i32* @stdout
%13 = call i32 @fputs(i8* %5, i32 %12)
ret i32 0
}