#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 indent_amount(const char *cp, const char **const end) {
  int cnt = 0;
  while (*cp == ' ' || *cp == '\t') {
    if (*cp == '\t')
      cnt = (cnt + 8) / 8 * 8;
    else
      cnt++;
    cp++;
  }
  if (end != NULL)
    *end = (char *)cp;
  return cnt;
}


x86 assembly (clang, -O0):
<indent_amount>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x15(%rbp)
je     1138 <indent_amount+0x38>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
sete   %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    1148 <indent_amount+0x48>
jmp    118b <indent_amount+0x8b>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
jne    1171 <indent_amount+0x71>
mov    -0x14(%rbp),%eax
add    $0x8,%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
shl    $0x3,%eax
mov    %eax,-0x14(%rbp)
jmp    117a <indent_amount+0x7a>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1113 <indent_amount+0x13>
cmpq   $0x0,-0x10(%rbp)
je     11a1 <indent_amount+0xa1>
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x14(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<indent_amount>:
xor    %eax,%eax
jmp    1117 <indent_amount+0x17>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%eax
add    $0x1,%rdi
movzbl (%rdi),%ecx
cmp    $0x20,%cl
je     1110 <indent_amount+0x10>
cmp    $0x9,%cl
jne    1138 <indent_amount+0x38>
lea    0x8(%rax),%ecx
add    $0xf,%eax
test   %ecx,%ecx
cmovns %ecx,%eax
and    $0xfffffff8,%eax
add    $0x1,%rdi
jmp    1117 <indent_amount+0x17>
test   %rsi,%rsi
je     1140 <indent_amount+0x40>
mov    %rdi,(%rsi)
ret

LLVM IR (-O0):
define i32 @indent_amount(i8* %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i8**
%5 = alloca i32
store i8* %0, i8** %3
store i8** %1, i8*** %4
store i32 0, i32* %5
br label %6
6: ; preds = %31, %2
%7 = load i8*, i8** %3
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 32
br i1 %10, label %16, label %11
11: ; preds = %6
%12 = load i8*, i8** %3
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 9
br label %16
16: ; preds = %11, %6
%17 = phi i1 [ true, %6 ], [ %15, %11 ]
br i1 %17, label %18, label %34
18: ; preds = %16
%19 = load i8*, i8** %3
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 9
br i1 %22, label %23, label %28
23: ; preds = %18
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 8
%26 = sdiv i32 %25, 8
%27 = mul nsw i32 %26, 8
store i32 %27, i32* %5
br label %31
28: ; preds = %18
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 1
store i32 %30, i32* %5
br label %31
31: ; preds = %28, %23
%32 = load i8*, i8** %3
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %3
br label %6
34: ; preds = %16
%35 = load i8**, i8*** %4
%36 = icmp ne i8** %35, null
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = load i8*, i8** %3
%39 = load i8**, i8*** %4
store i8* %38, i8** %39
br label %40
40: ; preds = %37, %34
%41 = load i32, i32* %5
ret i32 %41
}

LLVM IR (-O2):
define i32 @indent_amount(i8* %0, i8** writeonly %1) {
br label %3
3: ; preds = %13, %2
%4 = phi i8* [ %0, %2 ], [ %15, %13 ]
%5 = phi i32 [ 0, %2 ], [ %14, %13 ]
%6 = load i8, i8* %4
switch i8 %6, label %16 [
i8 9, label %7
i8 32, label %11
]
7: ; preds = %3
%8 = add nsw i32 %5, 8
%9 = sdiv i32 %8, 8
%10 = shl nsw i32 %9, 3
br label %13
11: ; preds = %3
%12 = add nsw i32 %5, 1
br label %13
13: ; preds = %11, %7
%14 = phi i32 [ %10, %7 ], [ %12, %11 ]
%15 = getelementptr inbounds i8, i8* %4, i64 1
br label %3
16: ; preds = %3
%17 = icmp eq i8** %1, null
br i1 %17, label %19, label %18
18: ; preds = %16
store i8* %4, i8** %1
br label %19
19: ; preds = %18, %16
ret i32 %5
}