#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*/ FILE;

/* Variables and functions */
int EOF;
int fscanf(int /*<<< orphan*/ *, char *, char *);
int name_copy(FILE *fptr, char *stringp) {
  int i;
  int ierror;
  for (i = 0; i < 5 - 1; ++i) {
    do {
      ierror = fscanf(fptr, "%c", &stringp[i]);
      if (ierror == EOF)
        return -2003;
      if (stringp[i] == ' ' && i != 1)
        stringp[i] = (char)0;
    } while (stringp[i] == '\n');
    if (ierror == 0)
      return -2003;
  }
  stringp[5 - 1] = (char)0;
  return -0;
}


x86 assembly (clang, -O0):
<name_copy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x4,-0x1c(%rbp)
jge    11e0 <name_copy+0xd0>
jmp    1136 <name_copy+0x26>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
movslq -0x1c(%rbp),%rax
add    %rax,%rdx
lea    0xeb4(%rip),%rsi
call   1030 <fscanf@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    0x2e8a(%rip),%rcx
cmp    (%rcx),%eax
jne    1172 <name_copy+0x62>
movl   $0xfffff82d,-0x4(%rbp)
jmp    11ef <name_copy+0xdf>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    119d <name_copy+0x8d>
cmpl   $0x1,-0x1c(%rbp)
je     119d <name_copy+0x8d>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    11a2 <name_copy+0x92>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
je     1136 <name_copy+0x26>
cmpl   $0x0,-0x20(%rbp)
jne    11cd <name_copy+0xbd>
movl   $0xfffff82d,-0x4(%rbp)
jmp    11ef <name_copy+0xdf>
jmp    11d2 <name_copy+0xc2>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1127 <name_copy+0x17>
mov    -0x18(%rbp),%rax
movb   $0x0,0x4(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<name_copy>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xed8(%rip),%r12
mov    0x2eb9(%rip),%r13
mov    $0xfffff82d,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1030 <fscanf@plt>
cmp    0x0(%r13),%eax
je     1223 <name_copy+0x113>
movzbl (%r14),%ecx
cmp    $0xa,%cl
je     1140 <name_copy+0x30>
cmp    $0x20,%cl
jne    116a <name_copy+0x5a>
movb   $0x0,(%r14)
test   %eax,%eax
je     1223 <name_copy+0x113>
lea    0x1(%r14),%rbx
lea    0xe83(%rip),%r12
nopl   (%rax)
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1030 <fscanf@plt>
cmp    0x0(%r13),%eax
je     1223 <name_copy+0x113>
cmpb   $0xa,(%rbx)
je     1180 <name_copy+0x70>
test   %eax,%eax
je     1223 <name_copy+0x113>
lea    0x2(%r14),%r12
lea    0xe50(%rip),%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
call   1030 <fscanf@plt>
cmp    0x0(%r13),%eax
je     1223 <name_copy+0x113>
movzbl (%r12),%ecx
cmp    $0xa,%cl
je     11b0 <name_copy+0xa0>
cmp    $0x20,%cl
jne    11d8 <name_copy+0xc8>
movb   $0x0,(%r12)
test   %eax,%eax
je     1223 <name_copy+0x113>
lea    0x3(%r14),%r12
lea    0xe19(%rip),%rbx
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
call   1030 <fscanf@plt>
cmp    0x0(%r13),%eax
je     1223 <name_copy+0x113>
movzbl (%r12),%ecx
cmp    $0xa,%cl
je     11f0 <name_copy+0xe0>
cmp    $0x20,%cl
jne    1218 <name_copy+0x108>
movb   $0x0,(%r12)
test   %eax,%eax
je     1223 <name_copy+0x113>
movb   $0x0,0x4(%r14)
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
@EOF = global i32 0
define i32 @name_copy(i32* nocapture %0, i8* %1) {
br label %38
3: ; preds = %45
%4 = getelementptr inbounds i8, i8* %1, i64 1
br label %5
5: ; preds = %9, %3
%6 = tail call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
%7 = load i32, i32* @EOF
%8 = icmp eq i32 %6, %7
br i1 %8, label %47, label %9
9: ; preds = %5
%10 = load i8, i8* %4
%11 = icmp eq i8 %10, 10
br i1 %11, label %5, label %12
12: ; preds = %9
%13 = icmp eq i32 %6, 0
br i1 %13, label %47, label %14
14: ; preds = %12
%15 = getelementptr inbounds i8, i8* %1, i64 2
br label %16
16: ; preds = %20, %14
%17 = tail call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %15)
%18 = load i32, i32* @EOF
%19 = icmp eq i32 %17, %18
br i1 %19, label %47, label %20
20: ; preds = %16
%21 = load i8, i8* %15
switch i8 %21, label %23 [
i8 32, label %22
i8 10, label %16
]
22: ; preds = %20
store i8 0, i8* %15
br label %23
23: ; preds = %20, %22
%24 = icmp eq i32 %17, 0
br i1 %24, label %47, label %25
25: ; preds = %23
%26 = getelementptr inbounds i8, i8* %1, i64 3
br label %27
27: ; preds = %31, %25
%28 = tail call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %26)
%29 = load i32, i32* @EOF
%30 = icmp eq i32 %28, %29
br i1 %30, label %47, label %31
31: ; preds = %27
%32 = load i8, i8* %26
switch i8 %32, label %34 [
i8 32, label %33
i8 10, label %27
]
33: ; preds = %31
store i8 0, i8* %26
br label %34
34: ; preds = %31, %33
%35 = icmp eq i32 %28, 0
br i1 %35, label %47, label %36
36: ; preds = %34
%37 = getelementptr inbounds i8, i8* %1, i64 4
store i8 0, i8* %37
br label %47
38: ; preds = %42, %2
%39 = tail call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %1)
%40 = load i32, i32* @EOF
%41 = icmp eq i32 %39, %40
br i1 %41, label %47, label %42
42: ; preds = %38
%43 = load i8, i8* %1
switch i8 %43, label %45 [
i8 32, label %44
i8 10, label %38
]
44: ; preds = %42
store i8 0, i8* %1
br label %45
45: ; preds = %42, %44
%46 = icmp eq i32 %39, 0
br i1 %46, label %47, label %3
47: ; preds = %38, %5, %16, %27, %45, %12, %23, %34, %36
%48 = phi i32 [ 0, %36 ], [ -2003, %34 ], [ -2003, %23 ], [ -2003, %12 ], [ -2003, %45 ], [ -2003, %27 ], [ -2003, %16 ], [ -2003, %5 ], [ -2003, %38 ]
ret i32 %48
}