#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 SCHED_FIFO;
int SCHED_OTHER;
int SCHED_RR;
int get_policy(char p, int *policy) {
  switch (p) {
  case 'f':
    *policy = SCHED_FIFO;
    return 1;
  case 'r':
    *policy = SCHED_RR;
    return 1;
  case 'o':
    *policy = SCHED_OTHER;
    return 1;
  default:
    return 0;
  }
}


x86 assembly (clang, -O0):
<get_policy>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x5(%rbp)
mov    %rsi,-0x10(%rbp)
movsbl -0x5(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0x66,%eax
je     1145 <get_policy+0x45>
jmp    1123 <get_policy+0x23>
mov    -0x14(%rbp),%eax
sub    $0x6f,%eax
je     117b <get_policy+0x7b>
jmp    1134 <get_policy+0x34>
mov    -0x14(%rbp),%eax
sub    $0x72,%eax
je     1160 <get_policy+0x60>
jmp    1196 <get_policy+0x96>
mov    0x2e9c(%rip),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    119d <get_policy+0x9d>
mov    0x2e61(%rip),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    119d <get_policy+0x9d>
mov    0x2e56(%rip),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    119d <get_policy+0x9d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_policy>:
cmp    $0x66,%edi
je     111a <get_policy+0x1a>
cmp    $0x6f,%edi
je     1123 <get_policy+0x23>
xor    %eax,%eax
cmp    $0x72,%edi
jne    1133 <get_policy+0x33>
mov    0x2eb0(%rip),%rax
jmp    112a <get_policy+0x2a>
mov    0x2ec7(%rip),%rax
jmp    112a <get_policy+0x2a>
mov    0x2eae(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%rsi)
mov    $0x1,%eax
ret

LLVM IR (-O0):
@SCHED_FIFO = global i32 0
@SCHED_RR = global i32 0
@SCHED_OTHER = global i32 0
define i32 @get_policy(i8 signext %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8
%5 = alloca i32*
store i8 %0, i8* %4
store i32* %1, i32** %5
%6 = load i8, i8* %4
%7 = sext i8 %6 to i32
switch i32 %7, label %17 [
i32 102, label %8
i32 114, label %11
i32 111, label %14
]
8: ; preds = %2
%9 = load i32, i32* @SCHED_FIFO
%10 = load i32*, i32** %5
store i32 %9, i32* %10
store i32 1, i32* %3
br label %18
11: ; preds = %2
%12 = load i32, i32* @SCHED_RR
%13 = load i32*, i32** %5
store i32 %12, i32* %13
store i32 1, i32* %3
br label %18
14: ; preds = %2
%15 = load i32, i32* @SCHED_OTHER
%16 = load i32*, i32** %5
store i32 %15, i32* %16
store i32 1, i32* %3
br label %18
17: ; preds = %2
store i32 0, i32* %3
br label %18
18: ; preds = %17, %14, %11, %8
%19 = load i32, i32* %3
ret i32 %19
}

LLVM IR (-O2):
@SCHED_FIFO = global i32 0
@SCHED_RR = global i32 0
@SCHED_OTHER = global i32 0
define i32 @get_policy(i8 signext %0, i32* nocapture writeonly %1) {
%3 = sext i8 %0 to i32
switch i32 %3, label %9 [
i32 102, label %6
i32 114, label %4
i32 111, label %5
]
4: ; preds = %2
br label %6
5: ; preds = %2
br label %6
6: ; preds = %2, %4, %5
%7 = phi i32* [ @SCHED_OTHER, %5 ], [ @SCHED_RR, %4 ], [ @SCHED_FIFO, %2 ]
%8 = load i32, i32* %7
store i32 %8, i32* %1
br label %9
9: ; preds = %6, %2
%10 = phi i32 [ 0, %2 ], [ 1, %6 ]
ret i32 %10
}