#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 fgetc(int /*<<< orphan*/ *);
scalar_t__ isspace(int);
char *loadquote(int /*<<< orphan*/ *);
char *loadraw(int /*<<< orphan*/ *);
int /*<<< orphan*/ ungetc(int, int /*<<< orphan*/ *);
char *loadfield(FILE *fp) {
  int ch;
  char *answer = 0;
  while ((ch = fgetc(fp)) != EOF) {
    if (ch == ',' || ch == '\n')
      break;
    if (isspace(ch))
      continue;
    if (ch == '"')
      answer = loadquote(fp);
    else {
      ungetc(ch, fp);
      answer = loadraw(fp);
    }
  }
  ungetc(ch, fp);
  return answer;
}


x86 assembly (clang, -O0):
<loadfield>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0xc(%rbp)
mov    0x2e71(%rip),%rcx
cmp    (%rcx),%eax
je     11e9 <loadfield+0x99>
cmpl   $0x2c,-0xc(%rbp)
je     1193 <loadfield+0x43>
cmpl   $0xa,-0xc(%rbp)
jne    1198 <loadfield+0x48>
jmp    11e9 <loadfield+0x99>
mov    -0xc(%rbp),%edi
call   1060 <isspace@plt>
cmp    $0x0,%rax
je     11af <loadfield+0x5f>
jmp    1164 <loadfield+0x14>
cmpl   $0x22,-0xc(%rbp)
jne    11cb <loadfield+0x7b>
mov    -0x8(%rbp),%rdi
call   1030 <loadquote@plt>
mov    %rax,-0x18(%rbp)
jmp    11e4 <loadfield+0x94>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1070 <ungetc@plt>
mov    -0x8(%rbp),%rdi
call   1040 <loadraw@plt>
mov    %rax,-0x18(%rbp)
jmp    1164 <loadfield+0x14>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1070 <ungetc@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<loadfield>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
xor    %r14d,%r14d
mov    0x2e84(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
call   1050 <fgetc@plt>
mov    %eax,%ebp
cmp    (%r15),%eax
je     11be <loadfield+0x6e>
cmp    $0xa,%ebp
je     11be <loadfield+0x6e>
cmp    $0x2c,%ebp
je     11be <loadfield+0x6e>
mov    %ebp,%edi
call   1060 <isspace@plt>
test   %rax,%rax
jne    1170 <loadfield+0x20>
cmp    $0x22,%ebp
jne    11a7 <loadfield+0x57>
mov    %rbx,%rdi
call   1030 <loadquote@plt>
mov    %rax,%r14
jmp    1170 <loadfield+0x20>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1070 <ungetc@plt>
mov    %rbx,%rdi
call   1040 <loadraw@plt>
mov    %rax,%r14
jmp    1170 <loadfield+0x20>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1070 <ungetc@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
define i8* @loadfield(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i8*
store i32* %0, i32** %2
store i8* null, i8** %4
br label %5
5: ; preds = %34, %21, %1
%6 = load i32*, i32** %2
%7 = call i32 @fgetc(i32* %6)
store i32 %7, i32* %3
%8 = load i32, i32* @EOF
%9 = icmp ne i32 %7, %8
br i1 %9, label %10, label %35
10: ; preds = %5
%11 = load i32, i32* %3
%12 = icmp eq i32 %11, 44
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = load i32, i32* %3
%15 = icmp eq i32 %14, 10
br i1 %15, label %16, label %17
16: ; preds = %13, %10
br label %35
17: ; preds = %13
%18 = load i32, i32* %3
%19 = call i64 @isspace(i32 %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %17
br label %5
22: ; preds = %17
%23 = load i32, i32* %3
%24 = icmp eq i32 %23, 34
br i1 %24, label %25, label %28
25: ; preds = %22
%26 = load i32*, i32** %2
%27 = call i8* @loadquote(i32* %26)
store i8* %27, i8** %4
br label %34
28: ; preds = %22
%29 = load i32, i32* %3
%30 = load i32*, i32** %2
%31 = call i32 @ungetc(i32 %29, i32* %30)
%32 = load i32*, i32** %2
%33 = call i8* @loadraw(i32* %32)
store i8* %33, i8** %4
br label %34
34: ; preds = %28, %25
br label %5
35: ; preds = %16, %5
%36 = load i32, i32* %3
%37 = load i32*, i32** %2
%38 = call i32 @ungetc(i32 %36, i32* %37)
%39 = load i8*, i8** %4
ret i8* %39
}

LLVM IR (-O2):
@EOF = global i32 0
define i8* @loadfield(i32* %0) {
br label %2
2: ; preds = %19, %1
%3 = phi i8* [ null, %1 ], [ %20, %19 ]
br label %4
4: ; preds = %2, %9
%5 = tail call i32 @fgetc(i32* %0)
%6 = load i32, i32* @EOF
%7 = icmp eq i32 %5, %6
br i1 %7, label %21, label %8
8: ; preds = %4
switch i32 %5, label %9 [
i32 44, label %21
i32 10, label %21
]
9: ; preds = %8
%10 = tail call i64 @isspace(i32 %5)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %4
12: ; preds = %9
%13 = icmp eq i32 %5, 34
br i1 %13, label %14, label %16
14: ; preds = %12
%15 = tail call i8* @loadquote(i32* %0)
br label %19
16: ; preds = %12
%17 = tail call i32 @ungetc(i32 %5, i32* %0)
%18 = tail call i8* @loadraw(i32* %0)
br label %19
19: ; preds = %16, %14
%20 = phi i8* [ %15, %14 ], [ %18, %16 ]
br label %2
21: ; preds = %8, %8, %4
%22 = tail call i32 @ungetc(i32 %5, i32* %0)
ret i8* %3
}