#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;
};
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strftime(char *, int, char *, struct tm *);
void time_show(struct tm *ptr, const char *prefix) {
  char buf[64];
  if (strftime(buf, sizeof(buf), "%c", ptr) == 0) {
    printf("strftime error\n");
    return;
  }
  printf("%s: time %s\n", prefix, buf);
}


x86 assembly (clang, -O0):
<time_show>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x40,%esi
lea    0xebc(%rip),%rdx
call   1040 <strftime@plt>
cmp    $0x0,%rax
jne    1166 <time_show+0x46>
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    117c <time_show+0x5c>
mov    -0x10(%rbp),%rsi
lea    -0x50(%rbp),%rdx
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<time_show>:
push   %rbx
sub    $0x40,%rsp
mov    %rsi,%rbx
mov    %rdi,%rcx
lea    0xebe(%rip),%rdx
mov    %rsp,%rdi
mov    $0x40,%esi
call   1050 <strftime@plt>
test   %rax,%rax
je     116a <time_show+0x3a>
lea    0xea8(%rip),%rdi
mov    %rsp,%rdx
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1176 <time_show+0x46>
lea    0xe9f(%rip),%rdi
call   1030 <puts@plt>
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [3 x i8] c"%c\00"
@.str.1 = [16 x i8] c"strftime error\0A\00"
@.str.2 = [13 x i8] c"%s: time %s\0A\00"
define void @time_show(%struct.tm* %0, i8* %1) {
%3 = alloca %struct.tm*
%4 = alloca i8*
%5 = alloca [64 x i8]
store %struct.tm* %0, %struct.tm** %3
store i8* %1, i8** %4
%6 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%7 = load %struct.tm*, %struct.tm** %3
%8 = call i64 @strftime(i8* %6, i32 64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %struct.tm* %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
br label %16
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %13, i8* %14)
br label %16
16: ; preds = %12, %10
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [3 x i8] c"%c\00"
@.str.2 = [13 x i8] c"%s: time %s\0A\00"
@str = [15 x i8] c"strftime error\00"
define void @time_show(%struct.tm* %0, i8* %1) {
%3 = alloca [64 x i8]
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%5 = call i64 @strftime(i8* %4, i32 64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %struct.tm* %0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
br label %11
9: ; preds = %2
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %1, i8* %4)
br label %11
11: ; preds = %9, %7
ret void
}