#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 */
scalar_t__ streq(char *, char *);
int strlen(char *);
int try_sep_from_arg(char *arg, char *pout) {
  if (streq(arg, "tab"))
    *pout = '\t';
  else if (streq(arg, "space"))
    *pout = ' ';
  else if (streq(arg, "newline"))
    *pout = '\n';
  else if (streq(arg, "pipe"))
    *pout = '|';
  else if (streq(arg, "semicolon"))
    *pout = '|';
  else if (strlen(arg) != 1)
    return 0;
  *pout = arg[0];
  return 1;
}


x86 assembly (clang, -O0):
<try_sep_from_arg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xec5(%rip),%rsi
call   1040 <streq@plt>
cmp    $0x0,%rax
je     1156 <try_sep_from_arg+0x36>
mov    -0x18(%rbp),%rax
movb   $0x9,(%rax)
jmp    1225 <try_sep_from_arg+0x105>
mov    -0x10(%rbp),%rdi
lea    0xea3(%rip),%rsi
call   1040 <streq@plt>
cmp    $0x0,%rax
je     117c <try_sep_from_arg+0x5c>
mov    -0x18(%rbp),%rax
movb   $0x20,(%rax)
jmp    1220 <try_sep_from_arg+0x100>
mov    -0x10(%rbp),%rdi
lea    0xe83(%rip),%rsi
call   1040 <streq@plt>
cmp    $0x0,%rax
je     11a2 <try_sep_from_arg+0x82>
mov    -0x18(%rbp),%rax
movb   $0xa,(%rax)
jmp    121b <try_sep_from_arg+0xfb>
mov    -0x10(%rbp),%rdi
lea    0xe65(%rip),%rsi
call   1040 <streq@plt>
cmp    $0x0,%rax
je     11c8 <try_sep_from_arg+0xa8>
mov    -0x18(%rbp),%rax
movb   $0x7c,(%rax)
jmp    1216 <try_sep_from_arg+0xf6>
mov    -0x10(%rbp),%rdi
lea    0xe44(%rip),%rsi
call   1040 <streq@plt>
cmp    $0x0,%rax
je     11ee <try_sep_from_arg+0xce>
mov    -0x18(%rbp),%rax
movb   $0x7c,(%rax)
jmp    1211 <try_sep_from_arg+0xf1>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x1,%eax
je     120c <try_sep_from_arg+0xec>
movl   $0x0,-0x4(%rbp)
jmp    1238 <try_sep_from_arg+0x118>
jmp    1211 <try_sep_from_arg+0xf1>
jmp    1216 <try_sep_from_arg+0xf6>
jmp    121b <try_sep_from_arg+0xfb>
jmp    1220 <try_sep_from_arg+0x100>
jmp    1225 <try_sep_from_arg+0x105>
mov    -0x10(%rbp),%rax
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<try_sep_from_arg>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xece(%rip),%rsi
call   1040 <streq@plt>
mov    $0x9,%bl
test   %rax,%rax
jne    1194 <try_sep_from_arg+0x74>
lea    0xebf(%rip),%rsi
mov    %r15,%rdi
call   1040 <streq@plt>
mov    $0x20,%bl
test   %rax,%rax
jne    1194 <try_sep_from_arg+0x74>
lea    0xeaf(%rip),%rsi
mov    %r15,%rdi
call   1040 <streq@plt>
mov    $0xa,%bl
test   %rax,%rax
jne    1194 <try_sep_from_arg+0x74>
lea    0xea1(%rip),%rsi
mov    %r15,%rdi
call   1040 <streq@plt>
mov    $0x7c,%bl
test   %rax,%rax
jne    1194 <try_sep_from_arg+0x74>
lea    0xe90(%rip),%rsi
mov    %r15,%rdi
call   1040 <streq@plt>
test   %rax,%rax
je     11a8 <try_sep_from_arg+0x88>
mov    %bl,(%r14)
mov    (%r15),%al
mov    %al,(%r14)
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x1,%ecx
je     1197 <try_sep_from_arg+0x77>
jmp    11a2 <try_sep_from_arg+0x82>

LLVM IR (-O0):
@.str = [4 x i8] c"tab\00"
@.str.1 = [6 x i8] c"space\00"
@.str.2 = [8 x i8] c"newline\00"
@.str.3 = [5 x i8] c"pipe\00"
@.str.4 = [10 x i8] c"semicolon\00"
define i32 @try_sep_from_arg(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%6 = load i8*, i8** %4
%7 = call i64 @streq(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = load i8*, i8** %5
store i8 9, i8* %10
br label %45
11: ; preds = %2
%12 = load i8*, i8** %4
%13 = call i64 @streq(i8* %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = load i8*, i8** %5
store i8 32, i8* %16
br label %44
17: ; preds = %11
%18 = load i8*, i8** %4
%19 = call i64 @streq(i8* %18, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = load i8*, i8** %5
store i8 10, i8* %22
br label %43
23: ; preds = %17
%24 = load i8*, i8** %4
%25 = call i64 @streq(i8* %24, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %23
%28 = load i8*, i8** %5
store i8 124, i8* %28
br label %42
29: ; preds = %23
%30 = load i8*, i8** %4
%31 = call i64 @streq(i8* %30, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %29
%34 = load i8*, i8** %5
store i8 124, i8* %34
br label %41
35: ; preds = %29
%36 = load i8*, i8** %4
%37 = call i32 @strlen(i8* %36)
%38 = icmp ne i32 %37, 1
br i1 %38, label %39, label %40
39: ; preds = %35
store i32 0, i32* %3
br label %50
40: ; preds = %35
br label %41
41: ; preds = %40, %33
br label %42
42: ; preds = %41, %27
br label %43
43: ; preds = %42, %21
br label %44
44: ; preds = %43, %15
br label %45
45: ; preds = %44, %9
%46 = load i8*, i8** %4
%47 = getelementptr inbounds i8, i8* %46, i64 0
%48 = load i8, i8* %47
%49 = load i8*, i8** %5
store i8 %48, i8* %49
store i32 1, i32* %3
br label %50
50: ; preds = %45, %39
%51 = load i32, i32* %3
ret i32 %51
}

LLVM IR (-O2):
@.str = [4 x i8] c"tab\00"
@.str.1 = [6 x i8] c"space\00"
@.str.2 = [8 x i8] c"newline\00"
@.str.3 = [5 x i8] c"pipe\00"
@.str.4 = [10 x i8] c"semicolon\00"
define i32 @try_sep_from_arg(i8* %0, i8* nocapture writeonly %1) {
%3 = tail call i64 @streq(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %20
5: ; preds = %2
%6 = tail call i64 @streq(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %20
8: ; preds = %5
%9 = tail call i64 @streq(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %20
11: ; preds = %8
%12 = tail call i64 @streq(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %20
14: ; preds = %11
%15 = tail call i64 @streq(i8* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = tail call i32 @strlen(i8* %0)
%19 = icmp eq i32 %18, 1
br i1 %19, label %22, label %24
20: ; preds = %14, %11, %8, %5, %2
%21 = phi i8 [ 9, %2 ], [ 32, %5 ], [ 10, %8 ], [ 124, %11 ], [ 124, %14 ]
store i8 %21, i8* %1
br label %22
22: ; preds = %20, %17
%23 = load i8, i8* %0
store i8 %23, i8* %1
br label %24
24: ; preds = %17, %22
%25 = phi i32 [ 1, %22 ], [ 0, %17 ]
ret i32 %25
}