#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 */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int strftime(char *, size_t, char *, struct tm *);
int strtime(time_t t, char *buff, size_t len) {
  int ret;
  struct tm *tm = localtime(&t);
  if (!tm) {
    fprintf(stderr, "localtime() failed\n");
    return -1;
  }
  ret = strftime(buff, len, "%H:%M", tm);
  return ((size_t)ret != len - 1);
}


x86 assembly (clang, -O0):
<strtime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x8(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    117c <strtime+0x4c>
mov    0x2e7e(%rip),%rax
mov    (%rax),%edi
lea    0xe95(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b1 <strtime+0x81>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rcx
lea    0xe85(%rip),%rdx
call   1050 <strftime@plt>
mov    %eax,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    $0x1,%rcx
cmp    %rcx,%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strtime>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %edi,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1030 <localtime@plt>
test   %rax,%rax
je     1173 <strtime+0x43>
lea    0xec0(%rip),%rdx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %rax,%rcx
call   1050 <strftime@plt>
movslq %eax,%rcx
add    $0xffffffffffffffff,%rbx
xor    %eax,%eax
cmp    %rcx,%rbx
setne  %al
jmp    118d <strtime+0x5d>
mov    0x2e66(%rip),%rax
mov    (%rax),%edi
lea    0xe7d(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
%struct.tm = type { i32 }
@stderr = global i32 0
@.str = [20 x i8] c"localtime() failed\0A\00"
@.str.1 = [6 x i8] c"%H:%M\00"
define i32 @strtime(i32 %0, i8* %1, i64 %2) {
%4 = alloca i32
store i32 %0, i32* %4
%5 = call %struct.tm* @localtime(i32* %4)
%6 = icmp eq %struct.tm* %5, null
br i1 %6, label %7, label %10
7: ; preds = %3
%8 = load i32, i32* @stderr
%9 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %16
10: ; preds = %3
%11 = call i32 @strftime(i8* %1, i64 %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %5)
%12 = sext i32 %11 to i64
%13 = add i64 %2, -1
%14 = icmp ne i64 %13, %12
%15 = zext i1 %14 to i32
br label %16
16: ; preds = %10, %7
%17 = phi i32 [ %15, %10 ], [ -1, %7 ]
ret i32 %17
}