#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*/ sprintf(char *, char *, int);
void space_pad3(char *buf, int value) {
  if (value < 10) {
    sprintf(buf, "  %d", value);
  }
  if (value >= 10 && value < 100) {
    sprintf(buf, " %d", value);
  } else if (value >= 100) {
    sprintf(buf, "%d", value);
  }
}


x86 assembly (clang, -O0):
<space_pad3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    113c <space_pad3+0x2c>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xec9(%rip),%rsi
call   1030 <sprintf@plt>
cmpl   $0xa,-0xc(%rbp)
jl     1168 <space_pad3+0x58>
cmpl   $0x64,-0xc(%rbp)
jge    1168 <space_pad3+0x58>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xea3(%rip),%rsi
call   1030 <sprintf@plt>
jmp    118a <space_pad3+0x7a>
cmpl   $0x64,-0xc(%rbp)
jl     1185 <space_pad3+0x75>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe82(%rip),%rsi
call   1030 <sprintf@plt>
jmp    118a <space_pad3+0x7a>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<space_pad3>:
mov    %esi,%edx
lea    -0xa(%rdx),%eax
cmp    $0x5a,%eax
lea    0xee2(%rip),%rax
lea    0xedc(%rip),%rcx
cmovb  %rax,%rcx
cmp    $0xa,%esi
lea    0xecc(%rip),%rsi
cmovge %rcx,%rsi
jmp    1030 <sprintf@plt>

LLVM IR (-O0):
@.str = [5 x i8] c" %d\00"
@.str.1 = [4 x i8] c" %d\00"
@.str.2 = [3 x i8] c"%d\00"
define void @space_pad3(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = icmp slt i32 %5, 10
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = load i8*, i8** %3
%9 = load i32, i32* %4
%10 = call i32 @sprintf(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %9)
br label %11
11: ; preds = %7, %2
%12 = load i32, i32* %4
%13 = icmp sge i32 %12, 10
br i1 %13, label %14, label %21
14: ; preds = %11
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, 100
br i1 %16, label %17, label %21
17: ; preds = %14
%18 = load i8*, i8** %3
%19 = load i32, i32* %4
%20 = call i32 @sprintf(i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %19)
br label %29
21: ; preds = %14, %11
%22 = load i32, i32* %4
%23 = icmp sge i32 %22, 100
br i1 %23, label %24, label %28
24: ; preds = %21
%25 = load i8*, i8** %3
%26 = load i32, i32* %4
%27 = call i32 @sprintf(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %24, %21
br label %29
29: ; preds = %28, %17
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c" %d\00"
@.str.1 = [4 x i8] c" %d\00"
@.str.2 = [3 x i8] c"%d\00"
define void @space_pad3(i8* nocapture writeonly %0, i32 %1) {
%3 = icmp slt i32 %1, 10
%4 = add nsw i32 %1, -10
%5 = icmp ult i32 %4, 90
%6 = select i1 %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0)
%7 = select i1 %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %6
%8 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) %7, i32 %1)
ret void
}