#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 */
struct csvline {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ csvline_addField(struct csvline *, char *,
                                    int /*<<< orphan*/, int /*<<< orphan*/);
struct csvline *csvline_create();
char *csvline_getField(struct csvline *, int /*<<< orphan*/);
scalar_t__ csvline_getFieldCnt(struct csvline *);
int /*<<< orphan*/ csvline_printToFile(struct csvline *, int /*<<< orphan*/);
int /*<<< orphan*/ csvline_reset(struct csvline *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strlen(char *);
int main(int argc, char **argv) {
  char txt[] = "hello";
  struct csvline *cline = csvline_create();
  int i;
  for (i = 0; i < 25; i++) {
    csvline_addField(cline, txt, 0, strlen(txt));
    csvline_printToFile(cline, stdout);
  }
  printf("Count = %d\n", (int)csvline_getFieldCnt(cline));
  printf("1st = %s\n", csvline_getField(cline, 0));
  csvline_reset(cline);
  csvline_printToFile(cline, stdout);
  if (cline) {
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xe64(%rip),%eax
mov    %eax,-0x16(%rbp)
mov    0xe5e(%rip),%ax
mov    %ax,-0x12(%rbp)
mov    $0x0,%al
call   10a0 <csvline_create@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x19,-0x24(%rbp)
jge    1210 <main+0x90>
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    -0x16(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    -0x16(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    %eax,%ecx
xor    %edx,%edx
call   1030 <csvline_addField@plt>
mov    -0x20(%rbp),%rdi
mov    0x2de5(%rip),%rax
mov    (%rax),%esi
call   1080 <csvline_printToFile@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11bc <main+0x3c>
mov    -0x20(%rbp),%rdi
call   1070 <csvline_getFieldCnt@plt>
mov    %eax,%esi
lea    0xde4(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
xor    %esi,%esi
call   1090 <csvline_getField@plt>
mov    %rax,%rsi
lea    0xdd4(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1040 <csvline_reset@plt>
mov    -0x20(%rbp),%rdi
mov    0x2d87(%rip),%rax
mov    (%rax),%esi
call   1080 <csvline_printToFile@plt>
cmpq   $0x0,-0x20(%rbp)
je     1270 <main+0xf0>
jmp    1270 <main+0xf0>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
movw   $0x6f,0x4(%rsp)
movl   $0x6c6c6568,(%rsp)
xor    %eax,%eax
call   10a0 <csvline_create@plt>
mov    %rax,%rbx
mov    $0x19,%ebp
mov    %rsp,%r14
mov    0x2e32(%rip),%r15
xchg   %ax,%ax
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %edx,%edx
mov    %eax,%ecx
call   1030 <csvline_addField@plt>
mov    (%r15),%esi
mov    %rbx,%rdi
call   1080 <csvline_printToFile@plt>
add    $0xffffffff,%ebp
jne    11b0 <main+0x30>
mov    %rbx,%rdi
call   1070 <csvline_getFieldCnt@plt>
lea    0xe20(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1090 <csvline_getField@plt>
lea    0xe12(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1040 <csvline_reset@plt>
mov    (%r15),%esi
mov    %rbx,%rdi
call   1080 <csvline_printToFile@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.csvline = type { i32 }
@__const.main.txt = [6 x i8] c"hello\00"
@stdout = global i32 0
@.str = [12 x i8] c"Count = %d\0A\00"
@.str.1 = [10 x i8] c"1st = %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [6 x i8]
%7 = alloca %struct.csvline*
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = bitcast [6 x i8]* %6 to i8*
%10 = call %struct.csvline* (...) @csvline_create()
store %struct.csvline* %10, %struct.csvline** %7
store i32 0, i32* %8
br label %11
11: ; preds = %23, %2
%12 = load i32, i32* %8
%13 = icmp slt i32 %12, 25
br i1 %13, label %14, label %26
14: ; preds = %11
%15 = load %struct.csvline*, %struct.csvline** %7
%16 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
%17 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
%18 = call i32 @strlen(i8* %17)
%19 = call i32 @csvline_addField(%struct.csvline* %15, i8* %16, i32 0, i32 %18)
%20 = load %struct.csvline*, %struct.csvline** %7
%21 = load i32, i32* @stdout
%22 = call i32 @csvline_printToFile(%struct.csvline* %20, i32 %21)
br label %23
23: ; preds = %14
%24 = load i32, i32* %8
%25 = add nsw i32 %24, 1
store i32 %25, i32* %8
br label %11
26: ; preds = %11
%27 = load %struct.csvline*, %struct.csvline** %7
%28 = call i64 @csvline_getFieldCnt(%struct.csvline* %27)
%29 = trunc i64 %28 to i32
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %29)
%31 = load %struct.csvline*, %struct.csvline** %7
%32 = call i8* @csvline_getField(%struct.csvline* %31, i32 0)
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %32)
%34 = load %struct.csvline*, %struct.csvline** %7
%35 = call i32 @csvline_reset(%struct.csvline* %34)
%36 = load %struct.csvline*, %struct.csvline** %7
%37 = load i32, i32* @stdout
%38 = call i32 @csvline_printToFile(%struct.csvline* %36, i32 %37)
%39 = load %struct.csvline*, %struct.csvline** %7
%40 = icmp ne %struct.csvline* %39, null
br i1 %40, label %41, label %42
41: ; preds = %26
br label %42
42: ; preds = %41, %26
ret i32 0
}

LLVM IR (-O2):
%struct.csvline = type { i32 }
@__const.main.txt = [6 x i8] c"hello\00"
@stdout = global i32 0
@.str = [12 x i8] c"Count = %d\0A\00"
@.str.1 = [10 x i8] c"1st = %s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [6 x i8]
%4 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%5 = tail call %struct.csvline* (...) @csvline_create()
br label %6
6: ; preds = %2, %6
%7 = phi i32 [ 0, %2 ], [ %12, %6 ]
%8 = call i32 @strlen(i8* %4)
%9 = call i32 @csvline_addField(%struct.csvline* %5, i8* %4, i32 0, i32 %8)
%10 = load i32, i32* @stdout
%11 = call i32 @csvline_printToFile(%struct.csvline* %5, i32 %10)
%12 = add nuw nsw i32 %7, 1
%13 = icmp eq i32 %12, 25
br i1 %13, label %14, label %6
14: ; preds = %6
%15 = call i64 @csvline_getFieldCnt(%struct.csvline* %5)
%16 = trunc i64 %15 to i32
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = call i8* @csvline_getField(%struct.csvline* %5, i32 0)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = call i32 @csvline_reset(%struct.csvline* %5)
%21 = load i32, i32* @stdout
%22 = call i32 @csvline_printToFile(%struct.csvline* %5, i32 %21)
ret i32 0
}