#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 advance_over(char const *, size_t *);
size_t actual_x(const char *text, size_t column) {
  const char *start = text;
  size_t width = 0;
  while (*text != '\0') {
    int charlen = advance_over(text, &width);
    if (width > column)
      break;
    text += charlen;
  }
  return (text - start);
}


x86 assembly (clang, -O0):
<actual_x>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1179 <actual_x+0x69>
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <advance_over@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jbe    1163 <actual_x+0x53>
jmp    1179 <actual_x+0x69>
mov    -0x24(%rbp),%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    1130 <actual_x+0x20>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    %rcx,%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<actual_x>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
movq   $0x0,(%rsp)
mov    %rsp,%r12
mov    %rdi,%rax
nopl   0x0(%rax)
mov    %rax,%rbx
cmpb   $0x0,(%rax)
je     114e <actual_x+0x3e>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1030 <advance_over@plt>
cltq
add    %rbx,%rax
cmp    %r15,(%rsp)
jbe    1130 <actual_x+0x20>
sub    %r14,%rbx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i64 @actual_x(i8* %0, i64 %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
store i64 0, i64* %3
br label %5
5: ; preds = %9, %2
%6 = phi i8* [ %0, %2 ], [ %14, %9 ]
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 0
br i1 %8, label %15, label %9
9: ; preds = %5
%10 = call i32 @advance_over(i8* %6, i64* %3)
%11 = load i64, i64* %3
%12 = icmp ugt i64 %11, %1
%13 = sext i32 %10 to i64
%14 = getelementptr inbounds i8, i8* %6, i64 %13
br i1 %12, label %15, label %5
15: ; preds = %9, %5
%16 = ptrtoint i8* %6 to i64
%17 = ptrtoint i8* %0 to i64
%18 = sub i64 %16, %17
ret i64 %18
}