#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 csvfield {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ csvfield_append(struct csvfield *, char *,
                                   int /*<<< orphan*/, int /*<<< orphan*/);
struct csvfield *csvfield_create();
int /*<<< orphan*/ csvfield_printToFile(struct csvfield *, int /*<<< orphan*/);
int /*<<< orphan*/ csvfield_reset(struct csvfield *);
int /*<<< orphan*/ csvfield_set(struct csvfield *, char *, int /*<<< orphan*/,
                                int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strlen(char *);
int main(int argc, char **argv) {
  printf("test\n");
  struct csvfield *cfield;
  cfield = csvfield_create();
  csvfield_printToFile(cfield, stderr);
  {
    char txt[] = "hello";
    csvfield_set(cfield, txt, 0, strlen(txt));
    csvfield_printToFile(cfield, stderr);
  }
  {
    char txt[] = "123";
    csvfield_set(cfield, txt, 0, strlen(txt));
    csvfield_printToFile(cfield, stderr);
  }
  {
    char txt[] = "123456789012345678901234567";
    csvfield_set(cfield, txt, 0, strlen(txt));
    csvfield_printToFile(cfield, stderr);
  }
  {
    char txt[] = "123";
    csvfield_set(cfield, txt, 0, strlen(txt));
    csvfield_append(cfield, txt, 0, strlen(txt));
    csvfield_printToFile(cfield, stderr);
  }
  csvfield_reset(cfield);
  csvfield_printToFile(cfield, stderr);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe70(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1030 <csvfield_create@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2e35(%rip),%rax
mov    (%rax),%esi
call   1090 <csvfield_printToFile@plt>
mov    0xe4e(%rip),%eax
mov    %eax,-0x1e(%rbp)
mov    0xe48(%rip),%ax
mov    %ax,-0x1a(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x98(%rbp)
lea    -0x1e(%rbp),%rax
mov    %rax,-0x90(%rbp)
lea    -0x1e(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x98(%rbp),%rdi
mov    -0x90(%rbp),%rsi
mov    %eax,%ecx
xor    %edx,%edx
call   1080 <csvfield_set@plt>
mov    -0x18(%rbp),%rdi
mov    0x2dd9(%rip),%rax
mov    (%rax),%esi
call   1090 <csvfield_printToFile@plt>
mov    0xdf8(%rip),%eax
mov    %eax,-0x22(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x88(%rbp)
lea    -0x22(%rbp),%rax
mov    %rax,-0x80(%rbp)
lea    -0x22(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x88(%rbp),%rdi
mov    -0x80(%rbp),%rsi
mov    %eax,%ecx
xor    %edx,%edx
call   1080 <csvfield_set@plt>
mov    -0x18(%rbp),%rdi
mov    0x2d8e(%rip),%rax
mov    (%rax),%esi
call   1090 <csvfield_printToFile@plt>
mov    0xdb0(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xdad(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xdaa(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xda8(%rip),%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x78(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0x70(%rbp)
lea    -0x40(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x78(%rbp),%rdi
mov    -0x70(%rbp),%rsi
mov    %eax,%ecx
xor    %edx,%edx
call   1080 <csvfield_set@plt>
mov    -0x18(%rbp),%rdi
mov    0x2d28(%rip),%rax
mov    (%rax),%esi
call   1090 <csvfield_printToFile@plt>
mov    0xd47(%rip),%eax
mov    %eax,-0x44(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x68(%rbp)
lea    -0x44(%rbp),%rax
mov    %rax,-0x60(%rbp)
lea    -0x44(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x68(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    %eax,%ecx
xor    %edx,%edx
call   1080 <csvfield_set@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x58(%rbp)
lea    -0x44(%rbp),%rax
mov    %rax,-0x50(%rbp)
lea    -0x44(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x58(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    %eax,%ecx
xor    %edx,%edx
call   1060 <csvfield_append@plt>
mov    -0x18(%rbp),%rdi
mov    0x2cb9(%rip),%rax
mov    (%rax),%esi
call   1090 <csvfield_printToFile@plt>
mov    -0x18(%rbp),%rdi
call   1070 <csvfield_reset@plt>
mov    -0x18(%rbp),%rdi
mov    0x2c9e(%rip),%rax
mov    (%rax),%esi
call   1090 <csvfield_printToFile@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
lea    0xe86(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <csvfield_create@plt>
mov    %rax,%rbx
mov    0x2e4a(%rip),%r15
mov    (%r15),%esi
mov    %rax,%rdi
call   1090 <csvfield_printToFile@plt>
movw   $0x6f,0x4(%rsp)
movl   $0x6c6c6568,(%rsp)
mov    %rsp,%r14
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %edx,%edx
mov    %eax,%ecx
call   1080 <csvfield_set@plt>
mov    (%r15),%esi
mov    %rbx,%rdi
call   1090 <csvfield_printToFile@plt>
movl   $0x333231,(%rsp)
mov    %rsp,%r14
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %edx,%edx
mov    %eax,%ecx
call   1080 <csvfield_set@plt>
mov    (%r15),%esi
mov    %rbx,%rdi
call   1090 <csvfield_printToFile@plt>
movups 0xe15(%rip),%xmm0
movups %xmm0,0xc(%rsp)
movaps 0xdfd(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%r14
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %edx,%edx
mov    %eax,%ecx
call   1080 <csvfield_set@plt>
mov    (%r15),%esi
mov    %rbx,%rdi
call   1090 <csvfield_printToFile@plt>
movl   $0x333231,(%rsp)
mov    %rsp,%r14
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %edx,%edx
mov    %eax,%ecx
call   1080 <csvfield_set@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %edx,%edx
mov    %eax,%ecx
call   1060 <csvfield_append@plt>
mov    (%r15),%esi
mov    %rbx,%rdi
call   1090 <csvfield_printToFile@plt>
mov    %rbx,%rdi
call   1070 <csvfield_reset@plt>
mov    (%r15),%esi
mov    %rbx,%rdi
call   1090 <csvfield_printToFile@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.csvfield = type { i32 }
@.str = [6 x i8] c"test\0A\00"
@stderr = global i32 0
@__const.main.txt = [6 x i8] c"hello\00"
@__const.main.txt.1 = [4 x i8] c"123\00"
@__const.main.txt.2 = [28 x i8] c"123456789012345678901234567\00"
@__const.main.txt.3 = [4 x i8] c"123\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.csvfield*
%7 = alloca [6 x i8]
%8 = alloca [4 x i8]
%9 = alloca [28 x i8]
%10 = alloca [4 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%12 = call %struct.csvfield* (...) @csvfield_create()
store %struct.csvfield* %12, %struct.csvfield** %6
%13 = load %struct.csvfield*, %struct.csvfield** %6
%14 = load i32, i32* @stderr
%15 = call i32 @csvfield_printToFile(%struct.csvfield* %13, i32 %14)
%16 = bitcast [6 x i8]* %7 to i8*
%17 = load %struct.csvfield*, %struct.csvfield** %6
%18 = getelementptr inbounds [6 x i8], [6 x i8]* %7, i64 0, i64 0
%19 = getelementptr inbounds [6 x i8], [6 x i8]* %7, i64 0, i64 0
%20 = call i32 @strlen(i8* %19)
%21 = call i32 @csvfield_set(%struct.csvfield* %17, i8* %18, i32 0, i32 %20)
%22 = load %struct.csvfield*, %struct.csvfield** %6
%23 = load i32, i32* @stderr
%24 = call i32 @csvfield_printToFile(%struct.csvfield* %22, i32 %23)
%25 = bitcast [4 x i8]* %8 to i8*
%26 = load %struct.csvfield*, %struct.csvfield** %6
%27 = getelementptr inbounds [4 x i8], [4 x i8]* %8, i64 0, i64 0
%28 = getelementptr inbounds [4 x i8], [4 x i8]* %8, i64 0, i64 0
%29 = call i32 @strlen(i8* %28)
%30 = call i32 @csvfield_set(%struct.csvfield* %26, i8* %27, i32 0, i32 %29)
%31 = load %struct.csvfield*, %struct.csvfield** %6
%32 = load i32, i32* @stderr
%33 = call i32 @csvfield_printToFile(%struct.csvfield* %31, i32 %32)
%34 = bitcast [28 x i8]* %9 to i8*
%35 = load %struct.csvfield*, %struct.csvfield** %6
%36 = getelementptr inbounds [28 x i8], [28 x i8]* %9, i64 0, i64 0
%37 = getelementptr inbounds [28 x i8], [28 x i8]* %9, i64 0, i64 0
%38 = call i32 @strlen(i8* %37)
%39 = call i32 @csvfield_set(%struct.csvfield* %35, i8* %36, i32 0, i32 %38)
%40 = load %struct.csvfield*, %struct.csvfield** %6
%41 = load i32, i32* @stderr
%42 = call i32 @csvfield_printToFile(%struct.csvfield* %40, i32 %41)
%43 = bitcast [4 x i8]* %10 to i8*
%44 = load %struct.csvfield*, %struct.csvfield** %6
%45 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 0
%46 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 0
%47 = call i32 @strlen(i8* %46)
%48 = call i32 @csvfield_set(%struct.csvfield* %44, i8* %45, i32 0, i32 %47)
%49 = load %struct.csvfield*, %struct.csvfield** %6
%50 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 0
%51 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 0
%52 = call i32 @strlen(i8* %51)
%53 = call i32 @csvfield_append(%struct.csvfield* %49, i8* %50, i32 0, i32 %52)
%54 = load %struct.csvfield*, %struct.csvfield** %6
%55 = load i32, i32* @stderr
%56 = call i32 @csvfield_printToFile(%struct.csvfield* %54, i32 %55)
%57 = load %struct.csvfield*, %struct.csvfield** %6
%58 = call i32 @csvfield_reset(%struct.csvfield* %57)
%59 = load %struct.csvfield*, %struct.csvfield** %6
%60 = load i32, i32* @stderr
%61 = call i32 @csvfield_printToFile(%struct.csvfield* %59, i32 %60)
ret i32 0
}

LLVM IR (-O2):
%struct.csvfield = type { i32 }
@stderr = global i32 0
@__const.main.txt = [6 x i8] c"hello\00"
@__const.main.txt.2 = [28 x i8] c"123456789012345678901234567\00"
@str = [5 x i8] c"test\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [6 x i8]
%4 = alloca i32
%5 = alloca [28 x i8]
%6 = alloca i32
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
%8 = tail call %struct.csvfield* (...) @csvfield_create()
%9 = load i32, i32* @stderr
%10 = tail call i32 @csvfield_printToFile(%struct.csvfield* %8, i32 %9)
%11 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%12 = call i32 @strlen(i8* %11)
%13 = call i32 @csvfield_set(%struct.csvfield* %8, i8* %11, i32 0, i32 %12)
%14 = load i32, i32* @stderr
%15 = call i32 @csvfield_printToFile(%struct.csvfield* %8, i32 %14)
%16 = bitcast i32* %4 to i8*
store i32 3355185, i32* %4
%17 = call i32 @strlen(i8* %16)
%18 = call i32 @csvfield_set(%struct.csvfield* %8, i8* %16, i32 0, i32 %17)
%19 = load i32, i32* @stderr
%20 = call i32 @csvfield_printToFile(%struct.csvfield* %8, i32 %19)
%21 = getelementptr inbounds [28 x i8], [28 x i8]* %5, i64 0, i64 0
%22 = call i32 @strlen(i8* %21)
%23 = call i32 @csvfield_set(%struct.csvfield* %8, i8* %21, i32 0, i32 %22)
%24 = load i32, i32* @stderr
%25 = call i32 @csvfield_printToFile(%struct.csvfield* %8, i32 %24)
%26 = bitcast i32* %6 to i8*
store i32 3355185, i32* %6
%27 = call i32 @strlen(i8* %26)
%28 = call i32 @csvfield_set(%struct.csvfield* %8, i8* %26, i32 0, i32 %27)
%29 = call i32 @strlen(i8* %26)
%30 = call i32 @csvfield_append(%struct.csvfield* %8, i8* %26, i32 0, i32 %29)
%31 = load i32, i32* @stderr
%32 = call i32 @csvfield_printToFile(%struct.csvfield* %8, i32 %31)
%33 = call i32 @csvfield_reset(%struct.csvfield* %8)
%34 = load i32, i32* @stderr
%35 = call i32 @csvfield_printToFile(%struct.csvfield* %8, i32 %34)
ret i32 0
}