#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 /*<<< orphan*/ assert(int);
int *csv_parse_int(int /*<<< orphan*/ *, size_t *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(int *);
void csv_parse_int_test() {
  FILE *f = fopen("../../shared/data/105_sets.in", "r");
  size_t size = 0;
  int *val = csv_parse_int(f, &size);
  assert(size == 8);
  assert(val[0] == 81);
  assert(val[7] == 65);
  free(val);
  fclose(f);
  f = fopen("/dev/null", "r");
  size = 0;
  val = csv_parse_int(f, &size);
  assert(size == 0);
  assert(val == NULL);
  fclose(f);
}


x86 assembly (clang, -O0):
<csv_parse_int_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xea1(%rip),%rdi
lea    0xeb8(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1070 <csv_parse_int@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x8,-0x10(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x18(%rbp),%rax
cmpl   $0x51,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x18(%rbp),%rax
cmpl   $0x41,0x1c(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xe44(%rip),%rdi
lea    0xe3b(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1070 <csv_parse_int@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
cmpq   $0x0,-0x18(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x8(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<csv_parse_int_test>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xea1(%rip),%rdi
lea    0xeb8(%rip),%r14
mov    %r14,%rsi
call   1060 <fopen@plt>
mov    %rax,%r12
movq   $0x0,(%rsp)
mov    %rsp,%r15
mov    %rax,%rdi
mov    %r15,%rsi
call   1070 <csv_parse_int@plt>
mov    %rax,%rbx
xor    %edi,%edi
cmpq   $0x8,(%rsp)
sete   %dil
call   1050 <assert@plt>
xor    %edi,%edi
cmpl   $0x51,(%rbx)
sete   %dil
call   1050 <assert@plt>
xor    %edi,%edi
cmpl   $0x41,0x1c(%rbx)
sete   %dil
call   1050 <assert@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1040 <fclose@plt>
lea    0xe52(%rip),%rdi
mov    %r14,%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
movq   $0x0,(%rsp)
mov    %rax,%rdi
mov    %r15,%rsi
call   1070 <csv_parse_int@plt>
mov    %rax,%r14
xor    %edi,%edi
cmpq   $0x0,(%rsp)
sete   %dil
call   1050 <assert@plt>
xor    %edi,%edi
test   %r14,%r14
sete   %dil
call   1050 <assert@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [30 x i8] c"../../shared/data/105_sets.in\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [10 x i8] c"/dev/null\00"
define void @csv_parse_int_test() {
%1 = alloca i32*
%2 = alloca i64
%3 = alloca i32*
%4 = call i32* @fopen(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %4, i32** %1
store i64 0, i64* %2
%5 = load i32*, i32** %1
%6 = call i32* @csv_parse_int(i32* %5, i64* %2)
store i32* %6, i32** %3
%7 = load i64, i64* %2
%8 = icmp eq i64 %7, 8
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = load i32*, i32** %3
%12 = getelementptr inbounds i32, i32* %11, i64 0
%13 = load i32, i32* %12
%14 = icmp eq i32 %13, 81
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = load i32*, i32** %3
%18 = getelementptr inbounds i32, i32* %17, i64 7
%19 = load i32, i32* %18
%20 = icmp eq i32 %19, 65
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = load i32*, i32** %3
%24 = call i32 @free(i32* %23)
%25 = load i32*, i32** %1
%26 = call i32 @fclose(i32* %25)
%27 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %27, i32** %1
store i64 0, i64* %2
%28 = load i32*, i32** %1
%29 = call i32* @csv_parse_int(i32* %28, i64* %2)
store i32* %29, i32** %3
%30 = load i64, i64* %2
%31 = icmp eq i64 %30, 0
%32 = zext i1 %31 to i32
%33 = call i32 @assert(i32 %32)
%34 = load i32*, i32** %3
%35 = icmp eq i32* %34, null
%36 = zext i1 %35 to i32
%37 = call i32 @assert(i32 %36)
%38 = load i32*, i32** %1
%39 = call i32 @fclose(i32* %38)
ret void
}

LLVM IR (-O2):
@.str = [30 x i8] c"../../shared/data/105_sets.in\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [10 x i8] c"/dev/null\00"
define void @csv_parse_int_test() {
%1 = alloca i64
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = bitcast i64* %1 to i8*
store i64 0, i64* %1
%4 = call i32* @csv_parse_int(i32* %2, i64* %1)
%5 = load i64, i64* %1
%6 = icmp eq i64 %5, 8
%7 = zext i1 %6 to i32
%8 = call i32 @assert(i32 %7)
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 81
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = getelementptr inbounds i32, i32* %4, i64 7
%14 = load i32, i32* %13
%15 = icmp eq i32 %14, 65
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = call i32 @free(i32* %4)
%19 = call i32 @fclose(i32* %2)
%20 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i64 0, i64* %1
%21 = call i32* @csv_parse_int(i32* %20, i64* %1)
%22 = load i64, i64* %1
%23 = icmp eq i64 %22, 0
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
%26 = icmp eq i32* %21, null
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
%29 = call i32 @fclose(i32* %20)
ret void
}