#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 */
scalar_t__ atoi(char *);
int proc_d_prefix(char *hdr, char *lbp) {
  char fill;
  int minsize, i;
  minsize = 0;
  if (hdr[0]) {
    if (hdr[0] == '0') {
      fill = '0';
    } else {
      fill = ' ';
    }
    minsize = (short)atoi(hdr);
    for (i = 0; i < minsize; i++) {
      *lbp++ = fill;
    }
  }
  return (minsize);
}


x86 assembly (clang, -O0):
<proc_d_prefix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     1198 <proc_d_prefix+0x88>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jne    114d <proc_d_prefix+0x3d>
movb   $0x30,-0x11(%rbp)
jmp    1151 <proc_d_prefix+0x41>
movb   $0x20,-0x11(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <atoi@plt>
cwtl
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1193 <proc_d_prefix+0x83>
mov    -0x11(%rbp),%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1165 <proc_d_prefix+0x55>
jmp    1198 <proc_d_prefix+0x88>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<proc_d_prefix>:
push   %rbp
push   %r14
push   %rbx
mov    (%rdi),%bl
test   %bl,%bl
je     115b <proc_d_prefix+0x3b>
mov    %rsi,%r14
cmp    $0x30,%bl
je     1134 <proc_d_prefix+0x14>
mov    $0x20,%bl
call   1040 <atoi@plt>
movswl %ax,%ebp
shl    $0x10,%eax
test   %eax,%eax
jle    115d <proc_d_prefix+0x3d>
cmp    $0x2,%ebp
mov    $0x1,%edx
cmovge %ebp,%edx
movzbl %bl,%esi
mov    %r14,%rdi
call   1030 <memset@plt>
jmp    115d <proc_d_prefix+0x3d>
xor    %ebp,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @proc_d_prefix(i8* nocapture %0, i8* nocapture writeonly %1) {
%3 = load i8, i8* %0
switch i8 %3, label %4 [
i8 0, label %15
i8 48, label %5
]
4: ; preds = %2
br label %5
5: ; preds = %2, %4
%6 = phi i8 [ 32, %4 ], [ %3, %2 ]
%7 = tail call i64 @atoi(i8* %0)
%8 = trunc i64 %7 to i32
%9 = shl i32 %8, 16
%10 = ashr exact i32 %9, 16
%11 = icmp sgt i32 %9, 0
br i1 %11, label %12, label %15
12: ; preds = %5
%13 = call i32 @llvm.smax.i32(i32 %10, i32 1)
%14 = zext i32 %13 to i64
br label %15
15: ; preds = %12, %5, %2
%16 = phi i32 [ 0, %2 ], [ %10, %5 ], [ %10, %12 ]
ret i32 %16
}