#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*/ dputc(char);
int /*<<< orphan*/ nprint(char *, char *, unsigned int, int);
char *ufmt(unsigned int, unsigned int, char *);
void iprint(int v, unsigned int base, unsigned int width, int pad) {
  char buffer[33], *e = buffer + 32, *p;
  unsigned int u;
  u = v > 0 ? v : -v;
  p = ufmt(u, base, e);
  if (v < 0) {
    if (pad == '0') {
      dputc('-');
      width -= 1;
    } else {
      *--p = '-';
    }
  }
  nprint(p, e, width, pad);
}


x86 assembly (clang, -O0):
<iprint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
lea    -0x40(%rbp),%rax
add    $0x20,%rax
mov    %rax,-0x48(%rbp)
cmpl   $0x0,-0x4(%rbp)
jle    1165 <iprint+0x35>
mov    -0x4(%rbp),%eax
mov    %eax,-0x58(%rbp)
jmp    116d <iprint+0x3d>
xor    %eax,%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    -0x58(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x54(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x48(%rbp),%rdx
call   1040 <ufmt@plt>
mov    %rax,-0x50(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    11ca <iprint+0x9a>
cmpl   $0x30,-0x10(%rbp)
jne    11b2 <iprint+0x82>
mov    $0x2d,%edi
call   1030 <dputc@plt>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11c5 <iprint+0x95>
mov    -0x50(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x50(%rbp)
movb   $0x2d,-0x1(%rax)
jmp    11ca <iprint+0x9a>
mov    -0x50(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
call   1050 <nprint@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iprint>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x30,%rsp
mov    %ecx,%r15d
mov    %edx,%r12d
mov    %edi,%ebp
lea    0x20(%rsp),%r14
neg    %edi
cmovs  %ebp,%edi
mov    %r14,%rdx
call   1040 <ufmt@plt>
mov    %rax,%rbx
test   %ebp,%ebp
jns    117b <iprint+0x4b>
cmp    $0x30,%r15d
jne    1173 <iprint+0x43>
mov    $0x2d,%edi
call   1030 <dputc@plt>
add    $0xffffffff,%r12d
jmp    117b <iprint+0x4b>
movb   $0x2d,-0x1(%rbx)
add    $0xffffffffffffffff,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r12d,%edx
mov    %r15d,%ecx
call   1050 <nprint@plt>
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @iprint(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca [33 x i8]
%6 = getelementptr inbounds [33 x i8], [33 x i8]* %5, i64 0, i64 0
%7 = getelementptr inbounds [33 x i8], [33 x i8]* %5, i64 0, i64 32
%8 = tail call i32 @llvm.abs.i32(i32 %0, i1 true)
%9 = call i8* @ufmt(i32 %8, i32 %1, i8* %7)
%10 = icmp slt i32 %0, 0
br i1 %10, label %11, label %18
11: ; preds = %4
%12 = icmp eq i32 %3, 48
br i1 %12, label %13, label %16
13: ; preds = %11
%14 = call i32 @dputc(i8 signext 45)
%15 = add i32 %2, -1
br label %18
16: ; preds = %11
%17 = getelementptr inbounds i8, i8* %9, i64 -1
store i8 45, i8* %17
br label %18
18: ; preds = %13, %16, %4
%19 = phi i8* [ %9, %13 ], [ %17, %16 ], [ %9, %4 ]
%20 = phi i32 [ %15, %13 ], [ %2, %16 ], [ %2, %4 ]
%21 = call i32 @nprint(i8* %19, i8* %7, i32 %20, i32 %3)
ret void
}