#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*/ printf(char *, int);
int strlen(char *);
int indent(char *line) {
  int indent = 0;
  int i;
  for (i = 0; i < strlen(line); i++) {
    if (line[i] == ' ') {
      indent += 1;
    } else if (line[i] == '\t') {
      indent += 8;
      ;
    } else {
      break;
    }
  }
  printf("Indent: %d \n", indent);
  return indent;
}


x86 assembly (clang, -O0):
<indent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jge    11b9 <indent+0x99>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    1179 <indent+0x59>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11a6 <indent+0x86>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x9,%eax
jne    119c <indent+0x7c>
mov    -0xc(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0xc(%rbp)
jmp    11a1 <indent+0x81>
jmp    11b9 <indent+0x99>
jmp    11a6 <indent+0x86>
jmp    11ab <indent+0x8b>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113a <indent+0x1a>
mov    -0xc(%rbp),%esi
lea    0xe3d(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<indent>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
call   1030 <strlen@plt>
test   %eax,%eax
jle    1170 <indent+0x50>
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    1155 <indent+0x35>
cs nopw 0x0(%rax,%rax,1)
add    %eax,%ebp
add    $0x1,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    1172 <indent+0x52>
movzbl (%r14,%rbx,1),%ecx
mov    $0x1,%eax
cmp    $0x20,%cl
je     1140 <indent+0x20>
cmp    $0x9,%cl
jne    1172 <indent+0x52>
mov    $0x8,%eax
jmp    1140 <indent+0x20>
xor    %ebp,%ebp
lea    0xe87(%rip),%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"Indent: %d \0A\00"
define i32 @indent(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
store i32 0, i32* %4
br label %5
5: ; preds = %35, %1
%6 = load i32, i32* %4
%7 = load i8*, i8** %2
%8 = call i32 @strlen(i8* %7)
%9 = icmp slt i32 %6, %8
br i1 %9, label %10, label %38
10: ; preds = %5
%11 = load i8*, i8** %2
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 32
br i1 %17, label %18, label %21
18: ; preds = %10
%19 = load i32, i32* %3
%20 = add nsw i32 %19, 1
store i32 %20, i32* %3
br label %34
21: ; preds = %10
%22 = load i8*, i8** %2
%23 = load i32, i32* %4
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 9
br i1 %28, label %29, label %32
29: ; preds = %21
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 8
store i32 %31, i32* %3
br label %33
32: ; preds = %21
br label %38
33: ; preds = %29
br label %34
34: ; preds = %33, %18
br label %35
35: ; preds = %34
%36 = load i32, i32* %4
%37 = add nsw i32 %36, 1
store i32 %37, i32* %4
br label %5
38: ; preds = %32, %5
%39 = load i32, i32* %3
%40 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %39)
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@.str = [13 x i8] c"Indent: %d \0A\00"
define i32 @indent(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %17
4: ; preds = %1, %10
%5 = phi i64 [ %13, %10 ], [ 0, %1 ]
%6 = phi i32 [ %12, %10 ], [ 0, %1 ]
%7 = getelementptr inbounds i8, i8* %0, i64 %5
%8 = load i8, i8* %7
switch i8 %8, label %17 [
i8 32, label %10
i8 9, label %9
]
9: ; preds = %4
br label %10
10: ; preds = %4, %9
%11 = phi i32 [ 8, %9 ], [ 1, %4 ]
%12 = add nuw nsw i32 %6, %11
%13 = add nuw nsw i64 %5, 1
%14 = tail call i32 @strlen(i8* %0)
%15 = sext i32 %14 to i64
%16 = icmp slt i64 %13, %15
br i1 %16, label %4, label %17
17: ; preds = %10, %4, %1
%18 = phi i32 [ 0, %1 ], [ %6, %4 ], [ %12, %10 ]
%19 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %18)
ret i32 %18
}