#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 */
struct tm *gmtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ log_d(char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
char *rfctime(time_t t, char *buf) {
  struct tm *tp;
  tp = gmtime(&t);
  if (tp == 0) {
    log_d("gmtime failed!?!?!?");
    strcpy(buf, "?");
    return buf;
  }
  strftime(buf, 31, "%a, %d %b %Y %H:%M:%S GMT", tp);
  return buf;
}


x86 assembly (clang, -O0):
<rfctime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0xc(%rbp),%rdi
call   1060 <gmtime@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1190 <rfctime+0x50>
lea    0xe92(%rip),%rdi
call   1040 <log_d@plt>
mov    -0x18(%rbp),%rdi
lea    0xe94(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11b1 <rfctime+0x71>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x1f,%esi
lea    0xe70(%rip),%rdx
call   1050 <strftime@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rfctime>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %edi,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1060 <gmtime@plt>
test   %rax,%rax
je     1174 <rfctime+0x34>
lea    0xeb2(%rip),%rdx
mov    %rbx,%rdi
mov    $0x1f,%esi
mov    %rax,%rcx
call   1050 <strftime@plt>
jmp    118f <rfctime+0x4f>
lea    0xe85(%rip),%rdi
call   1040 <log_d@plt>
lea    0xe8b(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [20 x i8] c"gmtime failed!?!?!?\00"
@.str.1 = [2 x i8] c"?\00"
@.str.2 = [26 x i8] c"%a, %d %b %Y %H:%M:%S GMT\00"
define i8* @rfctime(i32 %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca %struct.tm*
store i32 %0, i32* %4
store i8* %1, i8** %5
%7 = call %struct.tm* @gmtime(i32* %4)
store %struct.tm* %7, %struct.tm** %6
%8 = load %struct.tm*, %struct.tm** %6
%9 = icmp eq %struct.tm* %8, null
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = call i32 @log_d(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%12 = load i8*, i8** %5
%13 = call i32 @strcpy(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = load i8*, i8** %5
store i8* %14, i8** %3
br label %20
15: ; preds = %2
%16 = load i8*, i8** %5
%17 = load %struct.tm*, %struct.tm** %6
%18 = call i32 @strftime(i8* %16, i32 31, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), %struct.tm* %17)
%19 = load i8*, i8** %5
store i8* %19, i8** %3
br label %20
20: ; preds = %15, %10
%21 = load i8*, i8** %3
ret i8* %21
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [20 x i8] c"gmtime failed!?!?!?\00"
@.str.1 = [2 x i8] c"?\00"
@.str.2 = [26 x i8] c"%a, %d %b %Y %H:%M:%S GMT\00"
define i8* @rfctime(i32 %0, i8* returned %1) {
%3 = alloca i32
store i32 %0, i32* %3
%4 = call %struct.tm* @gmtime(i32* %3)
%5 = icmp eq %struct.tm* %4, null
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = call i32 @log_d(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @strcpy(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %11
9: ; preds = %2
%10 = call i32 @strftime(i8* %1, i32 31, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), %struct.tm* %4)
br label %11
11: ; preds = %9, %6
ret i8* %1
}