#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 uint32_t;
typedef int /*<<< orphan*/ temp;

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char const *, int);
int /*<<< orphan*/ strncat(char *, char *, int);
int date2str_(uint32_t mask, uint32_t a, const char *f, int v, char *str) {
  char temp[32];
  if ((mask & a) == a) {
    snprintf(temp, sizeof(temp) / sizeof(temp[0]), f, v);
    strncat(str, temp, sizeof(temp) / sizeof(temp[0]));
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<date2str_>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%eax
and    -0xc(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    117b <date2str_+0x5b>
lea    -0x50(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    $0x20,%esi
call   1030 <snprintf@plt>
mov    -0x28(%rbp),%rdi
lea    -0x50(%rbp),%rsi
mov    $0x20,%edx
call   1040 <strncat@plt>
movl   $0x1,-0x4(%rbp)
jmp    1182 <date2str_+0x62>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<date2str_>:
not    %edi
xor    %eax,%eax
test   %edi,%esi
jne    115e <date2str_+0x3e>
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %r8,%rbx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x20,%esi
call   1030 <snprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x20,%edx
call   1040 <strncat@plt>
mov    $0x1,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @date2str_(i32 %0, i32 %1, i8* %2, i32 %3, i8* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca [32 x i8]
store i32 %0, i32* %7
store i32 %1, i32* %8
store i8* %2, i8** %9
store i32 %3, i32* %10
store i8* %4, i8** %11
%13 = load i32, i32* %7
%14 = load i32, i32* %8
%15 = and i32 %13, %14
%16 = load i32, i32* %8
%17 = icmp eq i32 %15, %16
br i1 %17, label %18, label %26
18: ; preds = %5
%19 = getelementptr inbounds [32 x i8], [32 x i8]* %12, i64 0, i64 0
%20 = load i8*, i8** %9
%21 = load i32, i32* %10
%22 = call i32 @snprintf(i8* %19, i32 32, i8* %20, i32 %21)
%23 = load i8*, i8** %11
%24 = getelementptr inbounds [32 x i8], [32 x i8]* %12, i64 0, i64 0
%25 = call i32 @strncat(i8* %23, i8* %24, i32 32)
store i32 1, i32* %6
br label %27
26: ; preds = %5
store i32 0, i32* %6
br label %27
27: ; preds = %26, %18
%28 = load i32, i32* %6
ret i32 %28
}

LLVM IR (-O2):
define i32 @date2str_(i32 %0, i32 %1, i8* %2, i32 %3, i8* %4) {
%6 = alloca [32 x i8]
%7 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%8 = and i32 %1, %0
%9 = icmp eq i32 %8, %1
br i1 %9, label %10, label %13
10: ; preds = %5
%11 = call i32 @snprintf(i8* %7, i32 32, i8* %2, i32 %3)
%12 = call i32 @strncat(i8* %4, i8* %7, i32 32)
br label %13
13: ; preds = %5, %10
%14 = phi i32 [ 1, %10 ], [ 0, %5 ]
ret i32 %14
}