#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 */
char *strchr(char *, char);
int strlen(char *);
void explode(char *buf, char **cmd, char **param) {
  char *p;
  while ((p = &buf[strlen(buf) - 1]) && (*p == 'r' || *p == 'n'))
    *p = 0;
  p = strchr(buf, ' ');
  *cmd = buf;
  if (!p)
    *param = NULL;
  else {
    *p = 0;
    *param = p + 1;
  };
}


x86 assembly (clang, -O0):
<explode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rcx
sub    $0x1,%eax
cltq
add    %rax,%rcx
mov    %rcx,-0x20(%rbp)
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x21(%rbp)
je     118f <explode+0x6f>
mov    -0x20(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x72,%ecx
mov    %al,-0x31(%rbp)
je     1189 <explode+0x69>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x6e,%eax
sete   %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    119f <explode+0x7f>
jmp    11ab <explode+0x8b>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
jmp    1134 <explode+0x14>
mov    -0x8(%rbp),%rdi
mov    $0x20,%esi
call   1040 <strchr@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x20(%rbp)
jne    11e3 <explode+0xc3>
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
jmp    11f9 <explode+0xd9>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rcx
add    $0x1,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<explode>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
call   1030 <strlen@plt>
test   %rbx,%rbx
jne    114d <explode+0x2d>
jmp    115e <explode+0x3e>
nopw   0x0(%rax,%rax,1)
movb   $0x0,-0x1(%rbx,%rax,1)
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
movzbl -0x1(%rax,%rbx,1),%ecx
cmp    $0x72,%cl
je     1140 <explode+0x20>
cmp    $0x6e,%cl
je     1140 <explode+0x20>
mov    %rbx,%rdi
mov    $0x20,%esi
call   1040 <strchr@plt>
mov    %rbx,(%r15)
test   %rax,%rax
je     117c <explode+0x5c>
movb   $0x0,(%rax)
add    $0x1,%rax
jmp    117e <explode+0x5e>
xor    %eax,%eax
mov    %rax,(%r14)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @explode(i8* %0, i8** %1, i8** %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i8*
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i8** %2, i8*** %6
br label %8
8: ; preds = %30, %3
%9 = load i8*, i8** %4
%10 = load i8*, i8** %4
%11 = call i32 @strlen(i8* %10)
%12 = sub nsw i32 %11, 1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %9, i64 %13
store i8* %14, i8** %7
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %28
16: ; preds = %8
%17 = load i8*, i8** %7
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 114
br i1 %20, label %26, label %21
21: ; preds = %16
%22 = load i8*, i8** %7
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 110
br label %26
26: ; preds = %21, %16
%27 = phi i1 [ true, %16 ], [ %25, %21 ]
br label %28
28: ; preds = %26, %8
%29 = phi i1 [ false, %8 ], [ %27, %26 ]
br i1 %29, label %30, label %32
30: ; preds = %28
%31 = load i8*, i8** %7
store i8 0, i8* %31
br label %8
32: ; preds = %28
%33 = load i8*, i8** %4
%34 = call i8* @strchr(i8* %33, i8 signext 32)
store i8* %34, i8** %7
%35 = load i8*, i8** %4
%36 = load i8**, i8*** %5
store i8* %35, i8** %36
%37 = load i8*, i8** %7
%38 = icmp ne i8* %37, null
br i1 %38, label %41, label %39
39: ; preds = %32
%40 = load i8**, i8*** %6
store i8* null, i8** %40
br label %46
41: ; preds = %32
%42 = load i8*, i8** %7
store i8 0, i8* %42
%43 = load i8*, i8** %7
%44 = getelementptr inbounds i8, i8* %43, i64 1
%45 = load i8**, i8*** %6
store i8* %44, i8** %45
br label %46
46: ; preds = %41, %39
ret void
}

LLVM IR (-O2):
define void @explode(i8* %0, i8** nocapture writeonly %1, i8** nocapture writeonly %2) {
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp eq i8* %0, null
br i1 %5, label %14, label %6
6: ; preds = %3, %12
%7 = phi i32 [ %13, %12 ], [ %4, %3 ]
%8 = add nsw i32 %7, -1
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = load i8, i8* %10
switch i8 %11, label %14 [
i8 114, label %12
i8 110, label %12
]
12: ; preds = %6, %6
store i8 0, i8* %10
%13 = tail call i32 @strlen(i8* %0)
br label %6
14: ; preds = %6, %3
%15 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 32)
store i8* %0, i8** %1
%16 = icmp eq i8* %15, null
br i1 %16, label %19, label %17
17: ; preds = %14
store i8 0, i8* %15
%18 = getelementptr inbounds i8, i8* %15, i64 1
br label %19
19: ; preds = %14, %17
%20 = phi i8* [ %18, %17 ], [ null, %14 ]
store i8* %20, i8** %2
ret void
}