#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 */
int csv_read(int /*<<< orphan*/, char *, int, char **, int);
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ stdin;
int main() {
  int i, j;
  char buffer[256];
  char *ptrs[20];
  i = csv_read(stdin, buffer, sizeof buffer, ptrs, 20);
  printf("csv read returns %d\n", i);
  for (j = 0; j < i; j++)
    printf("%2d: %s\n", j, ptrs[j]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2eaf(%rip),%rax
mov    (%rax),%edi
lea    -0x110(%rbp),%rsi
lea    -0x1b0(%rbp),%rcx
mov    $0x100,%edx
mov    $0x14,%r8d
call   1040 <csv_read@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ab <main+0x8b>
mov    -0xc(%rbp),%esi
movslq -0xc(%rbp),%rax
mov    -0x1b0(%rbp,%rax,8),%rdx
ff
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1174 <main+0x54>
xor    %eax,%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x1a0,%rsp
mov    0x2eb5(%rip),%rax
mov    (%rax),%edi
lea    0xa0(%rsp),%rsi
mov    %rsp,%rcx
mov    $0x100,%edx
mov    $0x14,%r8d
call   1040 <csv_read@plt>
mov    %eax,%ebx
lea    0xea7(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
test   %ebx,%ebx
jle    1199 <main+0x79>
mov    %ebx,%r15d
lea    0xea5(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%rsp,%rbx,8),%rdx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1180 <main+0x60>
xor    %eax,%eax
add    $0x1a0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@stdin = global i32 0
@.str = [21 x i8] c"csv read returns %d\0A\00"
@.str.1 = [9 x i8] c"%2d: %s\0A\00"
define i32 @main() {
%1 = alloca [256 x i8]
%2 = alloca [20 x i8*]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%4 = bitcast [20 x i8*]* %2 to i8*
%5 = load i32, i32* @stdin
%6 = getelementptr inbounds [20 x i8*], [20 x i8*]* %2, i64 0, i64 0
%7 = call i32 @csv_read(i32 %5, i8* %3, i32 256, i8** %6, i32 20)
%8 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = icmp sgt i32 %7, 0
br i1 %9, label %10, label %20
10: ; preds = %0
%11 = zext i32 %7 to i64
br label %12
12: ; preds = %10, %12
%13 = phi i64 [ 0, %10 ], [ %18, %12 ]
%14 = getelementptr inbounds [20 x i8*], [20 x i8*]* %2, i64 0, i64 %13
%15 = load i8*, i8** %14
%16 = trunc i64 %13 to i32
%17 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %16, i8* %15)
%18 = add nuw nsw i64 %13, 1
%19 = icmp eq i64 %18, %11
br i1 %19, label %20, label %12
20: ; preds = %12, %0
ret i32 0
}