#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*/ putbc(int, int);
void putnum_s8(unsigned int s) {
  int j = 4;
  while ((s & 0xff000000) == 0 && j > 1) {
    s <<= 8;
    j--;
  }
  for (;;) {
    putbc(s >> 24, 0x80);
    if (j == 1)
      break;
    putbc(0x0, 0x1);
    s <<= 8;
    j--;
  }
  putbc(0x1, 0x1);
  return;
}


x86 assembly (clang, -O0):
<putnum_s8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x4,-0x8(%rbp)
mov    -0x4(%rbp),%ecx
and    $0xff000000,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x9(%rbp)
jne    1143 <putnum_s8+0x33>
cmpl   $0x1,-0x8(%rbp)
setg   %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
test   $0x1,%al
jne    1153 <putnum_s8+0x43>
jmp    116a <putnum_s8+0x5a>
mov    -0x4(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1122 <putnum_s8+0x12>
jmp    116f <putnum_s8+0x5f>
mov    -0x4(%rbp),%edi
shr    $0x18,%edi
mov    $0x80,%esi
call   1030 <putbc@plt>
cmpl   $0x1,-0x8(%rbp)
jne    118e <putnum_s8+0x7e>
jmp    11b1 <putnum_s8+0xa1>
xor    %edi,%edi
mov    $0x1,%esi
call   1030 <putbc@plt>
mov    -0x4(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    116f <putnum_s8+0x5f>
mov    $0x1,%esi
mov    %esi,%edi
call   1030 <putbc@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<putnum_s8>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
cmp    $0x1000000,%edi
jae    1150 <putnum_s8+0x40>
mov    %ebx,%r14d
shl    $0x8,%r14d
cmp    $0xffff,%ebx
ja     1166 <putnum_s8+0x56>
mov    %ebx,%eax
shl    $0x10,%eax
cmp    $0xff,%ebx
ja     1170 <putnum_s8+0x60>
mov    %ebx,%r14d
shl    $0x18,%r14d
mov    $0x1,%ebp
mov    $0x1,%r15b
mov    %eax,%ebx
jmp    117e <putnum_s8+0x6e>
mov    %ebx,%edi
shr    $0x18,%edi
mov    $0x80,%esi
call   1030 <putbc@plt>
mov    $0x4,%ebp
jmp    1195 <putnum_s8+0x85>
mov    $0x3,%ebp
xor    %r15d,%r15d
jmp    117e <putnum_s8+0x6e>
mov    $0x2,%ebp
xor    %r15d,%r15d
mov    %r14d,%ebx
mov    %eax,%r14d
shr    $0x10,%ebx
mov    %ebx,%edi
mov    $0x80,%esi
call   1030 <putbc@plt>
mov    %r14d,%ebx
test   %r15b,%r15b
jne    11c3 <putnum_s8+0xb3>
add    $0xffffffff,%ebp
nopl   0x0(%rax,%rax,1)
xor    %edi,%edi
mov    $0x1,%esi
call   1030 <putbc@plt>
shl    $0x8,%ebx
mov    %ebx,%edi
shr    $0x18,%edi
mov    $0x80,%esi
call   1030 <putbc@plt>
add    $0xffffffff,%ebp
jne    11a0 <putnum_s8+0x90>
mov    $0x1,%edi
mov    $0x1,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putbc@plt>

LLVM IR (-O0):
define void @putnum_s8(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 4, i32* %3
br label %4
4: ; preds = %13, %1
%5 = load i32, i32* %2
%6 = and i32 %5, -16777216
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %4
%9 = load i32, i32* %3
%10 = icmp sgt i32 %9, 1
br label %11
11: ; preds = %8, %4
%12 = phi i1 [ false, %4 ], [ %10, %8 ]
br i1 %12, label %13, label %18
13: ; preds = %11
%14 = load i32, i32* %2
%15 = shl i32 %14, 8
store i32 %15, i32* %2
%16 = load i32, i32* %3
%17 = add nsw i32 %16, -1
store i32 %17, i32* %3
br label %4
18: ; preds = %11
br label %19
19: ; preds = %26, %18
%20 = load i32, i32* %2
%21 = lshr i32 %20, 24
%22 = call i32 @putbc(i32 %21, i32 128)
%23 = load i32, i32* %3
%24 = icmp eq i32 %23, 1
br i1 %24, label %25, label %26
25: ; preds = %19
br label %32
26: ; preds = %19
%27 = call i32 @putbc(i32 0, i32 1)
%28 = load i32, i32* %2
%29 = shl i32 %28, 8
store i32 %29, i32* %2
%30 = load i32, i32* %3
%31 = add nsw i32 %30, -1
store i32 %31, i32* %3
br label %19
32: ; preds = %25
%33 = call i32 @putbc(i32 1, i32 1)
ret void
}

LLVM IR (-O2):
define void @putnum_s8(i32 %0) {
%2 = icmp ult i32 %0, 16777216
br i1 %2, label %16, label %3
3: ; preds = %1
%4 = lshr i32 %0, 24
%5 = tail call i32 @putbc(i32 %4, i32 128)
br label %13
6: ; preds = %22, %19, %16
%7 = phi i32 [ %0, %16 ], [ %17, %19 ], [ %20, %22 ]
%8 = phi i32 [ %17, %16 ], [ %20, %19 ], [ %23, %22 ]
%9 = phi i1 [ false, %16 ], [ false, %19 ], [ true, %22 ]
%10 = phi i32 [ 3, %16 ], [ 2, %19 ], [ 1, %22 ]
%11 = lshr i32 %7, 16
%12 = tail call i32 @putbc(i32 %11, i32 128)
br i1 %9, label %33, label %13
13: ; preds = %3, %6
%14 = phi i32 [ %10, %6 ], [ 4, %3 ]
%15 = phi i32 [ %8, %6 ], [ %0, %3 ]
br label %24
16: ; preds = %1
%17 = shl nuw i32 %0, 8
%18 = icmp ult i32 %0, 65536
br i1 %18, label %19, label %6
19: ; preds = %16
%20 = shl nuw i32 %0, 16
%21 = icmp ult i32 %0, 256
br i1 %21, label %22, label %6
22: ; preds = %19
%23 = shl nuw i32 %0, 24
br label %6
24: ; preds = %13, %24
%25 = phi i32 [ %29, %24 ], [ %14, %13 ]
%26 = phi i32 [ %28, %24 ], [ %15, %13 ]
%27 = tail call i32 @putbc(i32 0, i32 1)
%28 = shl i32 %26, 8
%29 = add nsw i32 %25, -1
%30 = lshr i32 %28, 24
%31 = tail call i32 @putbc(i32 %30, i32 128)
%32 = icmp eq i32 %29, 1
br i1 %32, label %33, label %24
33: ; preds = %24, %6
%34 = tail call i32 @putbc(i32 1, i32 1)
ret void
}