#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*/ assert(int);
int /*<<< orphan*/ serialize_number(int, int, char *);
scalar_t__ strcmp(int /*<<< orphan*/, char *);
void test_serialize(void) {
  char buf[65];
  assert(strcmp(serialize_number(1234, 10, buf), "1234") == 0);
  assert(strcmp(serialize_number(0xDEADBEEF, 16, buf), "DEADBEEF") == 0);
}


x86 assembly (clang, -O0):
<test_serialize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
lea    -0x50(%rbp),%rdx
mov    $0x4d2,%edi
mov    $0xa,%esi
call   1050 <serialize_number@plt>
mov    %eax,%edi
lea    0xeac(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    -0x50(%rbp),%rdx
mov    $0xdeadbeef,%edi
mov    $0x10,%esi
call   1050 <serialize_number@plt>
mov    %eax,%edi
lea    0xe7f(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_serialize>:
push   %rbx
sub    $0x50,%rsp
mov    %rsp,%rbx
mov    $0x4d2,%edi
mov    $0xa,%esi
mov    %rbx,%rdx
call   1050 <serialize_number@plt>
lea    0xeaf(%rip),%rsi
mov    %eax,%edi
call   1030 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1040 <assert@plt>
mov    $0xdeadbeef,%edi
mov    $0x10,%esi
mov    %rbx,%rdx
call   1050 <serialize_number@plt>
lea    0xe86(%rip),%rsi
mov    %eax,%edi
call   1030 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1040 <assert@plt>
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"1234\00"
@.str.1 = [9 x i8] c"DEADBEEF\00"
define void @test_serialize() {
%1 = alloca [65 x i8]
%2 = getelementptr inbounds [65 x i8], [65 x i8]* %1, i64 0, i64 0
%3 = call i32 @serialize_number(i32 1234, i32 10, i8* %2)
%4 = call i64 @strcmp(i32 %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
%6 = zext i1 %5 to i32
%7 = call i32 @assert(i32 %6)
%8 = getelementptr inbounds [65 x i8], [65 x i8]* %1, i64 0, i64 0
%9 = call i32 @serialize_number(i32 -559038737, i32 16, i8* %8)
%10 = call i64 @strcmp(i32 %9, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"1234\00"
@.str.1 = [9 x i8] c"DEADBEEF\00"
define void @test_serialize() {
%1 = alloca [65 x i8]
%2 = getelementptr inbounds [65 x i8], [65 x i8]* %1, i64 0, i64 0
%3 = call i32 @serialize_number(i32 1234, i32 10, i8* %2)
%4 = call i64 @strcmp(i32 %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
%6 = zext i1 %5 to i32
%7 = call i32 @assert(i32 %6)
%8 = call i32 @serialize_number(i32 -559038737, i32 16, i8* %2)
%9 = call i64 @strcmp(i32 %8, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
ret void
}