#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fputc(unsigned int, int /*<<< orphan*/ *);
void stb_fput_varlenu(FILE *f, unsigned int z) {
  if (z >= 0x10000000)
    fputc(0xF0, f);
  if (z >= 0x00200000)
    fputc((z < 0x10000000 ? 0xE0 : 0) + (z >> 24), f);
  if (z >= 0x00004000)
    fputc((z < 0x00200000 ? 0xC0 : 0) + (z >> 16), f);
  if (z >= 0x00000080)
    fputc((z < 0x00004000 ? 0x80 : 0) + (z >> 8), f);
  fputc(z, f);
}


x86 assembly (clang, -O0):
<stb_fput_varlenu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x10000000,-0xc(%rbp)
jb     113a <stb_fput_varlenu+0x2a>
mov    -0x8(%rbp),%rsi
mov    $0xf0,%edi
call   1030 <fputc@plt>
cmpl   $0x200000,-0xc(%rbp)
jb     116b <stb_fput_varlenu+0x5b>
mov    -0xc(%rbp),%ecx
xor    %edi,%edi
mov    $0xe0,%eax
cmp    $0x10000000,%ecx
cmovb  %eax,%edi
mov    -0xc(%rbp),%eax
shr    $0x18,%eax
add    %eax,%edi
mov    -0x8(%rbp),%rsi
call   1030 <fputc@plt>
cmpl   $0x4000,-0xc(%rbp)
jb     119c <stb_fput_varlenu+0x8c>
mov    -0xc(%rbp),%ecx
xor    %edi,%edi
mov    $0xc0,%eax
cmp    $0x200000,%ecx
cmovb  %eax,%edi
mov    -0xc(%rbp),%eax
shr    $0x10,%eax
add    %eax,%edi
mov    -0x8(%rbp),%rsi
call   1030 <fputc@plt>
cmpl   $0x80,-0xc(%rbp)
jb     11cd <stb_fput_varlenu+0xbd>
mov    -0xc(%rbp),%ecx
xor    %edi,%edi
mov    $0x80,%eax
cmp    $0x4000,%ecx
cmovb  %eax,%edi
mov    -0xc(%rbp),%eax
shr    $0x8,%eax
add    %eax,%edi
mov    -0x8(%rbp),%rsi
call   1030 <fputc@plt>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1030 <fputc@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stb_fput_varlenu>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
cmp    $0x10000000,%esi
jb     112f <stb_fput_varlenu+0x1f>
mov    $0xf0,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
jmp    1137 <stb_fput_varlenu+0x27>
cmp    $0x200000,%ebp
jb     119c <stb_fput_varlenu+0x8c>
mov    %ebp,%eax
shr    $0x18,%eax
lea    0xe0(%rax),%edi
cmp    $0x10000000,%ebp
cmovae %eax,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
mov    %ebp,%eax
shr    $0x10,%eax
lea    0xc0(%rax),%edi
cmp    $0x200000,%ebp
cmovae %eax,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
xor    %eax,%eax
cmp    $0x4000,%ebp
setb   %al
shl    $0x7,%eax
mov    %ebp,%edi
shr    $0x8,%edi
add    %eax,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <fputc@plt>
cmp    $0x4000,%ebp
jae    1153 <stb_fput_varlenu+0x43>
cmp    $0x80,%ebp
jae    116f <stb_fput_varlenu+0x5f>
jmp    118c <stb_fput_varlenu+0x7c>

LLVM IR (-O0):
define void @stb_fput_varlenu(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = icmp uge i32 %5, 268435456
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = load i32*, i32** %3
%9 = call i32 @fputc(i32 240, i32* %8)
br label %10
10: ; preds = %7, %2
%11 = load i32, i32* %4
%12 = icmp uge i32 %11, 2097152
br i1 %12, label %13, label %23
13: ; preds = %10
%14 = load i32, i32* %4
%15 = icmp ult i32 %14, 268435456
%16 = zext i1 %15 to i64
%17 = select i1 %15, i32 224, i32 0
%18 = load i32, i32* %4
%19 = lshr i32 %18, 24
%20 = add i32 %17, %19
%21 = load i32*, i32** %3
%22 = call i32 @fputc(i32 %20, i32* %21)
br label %23
23: ; preds = %13, %10
%24 = load i32, i32* %4
%25 = icmp uge i32 %24, 16384
br i1 %25, label %26, label %36
26: ; preds = %23
%27 = load i32, i32* %4
%28 = icmp ult i32 %27, 2097152
%29 = zext i1 %28 to i64
%30 = select i1 %28, i32 192, i32 0
%31 = load i32, i32* %4
%32 = lshr i32 %31, 16
%33 = add i32 %30, %32
%34 = load i32*, i32** %3
%35 = call i32 @fputc(i32 %33, i32* %34)
br label %36
36: ; preds = %26, %23
%37 = load i32, i32* %4
%38 = icmp uge i32 %37, 128
br i1 %38, label %39, label %49
39: ; preds = %36
%40 = load i32, i32* %4
%41 = icmp ult i32 %40, 16384
%42 = zext i1 %41 to i64
%43 = select i1 %41, i32 128, i32 0
%44 = load i32, i32* %4
%45 = lshr i32 %44, 8
%46 = add i32 %43, %45
%47 = load i32*, i32** %3
%48 = call i32 @fputc(i32 %46, i32* %47)
br label %49
49: ; preds = %39, %36
%50 = load i32, i32* %4
%51 = load i32*, i32** %3
%52 = call i32 @fputc(i32 %50, i32* %51)
ret void
}

LLVM IR (-O2):
define void @stb_fput_varlenu(i32* nocapture %0, i32 %1) {
%3 = icmp ugt i32 %1, 268435455
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @fputc(i32 240, i32* %0)
br label %8
6: ; preds = %2
%7 = icmp ugt i32 %1, 2097151
br i1 %7, label %8, label %14
8: ; preds = %6, %4
%9 = icmp ult i32 %1, 268435456
%10 = select i1 %9, i32 224, i32 0
%11 = lshr i32 %1, 24
%12 = add nuw nsw i32 %10, %11
%13 = tail call i32 @fputc(i32 %12, i32* %0)
br label %16
14: ; preds = %6
%15 = icmp ugt i32 %1, 16383
br i1 %15, label %16, label %22
16: ; preds = %14, %8
%17 = icmp ult i32 %1, 2097152
%18 = select i1 %17, i32 192, i32 0
%19 = lshr i32 %1, 16
%20 = add nuw nsw i32 %18, %19
%21 = tail call i32 @fputc(i32 %20, i32* %0)
br label %24
22: ; preds = %14
%23 = icmp ugt i32 %1, 127
br i1 %23, label %24, label %30
24: ; preds = %16, %22
%25 = icmp ult i32 %1, 16384
%26 = select i1 %25, i32 128, i32 0
%27 = lshr i32 %1, 8
%28 = add nuw nsw i32 %26, %27
%29 = tail call i32 @fputc(i32 %28, i32* %0)
br label %30
30: ; preds = %24, %22
%31 = tail call i32 @fputc(i32 %1, i32* %0)
ret void
}