#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(int);
void nprint(char *start, char *end, int width, int pad) {
  width -= (end - start);
  while (width-- > 0)
    dputc(pad);
  while (start < end)
    dputc(*start++);
}


x86 assembly (clang, -O0):
<nprint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%rax
sub    %rax,%rcx
movslq -0x14(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
jle    115c <nprint+0x4c>
mov    -0x18(%rbp),%edi
call   1030 <dputc@plt>
jmp    113b <nprint+0x2b>
jmp    1161 <nprint+0x51>
mov    -0x8(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    118b <nprint+0x7b>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movsbl (%rax),%edi
call   1030 <dputc@plt>
jmp    1161 <nprint+0x51>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nprint>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
mov    %r14d,%eax
sub    %r15d,%eax
add    %edx,%eax
test   %eax,%eax
jle    114f <nprint+0x3f>
mov    %ecx,%ebp
mov    %edx,%ebx
add    %r14d,%ebx
sub    %r15d,%ebx
add    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    %ebp,%edi
call   1030 <dputc@plt>
add    $0xffffffff,%ebx
cmp    $0x1,%ebx
ja     1140 <nprint+0x30>
cmp    %r15,%r14
jae    1173 <nprint+0x63>
sub    %r14,%r15
xor    %ebx,%ebx
nopl   0x0(%rax)
movsbl (%r14,%rbx,1),%edi
call   1030 <dputc@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1160 <nprint+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @nprint(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i8*, i8** %6
%10 = load i8*, i8** %5
%11 = ptrtoint i8* %9 to i64
%12 = ptrtoint i8* %10 to i64
%13 = sub i64 %11, %12
%14 = load i32, i32* %7
%15 = sext i32 %14 to i64
%16 = sub nsw i64 %15, %13
%17 = trunc i64 %16 to i32
store i32 %17, i32* %7
br label %18
18: ; preds = %22, %4
%19 = load i32, i32* %7
%20 = add nsw i32 %19, -1
store i32 %20, i32* %7
%21 = icmp sgt i32 %19, 0
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = load i32, i32* %8
%24 = call i32 @dputc(i32 %23)
br label %18
25: ; preds = %18
br label %26
26: ; preds = %30, %25
%27 = load i8*, i8** %5
%28 = load i8*, i8** %6
%29 = icmp ult i8* %27, %28
br i1 %29, label %30, label %36
30: ; preds = %26
%31 = load i8*, i8** %5
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %5
%33 = load i8, i8* %31
%34 = sext i8 %33 to i32
%35 = call i32 @dputc(i32 %34)
br label %26
36: ; preds = %26
ret void
}

LLVM IR (-O2):
define void @nprint(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = ptrtoint i8* %1 to i64
%6 = ptrtoint i8* %0 to i64
%7 = sub i64 %6, %5
%8 = trunc i64 %7 to i32
%9 = add i32 %8, %2
%10 = icmp sgt i32 %9, 0
br i1 %10, label %16, label %11
11: ; preds = %16, %4
%12 = icmp ult i8* %0, %1
br i1 %12, label %13, label %28
13: ; preds = %11
%14 = sub i64 %5, %6
%15 = getelementptr i8, i8* %0, i64 %14
br label %21
16: ; preds = %4, %16
%17 = phi i32 [ %18, %16 ], [ %9, %4 ]
%18 = add nsw i32 %17, -1
%19 = tail call i32 @dputc(i32 %3)
%20 = icmp ugt i32 %17, 1
br i1 %20, label %16, label %11
21: ; preds = %13, %21
%22 = phi i8* [ %23, %21 ], [ %0, %13 ]
%23 = getelementptr inbounds i8, i8* %22, i64 1
%24 = load i8, i8* %22
%25 = sext i8 %24 to i32
%26 = tail call i32 @dputc(i32 %25)
%27 = icmp eq i8* %23, %15
br i1 %27, label %28, label %21
28: ; preds = %21, %11
ret void
}