#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 */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, size_t);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *strtok(char *, char *);
void fprocess(const char *in_name, const char *of_name) {
  char buffer[300];
  char word[17];
  size_t len = 17;
  FILE *f = fopen(in_name, "r");
  for (size_t i = 0; i < 5; i++)
    fgets(buffer, (sizeof(buffer) / sizeof((buffer)[0])), f);
  fclose(f);
  char *w = strtok(buffer, " ");
  while (w != NULL) {
    if (len > strlen(w)) {
      len = strlen(w);
      strcpy(word, w);
    }
    w = strtok(NULL, " ");
  }
  if (word[strlen(word) - 1] == '\n')
    len--;
  f = fopen(of_name, "w");
  fprintf(f, "%zu", len);
  fclose(f);
}


x86 assembly (clang, -O0):
<fprocess>:
push   %rbp
mov    %rsp,%rbp
sub    $0x190,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x11,-0x168(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe67(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x170(%rbp)
movq   $0x0,-0x178(%rbp)
cmpq   $0x5,-0x178(%rbp)
05
jae    11ed <fprocess+0x7d>
lea    -0x140(%rbp),%rdi
mov    -0x170(%rbp),%rdx
mov    $0x12c,%esi
call   1060 <fgets@plt>
mov    -0x178(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x178(%rbp)
jmp    11b0 <fprocess+0x40>
mov    -0x170(%rbp),%rdi
call   1040 <fclose@plt>
lea    -0x140(%rbp),%rdi
lea    0xdfb(%rip),%rsi
call   1090 <strtok@plt>
mov    %rax,-0x180(%rbp)
cmpq   $0x0,-0x180(%rbp)
je     1294 <fprocess+0x124>
mov    -0x168(%rbp),%rax
mov    %rax,-0x188(%rbp)
mov    -0x180(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x188(%rbp),%rax
movslq %ecx,%rcx
cmp    %rcx,%rax
jbe    1278 <fprocess+0x108>
mov    -0x180(%rbp),%rdi
call   1050 <strlen@plt>
cltq
mov    %rax,-0x168(%rbp)
lea    -0x160(%rbp),%rdi
mov    -0x180(%rbp),%rsi
call   1030 <strcpy@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xd7f(%rip),%rsi
call   1090 <strtok@plt>
mov    %rax,-0x180(%rbp)
jmp    1213 <fprocess+0xa3>
lea    -0x160(%rbp),%rdi
call   1050 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0x160(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
jne    12c8 <fprocess+0x158>
mov    -0x168(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x168(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xd31(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x170(%rbp)
mov    -0x170(%rbp),%rdi
mov    -0x168(%rbp),%rdx
lea    0xd12(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x170(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x190,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fprocess>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x150,%rsp
mov    %rsi,%r14
lea    0xe76(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
lea    0x20(%rsp),%r15
mov    %r15,%rdi
mov    $0x12c,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
mov    %r15,%rdi
mov    $0x12c,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
mov    %r15,%rdi
mov    $0x12c,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
mov    %r15,%rdi
mov    $0x12c,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
mov    %r15,%rdi
mov    $0x12c,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0xe0c(%rip),%rsi
mov    %r15,%rdi
call   1090 <strtok@plt>
test   %rax,%rax
je     1259 <fprocess+0xe9>
mov    %rax,%rbx
mov    $0x11,%r13d
mov    %rsp,%r15
lea    0xdec(%rip),%r12
jmp    1232 <fprocess+0xc2>
nopl   0x0(%rax,%rax,1)
xor    %edi,%edi
mov    %r12,%rsi
call   1090 <strtok@plt>
mov    %rax,%rbx
test   %rax,%rax
je     125f <fprocess+0xef>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
cmp    %rax,%r13
jbe    1220 <fprocess+0xb0>
mov    %rbx,%rdi
call   1050 <strlen@plt>
movslq %eax,%r13
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
jmp    1220 <fprocess+0xb0>
mov    $0x11,%r13d
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
xor    %ecx,%ecx
cmpb   $0xa,-0x1(%rax,%rbx,1)
sete   %cl
sub    %rcx,%r13
lea    0xd84(%rip),%rsi
mov    %r14,%rdi
call   1080 <fopen@plt>
mov    %rax,%rbx
lea    0xd74(%rip),%rsi
mov    %rax,%rdi
mov    %r13,%rdx
call   1070 <fprintf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
add    $0x150,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [4 x i8] c"%zu\00"
define void @fprocess(i8* nocapture %0, i8* nocapture %1) {
%3 = alloca [300 x i8]
%4 = alloca [17 x i8]
%5 = getelementptr inbounds [300 x i8], [300 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 0
%7 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @fgets(i8* %5, i32 300, i32* %7)
%9 = call i32 @fgets(i8* %5, i32 300, i32* %7)
%10 = call i32 @fgets(i8* %5, i32 300, i32* %7)
%11 = call i32 @fgets(i8* %5, i32 300, i32* %7)
%12 = call i32 @fgets(i8* %5, i32 300, i32* %7)
%13 = call i32 @fclose(i32* %7)
%14 = call i8* @strtok(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i8* %14, null
br i1 %15, label %30, label %16
16: ; preds = %2, %26
%17 = phi i8* [ %28, %26 ], [ %14, %2 ]
%18 = phi i64 [ %27, %26 ], [ 17, %2 ]
%19 = call i32 @strlen(i8* %17)
%20 = sext i32 %19 to i64
%21 = icmp ugt i64 %18, %20
br i1 %21, label %22, label %26
22: ; preds = %16
%23 = call i32 @strlen(i8* %17)
%24 = sext i32 %23 to i64
%25 = call i32 @strcpy(i8* %6, i8* %17)
br label %26
26: ; preds = %22, %16
%27 = phi i64 [ %24, %22 ], [ %18, %16 ]
%28 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%29 = icmp eq i8* %28, null
br i1 %29, label %30, label %16
30: ; preds = %26, %2
%31 = phi i64 [ 17, %2 ], [ %27, %26 ]
%32 = call i32 @strlen(i8* %6)
%33 = add nsw i32 %32, -1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = icmp eq i8 %36, 10
%38 = sext i1 %37 to i64
%39 = add i64 %31, %38
%40 = call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%41 = call i32 @fprintf(i32* %40, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 %39)
%42 = call i32 @fclose(i32* %40)
ret void
}