#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 scalar_t__ uint64_t;
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ putchar(int);
void print_sig(uint32_t sig) {
  for (uint64_t i = (8); i > 0; i--) {
    putchar(sig % 3 + '0');
    sig /= 3;
  }
}


x86 assembly (clang, -O0):
<print_sig>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movq   $0x8,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jle    1162 <print_sig+0x52>
mov    -0x4(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
add    $0x30,%edi
call   1030 <putchar@plt>
mov    -0x4(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
jmp    1123 <print_sig+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_sig>:
push   %r14
push   %rbx
push   %rax
movslq %edi,%r14
imul   $0x55555556,%r14,%rbx
mov    %rbx,%rax
shr    $0x3f,%rax
shr    $0x20,%rbx
add    %eax,%ebx
lea    (%rbx,%rbx,2),%eax
neg    %eax
add    %eax,%edi
add    $0x30,%edi
call   1030 <putchar@plt>
movslq %ebx,%rdi
imul   $0x55555556,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
lea    (%rax,%rax,2),%eax
sub    %eax,%edi
add    $0x30,%edi
call   1030 <putchar@plt>
imul   $0x38e38e39,%r14,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
sar    %eax
add    %ecx,%eax
movslq %eax,%rdi
imul   $0x55555556,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
lea    (%rax,%rax,2),%eax
sub    %eax,%edi
add    $0x30,%edi
call   1030 <putchar@plt>
imul   $0x4bda12f7,%r14,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
sar    $0x3,%eax
add    %ecx,%eax
movslq %eax,%rdi
imul   $0x55555556,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
lea    (%rax,%rax,2),%eax
sub    %eax,%edi
add    $0x30,%edi
call   1030 <putchar@plt>
imul   $0x1948b0fd,%r14,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
sar    $0x3,%eax
add    %ecx,%eax
movslq %eax,%rdi
imul   $0x55555556,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
lea    (%rax,%rax,2),%eax
sub    %eax,%edi
add    $0x30,%edi
call   1030 <putchar@plt>
imul   $0xffffffff86d90545,%r14,%rax
shr    $0x20,%rax
add    %r14d,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x7,%eax
add    %ecx,%eax
movslq %eax,%rdi
imul   $0x55555556,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
lea    (%rax,%rax,2),%eax
sub    %eax,%edi
add    $0x30,%edi
call   1030 <putchar@plt>
imul   $0x59e60383,%r14,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
sar    $0x8,%eax
add    %ecx,%eax
movslq %eax,%rdi
imul   $0x55555556,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
lea    (%rax,%rax,2),%eax
sub    %eax,%edi
add    $0x30,%edi
call   1030 <putchar@plt>
imul   $0x1df75681,%r14,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
sar    $0x8,%eax
add    %ecx,%eax
movslq %eax,%rdi
imul   $0x55555556,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
lea    (%rax,%rax,2),%eax
sub    %eax,%edi
add    $0x30,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <putchar@plt>

LLVM IR (-O0):
define void @print_sig(i32 %0) {
%2 = alloca i32
%3 = alloca i64
store i32 %0, i32* %2
store i64 8, i64* %3
br label %4
4: ; preds = %14, %1
%5 = load i64, i64* %3
%6 = icmp sgt i64 %5, 0
br i1 %6, label %7, label %17
7: ; preds = %4
%8 = load i32, i32* %2
%9 = srem i32 %8, 3
%10 = add nsw i32 %9, 48
%11 = call i32 @putchar(i32 %10)
%12 = load i32, i32* %2
%13 = sdiv i32 %12, 3
store i32 %13, i32* %2
br label %14
14: ; preds = %7
%15 = load i64, i64* %3
%16 = add nsw i64 %15, -1
store i64 %16, i64* %3
br label %4
17: ; preds = %4
ret void
}

LLVM IR (-O2):
define void @print_sig(i32 %0) {
%2 = srem i32 %0, 3
%3 = add nsw i32 %2, 48
%4 = tail call i32 @putchar(i32 %3)
%5 = sdiv i32 %0, 3
%6 = srem i32 %5, 3
%7 = add nsw i32 %6, 48
%8 = tail call i32 @putchar(i32 %7)
%9 = sdiv i32 %0, 9
%10 = srem i32 %9, 3
%11 = add nsw i32 %10, 48
%12 = tail call i32 @putchar(i32 %11)
%13 = sdiv i32 %0, 27
%14 = srem i32 %13, 3
%15 = add nsw i32 %14, 48
%16 = tail call i32 @putchar(i32 %15)
%17 = sdiv i32 %0, 81
%18 = srem i32 %17, 3
%19 = add nsw i32 %18, 48
%20 = tail call i32 @putchar(i32 %19)
%21 = sdiv i32 %0, 243
%22 = srem i32 %21, 3
%23 = add nsw i32 %22, 48
%24 = tail call i32 @putchar(i32 %23)
%25 = sdiv i32 %0, 729
%26 = srem i32 %25, 3
%27 = add nsw i32 %26, 48
%28 = tail call i32 @putchar(i32 %27)
%29 = sdiv i32 %0, 2187
%30 = srem i32 %29, 3
%31 = add nsw i32 %30, 48
%32 = tail call i32 @putchar(i32 %31)
ret void
}