#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*/ general_uintformat(char *, long, int, int);
void int_dec_str(char *buf, long value, int num_chr, int signd) {
  if ((value & 0x80000000) && signd) {
    general_uintformat(buf + 1, (-value), 10, num_chr);
    *buf = '-';
  } else {
    general_uintformat(buf, value, 10, num_chr);
  }
}


x86 assembly (clang, -O0):
<int_dec_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movabs $0x80000000,%rax
and    -0x10(%rbp),%rax
cmp    $0x0,%rax
je     1171 <int_dec_str+0x61>
cmpl   $0x0,-0x18(%rbp)
je     1171 <int_dec_str+0x61>
mov    -0x8(%rbp),%rdi
add    $0x1,%rdi
xor    %eax,%eax
mov    %eax,%esi
sub    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%ecx
mov    $0xa,%edx
call   1030 <general_uintformat@plt>
mov    -0x8(%rbp),%rax
movb   $0x2d,(%rax)
jmp    1186 <int_dec_str+0x76>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%ecx
mov    $0xa,%edx
call   1030 <general_uintformat@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<int_dec_str>:
push   %rbx
mov    %edx,%eax
mov    %rdi,%rbx
test   $0x80000000,%esi
je     113a <int_dec_str+0x2a>
test   %ecx,%ecx
je     113a <int_dec_str+0x2a>
lea    0x1(%rbx),%rdi
neg    %rsi
mov    $0xa,%edx
mov    %eax,%ecx
call   1030 <general_uintformat@plt>
movb   $0x2d,(%rbx)
pop    %rbx
ret
mov    %rbx,%rdi
mov    $0xa,%edx
mov    %eax,%ecx
pop    %rbx
jmp    1030 <general_uintformat@plt>

LLVM IR (-O0):
define void @int_dec_str(i8* %0, i64 %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %5
store i64 %1, i64* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i64, i64* %6
%10 = and i64 %9, 2147483648
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %23
12: ; preds = %4
%13 = load i32, i32* %8
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %23
15: ; preds = %12
%16 = load i8*, i8** %5
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = load i64, i64* %6
%19 = sub nsw i64 0, %18
%20 = load i32, i32* %7
%21 = call i32 @general_uintformat(i8* %17, i64 %19, i32 10, i32 %20)
%22 = load i8*, i8** %5
store i8 45, i8* %22
br label %28
23: ; preds = %12, %4
%24 = load i8*, i8** %5
%25 = load i64, i64* %6
%26 = load i32, i32* %7
%27 = call i32 @general_uintformat(i8* %24, i64 %25, i32 10, i32 %26)
br label %28
28: ; preds = %23, %15
ret void
}

LLVM IR (-O2):
define void @int_dec_str(i8* %0, i64 %1, i32 %2, i32 %3) {
%5 = and i64 %1, 2147483648
%6 = icmp ne i64 %5, 0
%7 = icmp ne i32 %3, 0
%8 = and i1 %6, %7
br i1 %8, label %9, label %13
9: ; preds = %4
%10 = getelementptr inbounds i8, i8* %0, i64 1
%11 = sub nsw i64 0, %1
%12 = tail call i32 @general_uintformat(i8* %10, i64 %11, i32 10, i32 %2)
store i8 45, i8* %0
br label %15
13: ; preds = %4
%14 = tail call i32 @general_uintformat(i8* %0, i64 %1, i32 10, i32 %2)
br label %15
15: ; preds = %13, %9
ret void
}