#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 fmt_long(char *, int);
int /*<<< orphan*/ str_diff(char *, char *);
int main() {
  char buf[1024];
  assert(fmt_long(0, 12345) == 5);
  assert(fmt_long(0, -12345) == 6);
  assert(fmt_long(buf, 12345) == 5);
  buf[5] = 0;
  assert((!str_diff((buf), ("12345"))));
  assert(fmt_long(buf, -12345) == 6);
  buf[6] = 0;
  assert((!str_diff((buf), ("-12345"))));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
mov    $0x3039,%esi
call   1050 <fmt_long@plt>
cmp    $0x5,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
xor    %eax,%eax
mov    %eax,%edi
mov    $0xffffcfc7,%esi
call   1050 <fmt_long@plt>
cmp    $0x6,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    -0x410(%rbp),%rdi
mov    $0x3039,%esi
call   1050 <fmt_long@plt>
cmp    $0x5,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movb   $0x0,-0x40b(%rbp)
lea    -0x410(%rbp),%rdi
lea    0xe4d(%rip),%rsi
call   1040 <str_diff@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    -0x410(%rbp),%rdi
mov    $0xffffcfc7,%esi
call   1050 <fmt_long@plt>
cmp    $0x6,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movb   $0x0,-0x40a(%rbp)
lea    -0x410(%rbp),%rdi
lea    0xdff(%rip),%rsi
call   1040 <str_diff@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x400,%rsp
xor    %edi,%edi
mov    $0x3039,%esi
call   1050 <fmt_long@plt>
xor    %edi,%edi
cmp    $0x5,%eax
sete   %dil
call   1030 <assert@plt>
xor    %edi,%edi
mov    $0xffffcfc7,%esi
call   1050 <fmt_long@plt>
xor    %edi,%edi
cmp    $0x6,%eax
sete   %dil
call   1030 <assert@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x3039,%esi
call   1050 <fmt_long@plt>
xor    %edi,%edi
cmp    $0x5,%eax
sete   %dil
call   1030 <assert@plt>
movb   $0x0,0x5(%rsp)
lea    0xe6b(%rip),%rsi
mov    %rbx,%rdi
call   1040 <str_diff@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1030 <assert@plt>
mov    %rbx,%rdi
mov    $0xffffcfc7,%esi
call   1050 <fmt_long@plt>
xor    %edi,%edi
cmp    $0x6,%eax
sete   %dil
call   1030 <assert@plt>
movb   $0x0,0x6(%rsp)
lea    0xe2e(%rip),%rsi
mov    %rbx,%rdi
call   1040 <str_diff@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1030 <assert@plt>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"12345\00"
@.str.1 = [7 x i8] c"-12345\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1024 x i8]
store i32 0, i32* %1
%3 = call i32 @fmt_long(i8* null, i32 12345)
%4 = icmp eq i32 %3, 5
%5 = zext i1 %4 to i32
%6 = call i32 @assert(i32 %5)
%7 = call i32 @fmt_long(i8* null, i32 -12345)
%8 = icmp eq i32 %7, 6
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%12 = call i32 @fmt_long(i8* %11, i32 12345)
%13 = icmp eq i32 %12, 5
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 5
store i8 0, i8* %16
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%18 = call i32 @str_diff(i8* %17, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%19 = icmp ne i32 %18, 0
%20 = xor i1 %19, true
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%24 = call i32 @fmt_long(i8* %23, i32 -12345)
%25 = icmp eq i32 %24, 6
%26 = zext i1 %25 to i32
%27 = call i32 @assert(i32 %26)
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 6
store i8 0, i8* %28
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%30 = call i32 @str_diff(i8* %29, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%31 = icmp ne i32 %30, 0
%32 = xor i1 %31, true
%33 = zext i1 %32 to i32
%34 = call i32 @assert(i32 %33)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"12345\00"
@.str.1 = [7 x i8] c"-12345\00"
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @fmt_long(i8* null, i32 12345)
%4 = icmp eq i32 %3, 5
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = tail call i32 @fmt_long(i8* null, i32 -12345)
%8 = icmp eq i32 %7, 6
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = call i32 @fmt_long(i8* %2, i32 12345)
%12 = icmp eq i32 %11, 5
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 5
store i8 0, i8* %15
%16 = call i32 @str_diff(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%17 = icmp eq i32 %16, 0
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
%20 = call i32 @fmt_long(i8* %2, i32 -12345)
%21 = icmp eq i32 %20, 6
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 6
store i8 0, i8* %24
%25 = call i32 @str_diff(i8* %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp eq i32 %25, 0
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
ret i32 0
}