#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 *, char);
void decode(int x) {
  int i, buf[4];
  for (i = 0; i < 4; i++) {
    buf[i] = x & 255;
    x >>= 8;
  }
  for (i = 3; i >= 0; i--)
    printf("%c", (char)buf[i]);
}


x86 assembly (clang, -O0):
<decode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    1154 <decode+0x44>
mov    -0x4(%rbp),%ecx
and    $0xff,%ecx
movslq -0x8(%rbp),%rax
mov    %ecx,-0x20(%rbp,%rax,4)
mov    -0x4(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1122 <decode+0x12>
movl   $0x3,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     118a <decode+0x7a>
movslq -0x8(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%eax
lea    0xe8c(%rip),%rdi
movsbl %al,%esi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    115b <decode+0x4b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decode>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebp
mov    %edi,%r15d
shr    $0x8,%r15d
mov    %edi,%ebx
shr    $0x10,%ebx
mov    %edi,%esi
sar    $0x18,%esi
lea    0xecf(%rip),%r14
mov    %r14,%rdi
call   1030 <printf@plt>
movsbl %bl,%esi
mov    %r14,%rdi
call   1030 <printf@plt>
movsbl %r15b,%esi
mov    %r14,%rdi
call   1030 <printf@plt>
movsbl %bpl,%esi
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
define void @decode(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [4 x i32]
store i32 %0, i32* %2
store i32 0, i32* %3
br label %5
5: ; preds = %16, %1
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 4
br i1 %7, label %8, label %19
8: ; preds = %5
%9 = load i32, i32* %2
%10 = and i32 %9, 255
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 %12
store i32 %10, i32* %13
%14 = load i32, i32* %2
%15 = ashr i32 %14, 8
store i32 %15, i32* %2
br label %16
16: ; preds = %8
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %3
br label %5
19: ; preds = %5
store i32 3, i32* %3
br label %20
20: ; preds = %30, %19
%21 = load i32, i32* %3
%22 = icmp sge i32 %21, 0
br i1 %22, label %23, label %33
23: ; preds = %20
%24 = load i32, i32* %3
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 %25
%27 = load i32, i32* %26
%28 = trunc i32 %27 to i8
%29 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %28)
br label %30
30: ; preds = %23
%31 = load i32, i32* %3
%32 = add nsw i32 %31, -1
store i32 %32, i32* %3
br label %20
33: ; preds = %20
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
define void @decode(i32 %0) {
%2 = lshr i32 %0, 8
%3 = lshr i32 %0, 16
%4 = lshr i32 %0, 24
%5 = trunc i32 %4 to i8
%6 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %5)
%7 = trunc i32 %3 to i8
%8 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %7)
%9 = trunc i32 %2 to i8
%10 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %9)
%11 = trunc i32 %0 to i8
%12 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %11)
ret void
}