#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*/ sprintf(char *, char *, int);
const char *strind(int ind) {
  static char buf[16];
  switch (ind) {
  case -1:
    buf[0] = '$';
    buf[1] = 0;
    break;
  case -2:
    buf[0] = '*';
    buf[1] = 0;
    break;
  default:
    sprintf(buf, "%d", ind);
    break;
  }
  return buf;
}


x86 assembly (clang, -O0):
<strind>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
sub    $0xfffffffe,%eax
je     1153 <strind+0x43>
jmp    112f <strind+0x1f>
mov    -0x8(%rbp),%eax
sub    $0xffffffff,%eax
jne    1166 <strind+0x56>
jmp    1140 <strind+0x30>
movb   $0x24,0x2ef9(%rip)
movb   $0x0,0x2ef3(%rip)
jmp    117c <strind+0x6c>
movb   $0x2a,0x2ee6(%rip)
movb   $0x0,0x2ee0(%rip)
jmp    117c <strind+0x6c>
mov    -0x4(%rbp),%edx
lea    0x2ed0(%rip),%rdi
lea    0xe89(%rip),%rsi
call   1030 <sprintf@plt>
lea    0x2ebd(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strind>:
push   %rax
cmp    $0xfffffffe,%edi
je     1128 <strind+0x18>
mov    %edi,%edx
cmp    $0xffffffff,%edi
jne    1133 <strind+0x23>
movw   $0x24,0x2f1a(%rip)
jmp    1146 <strind+0x36>
movw   $0x2a,0x2f0f(%rip)
jmp    1146 <strind+0x36>
lea    0x2f06(%rip),%rdi
lea    0xebf(%rip),%rsi
call   1030 <sprintf@plt>
lea    0x2ef3(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
@strind.buf = internal global [16 x i8] zeroinitializer
@.str = [3 x i8] c"%d\00"
define i8* @strind(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
switch i32 %3, label %6 [
i32 -1, label %4
i32 -2, label %5
]
4: ; preds = %1
store i8 36, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @strind.buf, i64 0, i64 0)
store i8 0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @strind.buf, i64 0, i64 1)
br label %9
5: ; preds = %1
store i8 42, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @strind.buf, i64 0, i64 0)
store i8 0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @strind.buf, i64 0, i64 1)
br label %9
6: ; preds = %1
%7 = load i32, i32* %2
%8 = call i32 @sprintf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @strind.buf, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %7)
br label %9
9: ; preds = %6, %5, %4
ret i8* getelementptr inbounds ([16 x i8], [16 x i8]* @strind.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@strind.buf = internal global [16 x i8] zeroinitializer
@.str = [3 x i8] c"%d\00"
define i8* @strind(i32 %0) {
switch i32 %0, label %4 [
i32 -1, label %2
i32 -2, label %3
]
2: ; preds = %1
store i8 36, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @strind.buf, i64 0, i64 0)
store i8 0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @strind.buf, i64 0, i64 1)
br label %6
3: ; preds = %1
store i8 42, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @strind.buf, i64 0, i64 0)
store i8 0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @strind.buf, i64 0, i64 1)
br label %6
4: ; preds = %1
%5 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @strind.buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %6
6: ; preds = %4, %3, %2
ret i8* getelementptr inbounds ([16 x i8], [16 x i8]* @strind.buf, i64 0, i64 0)
}