#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 /*<<< orphan*/ strcpy(char *, char *);
void get_policy_str(char *buf, int policy) {
  switch (policy) {
  case 0:
    strcpy(buf, "normal");
    break;
  case 6:
    strcpy(buf, "other_rr");
    break;
  default:
    sprintf(buf, "%d (unknown)", policy);
    break;
  }
}


x86 assembly (clang, -O0):
<get_policy_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
test   %eax,%eax
je     1153 <get_policy_str+0x33>
jmp    1142 <get_policy_str+0x22>
mov    -0x10(%rbp),%eax
sub    $0x6,%eax
je     1168 <get_policy_str+0x48>
jmp    117d <get_policy_str+0x5d>
mov    -0x8(%rbp),%rdi
lea    0xea2(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1190 <get_policy_str+0x70>
mov    -0x8(%rbp),%rdi
lea    0xe94(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1190 <get_policy_str+0x70>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe85(%rip),%rsi
call   1040 <sprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_policy_str>:
cmp    $0x6,%esi
je     1137 <get_policy_str+0x17>
mov    %esi,%edx
test   %esi,%esi
jne    1143 <get_policy_str+0x23>
lea    0xece(%rip),%rsi
jmp    1030 <strcpy@plt>
lea    0xec9(%rip),%rsi
jmp    1030 <strcpy@plt>
lea    0xec6(%rip),%rsi
jmp    1040 <sprintf@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"normal\00"
@.str.1 = [9 x i8] c"other_rr\00"
@.str.2 = [13 x i8] c"%d (unknown)\00"
define void @get_policy_str(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
switch i32 %5, label %12 [
i32 0, label %6
i32 6, label %9
]
6: ; preds = %2
%7 = load i8*, i8** %3
%8 = call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %16
9: ; preds = %2
%10 = load i8*, i8** %3
%11 = call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %16
12: ; preds = %2
%13 = load i8*, i8** %3
%14 = load i32, i32* %4
%15 = call i32 @sprintf(i8* %13, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %12, %9, %6
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"normal\00"
@.str.1 = [9 x i8] c"other_rr\00"
@.str.2 = [13 x i8] c"%d (unknown)\00"
define void @get_policy_str(i8* %0, i32 %1) {
switch i32 %1, label %7 [
i32 0, label %3
i32 6, label %5
]
3: ; preds = %2
%4 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %9
5: ; preds = %2
%6 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %9
7: ; preds = %2
%8 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %1)
br label %9
9: ; preds = %7, %5, %3
ret void
}