#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 tm {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ INT_MAX;
char *getenv(char *);
scalar_t__ strftime(char *, int /*<<< orphan*/, char const *,
                    struct tm const *);
int ascftime(char *s, const char *format, const struct tm *timeptr) {
  if (!format || *format == '\0' || !(format = getenv("CFTIME")) ||
      *format == '\0')
    format = "%C";
  return ((int)strftime(s, INT_MAX, format, timeptr));
}


x86 assembly (clang, -O0):
<ascftime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1179 <ascftime+0x59>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1179 <ascftime+0x59>
lea    0xeaa(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     1179 <ascftime+0x59>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1184 <ascftime+0x64>
lea    0xe87(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e59(%rip),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
call   1040 <strftime@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ascftime>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rdi,%rbx
test   %rsi,%rsi
je     114d <ascftime+0x2d>
cmpb   $0x0,(%rsi)
je     114d <ascftime+0x2d>
lea    0xec5(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     114d <ascftime+0x2d>
mov    %rax,%rdx
cmpb   $0x0,(%rax)
jne    1154 <ascftime+0x34>
lea    0xeb3(%rip),%rdx
mov    0x2e8d(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
mov    %r14,%rcx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <strftime@plt>

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [7 x i8] c"CFTIME\00"
@.str.1 = [3 x i8] c"%C\00"
@INT_MAX = global i32 0
define i32 @ascftime(i8* %0, i8* %1, %struct.tm* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca %struct.tm*
store i8* %0, i8** %4
store i8* %1, i8** %5
store %struct.tm* %2, %struct.tm** %6
%7 = load i8*, i8** %5
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %22
9: ; preds = %3
%10 = load i8*, i8** %5
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 0
br i1 %13, label %22, label %14
14: ; preds = %9
%15 = call i8* @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i8* %15, i8** %5
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %22
17: ; preds = %14
%18 = load i8*, i8** %5
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %17, %14, %9, %3
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %5
br label %23
23: ; preds = %22, %17
%24 = load i8*, i8** %4
%25 = load i32, i32* @INT_MAX
%26 = load i8*, i8** %5
%27 = load %struct.tm*, %struct.tm** %6
%28 = call i64 @strftime(i8* %24, i32 %25, i8* %26, %struct.tm* %27)
%29 = trunc i64 %28 to i32
ret i32 %29
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [7 x i8] c"CFTIME\00"
@.str.1 = [3 x i8] c"%C\00"
@INT_MAX = global i32 0
define i32 @ascftime(i8* %0, i8* %1, %struct.tm* %2) {
%4 = icmp eq i8* %1, null
br i1 %4, label %14, label %5
5: ; preds = %3
%6 = load i8, i8* %1
%7 = icmp eq i8 %6, 0
br i1 %7, label %14, label %8
8: ; preds = %5
%9 = tail call i8* @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i8* %9, null
br i1 %10, label %14, label %11
11: ; preds = %8
%12 = load i8, i8* %9
%13 = icmp eq i8 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %11, %8, %5, %3
br label %15
15: ; preds = %14, %11
%16 = phi i8* [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %14 ], [ %9, %11 ]
%17 = load i32, i32* @INT_MAX
%18 = tail call i64 @strftime(i8* %0, i32 %17, i8* %16, %struct.tm* %2)
%19 = trunc i64 %18 to i32
ret i32 %19
}