#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*/ printf(char *, ...);
void print_format(unsigned long val) {
  if (val == 0)
    printf("00");
  else if (val < 10)
    printf("0%d", (int)val);
  else
    printf("%ld", val);
}


x86 assembly (clang, -O0):
<print_format>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    113a <print_format+0x2a>
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1175 <print_format+0x65>
cmpq   $0xa,-0x8(%rbp)
jae    115e <print_format+0x4e>
mov    -0x8(%rbp),%rax
mov    %eax,%esi
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1170 <print_format+0x60>
mov    -0x8(%rbp),%rsi
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1175 <print_format+0x65>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_format>:
test   %rdi,%rdi
je     112c <print_format+0x1c>
mov    %rdi,%rsi
cmp    $0x9,%rdi
ja     113a <print_format+0x2a>
lea    0xede(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>
lea    0xecd(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>
lea    0xec6(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"00\00"
@.str.1 = [4 x i8] c"0%d\00"
@.str.2 = [4 x i8] c"%ld\00"
define void @print_format(i64 %0) {
%2 = alloca i64
store i64 %0, i64* %2
%3 = load i64, i64* %2
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %18
7: ; preds = %1
%8 = load i64, i64* %2
%9 = icmp ult i64 %8, 10
br i1 %9, label %10, label %14
10: ; preds = %7
%11 = load i64, i64* %2
%12 = trunc i64 %11 to i32
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %12)
br label %17
14: ; preds = %7
%15 = load i64, i64* %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64 %15)
br label %17
17: ; preds = %14, %10
br label %18
18: ; preds = %17, %5
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"00\00"
@.str.1 = [4 x i8] c"0%d\00"
@.str.2 = [4 x i8] c"%ld\00"
define void @print_format(i64 %0) {
%2 = icmp eq i64 %0, 0
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %12
5: ; preds = %1
%6 = icmp ult i64 %0, 10
br i1 %6, label %7, label %10
7: ; preds = %5
%8 = trunc i64 %0 to i32
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %8)
br label %12
10: ; preds = %5
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64 %0)
br label %12
12: ; preds = %7, %10, %3
ret void
}