#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 - 2);
  while (*ptr == ' ' || *ptr == '\t')
    ptr++;
  strncpy(string, ptr, buffsize - (2 + 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
sub    $0x2,%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     1183 <trim_leading+0x73>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
sete   %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    1193 <trim_leading+0x83>
jmp    11a4 <trim_leading+0x94>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    115e <trim_leading+0x4e>
mov    -0x30(%rbp),%rdx
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
add    $0x2,%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
add    $0xfffffffe,%r15d
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15d,%edx
call   1030 <strncpy@plt>
jmp    1158 <trim_leading+0x48>
cs nopw 0x0(%rax,%rax,1)
nop
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 = sub i64 %12, 2
%14 = trunc i64 %13 to i32
%15 = call i32 @strncpy(i8* %10, i8* %11, i32 %14)
br label %16
16: ; preds = %28, %2
%17 = load i8*, i8** %7
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 32
br i1 %20, label %26, label %21
21: ; preds = %16
%22 = load i8*, i8** %7
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 9
br label %26
26: ; preds = %21, %16
%27 = phi i1 [ true, %16 ], [ %25, %21 ]
br i1 %27, label %28, label %31
28: ; preds = %26
%29 = load i8*, i8** %7
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %7
br label %16
31: ; preds = %26
%32 = load i8*, i8** %3
%33 = load i8*, i8** %7
%34 = load i64, i64* %4
%35 = load i8*, i8** %7
%36 = getelementptr inbounds i8, i8* %35, i64 2
%37 = ptrtoint i8* %36 to i64
%38 = ptrtoint i8* %10 to i64
%39 = sub i64 %37, %38
%40 = sub i64 %34, %39
%41 = trunc i64 %40 to i32
%42 = call i32 @strncpy(i8* %32, i8* %33, i32 %41)
%43 = 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 = add i32 %4, -2
%6 = call i32 @strncpy(i8* %3, i8* %0, i32 %5)
br label %7
7: ; preds = %10, %2
%8 = phi i8* [ %3, %2 ], [ %11, %10 ]
%9 = load i8, i8* %8
switch i8 %9, label %12 [
i8 32, label %10
i8 9, label %10
]
10: ; preds = %7, %7
%11 = getelementptr inbounds i8, i8* %8, i64 1
br label %7
12: ; preds = %7
%13 = getelementptr inbounds i8, i8* %8, i64 2
%14 = ptrtoint i8* %13 to i64
%15 = ptrtoint i8* %3 to i64
%16 = add i64 %15, %1
%17 = sub i64 %16, %14
%18 = trunc i64 %17 to i32
%19 = call i32 @strncpy(i8* %0, i8* %8, i32 %18)
ret void
}