char *iupStrGetSmallMem(void) {
  static char buffers[100][80];
  static int buffers_index = -1;
  char *ret_str;
  if (buffers_index == -1) {
    memset(buffers, 0, sizeof(char *) * 100);
    buffers_index = 0;
  }
  memset(buffers[buffers_index], 0, 80);
  ret_str = buffers[buffers_index];
  buffers_index++;
  if (buffers_index == 100)
    buffers_index = 0;
  return ret_str;
}


x86 assembly (clang, -O0):
<iupStrGetSmallMem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
cmpl   $0xffffffff,0x2f09(%rip)
jne    1142 <iupStrGetSmallMem+0x32>
lea    0x2f14(%rip),%rdi
xor    %esi,%esi
mov    $0x320,%edx
call   1030 <memset@plt>
movl   $0x0,0x2ee6(%rip)
movslq 0x2edf(%rip),%rax
lea    0x2ef0(%rip),%rdi
imul   $0x50,%rax,%rax
add    %rax,%rdi
xor    %esi,%esi
mov    $0x50,%edx
call   1030 <memset@plt>
movslq 0x2ebe(%rip),%rcx
lea    0x2ecf(%rip),%rax
imul   $0x50,%rcx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    0x2ea6(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2e9d(%rip)
cmpl   $0x64,0x2e96(%rip)
jne    11a2 <iupStrGetSmallMem+0x92>
movl   $0x0,0x2e86(%rip)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iupStrGetSmallMem>:
push   %rbx
mov    0x2f11(%rip),%ebx
cmp    $0xffffffff,%ebx
jne    1131 <iupStrGetSmallMem+0x21>
lea    0x2f1d(%rip),%rdi
xor    %ebx,%ebx
mov    $0x320,%edx
xor    %esi,%esi
call   1030 <memset@plt>
movslq %ebx,%rcx
lea    (%rcx,%rcx,4),%rdx
shl    $0x4,%rdx
lea    0x2efd(%rip),%rsi
lea    (%rsi,%rdx,1),%rax
xorps  %xmm0,%xmm0
movaps %xmm0,0x40(%rdx,%rsi,1)
movaps %xmm0,0x30(%rdx,%rsi,1)
movaps %xmm0,0x20(%rdx,%rsi,1)
movaps %xmm0,0x10(%rdx,%rsi,1)
movaps %xmm0,(%rdx,%rsi,1)
add    $0x1,%ecx
xor    %edx,%edx
cmp    $0x64,%ecx
cmovne %ecx,%edx
mov    %edx,0x2eb5(%rip)
pop    %rbx
ret

LLVM IR (-O0):
@iupStrGetSmallMem.buffers = internal global [100 x [80 x i8]] zeroinitializer
@iupStrGetSmallMem.buffers_index = internal global i32 -1
define i8* @iupStrGetSmallMem() {
%1 = alloca i8*
%2 = load i32, i32* @iupStrGetSmallMem.buffers_index
%3 = icmp eq i32 %2, -1
br i1 %3, label %4, label %5
4: ; preds = %0
store i32 0, i32* @iupStrGetSmallMem.buffers_index
br label %5
5: ; preds = %4, %0
%6 = load i32, i32* @iupStrGetSmallMem.buffers_index
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds [100 x [80 x i8]], [100 x [80 x i8]]* @iupStrGetSmallMem.buffers, i64 0, i64 %7
%9 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%10 = load i32, i32* @iupStrGetSmallMem.buffers_index
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [100 x [80 x i8]], [100 x [80 x i8]]* @iupStrGetSmallMem.buffers, i64 0, i64 %11
%13 = getelementptr inbounds [80 x i8], [80 x i8]* %12, i64 0, i64 0
store i8* %13, i8** %1
%14 = load i32, i32* @iupStrGetSmallMem.buffers_index
%15 = add nsw i32 %14, 1
store i32 %15, i32* @iupStrGetSmallMem.buffers_index
%16 = load i32, i32* @iupStrGetSmallMem.buffers_index
%17 = icmp eq i32 %16, 100
br i1 %17, label %18, label %19
18: ; preds = %5
store i32 0, i32* @iupStrGetSmallMem.buffers_index
br label %19
19: ; preds = %18, %5
%20 = load i8*, i8** %1
ret i8* %20
}

LLVM IR (-O2):
@iupStrGetSmallMem.buffers = internal global [100 x [80 x i8]] zeroinitializer
@iupStrGetSmallMem.buffers_index = internal unnamed_addr global i32 -1
define i8* @iupStrGetSmallMem() {
%1 = load i32, i32* @iupStrGetSmallMem.buffers_index
%2 = icmp eq i32 %1, -1
br i1 %2, label %3, label %4
3: ; preds = %0
tail call void @llvm.memset.p0i8.i64(i8* align 16 dereferenceable(800) getelementptr inbounds ([100 x [80 x i8]], [100 x [80 x i8]]* @iupStrGetSmallMem.buffers, i64 0, i64 0, i64 0), i8 0, i64 800, i1 false)
br label %4
4: ; preds = %3, %0
%5 = phi i32 [ 0, %3 ], [ %1, %0 ]
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds [100 x [80 x i8]], [100 x [80 x i8]]* @iupStrGetSmallMem.buffers, i64 0, i64 %6, i64 0
tail call void @llvm.memset.p0i8.i64(i8* align 16 dereferenceable(80) %7, i8 0, i64 80, i1 false)
%8 = add nuw nsw i32 %5, 1
%9 = icmp eq i32 %8, 100
%10 = select i1 %9, i32 0, i32 %8
store i32 %10, i32* @iupStrGetSmallMem.buffers_index
ret i8* %7
}