#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*/ _ltostr(int, int, char, char **);
void _ecpy(int exp, char letter, char **a_it) {
  _ltostr((exp > 0) ? exp : -exp, 10, 'd', a_it);
  if (letter != 'p' && letter != 'P' && (exp < 10 && exp > -10))
    *((*a_it)--) = '0';
  *((*a_it)--) = (exp < 0) ? '-' : '+';
  *((*a_it)--) = letter;
}


x86 assembly (clang, -O0):
<_ecpy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %edi,-0x4(%rbp)
mov    %al,-0x5(%rbp)
mov    %rdx,-0x10(%rbp)
cmpl   $0x0,-0x4(%rbp)
jle    113a <_ecpy+0x2a>
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1142 <_ecpy+0x32>
xor    %eax,%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rcx
mov    $0xa,%esi
mov    $0x64,%edx
call   1030 <_ltostr@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x70,%eax
je     119a <_ecpy+0x8a>
movsbl -0x5(%rbp),%eax
cmp    $0x50,%eax
je     119a <_ecpy+0x8a>
cmpl   $0xa,-0x4(%rbp)
jge    119a <_ecpy+0x8a>
cmpl   $0xfffffff6,-0x4(%rbp)
jle    119a <_ecpy+0x8a>
mov    -0x10(%rbp),%rcx
mov    (%rcx),%rax
mov    %rax,%rdx
add    $0xffffffffffffffff,%rdx
mov    %rdx,(%rcx)
movb   $0x30,(%rax)
mov    -0x4(%rbp),%edx
mov    $0x2b,%eax
mov    $0x2d,%ecx
cmp    $0x0,%edx
cmovl  %ecx,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rdx
mov    (%rdx),%rax
mov    %rax,%rsi
add    $0xffffffffffffffff,%rsi
mov    %rsi,(%rdx)
mov    %cl,(%rax)
mov    -0x5(%rbp),%cl
mov    -0x10(%rbp),%rdx
mov    (%rdx),%rax
mov    %rax,%rsi
add    $0xffffffffffffffff,%rsi
mov    %rsi,(%rdx)
mov    %cl,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_ecpy>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %esi,%r14d
mov    %edi,%ebp
neg    %edi
cmovs  %ebp,%edi
mov    $0xa,%esi
mov    $0x64,%edx
mov    %rbx,%rcx
call   1030 <_ltostr@plt>
lea    0x9(%rbp),%eax
cmp    $0x12,%eax
ja     1151 <_ecpy+0x41>
mov    %r14d,%eax
and    $0xdf,%al
cmp    $0x50,%al
je     1151 <_ecpy+0x41>
mov    (%rbx),%rax
lea    -0x1(%rax),%rcx
mov    %rcx,(%rbx)
movb   $0x30,(%rax)
shr    $0x1f,%ebp
add    %bpl,%bpl
add    $0x2b,%bpl
mov    (%rbx),%rax
lea    -0x1(%rax),%rcx
mov    %rcx,(%rbx)
mov    %bpl,(%rax)
mov    (%rbx),%rax
lea    -0x1(%rax),%rcx
mov    %rcx,(%rbx)
mov    %r14b,(%rax)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @_ecpy(i32 %0, i8 signext %1, i8** %2) {
%4 = alloca i32
%5 = alloca i8
%6 = alloca i8**
store i32 %0, i32* %4
store i8 %1, i8* %5
store i8** %2, i8*** %6
%7 = load i32, i32* %4
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %3
%10 = load i32, i32* %4
br label %14
11: ; preds = %3
%12 = load i32, i32* %4
%13 = sub nsw i32 0, %12
br label %14
14: ; preds = %11, %9
%15 = phi i32 [ %10, %9 ], [ %13, %11 ]
%16 = load i8**, i8*** %6
%17 = call i32 @_ltostr(i32 %15, i32 10, i8 signext 100, i8** %16)
%18 = load i8, i8* %5
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 112
br i1 %20, label %21, label %35
21: ; preds = %14
%22 = load i8, i8* %5
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 80
br i1 %24, label %25, label %35
25: ; preds = %21
%26 = load i32, i32* %4
%27 = icmp slt i32 %26, 10
br i1 %27, label %28, label %35
28: ; preds = %25
%29 = load i32, i32* %4
%30 = icmp sgt i32 %29, -10
br i1 %30, label %31, label %35
31: ; preds = %28
%32 = load i8**, i8*** %6
%33 = load i8*, i8** %32
%34 = getelementptr inbounds i8, i8* %33, i32 -1
store i8* %34, i8** %32
store i8 48, i8* %33
br label %35
35: ; preds = %31, %28, %25, %21, %14
%36 = load i32, i32* %4
%37 = icmp slt i32 %36, 0
%38 = zext i1 %37 to i64
%39 = select i1 %37, i32 45, i32 43
%40 = trunc i32 %39 to i8
%41 = load i8**, i8*** %6
%42 = load i8*, i8** %41
%43 = getelementptr inbounds i8, i8* %42, i32 -1
store i8* %43, i8** %41
store i8 %40, i8* %42
%44 = load i8, i8* %5
%45 = load i8**, i8*** %6
%46 = load i8*, i8** %45
%47 = getelementptr inbounds i8, i8* %46, i32 -1
store i8* %47, i8** %45
store i8 %44, i8* %46
ret void
}

LLVM IR (-O2):
define void @_ecpy(i32 %0, i8 signext %1, i8** %2) {
%4 = tail call i32 @llvm.abs.i32(i32 %0, i1 true)
%5 = tail call i32 @_ltostr(i32 %4, i32 10, i8 signext 100, i8** %2)
%6 = and i8 %1, -33
%7 = icmp ne i8 %6, 80
%8 = add i32 %0, 9
%9 = icmp ult i32 %8, 19
%10 = and i1 %9, %7
br i1 %10, label %11, label %14
11: ; preds = %3
%12 = load i8*, i8** %2
%13 = getelementptr inbounds i8, i8* %12, i64 -1
store i8* %13, i8** %2
store i8 48, i8* %12
br label %14
14: ; preds = %11, %3
%15 = icmp slt i32 %0, 0
%16 = select i1 %15, i8 45, i8 43
%17 = load i8*, i8** %2
%18 = getelementptr inbounds i8, i8* %17, i64 -1
store i8* %18, i8** %2
store i8 %16, i8* %17
%19 = load i8*, i8** %2
%20 = getelementptr inbounds i8, i8* %19, i64 -1
store i8* %20, i8** %2
store i8 %1, i8* %19
ret void
}