#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 strlen(char *);
int real_column(char *mat) {
  int i = 0, c;
  c = strlen(mat);
  while (mat[i] != '\n' && mat[i] != '\0' && i < c)
    i++;
  return i;
}


x86 assembly (clang, -O0):
<real_column>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x11(%rbp)
je     116f <real_column+0x5f>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x11(%rbp)
je     116f <real_column+0x5f>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
setl   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    117f <real_column+0x6f>
jmp    118d <real_column+0x7d>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    112f <real_column+0x1f>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<real_column>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
xor    %ecx,%ecx
test   %eax,%eax
cmovle %ecx,%eax
movzbl (%rbx,%rcx,1),%edx
test   %dl,%dl
je     1138 <real_column+0x28>
cmp    $0xa,%dl
je     1138 <real_column+0x28>
cmp    %rcx,%rax
je     113a <real_column+0x2a>
add    $0x1,%rcx
jmp    1120 <real_column+0x10>
mov    %ecx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @real_column(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
%5 = load i8*, i8** %2
%6 = call i32 @strlen(i8* %5)
store i32 %6, i32* %4
br label %7
7: ; preds = %29, %1
%8 = load i8*, i8** %2
%9 = load i32, i32* %3
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %8, i64 %10
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 10
br i1 %14, label %15, label %27
15: ; preds = %7
%16 = load i8*, i8** %2
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %15
%24 = load i32, i32* %3
%25 = load i32, i32* %4
%26 = icmp slt i32 %24, %25
br label %27
27: ; preds = %23, %15, %7
%28 = phi i1 [ false, %15 ], [ false, %7 ], [ %26, %23 ]
br i1 %28, label %29, label %32
29: ; preds = %27
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 1
store i32 %31, i32* %3
br label %7
32: ; preds = %27
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
define i32 @real_column(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = call i32 @llvm.smax.i32(i32 %2, i32 0)
%4 = zext i32 %3 to i64
br label %5
5: ; preds = %11, %1
%6 = phi i64 [ %12, %11 ], [ 0, %1 ]
%7 = getelementptr inbounds i8, i8* %0, i64 %6
%8 = load i8, i8* %7
switch i8 %8, label %9 [
i8 10, label %13
i8 0, label %13
]
9: ; preds = %5
%10 = icmp eq i64 %6, %4
br i1 %10, label %15, label %11
11: ; preds = %9
%12 = add nuw nsw i64 %6, 1
br label %5
13: ; preds = %5, %5
%14 = trunc i64 %6 to i32
br label %15
15: ; preds = %9, %13
%16 = phi i32 [ %14, %13 ], [ %3, %9 ]
ret i32 %16
}