#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 *strtok(char *, char *);
int word_count(char *);
void parse_input(char *pkt, char **arg1, char **arg2) {
  int count = word_count(pkt);
  if (count > 1) {
    *arg1 = strtok(pkt, " ");
    *arg2 = strtok(NULL, " ");
  } else {
    *arg1 = strtok(pkt, " ");
  }
}


x86 assembly (clang, -O0):
<parse_input>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <word_count@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jle    1183 <parse_input+0x63>
mov    -0x8(%rbp),%rdi
lea    0xeab(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe91(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    119d <parse_input+0x7d>
mov    -0x8(%rbp),%rdi
lea    0xe72(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_input>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
call   1030 <word_count@plt>
mov    %eax,%ebp
lea    0xec2(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strtok@plt>
mov    %rax,(%r15)
cmp    $0x2,%ebp
jl     115f <parse_input+0x3f>
lea    0xeab(%rip),%rsi
xor    %edi,%edi
call   1040 <strtok@plt>
mov    %rax,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
define void @parse_input(i8* %0, i8** %1, i8** %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i32
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i8** %2, i8*** %6
%8 = load i8*, i8** %4
%9 = call i32 @word_count(i8* %8)
store i32 %9, i32* %7
%10 = load i32, i32* %7
%11 = icmp sgt i32 %10, 1
br i1 %11, label %12, label %18
12: ; preds = %3
%13 = load i8*, i8** %4
%14 = call i8* @strtok(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%15 = load i8**, i8*** %5
store i8* %14, i8** %15
%16 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%17 = load i8**, i8*** %6
store i8* %16, i8** %17
br label %22
18: ; preds = %3
%19 = load i8*, i8** %4
%20 = call i8* @strtok(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%21 = load i8**, i8*** %5
store i8* %20, i8** %21
br label %22
22: ; preds = %18, %12
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
define void @parse_input(i8* %0, i8** nocapture writeonly %1, i8** nocapture writeonly %2) {
%4 = tail call i32 @word_count(i8* %0)
%5 = icmp sgt i32 %4, 1
%6 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %6, i8** %1
br i1 %5, label %7, label %9
7: ; preds = %3
%8 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %8, i8** %2
br label %9
9: ; preds = %3, %7
ret void
}