#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__ strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, size_t);
char *strtok(char *, char *);
int parse_two(char *line, char *field1, char *field2) {
  char *ptr;
  int i, n, rc;
  i = 0;
  rc = 0;
  ptr = strtok(line, "\t\n");
  while (ptr != NULL) {
    i++;
    switch (i) {
    case 1:
      n = (int)strlen(ptr);
      if (n > 2048 - 1)
        n = 2048 - 1;
      strncpy(field1, ptr, (size_t)n);
      field1[n] = (char)'\0';
      rc += 1;
      break;
    case 2:
      n = (int)strlen(ptr);
      if (n > 2048 - 1)
        n = 2048 - 1;
      strncpy(field2, ptr, (size_t)n);
      field2[n] = (char)'\0';
      rc += 2;
      break;
    default:
      rc = 0;
    }
    ptr = strtok(NULL, "\t\n");
  }
  if (rc == 3)
    return (0);
  else
    return (1);
}


x86 assembly (clang, -O0):
<parse_two>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea3(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1255 <parse_two+0x125>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x38(%rbp)
sub    $0x1,%eax
je     119f <parse_two+0x6f>
jmp    118e <parse_two+0x5e>
mov    -0x38(%rbp),%eax
sub    $0x2,%eax
je     11ea <parse_two+0xba>
jmp    1235 <parse_two+0x105>
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x7ff,-0x30(%rbp)
jle    11bf <parse_two+0x8f>
movl   $0x7ff,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
movslq -0x30(%rbp),%rdx
call   1030 <strncpy@plt>
mov    -0x18(%rbp),%rax
movslq -0x30(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    123c <parse_two+0x10c>
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x7ff,-0x30(%rbp)
jle    120a <parse_two+0xda>
movl   $0x7ff,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
movslq -0x30(%rbp),%rdx
call   1030 <strncpy@plt>
mov    -0x20(%rbp),%rax
movslq -0x30(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x34(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x34(%rbp)
jmp    123c <parse_two+0x10c>
movl   $0x0,-0x34(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xdb9(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x28(%rbp)
jmp    1166 <parse_two+0x36>
cmpl   $0x3,-0x34(%rbp)
jne    126b <parse_two+0x13b>
movl   $0x0,-0x4(%rbp)
jmp    1272 <parse_two+0x142>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_two>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r12
lea    0xeb8(%rip),%rsi
call   1050 <strtok@plt>
test   %rax,%rax
je     11f3 <parse_two+0xc3>
mov    %rax,%r13
xor    %r15d,%r15d
xor    %ebp,%ebp
jmp    11b4 <parse_two+0x84>
mov    %r13,%rdi
call   1040 <strlen@plt>
cmp    $0x7ff,%eax
movslq %eax,%rbx
mov    $0x7ff,%eax
cmovge %rax,%rbx
mov    %r14,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1030 <strncpy@plt>
add    %r14,%rbx
mov    $0x2,%eax
add    %eax,%r15d
movb   $0x0,(%rbx)
mov    %r15d,%ebx
xor    %edi,%edi
lea    0xe5f(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,%r13
add    $0x1,%ebp
mov    %ebx,%r15d
test   %rax,%rax
je     11f5 <parse_two+0xc5>
cmp    $0x1,%ebp
je     1160 <parse_two+0x30>
mov    $0x0,%ebx
test   %ebp,%ebp
jne    1198 <parse_two+0x68>
mov    %r13,%rdi
call   1040 <strlen@plt>
cmp    $0x7ff,%eax
movslq %eax,%rbx
mov    $0x7ff,%eax
cmovge %rax,%rbx
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1030 <strncpy@plt>
add    %r12,%rbx
mov    $0x1,%eax
jmp    118f <parse_two+0x5f>
xor    %ebx,%ebx
xor    %eax,%eax
cmp    $0x3,%ebx
setne  %al
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"\09\0A\00"
define i32 @parse_two(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 0, i32* %9
store i32 0, i32* %11
%12 = load i8*, i8** %5
%13 = call i8* @strtok(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %13, i8** %8
br label %14
14: ; preds = %60, %3
%15 = load i8*, i8** %8
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %62
17: ; preds = %14
%18 = load i32, i32* %9
%19 = add nsw i32 %18, 1
store i32 %19, i32* %9
%20 = load i32, i32* %9
switch i32 %20, label %59 [
i32 1, label %21
i32 2, label %40
]
21: ; preds = %17
%22 = load i8*, i8** %8
%23 = call i64 @strlen(i8* %22)
%24 = trunc i64 %23 to i32
store i32 %24, i32* %10
%25 = load i32, i32* %10
%26 = icmp sgt i32 %25, 2047
br i1 %26, label %27, label %28
27: ; preds = %21
store i32 2047, i32* %10
br label %28
28: ; preds = %27, %21
%29 = load i8*, i8** %6
%30 = load i8*, i8** %8
%31 = load i32, i32* %10
%32 = sext i32 %31 to i64
%33 = call i32 @strncpy(i8* %29, i8* %30, i64 %32)
%34 = load i8*, i8** %6
%35 = load i32, i32* %10
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
store i8 0, i8* %37
%38 = load i32, i32* %11
%39 = add nsw i32 %38, 1
store i32 %39, i32* %11
br label %60
40: ; preds = %17
%41 = load i8*, i8** %8
%42 = call i64 @strlen(i8* %41)
%43 = trunc i64 %42 to i32
store i32 %43, i32* %10
%44 = load i32, i32* %10
%45 = icmp sgt i32 %44, 2047
br i1 %45, label %46, label %47
46: ; preds = %40
store i32 2047, i32* %10
br label %47
47: ; preds = %46, %40
%48 = load i8*, i8** %7
%49 = load i8*, i8** %8
%50 = load i32, i32* %10
%51 = sext i32 %50 to i64
%52 = call i32 @strncpy(i8* %48, i8* %49, i64 %51)
%53 = load i8*, i8** %7
%54 = load i32, i32* %10
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %53, i64 %55
store i8 0, i8* %56
%57 = load i32, i32* %11
%58 = add nsw i32 %57, 2
store i32 %58, i32* %11
br label %60
59: ; preds = %17
store i32 0, i32* %11
br label %60
60: ; preds = %59, %47, %28
%61 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %61, i8** %8
br label %14
62: ; preds = %14
%63 = load i32, i32* %11
%64 = icmp eq i32 %63, 3
br i1 %64, label %65, label %66
65: ; preds = %62
store i32 0, i32* %4
br label %67
66: ; preds = %62
store i32 1, i32* %4
br label %67
67: ; preds = %66, %65
%68 = load i32, i32* %4
ret i32 %68
}

LLVM IR (-O2):
@.str = [3 x i8] c"\09\0A\00"
define i32 @parse_two(i8* %0, i8* %1, i8* %2) {
%4 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i8* %4, null
br i1 %5, label %37, label %6
6: ; preds = %3, %33
%7 = phi i32 [ %34, %33 ], [ 0, %3 ]
%8 = phi i32 [ %10, %33 ], [ 0, %3 ]
%9 = phi i8* [ %35, %33 ], [ %4, %3 ]
%10 = add nuw nsw i32 %8, 1
switch i32 %8, label %33 [
i32 0, label %11
i32 1, label %20
]
11: ; preds = %6
%12 = tail call i64 @strlen(i8* %9)
%13 = trunc i64 %12 to i32
%14 = icmp slt i32 %13, 2047
%15 = shl i64 %12, 32
%16 = ashr exact i64 %15, 32
%17 = select i1 %14, i64 %16, i64 2047
%18 = tail call i32 @strncpy(i8* %1, i8* %9, i64 %17)
%19 = getelementptr inbounds i8, i8* %1, i64 %17
br label %29
20: ; preds = %6
%21 = tail call i64 @strlen(i8* %9)
%22 = trunc i64 %21 to i32
%23 = icmp slt i32 %22, 2047
%24 = shl i64 %21, 32
%25 = ashr exact i64 %24, 32
%26 = select i1 %23, i64 %25, i64 2047
%27 = tail call i32 @strncpy(i8* %2, i8* %9, i64 %26)
%28 = getelementptr inbounds i8, i8* %2, i64 %26
br label %29
29: ; preds = %11, %20
%30 = phi i8* [ %28, %20 ], [ %19, %11 ]
%31 = phi i32 [ 2, %20 ], [ 1, %11 ]
store i8 0, i8* %30
%32 = add nsw i32 %7, %31
br label %33
33: ; preds = %29, %6
%34 = phi i32 [ 0, %6 ], [ %32, %29 ]
%35 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%36 = icmp eq i8* %35, null
br i1 %36, label %37, label %6
37: ; preds = %33, %3
%38 = phi i32 [ 0, %3 ], [ %34, %33 ]
%39 = icmp ne i32 %38, 3
%40 = zext i1 %39 to i32
ret i32 %40
}