#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 off_t;
typedef int /*<<< orphan*/ off;

/* Variables and functions */
int /*<<< orphan*/ sprintf(char *, char *, int);
char *off_to_str(off_t off) {
  static char bufs[4][80];
  static char(*next_buf)[80] = bufs;
  if (next_buf > (bufs + 4))
    next_buf = bufs;
  if (sizeof(off) > sizeof(long))
    sprintf(*next_buf, "%qd", off);
  else if (sizeof(off) == sizeof(long))
    sprintf(*next_buf, "%ld", off);
  else
    sprintf(*next_buf, "%d", off);
  return *next_buf++;
}


x86 assembly (clang, -O0):
<off_to_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0x2f1e(%rip),%rax
add    $0x140,%rax
cmp    %rax,0x2ef9(%rip)
jbe    1143 <off_to_str+0x33>
lea    0x2f04(%rip),%rax
mov    %rax,0x2ee5(%rip)
mov    0x2ede(%rip),%rdi
mov    -0x4(%rbp),%edx
lea    0xeac(%rip),%rsi
call   1030 <sprintf@plt>
mov    0x2ec8(%rip),%rax
mov    %rax,%rcx
add    $0x50,%rcx
mov    %rcx,0x2eba(%rip)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<off_to_str>:
push   %rax
mov    %edi,%edx
mov    0x2f0e(%rip),%rdi
lea    0x305f(%rip),%rax
cmp    %rax,%rdi
jbe    1134 <off_to_str+0x24>
lea    0x2f13(%rip),%rdi
mov    %rdi,0x2ef4(%rip)
lea    0xec5(%rip),%rsi
call   1030 <sprintf@plt>
mov    0x2ee1(%rip),%rax
lea    0x50(%rax),%rcx
mov    %rcx,0x2ed6(%rip)
pop    %rcx
ret

LLVM IR (-O0):
@off_to_str.bufs = internal global [4 x [80 x i8]] zeroinitializer
@off_to_str.next_buf = internal global [80 x i8]* getelementptr inbounds ([4 x [80 x i8]], [4 x [80 x i8]]* @off_to_str.bufs, i32 0, i32 0)
@.str = [3 x i8] c"%d\00"
define i8* @off_to_str(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load [80 x i8]*, [80 x i8]** @off_to_str.next_buf
%4 = icmp ugt [80 x i8]* %3, getelementptr inbounds ([4 x [80 x i8]], [4 x [80 x i8]]* @off_to_str.bufs, i64 1, i64 0)
br i1 %4, label %5, label %6
5: ; preds = %1
store [80 x i8]* getelementptr inbounds ([4 x [80 x i8]], [4 x [80 x i8]]* @off_to_str.bufs, i64 0, i64 0), [80 x i8]** @off_to_str.next_buf
br label %6
6: ; preds = %5, %1
%7 = load [80 x i8]*, [80 x i8]** @off_to_str.next_buf
%8 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%9 = load i32, i32* %2
%10 = call i32 @sprintf(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = load [80 x i8]*, [80 x i8]** @off_to_str.next_buf
%12 = getelementptr inbounds [80 x i8], [80 x i8]* %11, i32 1
store [80 x i8]* %12, [80 x i8]** @off_to_str.next_buf
%13 = getelementptr inbounds [80 x i8], [80 x i8]* %11, i64 0, i64 0
ret i8* %13
}

LLVM IR (-O2):
@off_to_str.bufs = internal global [4 x [80 x i8]] zeroinitializer
@off_to_str.next_buf = internal unnamed_addr global [80 x i8]* getelementptr inbounds ([4 x [80 x i8]], [4 x [80 x i8]]* @off_to_str.bufs, i64 0, i64 0)
@.str = [3 x i8] c"%d\00"
define i8* @off_to_str(i32 %0) {
%2 = load [80 x i8]*, [80 x i8]** @off_to_str.next_buf
%3 = icmp ugt [80 x i8]* %2, getelementptr inbounds ([4 x [80 x i8]], [4 x [80 x i8]]* @off_to_str.bufs, i64 1, i64 0)
br i1 %3, label %4, label %5
4: ; preds = %1
store [80 x i8]* getelementptr inbounds ([4 x [80 x i8]], [4 x [80 x i8]]* @off_to_str.bufs, i64 0, i64 0), [80 x i8]** @off_to_str.next_buf
br label %5
5: ; preds = %4, %1
%6 = phi [80 x i8]* [ getelementptr inbounds ([4 x [80 x i8]], [4 x [80 x i8]]* @off_to_str.bufs, i64 0, i64 0), %4 ], [ %2, %1 ]
%7 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%8 = tail call i32 @sprintf(i8* dereferenceable(1) %7, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %0)
%9 = load [80 x i8]*, [80 x i8]** @off_to_str.next_buf
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 1
store [80 x i8]* %10, [80 x i8]** @off_to_str.next_buf
%11 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
ret i8* %11
}