#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*/ strncpy(char *, char *, int);
void trim_leading(char *string, size_t buffsize) {
  char tmp[buffsize];
  char *ptr = tmp;
  strncpy(tmp, string, buffsize);
  while (*ptr == ' ' || *ptr == '\t')
    ptr++;
  strncpy(string, ptr, buffsize - (ptr - tmp));
}


x86 assembly (clang, -O0):
<trim_leading>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x30(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x20(%rbp)
mov    %rdi,-0x28(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    %eax,%edx
call   1030 <strncpy@plt>
mov    -0x28(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x31(%rbp)
je     117f <trim_leading+0x6f>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
sete   %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    118f <trim_leading+0x7f>
jmp    11a0 <trim_leading+0x90>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    115a <trim_leading+0x4a>
mov    -0x30(%rbp),%rdx
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
sub    %rdx,%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1030 <strncpy@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trim_leading>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rsp,%rbx
lea    0xf(%rsi),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15d,%edx
call   1030 <strncpy@plt>
jmp    1158 <trim_leading+0x48>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
add    $0xffffffff,%r15d
movzbl (%rbx),%eax
cmp    $0x20,%al
je     1150 <trim_leading+0x40>
cmp    $0x9,%al
je     1150 <trim_leading+0x40>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1030 <strncpy@plt>
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @trim_leading(i8* %0, i64 %1) {
%3 = alloca i8, i64 %1
%4 = trunc i64 %1 to i32
%5 = call i32 @strncpy(i8* %3, i8* %0, i32 %4)
br label %6
6: ; preds = %9, %2
%7 = phi i8* [ %3, %2 ], [ %10, %9 ]
%8 = load i8, i8* %7
switch i8 %8, label %11 [
i8 32, label %9
i8 9, label %9
]
9: ; preds = %6, %6
%10 = getelementptr inbounds i8, i8* %7, i64 1
br label %6
11: ; preds = %6
%12 = ptrtoint i8* %7 to i64
%13 = ptrtoint i8* %3 to i64
%14 = add i64 %13, %1
%15 = sub i64 %14, %12
%16 = trunc i64 %15 to i32
%17 = call i32 @strncpy(i8* %0, i8* %7, i32 %16)
ret void
}