#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 /*<<< orphan*/ split_string_and_return_specific_index(char *, char *, int,
                                                          int);
scalar_t__ strcmp(char *, char *);
int get_number_of_columns(char *column_header) {
  int number_of_columns = 0;
  char result[100] = {0};
  do {
    split_string_and_return_specific_index(result, column_header,
                                           number_of_columns, 100000);
    if (result == NULL || result[0] == '\n') {
      break;
    }
    number_of_columns++;
  } while (!(strcmp(result, "") == 0));
  return number_of_columns;
}


x86 assembly (clang, -O0):
<get_number_of_columns>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1030 <memset@plt>
lea    -0x70(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    $0x186a0,%ecx
call   1050 <split_string_and_return_specific_index@plt>
movsbl -0x70(%rbp),%eax
cmp    $0xa,%eax
jne    117a <get_number_of_columns+0x4a>
jmp    11a4 <get_number_of_columns+0x74>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
lea    -0x70(%rbp),%rdi
lea    0xe72(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
xor    $0xff,%al
test   $0x1,%al
jne    1153 <get_number_of_columns+0x23>
mov    -0xc(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_number_of_columns>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x68,%rsp
mov    %rdi,%r14
xorps  %xmm0,%xmm0
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movl   $0x0,0x60(%rsp)
xor    %ebp,%ebp
mov    %rsp,%rbx
lea    0xe9f(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
mov    $0x186a0,%ecx
call   1040 <split_string_and_return_specific_index@plt>
cmpb   $0xa,(%rsp)
je     119b <get_number_of_columns+0x7b>
add    $0x1,%ebp
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
jne    1170 <get_number_of_columns+0x50>
mov    %ebp,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
define i32 @get_number_of_columns(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca [100 x i8]
store i8* %0, i8** %2
store i32 0, i32* %3
%5 = bitcast [100 x i8]* %4 to i8*
br label %6
6: ; preds = %19, %1
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%8 = load i8*, i8** %2
%9 = load i32, i32* %3
%10 = call i32 @split_string_and_return_specific_index(i8* %7, i8* %8, i32 %9, i32 100000)
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 10
br i1 %14, label %15, label %16
15: ; preds = %6
br label %24
16: ; preds = %6
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %3
br label %19
19: ; preds = %16
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
%23 = xor i1 %22, true
br i1 %23, label %6, label %24
24: ; preds = %19, %15
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
define i32 @get_number_of_columns(i8* %0) {
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
br label %4
4: ; preds = %9, %1
%5 = phi i32 [ 0, %1 ], [ %10, %9 ]
%6 = call i32 @split_string_and_return_specific_index(i8* %3, i8* %0, i32 %5, i32 100000)
%7 = load i8, i8* %3
%8 = icmp eq i8 %7, 10
br i1 %8, label %13, label %9
9: ; preds = %4
%10 = add nuw nsw i32 %5, 1
%11 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %4
13: ; preds = %4, %9
%14 = phi i32 [ %5, %4 ], [ %10, %9 ]
ret i32 %14
}