#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 */
size_t _clog_append_str(char **, char *, char *, size_t);
size_t strftime(char *, int, char const *, struct tm *);
size_t _clog_append_time(char **dst, char *orig_buf, struct tm *lt,
                         const char *fmt, size_t cur_size) {
  char buf[256];
  size_t result = strftime(buf, 256, fmt, lt);
  if (result > 0) {
    return _clog_append_str(dst, orig_buf, buf, cur_size);
  }
  return cur_size;
}


x86 assembly (clang, -O0):
<_clog_append_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
lea    -0x130(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    $0x100,%esi
call   1040 <strftime@plt>
mov    %rax,-0x138(%rbp)
cmpq   $0x0,-0x138(%rbp)
jbe    118e <_clog_append_time+0x6e>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x130(%rbp),%rdx
mov    -0x30(%rbp),%rcx
call   1030 <_clog_append_str@plt>
mov    %rax,-0x8(%rbp)
jmp    1196 <_clog_append_time+0x76>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_clog_append_time>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %r8,%rbx
mov    %rdx,%rax
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rsp,%rdi
mov    $0x100,%esi
mov    %rcx,%rdx
mov    %rax,%rcx
call   1040 <strftime@plt>
test   %rax,%rax
je     1164 <_clog_append_time+0x44>
mov    %rsp,%rdx
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rcx
call   1030 <_clog_append_str@plt>
mov    %rax,%rbx
mov    %rbx,%rax
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
define i64 @_clog_append_time(i8** %0, i8* %1, %struct.tm* %2, i8* %3, i64 %4) {
%6 = alloca i64
%7 = alloca i8**
%8 = alloca i8*
%9 = alloca %struct.tm*
%10 = alloca i8*
%11 = alloca i64
%12 = alloca [256 x i8]
%13 = alloca i64
store i8** %0, i8*** %7
store i8* %1, i8** %8
store %struct.tm* %2, %struct.tm** %9
store i8* %3, i8** %10
store i64 %4, i64* %11
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%15 = load i8*, i8** %10
%16 = load %struct.tm*, %struct.tm** %9
%17 = call i64 @strftime(i8* %14, i32 256, i8* %15, %struct.tm* %16)
store i64 %17, i64* %13
%18 = load i64, i64* %13
%19 = icmp ugt i64 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %5
%21 = load i8**, i8*** %7
%22 = load i8*, i8** %8
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%24 = load i64, i64* %11
%25 = call i64 @_clog_append_str(i8** %21, i8* %22, i8* %23, i64 %24)
store i64 %25, i64* %6
br label %28
26: ; preds = %5
%27 = load i64, i64* %11
store i64 %27, i64* %6
br label %28
28: ; preds = %26, %20
%29 = load i64, i64* %6
ret i64 %29
}

LLVM IR (-O2):
%struct.tm = type { i32 }
define i64 @_clog_append_time(i8** %0, i8* %1, %struct.tm* %2, i8* %3, i64 %4) {
%6 = alloca [256 x i8]
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%8 = call i64 @strftime(i8* %7, i32 256, i8* %3, %struct.tm* %2)
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %5
%11 = call i64 @_clog_append_str(i8** %0, i8* %1, i8* %7, i64 %4)
br label %12
12: ; preds = %5, %10
%13 = phi i64 [ %11, %10 ], [ %4, %5 ]
ret i64 %13
}