#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, int);
int /*<<< orphan*/ strcpy(char *, char *);
void get_place_str(int place, char *str) {
  int ch[4] = {'a', 'b', 'c', 'd'};
  str[0] = '\0';
  if (place >= 0 && place <= 31)
    sprintf(str, "%c%d", ch[place % 4], 7 - place / 4 + 1);
  else
    strcpy(str, "0");
}


x86 assembly (clang, -O0):
<get_place_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
cmpl   $0x0,-0x4(%rbp)
jl     11a2 <get_place_str+0x82>
cmpl   $0x1f,-0x4(%rbp)
jg     11a2 <get_place_str+0x82>
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
mov    -0x20(%rbp,%rax,4),%eax
mov    %eax,-0x24(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    -0x24(%rbp),%edx
mov    $0x7,%ecx
sub    %eax,%ecx
add    $0x1,%ecx
lea    0xe78(%rip),%rsi
call   1040 <sprintf@plt>
jmp    11b2 <get_place_str+0x92>
mov    -0x10(%rbp),%rdi
lea    0xe68(%rip),%rsi
call   1030 <strcpy@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_place_str>:
mov    %rsi,%rax
movb   $0x0,(%rsi)
cmp    $0x1f,%edi
ja     1153 <get_place_str+0x33>
mov    %edi,%ecx
and    $0x3,%ecx
lea    0xec9(%rip),%rdx
mov    (%rdx,%rcx,4),%edx
shr    $0x2,%edi
mov    $0x8,%ecx
sub    %edi,%ecx
lea    0xec5(%rip),%rsi
mov    %rax,%rdi
jmp    1040 <sprintf@plt>
lea    0xebb(%rip),%rsi
mov    %rax,%rdi
jmp    1030 <strcpy@plt>

LLVM IR (-O0):
@__const.get_place_str.ch = [4 x i32] [i32 97, i32 98, i32 99, i32 100]
@.str = [5 x i8] c"%c%d\00"
@.str.1 = [2 x i8] c"0\00"
define void @get_place_str(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca [4 x i32]
store i32 %0, i32* %3
store i8* %1, i8** %4
%6 = bitcast [4 x i32]* %5 to i8*
%7 = load i8*, i8** %4
%8 = getelementptr inbounds i8, i8* %7, i64 0
store i8 0, i8* %8
%9 = load i32, i32* %3
%10 = icmp sge i32 %9, 0
br i1 %10, label %11, label %26
11: ; preds = %2
%12 = load i32, i32* %3
%13 = icmp sle i32 %12, 31
br i1 %13, label %14, label %26
14: ; preds = %11
%15 = load i8*, i8** %4
%16 = load i32, i32* %3
%17 = srem i32 %16, 4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 %18
%20 = load i32, i32* %19
%21 = load i32, i32* %3
%22 = sdiv i32 %21, 4
%23 = sub nsw i32 7, %22
%24 = add nsw i32 %23, 1
%25 = call i32 @sprintf(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %20, i32 %24)
br label %29
26: ; preds = %11, %2
%27 = load i8*, i8** %4
%28 = call i32 @strcpy(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %29
29: ; preds = %26, %14
ret void
}

LLVM IR (-O2):
@__const.get_place_str.ch = [4 x i32] [i32 97, i32 98, i32 99, i32 100]
@.str = [5 x i8] c"%c%d\00"
@.str.1 = [2 x i8] c"0\00"
define void @get_place_str(i32 %0, i8* %1) {
store i8 0, i8* %1
%3 = icmp ult i32 %0, 32
br i1 %3, label %4, label %12
4: ; preds = %2
%5 = and i32 %0, 3
%6 = zext i32 %5 to i64
%7 = getelementptr inbounds [4 x i32], [4 x i32]* @__const.get_place_str.ch, i64 0, i64 %6
%8 = load i32, i32* %7
%9 = lshr i32 %0, 2
%10 = sub nuw nsw i32 8, %9
%11 = tail call i32 @sprintf(i8* %1, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %10)
br label %14
12: ; preds = %2
%13 = tail call i32 @strcpy(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %12, %4
ret void
}