#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 */
char *csvfield(int);
char *csvgetline(int /*<<< orphan*/);
int csvnfield();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int main(void) {
  int i;
  char *line;
  while ((line = csvgetline(stdin)) != NULL) {
    printf("line = `%s'\n", line);
    for (i = 0; i < csvnfield(); i++)
      printf("field[%d] = `%s'\n", i, csvfield(i));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e92(%rip),%rax
mov    (%rax),%edi
call   1040 <csvgetline@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     11d3 <main+0x93>
mov    -0x10(%rbp),%rsi
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1060 <csvnfield@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jge    11ce <main+0x8e>
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <csvfield@plt>
mov    -0x18(%rbp),%esi
mov    %rax,%rdx
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1184 <main+0x44>
jmp    114f <main+0xf>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    0x2e9a(%rip),%r15
mov    (%r15),%edi
call   1040 <csvgetline@plt>
test   %rax,%rax
je     11c6 <main+0x86>
lea    0xe9e(%rip),%r14
lea    0xea4(%rip),%rbx
jmp    117d <main+0x3d>
nopl   0x0(%rax,%rax,1)
mov    (%r15),%edi
call   1040 <csvgetline@plt>
test   %rax,%rax
je     11c6 <main+0x86>
mov    %r14,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1060 <csvnfield@plt>
test   %eax,%eax
jle    1170 <main+0x30>
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    %ebp,%edi
call   1050 <csvfield@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%ebp
xor    %eax,%eax
call   1060 <csvnfield@plt>
cmp    %eax,%ebp
jl     11a0 <main+0x60>
jmp    1170 <main+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [13 x i8] c"line = `%s'\0A\00"
@.str.1 = [18 x i8] c"field[%d] = `%s'\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
store i32 0, i32* %1
br label %4
4: ; preds = %23, %0
%5 = load i32, i32* @stdin
%6 = call i8* @csvgetline(i32 %5)
store i8* %6, i8** %3
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %24
8: ; preds = %4
%9 = load i8*, i8** %3
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %9)
store i32 0, i32* %2
br label %11
11: ; preds = %20, %8
%12 = load i32, i32* %2
%13 = call i32 (...) @csvnfield()
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %23
15: ; preds = %11
%16 = load i32, i32* %2
%17 = load i32, i32* %2
%18 = call i8* @csvfield(i32 %17)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %16, i8* %18)
br label %20
20: ; preds = %15
%21 = load i32, i32* %2
%22 = add nsw i32 %21, 1
store i32 %22, i32* %2
br label %11
23: ; preds = %11
br label %4
24: ; preds = %4
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [13 x i8] c"line = `%s'\0A\00"
@.str.1 = [18 x i8] c"field[%d] = `%s'\0A\00"
define i32 @main() {
%1 = load i32, i32* @stdin
%2 = tail call i8* @csvgetline(i32 %1)
%3 = icmp eq i8* %2, null
br i1 %3, label %20, label %8
4: ; preds = %13, %8
%5 = load i32, i32* @stdin
%6 = tail call i8* @csvgetline(i32 %5)
%7 = icmp eq i8* %6, null
br i1 %7, label %20, label %8
8: ; preds = %0, %4
%9 = phi i8* [ %6, %4 ], [ %2, %0 ]
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = tail call i32 (...) @csvnfield()
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %4
13: ; preds = %8, %13
%14 = phi i32 [ %17, %13 ], [ 0, %8 ]
%15 = tail call i8* @csvfield(i32 %14)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %14, i8* %15)
%17 = add nuw nsw i32 %14, 1
%18 = tail call i32 (...) @csvnfield()
%19 = icmp slt i32 %17, %18
br i1 %19, label %13, label %4
20: ; preds = %4, %0
ret i32 0
}