#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 /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ emitString(int /*<<< orphan*/ *, char **, char *, int, int,
                              int *);
int /*<<< orphan*/ xtoa(unsigned int, char *, int, int);
void emitInt(FILE *file, char **buffer, int val, int base, int width, int flags,
             int *left) {
  char lBuf[12];
  char *str = lBuf;
  if (flags & (1 << 5)) {
    xtoa(val, str, base, (val < 0));
  } else {
    xtoa((unsigned)val, str, base, 0);
  }
  emitString(file, buffer, str, width, flags, left);
}


x86 assembly (clang, -O0):
<emitInt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
lea    -0x2c(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%eax
and    $0x20,%eax
cmp    $0x0,%eax
je     1179 <emitInt+0x59>
mov    -0x14(%rbp),%edi
mov    -0x38(%rbp),%rsi
mov    -0x18(%rbp),%edx
cmpl   $0x0,-0x14(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%ecx
call   1040 <xtoa@plt>
jmp    118a <emitInt+0x6a>
mov    -0x14(%rbp),%edi
mov    -0x38(%rbp),%rsi
mov    -0x18(%rbp),%edx
xor    %ecx,%ecx
call   1040 <xtoa@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
mov    0x10(%rbp),%r9
call   1030 <emitString@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<emitInt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9d,%ebx
mov    %r8d,%r14d
mov    %rsi,%r15
mov    %rdi,%rbp
mov    0x50(%rsp),%r12
mov    %r9d,%esi
shr    $0x5,%esi
mov    %edx,%eax
shr    $0x1f,%eax
and    %esi,%eax
lea    0xc(%rsp),%r13
mov    %edx,%edi
mov    %r13,%rsi
mov    %ecx,%edx
mov    %eax,%ecx
call   1040 <xtoa@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %r13,%rdx
mov    %r14d,%ecx
mov    %ebx,%r8d
mov    %r12,%r9
call   1030 <emitString@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @emitInt(i32* %0, i8** %1, i32 %2, i32 %3, i32 %4, i32 %5, i32* %6) {
%8 = alloca i32*
%9 = alloca i8**
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32*
%15 = alloca [12 x i8]
%16 = alloca i8*
store i32* %0, i32** %8
store i8** %1, i8*** %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i32 %5, i32* %13
store i32* %6, i32** %14
%17 = getelementptr inbounds [12 x i8], [12 x i8]* %15, i64 0, i64 0
store i8* %17, i8** %16
%18 = load i32, i32* %13
%19 = and i32 %18, 32
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %29
21: ; preds = %7
%22 = load i32, i32* %10
%23 = load i8*, i8** %16
%24 = load i32, i32* %11
%25 = load i32, i32* %10
%26 = icmp slt i32 %25, 0
%27 = zext i1 %26 to i32
%28 = call i32 @xtoa(i32 %22, i8* %23, i32 %24, i32 %27)
br label %34
29: ; preds = %7
%30 = load i32, i32* %10
%31 = load i8*, i8** %16
%32 = load i32, i32* %11
%33 = call i32 @xtoa(i32 %30, i8* %31, i32 %32, i32 0)
br label %34
34: ; preds = %29, %21
%35 = load i32*, i32** %8
%36 = load i8**, i8*** %9
%37 = load i8*, i8** %16
%38 = load i32, i32* %12
%39 = load i32, i32* %13
%40 = load i32*, i32** %14
%41 = call i32 @emitString(i32* %35, i8** %36, i8* %37, i32 %38, i32 %39, i32* %40)
ret void
}

LLVM IR (-O2):
define void @emitInt(i32* %0, i8** %1, i32 %2, i32 %3, i32 %4, i32 %5, i32* %6) {
%8 = alloca [12 x i8]
%9 = getelementptr inbounds [12 x i8], [12 x i8]* %8, i64 0, i64 0
%10 = and i32 %5, 32
%11 = icmp eq i32 %10, 0
%12 = lshr i32 %2, 31
%13 = select i1 %11, i32 0, i32 %12
%14 = call i32 @xtoa(i32 %2, i8* %9, i32 %3, i32 %13)
%15 = call i32 @emitString(i32* %0, i8** %1, i8* %9, i32 %4, i32 %5, i32* %6)
ret void
}