#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_l1a(unsigned int i) {
  int j;
  if (i == 1) {
    putbc(0x1, 0x1);
    return;
  }
  j = 31;
  while ((i & 0x80000000) == 0) {
    i <<= 1;
    j--;
  }
  do {
    i <<= 1;
    if (i & 0x80000000)
      putbc(0x1, 0x2);
    else
      putbc(0x0, 0x2);
  } while (--j);
  putbc(0x1, 0x1);
  return;
}


x86 assembly (clang, -O0):
<putnum_l1a>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x1,-0x4(%rbp)
jne    1136 <putnum_l1a+0x26>
mov    $0x1,%esi
mov    %esi,%edi
call   1030 <putbc@plt>
jmp    11c7 <putnum_l1a+0xb7>
movl   $0x1f,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x80000000,%eax
cmp    $0x0,%eax
jne    1165 <putnum_l1a+0x55>
mov    -0x4(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    113d <putnum_l1a+0x2d>
jmp    116a <putnum_l1a+0x5a>
mov    -0x4(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0x80000000,%eax
cmp    $0x0,%eax
je     1198 <putnum_l1a+0x88>
mov    $0x1,%edi
mov    $0x2,%esi
call   1030 <putbc@plt>
jmp    11a4 <putnum_l1a+0x94>
xor    %edi,%edi
mov    $0x2,%esi
call   1030 <putbc@plt>
jmp    11a9 <putnum_l1a+0x99>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jne    116a <putnum_l1a+0x5a>
mov    $0x1,%esi
mov    %esi,%edi
call   1030 <putbc@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<putnum_l1a>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x1,%edi
je     1156 <putnum_l1a+0x46>
mov    %edi,%ebx
mov    $0x1f,%ebp
test   %ebx,%ebx
js     1140 <putnum_l1a+0x30>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    %ebx,%ebx
add    $0xffffffff,%ebp
test   %ebx,%ebx
jns    1130 <putnum_l1a+0x20>
nopl   0x0(%rax)
add    %ebx,%ebx
mov    %ebx,%edi
shr    $0x1f,%edi
mov    $0x2,%esi
call   1030 <putbc@plt>
add    $0xffffffff,%ebp
jne    1140 <putnum_l1a+0x30>
mov    $0x1,%edi
mov    $0x1,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <putbc@plt>

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

LLVM IR (-O2):
define void @putnum_l1a(i32 %0) {
%2 = icmp eq i32 %0, 1
br i1 %2, label %22, label %3
3: ; preds = %1
%4 = icmp sgt i32 %0, -1
br i1 %4, label %5, label %11
5: ; preds = %3, %5
%6 = phi i32 [ %9, %5 ], [ 31, %3 ]
%7 = phi i32 [ %8, %5 ], [ %0, %3 ]
%8 = shl nuw i32 %7, 1
%9 = add nsw i32 %6, -1
%10 = icmp sgt i32 %8, -1
br i1 %10, label %5, label %11
11: ; preds = %5, %3
%12 = phi i32 [ %0, %3 ], [ %8, %5 ]
%13 = phi i32 [ 31, %3 ], [ %9, %5 ]
br label %14
14: ; preds = %11, %14
%15 = phi i32 [ %17, %14 ], [ %12, %11 ]
%16 = phi i32 [ %20, %14 ], [ %13, %11 ]
%17 = shl i32 %15, 1
%18 = lshr i32 %17, 31
%19 = tail call i32 @putbc(i32 %18, i32 2)
%20 = add nsw i32 %16, -1
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %14
22: ; preds = %14, %1
%23 = tail call i32 @putbc(i32 1, i32 1)
ret void
}