#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*/ ngets(char *, int);
int /*<<< orphan*/ sprintf(char *, char *);
char *strtok(char *, char *);
int scanpair(char *verb, char *noun) {
  char buf[80];
  char *tok;
  verb[0] = 0;
  noun[0] = 0;
  ngets(buf, sizeof buf);
  tok = strtok(buf, " ");
  if (tok == NULL)
    return 0;
  sprintf(verb, tok);
  tok = strtok(NULL, " \0");
  if (tok != NULL) {
    sprintf(noun, tok);
    while (tok != NULL)
      tok = strtok(NULL, " \n");
    return 2;
  }
  return 1;
}


x86 assembly (clang, -O0):
<scanpair>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x70(%rbp),%rdi
mov    $0x50,%esi
call   1030 <ngets@plt>
lea    -0x70(%rbp),%rdi
lea    0xe96(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x78(%rbp)
jne    118a <scanpair+0x5a>
movl   $0x0,-0x4(%rbp)
jmp    11fa <scanpair+0xca>
mov    -0x10(%rbp),%rdi
mov    -0x78(%rbp),%rsi
call   1050 <sprintf@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe63(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x78(%rbp)
je     11f3 <scanpair+0xc3>
mov    -0x18(%rbp),%rdi
mov    -0x78(%rbp),%rsi
call   1050 <sprintf@plt>
cmpq   $0x0,-0x78(%rbp)
je     11e7 <scanpair+0xb7>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe29(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x78(%rbp)
jmp    11c3 <scanpair+0x93>
movl   $0x2,-0x4(%rbp)
jmp    11fa <scanpair+0xca>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scanpair>:
push   %r15
push   %r14
push   %rbx
sub    $0x50,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movb   $0x0,(%rdi)
movb   $0x0,(%rsi)
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0x50,%esi
call   1030 <ngets@plt>
lea    0xea4(%rip),%rsi
mov    %r15,%rdi
call   1040 <strtok@plt>
test   %rax,%rax
je     11b6 <scanpair+0x86>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1050 <sprintf@plt>
lea    0xe8a(%rip),%rsi
xor    %edi,%edi
call   1040 <strtok@plt>
test   %rax,%rax
je     11ba <scanpair+0x8a>
mov    %r14,%rdi
mov    %rax,%rsi
call   1050 <sprintf@plt>
lea    0xe69(%rip),%rbx
nopl   0x0(%rax)
xor    %edi,%edi
mov    %rbx,%rsi
call   1040 <strtok@plt>
test   %rax,%rax
jne    11a0 <scanpair+0x70>
mov    $0x2,%eax
jmp    11bf <scanpair+0x8f>
xor    %eax,%eax
jmp    11bf <scanpair+0x8f>
mov    $0x1,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [3 x i8] c" \00\00"
@.str.2 = [3 x i8] c" \0A\00"
define i32 @scanpair(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [80 x i8]
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %4
%9 = getelementptr inbounds i8, i8* %8, i64 0
store i8 0, i8* %9
%10 = load i8*, i8** %5
%11 = getelementptr inbounds i8, i8* %10, i64 0
store i8 0, i8* %11
%12 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%13 = call i32 @ngets(i8* %12, i32 80)
%14 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%15 = call i8* @strtok(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %15, i8** %7
%16 = load i8*, i8** %7
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %19
18: ; preds = %2
store i32 0, i32* %3
br label %37
19: ; preds = %2
%20 = load i8*, i8** %4
%21 = load i8*, i8** %7
%22 = call i32 @sprintf(i8* %20, i8* %21)
%23 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i8* %23, i8** %7
%24 = load i8*, i8** %7
%25 = icmp ne i8* %24, null
br i1 %25, label %26, label %36
26: ; preds = %19
%27 = load i8*, i8** %5
%28 = load i8*, i8** %7
%29 = call i32 @sprintf(i8* %27, i8* %28)
br label %30
30: ; preds = %33, %26
%31 = load i8*, i8** %7
%32 = icmp ne i8* %31, null
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i8* %34, i8** %7
br label %30
35: ; preds = %30
store i32 2, i32* %3
br label %37
36: ; preds = %19
store i32 1, i32* %3
br label %37
37: ; preds = %36, %35, %18
%38 = load i32, i32* %3
ret i32 %38
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
@.str.1 = [3 x i8] c" \00\00"
@.str.2 = [3 x i8] c" \0A\00"
define i32 @scanpair(i8* nocapture writeonly %0, i8* nocapture writeonly %1) {
%3 = alloca [80 x i8]
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
store i8 0, i8* %0
store i8 0, i8* %1
%5 = call i32 @ngets(i8* %4, i32 80)
%6 = call i8* @strtok(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i8* %6, null
br i1 %7, label %17, label %8
8: ; preds = %2
%9 = call i32 @sprintf(i8* %0, i8* %6)
%10 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i8* %10, null
br i1 %11, label %17, label %12
12: ; preds = %8
%13 = call i32 @sprintf(i8* %1, i8* %10)
br label %14
14: ; preds = %12, %14
%15 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %14
17: ; preds = %14, %8, %2
%18 = phi i32 [ 0, %2 ], [ 1, %8 ], [ 2, %14 ]
ret i32 %18
}