#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*/ buff;

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, int);
const char *page0(int disp) {
  static char buff[4][16];
  static int which = 0;
  char *dst;
  which = (which + 1) % 4;
  dst = buff[which];
  snprintf(dst, sizeof(buff[0]), "0%o", disp & 0377);
  return buff[which];
}


x86 assembly (clang, -O0):
<page0>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2f5f(%rip),%eax
add    $0x1,%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,0x2f4e(%rip)
movslq 0x2f47(%rip),%rcx
lea    0x2f00(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%ecx
and    $0xff,%ecx
mov    $0x10,%esi
lea    0xe9c(%rip),%rdx
call   1030 <snprintf@plt>
movslq 0x2f10(%rip),%rcx
lea    0x2ec9(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<page0>:
push   %rbx
mov    0x2f69(%rip),%eax
lea    0x1(%rax),%ecx
lea    0x4(%rax),%edx
test   %ecx,%ecx
cmovns %ecx,%edx
and    $0xfffffffc,%edx
neg    %edx
add    %edx,%eax
add    $0x1,%eax
mov    %eax,0x2f4e(%rip)
shl    $0x4,%rax
lea    0x2f03(%rip),%rbx
add    %rbx,%rax
movzbl %dil,%ecx
lea    0xeb5(%rip),%rdx
mov    %rax,%rdi
mov    $0x10,%esi
call   1030 <snprintf@plt>
mov    0x2f22(%rip),%eax
shl    $0x4,%rax
add    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@page0.buff = internal global [4 x [16 x i8]] zeroinitializer
@page0.which = internal global i32 0
@.str = [4 x i8] c"0%o\00"
define i8* @page0(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
store i32 %0, i32* %2
%4 = load i32, i32* @page0.which
%5 = add nsw i32 %4, 1
%6 = srem i32 %5, 4
store i32 %6, i32* @page0.which
%7 = load i32, i32* @page0.which
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [4 x [16 x i8]], [4 x [16 x i8]]* @page0.buff, i64 0, i64 %8
%10 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
store i8* %10, i8** %3
%11 = load i8*, i8** %3
%12 = load i32, i32* %2
%13 = and i32 %12, 255
%14 = call i32 @snprintf(i8* %11, i32 16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = load i32, i32* @page0.which
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [4 x [16 x i8]], [4 x [16 x i8]]* @page0.buff, i64 0, i64 %16
%18 = getelementptr inbounds [16 x i8], [16 x i8]* %17, i64 0, i64 0
ret i8* %18
}

LLVM IR (-O2):
@page0.buff = internal global [4 x [16 x i8]] zeroinitializer
@page0.which = internal unnamed_addr global i32 0
@.str = [4 x i8] c"0%o\00"
define i8* @page0(i32 %0) {
%2 = load i32, i32* @page0.which
%3 = add nsw i32 %2, 1
%4 = srem i32 %3, 4
store i32 %4, i32* @page0.which
%5 = zext i32 %4 to i64
%6 = getelementptr inbounds [4 x [16 x i8]], [4 x [16 x i8]]* @page0.buff, i64 0, i64 %5, i64 0
%7 = and i32 %0, 255
%8 = tail call i32 @snprintf(i8* %6, i32 16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = load i32, i32* @page0.which
%10 = zext i32 %9 to i64
%11 = getelementptr inbounds [4 x [16 x i8]], [4 x [16 x i8]]* @page0.buff, i64 0, i64 %10, i64 0
ret i8* %11
}