#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 */
typedef int /*<<< orphan*/ buffer;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ check_for_phone(char *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ printf(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
void process_list_file(FILE *ifp, FILE *ofp) {
  char buffer[256];
  char phone[4];
  char *pos = NULL;
  int len = 0;
  while (fgets(buffer, sizeof(buffer), ifp) != 0) {
    if (buffer[0] == '\n')
      continue;
    buffer[strlen(buffer) - 1] = '\0';
    pos = buffer;
    fprintf(ofp, "%s\t", pos);
    while (*pos) {
      strncpy(phone, pos, 3);
      phone[3] = '\0';
      len = 3;
      while (len) {
        len = strlen(phone);
        if (check_for_phone(phone)) {
          fprintf(ofp, "%s ", phone);
          break;
        } else {
          if (len == 1) {
            printf("Error translating: '%s'\n", buffer);
            printf("Missing phone is: '%s'\n", phone);
            break;
          }
          phone[len - 1] = '\0';
        }
      }
      pos += len;
    }
    fprintf(ofp, "\n");
  }
}


x86 assembly (clang, -O0):
<process_list_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x120(%rbp)
movl   $0x0,-0x124(%rbp)
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x100,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     130e <process_list_file+0x1ae>
movsbl -0x110(%rbp),%eax
cmp    $0xa,%eax
jne    11bc <process_list_file+0x5c>
jmp    1188 <process_list_file+0x28>
lea    -0x110(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x110(%rbp,%rax,1)
lea    -0x110(%rbp),%rax
mov    %rax,-0x120(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x120(%rbp),%rdx
lea    0xe0b(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x120(%rbp),%rax
cmpb   $0x0,(%rax)
je     12f7 <process_list_file+0x197>
lea    -0x114(%rbp),%rdi
mov    -0x120(%rbp),%rsi
mov    $0x3,%edx
call   1030 <strncpy@plt>
movb   $0x0,-0x111(%rbp)
movl   $0x3,-0x124(%rbp)
cmpl   $0x0,-0x124(%rbp)
je     12d8 <process_list_file+0x178>
lea    -0x114(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x124(%rbp)
lea    -0x114(%rbp),%rdi
call   1060 <check_for_phone@plt>
cmp    $0x0,%rax
je     1288 <process_list_file+0x128>
mov    -0x10(%rbp),%rdi
lea    -0x114(%rbp),%rdx
lea    0xd88(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    12d8 <process_list_file+0x178>
cmpl   $0x1,-0x124(%rbp)
jne    12c0 <process_list_file+0x160>
lea    -0x110(%rbp),%rsi
lea    0xd65(%rip),%rdi
call   1050 <printf@plt>
lea    -0x114(%rbp),%rsi
lea    0xd6b(%rip),%rdi
call   1050 <printf@plt>
jmp    12d8 <process_list_file+0x178>
mov    -0x124(%rbp),%eax
sub    $0x1,%eax
cltq
movb   $0x0,-0x114(%rbp,%rax,1)
jmp    1235 <process_list_file+0xd5>
mov    -0x124(%rbp),%ecx
mov    -0x120(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x120(%rbp)
jmp    11fc <process_list_file+0x9c>
mov    -0x10(%rbp),%rdi
lea    0xd1d(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    1188 <process_list_file+0x28>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_list_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    %rsi,%r13
mov    %rdi,%rbp
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0x100,%esi
mov    %rbp,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     12a9 <process_list_file+0x139>
lea    0xc(%rsp),%rbx
jmp    11d6 <process_list_file+0x66>
nopl   0x0(%rax)
mov    $0xa,%edi
mov    %r13,%rsi
call   1070 <fputc@plt>
mov    %r14,%rdi
mov    $0x100,%esi
mov    %rbp,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     12a9 <process_list_file+0x139>
cmpb   $0xa,0x10(%rsp)
je     11bd <process_list_file+0x4d>
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%r14,1)
mov    %r13,%rdi
lea    0xe09(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
cmpb   $0x0,0x10(%rsp)
je     11b0 <process_list_file+0x40>
mov    %r14,%r15
jmp    1236 <process_list_file+0xc6>
nopl   (%rax)
mov    %r13,%rdi
lea    0xdea(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
movslq %r12d,%rax
cmpb   $0x0,(%r15,%rax,1)
lea    (%r15,%rax,1),%r15
je     11b0 <process_list_file+0x40>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x3,%edx
call   1030 <strncpy@plt>
movb   $0x0,0xf(%rsp)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%r12d
mov    %rbx,%rdi
call   1060 <check_for_phone@plt>
test   %rax,%rax
jne    1210 <process_list_file+0xa0>
cmp    $0x1,%r12d
je     1280 <process_list_file+0x110>
movslq %r12d,%rax
movb   $0x0,-0x1(%rax,%rbx,1)
test   %r12d,%r12d
jne    1250 <process_list_file+0xe0>
xor    %r12d,%r12d
jmp    1224 <process_list_file+0xb4>
lea    0xd81(%rip),%rdi
mov    %r14,%rsi
call   1050 <printf@plt>
lea    0xd8b(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
mov    $0x1,%r12d
jmp    1224 <process_list_file+0xb4>
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%s\09\00"
@.str.1 = [4 x i8] c"%s \00"
@.str.2 = [25 x i8] c"Error translating: '%s'\0A\00"
@.str.3 = [24 x i8] c"Missing phone is: '%s'\0A\00"
define void @process_list_file(i32* nocapture %0, i32* nocapture %1) {
%3 = alloca [256 x i8]
%4 = alloca [4 x i8]
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%7 = call i64 @fgets(i8* %5, i32 256, i32* %0)
%8 = icmp eq i64 %7, 0
br i1 %8, label %52, label %9
9: ; preds = %2
%10 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 3
br label %11
11: ; preds = %9, %49
%12 = load i8, i8* %5
%13 = icmp eq i8 %12, 10
br i1 %13, label %49, label %14
14: ; preds = %11
%15 = call i32 @strlen(i8* %5)
%16 = add nsw i32 %15, -1
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %17
store i8 0, i8* %18
%19 = call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %5)
%20 = load i8, i8* %5
%21 = icmp eq i8 %20, 0
br i1 %21, label %47, label %22
22: ; preds = %14, %41
%23 = phi i8* [ %44, %41 ], [ %5, %14 ]
%24 = call i32 @strncpy(i8* %6, i8* %23, i32 3)
store i8 0, i8* %10
br label %25
25: ; preds = %22, %36
%26 = call i32 @strlen(i8* %6)
%27 = call i64 @check_for_phone(i8* %6)
%28 = icmp eq i64 %27, 0
br i1 %28, label %31, label %29
29: ; preds = %25
%30 = call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %6)
br label %41
31: ; preds = %25
%32 = icmp eq i32 %26, 1
br i1 %32, label %33, label %36
33: ; preds = %31
%34 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%35 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %6)
br label %41
36: ; preds = %31
%37 = add nsw i32 %26, -1
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 %38
store i8 0, i8* %39
%40 = icmp eq i32 %26, 0
br i1 %40, label %41, label %25
41: ; preds = %36, %33, %29
%42 = phi i32 [ %26, %29 ], [ 1, %33 ], [ 0, %36 ]
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %23, i64 %43
%45 = load i8, i8* %44
%46 = icmp eq i8 %45, 0
br i1 %46, label %47, label %22
47: ; preds = %41, %14
%48 = call i32 @fputc(i32 10, i32* %1)
br label %49
49: ; preds = %47, %11
%50 = call i64 @fgets(i8* %5, i32 256, i32* %0)
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %11
52: ; preds = %49, %2
ret void
}