#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 */

/* Variables and functions */
int /*<<< orphan*/ al_gen_segment(int, int, int, char *, int *, int *, int);
int /*<<< orphan*/ al_gen_subsegment(int, int, int, int, char *, int);
scalar_t__ al_get_datetime(char *, int, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int al_segment_datetime(int *is_first, int *last_bg, int position) {
  char text[2][64];
  int color_fg = 0;
  int color_bg = 2;
  char date[32];
  char time[32];
  if (al_get_datetime(date, 32, "%a, %d. %b") != 0) {
    return -1;
  }
  if (al_get_datetime(time, 32, "%H:%M:%S") != 0) {
    return -1;
  }
  snprintf(text[0], 64, " %s ", date);
  snprintf(text[1], 64, " %s ", time);
  al_gen_segment(color_fg, color_bg, 22, text[0], is_first, last_bg, position);
  al_gen_subsegment(color_fg, color_bg, 245, 22, text[1], position);
  return 0;
}


x86 assembly (clang, -O0):
<al_segment_datetime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movl   $0x0,-0xa4(%rbp)
movl   $0x2,-0xa8(%rbp)
lea    -0xd0(%rbp),%rdi
mov    $0x20,%esi
lea    0xe83(%rip),%rdx
call   1050 <al_get_datetime@plt>
cmp    $0x0,%rax
je     1198 <al_segment_datetime+0x58>
movl   $0xffffffff,-0x4(%rbp)
jmp    1264 <al_segment_datetime+0x124>
lea    -0xf0(%rbp),%rdi
mov    $0x20,%esi
lea    0xe60(%rip),%rdx
call   1050 <al_get_datetime@plt>
cmp    $0x0,%rax
je     11c6 <al_segment_datetime+0x86>
movl   $0xffffffff,-0x4(%rbp)
jmp    1264 <al_segment_datetime+0x124>
lea    -0xa0(%rbp),%rdi
lea    -0xd0(%rbp),%rcx
mov    $0x40,%esi
lea    0xe34(%rip),%rdx
call   1040 <snprintf@plt>
lea    -0xa0(%rbp),%rdi
add    $0x40,%rdi
lea    -0xf0(%rbp),%rcx
mov    $0x40,%esi
lea    0xe11(%rip),%rdx
call   1040 <snprintf@plt>
mov    -0xa4(%rbp),%edi
mov    -0xa8(%rbp),%esi
lea    -0xa0(%rbp),%rcx
mov    -0x10(%rbp),%r8
mov    -0x18(%rbp),%r9
mov    -0x1c(%rbp),%eax
mov    $0x16,%edx
mov    %eax,(%rsp)
call   1060 <al_gen_segment@plt>
mov    -0xa4(%rbp),%edi
mov    -0xa8(%rbp),%esi
lea    -0xa0(%rbp),%r8
add    $0x40,%r8
mov    -0x1c(%rbp),%r9d
mov    $0xf5,%edx
mov    $0x16,%ecx
call   1030 <al_gen_subsegment@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<al_segment_datetime>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%rbp
lea    0xe9f(%rip),%rdx
lea    0x30(%rsp),%rdi
mov    $0x20,%esi
call   1050 <al_get_datetime@plt>
mov    $0xffffffff,%ebx
test   %rax,%rax
jne    1213 <al_segment_datetime+0xd3>
lea    0xe86(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0x20,%esi
call   1050 <al_get_datetime@plt>
test   %rax,%rax
jne    1213 <al_segment_datetime+0xd3>
lea    0xe74(%rip),%rbx
lea    0x50(%rsp),%r12
lea    0x30(%rsp),%rcx
mov    %r12,%rdi
mov    $0x40,%esi
mov    %rbx,%rdx
call   1040 <snprintf@plt>
lea    0x90(%rsp),%r13
lea    0x10(%rsp),%rcx
mov    %r13,%rdi
mov    $0x40,%esi
mov    %rbx,%rdx
call   1040 <snprintf@plt>
mov    %r14d,(%rsp)
xor    %ebx,%ebx
xor    %edi,%edi
mov    $0x2,%esi
mov    $0x16,%edx
mov    %r12,%rcx
mov    %rbp,%r8
mov    %r15,%r9
call   1060 <al_gen_segment@plt>
xor    %edi,%edi
mov    $0x2,%esi
mov    $0xf5,%edx
mov    $0x16,%ecx
mov    %r13,%r8
mov    %r14d,%r9d
call   1030 <al_gen_subsegment@plt>
mov    %ebx,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"%a, %d. %b\00"
@.str.1 = [9 x i8] c"%H:%M:%S\00"
@.str.2 = [5 x i8] c" %s \00"
define i32 @al_segment_datetime(i32* %0, i32* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca [2 x [64 x i8]]
%9 = alloca i32
%10 = alloca i32
%11 = alloca [32 x i8]
%12 = alloca [32 x i8]
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i32 0, i32* %9
store i32 2, i32* %10
%13 = getelementptr inbounds [32 x i8], [32 x i8]* %11, i64 0, i64 0
%14 = call i64 @al_get_datetime(i8* %13, i32 32, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %3
store i32 -1, i32* %4
br label %45
17: ; preds = %3
%18 = getelementptr inbounds [32 x i8], [32 x i8]* %12, i64 0, i64 0
%19 = call i64 @al_get_datetime(i8* %18, i32 32, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %17
store i32 -1, i32* %4
br label %45
22: ; preds = %17
%23 = getelementptr inbounds [2 x [64 x i8]], [2 x [64 x i8]]* %8, i64 0, i64 0
%24 = getelementptr inbounds [64 x i8], [64 x i8]* %23, i64 0, i64 0
%25 = getelementptr inbounds [32 x i8], [32 x i8]* %11, i64 0, i64 0
%26 = call i32 @snprintf(i8* %24, i32 64, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %25)
%27 = getelementptr inbounds [2 x [64 x i8]], [2 x [64 x i8]]* %8, i64 0, i64 1
%28 = getelementptr inbounds [64 x i8], [64 x i8]* %27, i64 0, i64 0
%29 = getelementptr inbounds [32 x i8], [32 x i8]* %12, i64 0, i64 0
%30 = call i32 @snprintf(i8* %28, i32 64, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %29)
%31 = load i32, i32* %9
%32 = load i32, i32* %10
%33 = getelementptr inbounds [2 x [64 x i8]], [2 x [64 x i8]]* %8, i64 0, i64 0
%34 = getelementptr inbounds [64 x i8], [64 x i8]* %33, i64 0, i64 0
%35 = load i32*, i32** %5
%36 = load i32*, i32** %6
%37 = load i32, i32* %7
%38 = call i32 @al_gen_segment(i32 %31, i32 %32, i32 22, i8* %34, i32* %35, i32* %36, i32 %37)
%39 = load i32, i32* %9
%40 = load i32, i32* %10
%41 = getelementptr inbounds [2 x [64 x i8]], [2 x [64 x i8]]* %8, i64 0, i64 1
%42 = getelementptr inbounds [64 x i8], [64 x i8]* %41, i64 0, i64 0
%43 = load i32, i32* %7
%44 = call i32 @al_gen_subsegment(i32 %39, i32 %40, i32 245, i32 22, i8* %42, i32 %43)
store i32 0, i32* %4
br label %45
45: ; preds = %22, %21, %16
%46 = load i32, i32* %4
ret i32 %46
}

LLVM IR (-O2):
@.str = [11 x i8] c"%a, %d. %b\00"
@.str.1 = [9 x i8] c"%H:%M:%S\00"
@.str.2 = [5 x i8] c" %s \00"
define i32 @al_segment_datetime(i32* %0, i32* %1, i32 %2) {
%4 = alloca [2 x [64 x i8]]
%5 = alloca [32 x i8]
%6 = alloca [32 x i8]
%7 = getelementptr inbounds [2 x [64 x i8]], [2 x [64 x i8]]* %4, i64 0, i64 0, i64 0
%8 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%9 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%10 = call i64 @al_get_datetime(i8* %8, i32 32, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %21
12: ; preds = %3
%13 = call i64 @al_get_datetime(i8* %9, i32 32, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %21
15: ; preds = %12
%16 = call i32 @snprintf(i8* %7, i32 64, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%17 = getelementptr inbounds [2 x [64 x i8]], [2 x [64 x i8]]* %4, i64 0, i64 1, i64 0
%18 = call i32 @snprintf(i8* %17, i32 64, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %9)
%19 = call i32 @al_gen_segment(i32 0, i32 2, i32 22, i8* %7, i32* %0, i32* %1, i32 %2)
%20 = call i32 @al_gen_subsegment(i32 0, i32 2, i32 245, i32 22, i8* %17, i32 %2)
br label %21
21: ; preds = %12, %3, %15
%22 = phi i32 [ 0, %15 ], [ -1, %3 ], [ -1, %12 ]
ret i32 %22
}