#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 char *time_t;
struct tm {
  int dummy;
};
typedef int /*<<< orphan*/ outstr;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
char *asctime(struct tm *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
struct tm *gmtime_r(char **, struct tm *);
struct tm *localtime_r(char **, struct tm *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
scalar_t__ strftime(char *, int, char *, struct tm *);
char *time(int /*<<< orphan*/ *);
void show_today() {
  time_t now = time(NULL);
  printf("Unix Time: %ld\n", now);
  struct tm *utctm, *localtm;
  struct tm tmp;
  utctm = gmtime_r(&now, &tmp);
  if (utctm == NULL) {
    perror("gmtime");
    exit(EXIT_FAILURE);
  }
  printf("UTC: %s", asctime(utctm));
  localtm = localtime_r(&now, &tmp);
  if (localtm == NULL) {
    perror("localtime");
    exit(EXIT_FAILURE);
  }
  printf("UTC: %s", asctime(utctm));
  printf("JST: %s", asctime(localtm));
  char outstr[200] = {0};
  char format[] = "%Y-%m-%d %H:%M:%S";
  if (strftime(outstr, sizeof(outstr), format, localtm) == 0) {
    fprintf(stderr, "strftime returned 0");
    exit(EXIT_FAILURE);
  }
  printf("JST: %s\n", outstr);
}


x86 assembly (clang, -O0):
<show_today>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
xor    %eax,%eax
mov    %eax,%edi
call   1090 <time@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe3d(%rip),%rdi
call   1050 <printf@plt>
lea    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1060 <gmtime_r@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11fe <show_today+0x5e>
lea    0xe25(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rdi
call   1040 <asctime@plt>
mov    %rax,%rsi
lea    0xe06(%rip),%rdi
call   1050 <printf@plt>
lea    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <localtime_r@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    124c <show_today+0xac>
lea    0xde6(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2d93(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rdi
call   1040 <asctime@plt>
mov    %rax,%rsi
lea    0xdb8(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <asctime@plt>
mov    %rax,%rsi
lea    0xdb2(%rip),%rdi
call   1050 <printf@plt>
lea    -0xf0(%rbp),%rdi
xor    %esi,%esi
mov    $0xc8,%edx
call   1070 <memset@plt>
mov    0xdba(%rip),%rax
mov    %rax,-0x110(%rbp)
mov    0xdb4(%rip),%rax
mov    %rax,-0x108(%rbp)
mov    0xdae(%rip),%ax
mov    %ax,-0x100(%rbp)
lea    -0xf0(%rbp),%rdi
lea    -0x110(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    $0xc8,%esi
call   10a0 <strftime@plt>
cmp    $0x0,%rax
jne    1302 <show_today+0x162>
mov    0x2cfa(%rip),%rax
mov    (%rax),%edi
lea    0xd42(%rip),%rsi
call   1080 <fprintf@plt>
mov    0x2cdd(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
lea    -0xf0(%rbp),%rsi
lea    0xd35(%rip),%rdi
call   1050 <printf@plt>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_today>:
push   %r14
push   %rbx
sub    $0xf8,%rsp
xor    %edi,%edi
call   1080 <time@plt>
mov    %rax,0x8(%rsp)
lea    0xe53(%rip),%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
lea    0x8(%rsp),%rdi
mov    %rsp,%rsi
call   1060 <gmtime_r@plt>
test   %rax,%rax
je     12d7 <show_today+0x147>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <asctime@plt>
lea    0xe3a(%rip),%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
lea    0x8(%rsp),%rdi
mov    %rsp,%rsi
call   1030 <localtime_r@plt>
test   %rax,%rax
je     12e0 <show_today+0x150>
mov    %rax,%r14
mov    %rbx,%rdi
call   1040 <asctime@plt>
lea    0xe0a(%rip),%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
mov    %r14,%rdi
call   1040 <asctime@plt>
lea    0xe05(%rip),%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movq   $0x0,0xf0(%rsp)
movaps 0xdbd(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movw   $0x53,0x20(%rsp)
lea    0x30(%rsp),%rdi
lea    0x10(%rsp),%rdx
mov    $0xc8,%esi
mov    %r14,%rcx
call   1090 <strftime@plt>
test   %rax,%rax
je     12ee <show_today+0x15e>
lea    0xd83(%rip),%rdi
lea    0x30(%rsp),%rsi
call   1050 <printf@plt>
add    $0xf8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xd32(%rip),%rdi
jmp    12e7 <show_today+0x157>
lea    0xd38(%rip),%rdi
call   10a0 <perror@plt>
jmp    1303 <show_today+0x173>
mov    0x2ceb(%rip),%rax
mov    (%rax),%edi
lea    0xd33(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2cce(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [16 x i8] c"Unix Time: %ld\0A\00"
@.str.1 = [7 x i8] c"gmtime\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [8 x i8] c"UTC: %s\00"
@.str.3 = [10 x i8] c"localtime\00"
@.str.4 = [8 x i8] c"JST: %s\00"
@__const.show_today.format = [18 x i8] c"%Y-%m-%d %H:%M:%S\00"
@stderr = global i32 0
@.str.5 = [20 x i8] c"strftime returned 0\00"
@.str.6 = [9 x i8] c"JST: %s\0A\00"
define void @show_today() {
%1 = alloca i8*
%2 = alloca %struct.tm*
%3 = alloca %struct.tm*
%4 = alloca %struct.tm
%5 = alloca [200 x i8]
%6 = alloca [18 x i8]
%7 = call i8* @time(i32* null)
store i8* %7, i8** %1
%8 = load i8*, i8** %1
%9 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = call %struct.tm* @gmtime_r(i8** %1, %struct.tm* %4)
store %struct.tm* %10, %struct.tm** %2
%11 = load %struct.tm*, %struct.tm** %2
%12 = icmp eq %struct.tm* %11, null
br i1 %12, label %13, label %17
13: ; preds = %0
%14 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @exit(i32 %15)
unreachable
17: ; preds = %0
%18 = load %struct.tm*, %struct.tm** %2
%19 = call i8* @asctime(%struct.tm* %18)
%20 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %19)
%21 = call %struct.tm* @localtime_r(i8** %1, %struct.tm* %4)
store %struct.tm* %21, %struct.tm** %3
%22 = load %struct.tm*, %struct.tm** %3
%23 = icmp eq %struct.tm* %22, null
br i1 %23, label %24, label %28
24: ; preds = %17
%25 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%26 = load i32, i32* @EXIT_FAILURE
%27 = call i32 @exit(i32 %26)
unreachable
28: ; preds = %17
%29 = load %struct.tm*, %struct.tm** %2
%30 = call i8* @asctime(%struct.tm* %29)
%31 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %30)
%32 = load %struct.tm*, %struct.tm** %3
%33 = call i8* @asctime(%struct.tm* %32)
%34 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %33)
%35 = bitcast [200 x i8]* %5 to i8*
%36 = bitcast [18 x i8]* %6 to i8*
%37 = getelementptr inbounds [200 x i8], [200 x i8]* %5, i64 0, i64 0
%38 = getelementptr inbounds [18 x i8], [18 x i8]* %6, i64 0, i64 0
%39 = load %struct.tm*, %struct.tm** %3
%40 = call i64 @strftime(i8* %37, i32 200, i8* %38, %struct.tm* %39)
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %47
42: ; preds = %28
%43 = load i32, i32* @stderr
%44 = call i32 @fprintf(i32 %43, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
%45 = load i32, i32* @EXIT_FAILURE
%46 = call i32 @exit(i32 %45)
unreachable
47: ; preds = %28
%48 = getelementptr inbounds [200 x i8], [200 x i8]* %5, i64 0, i64 0
%49 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8* %48)
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [16 x i8] c"Unix Time: %ld\0A\00"
@.str.1 = [7 x i8] c"gmtime\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [8 x i8] c"UTC: %s\00"
@.str.3 = [10 x i8] c"localtime\00"
@.str.4 = [8 x i8] c"JST: %s\00"
@__const.show_today.format = [18 x i8] c"%Y-%m-%d %H:%M:%S\00"
@stderr = global i32 0
@.str.5 = [20 x i8] c"strftime returned 0\00"
@.str.6 = [9 x i8] c"JST: %s\0A\00"
define void @show_today() {
%1 = alloca i8*
%2 = alloca %struct.tm
%3 = alloca [200 x i8]
%4 = alloca [18 x i8]
%5 = bitcast i8** %1 to i8*
%6 = tail call i8* @time(i32* null)
store i8* %6, i8** %1
%7 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = bitcast %struct.tm* %2 to i8*
%9 = call %struct.tm* @gmtime_r(i8** %1, %struct.tm* %2)
%10 = icmp eq %struct.tm* %9, null
br i1 %10, label %11, label %15
11: ; preds = %0
%12 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32, i32* @EXIT_FAILURE
%14 = call i32 @exit(i32 %13)
unreachable
15: ; preds = %0
%16 = call i8* @asctime(%struct.tm* %9)
%17 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %16)
%18 = call %struct.tm* @localtime_r(i8** %1, %struct.tm* %2)
%19 = icmp eq %struct.tm* %18, null
br i1 %19, label %20, label %24
20: ; preds = %15
%21 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%22 = load i32, i32* @EXIT_FAILURE
%23 = call i32 @exit(i32 %22)
unreachable
24: ; preds = %15
%25 = call i8* @asctime(%struct.tm* %9)
%26 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %25)
%27 = call i8* @asctime(%struct.tm* %18)
%28 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %27)
%29 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%30 = getelementptr inbounds [18 x i8], [18 x i8]* %4, i64 0, i64 0
%31 = call i64 @strftime(i8* %29, i32 200, i8* %30, %struct.tm* %18)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %38
33: ; preds = %24
%34 = load i32, i32* @stderr
%35 = call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
%36 = load i32, i32* @EXIT_FAILURE
%37 = call i32 @exit(i32 %36)
unreachable
38: ; preds = %24
%39 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8* %29)
ret void
}