#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 */
char *column_fill_characters(char *, char *);
char *column_skip_spaces(char *);
int count_columns(char *string) {
  char put_here[1024];
  int this_column;
  this_column = 0;
  string = column_skip_spaces(string);
  while (*string) {
    this_column++;
    string = column_fill_characters(put_here, string);
    string = column_skip_spaces(string);
  }
  return this_column;
}


x86 assembly (clang, -O0):
<count_columns>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x414(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <column_skip_spaces@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     1188 <count_columns+0x68>
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <column_fill_characters@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <column_skip_spaces@plt>
mov    %rax,-0x8(%rbp)
jmp    1146 <count_columns+0x26>
mov    -0x414(%rbp),%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<count_columns>:
push   %r14
push   %rbx
sub    $0x408,%rsp
call   1040 <column_skip_spaces@plt>
cmpb   $0x0,(%rax)
je     115d <count_columns+0x3d>
xor    %ebx,%ebx
mov    %rsp,%r14
nopl   0x0(%rax)
add    $0x1,%ebx
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <column_fill_characters@plt>
mov    %rax,%rdi
call   1040 <column_skip_spaces@plt>
cmpb   $0x0,(%rax)
jne    1140 <count_columns+0x20>
jmp    115f <count_columns+0x3f>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @count_columns(i8* %0) {
%2 = alloca i8*
%3 = alloca [1024 x i8]
%4 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %4
%5 = load i8*, i8** %2
%6 = call i8* @column_skip_spaces(i8* %5)
store i8* %6, i8** %2
br label %7
7: ; preds = %11, %1
%8 = load i8*, i8** %2
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 0
br i1 %10, label %11, label %19
11: ; preds = %7
%12 = load i32, i32* %4
%13 = add nsw i32 %12, 1
store i32 %13, i32* %4
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%15 = load i8*, i8** %2
%16 = call i8* @column_fill_characters(i8* %14, i8* %15)
store i8* %16, i8** %2
%17 = load i8*, i8** %2
%18 = call i8* @column_skip_spaces(i8* %17)
store i8* %18, i8** %2
br label %7
19: ; preds = %7
%20 = load i32, i32* %4
ret i32 %20
}

LLVM IR (-O2):
define i32 @count_columns(i8* %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%4 = tail call i8* @column_skip_spaces(i8* %0)
%5 = load i8, i8* %4
%6 = icmp eq i8 %5, 0
br i1 %6, label %15, label %7
7: ; preds = %1, %7
%8 = phi i32 [ %10, %7 ], [ 0, %1 ]
%9 = phi i8* [ %12, %7 ], [ %4, %1 ]
%10 = add nuw nsw i32 %8, 1
%11 = call i8* @column_fill_characters(i8* %3, i8* %9)
%12 = call i8* @column_skip_spaces(i8* %11)
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %15, label %7
15: ; preds = %7, %1
%16 = phi i32 [ 0, %1 ], [ %10, %7 ]
ret i32 %16
}