#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__ isspace(char);
int /*<<< orphan*/ sprintf(char *, char *, int, int);
char *timlib_pad_zero(int number, int length) {
  static char return_string[32];
  char *ptr = return_string;
  sprintf(return_string, "%*d", length, number);
  while (*ptr && isspace(*ptr))
    *ptr++ = '0';
  return return_string;
}


x86 assembly (clang, -O0):
<timlib_pad_zero>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    0x2f0b(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%edx
mov    -0x4(%rbp),%ecx
lea    0x2efa(%rip),%rdi
lea    0xeb3(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x11(%rbp)
je     117d <timlib_pad_zero+0x5d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    118d <timlib_pad_zero+0x6d>
jmp    11a4 <timlib_pad_zero+0x84>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x30,(%rax)
jmp    1152 <timlib_pad_zero+0x32>
lea    0x2e95(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<timlib_pad_zero>:
push   %rbx
mov    %esi,%edx
mov    %edi,%ecx
lea    0x2f14(%rip),%rdi
lea    0xecd(%rip),%rsi
call   1040 <sprintf@plt>
mov    0x2f02(%rip),%al
test   %al,%al
je     116c <timlib_pad_zero+0x4c>
lea    0x2ef8(%rip),%rbx
nopl   0x0(%rax)
movsbl %al,%edi
call   1030 <isspace@plt>
test   %rax,%rax
je     116c <timlib_pad_zero+0x4c>
movb   $0x30,-0x1(%rbx)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1150 <timlib_pad_zero+0x30>
lea    0x2ecd(%rip),%rax
pop    %rbx
ret

LLVM IR (-O0):
@timlib_pad_zero.return_string = internal global [32 x i8] zeroinitializer
@.str = [4 x i8] c"%*d\00"
define i8* @timlib_pad_zero(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
store i32 %0, i32* %3
store i32 %1, i32* %4
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @timlib_pad_zero.return_string, i64 0, i64 0), i8** %5
%6 = load i32, i32* %4
%7 = load i32, i32* %3
%8 = call i32 @sprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @timlib_pad_zero.return_string, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %7)
br label %9
9: ; preds = %21, %2
%10 = load i8*, i8** %5
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %9
%15 = load i8*, i8** %5
%16 = load i8, i8* %15
%17 = call i64 @isspace(i8 signext %16)
%18 = icmp ne i64 %17, 0
br label %19
19: ; preds = %14, %9
%20 = phi i1 [ false, %9 ], [ %18, %14 ]
br i1 %20, label %21, label %24
21: ; preds = %19
%22 = load i8*, i8** %5
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %5
store i8 48, i8* %22
br label %9
24: ; preds = %19
ret i8* getelementptr inbounds ([32 x i8], [32 x i8]* @timlib_pad_zero.return_string, i64 0, i64 0)
}

LLVM IR (-O2):
@timlib_pad_zero.return_string = internal global [32 x i8] zeroinitializer
@.str = [4 x i8] c"%*d\00"
define i8* @timlib_pad_zero(i32 %0, i32 %1) {
%3 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @timlib_pad_zero.return_string, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %0)
%4 = load i8, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @timlib_pad_zero.return_string, i64 0, i64 0)
%5 = icmp eq i8 %4, 0
br i1 %5, label %15, label %6
6: ; preds = %2, %11
%7 = phi i8 [ %13, %11 ], [ %4, %2 ]
%8 = phi i8* [ %12, %11 ], [ getelementptr inbounds ([32 x i8], [32 x i8]* @timlib_pad_zero.return_string, i64 0, i64 0), %2 ]
%9 = tail call i64 @isspace(i8 signext %7)
%10 = icmp eq i64 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %6
%12 = getelementptr inbounds i8, i8* %8, i64 1
store i8 48, i8* %8
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %15, label %6
15: ; preds = %6, %11, %2
ret i8* getelementptr inbounds ([32 x i8], [32 x i8]* @timlib_pad_zero.return_string, i64 0, i64 0)
}